
    9i                         S r SSKJr  SSKJr  SSKJrJr  SSKJ	r	  SSK
Jr  SSKJr  SSKJr  S	S
KJr  \R&                  " 5       r/ r\	R*                  " \R,                  \R.                  S9 " S S\\5      5       rg)zSPyTorch Veco model. mainly copied from :module:`~transformers.modeling_xlm_roberta`    )RobertaModel)Models)Model
TorchModel)MODELS)AttentionBackboneModelOutput)logger)Tasks   )
VecoConfig)module_namec                   R   ^  \ rS rSrSr\rU 4S jrU 4S jr\	U 4S j5       r
SrU =r$ )	VecoModel"   a  The bare Veco Model transformer outputting raw hidden-states without any specific head on top.

This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic
methods the library implements for all its model (such as downloading or saving, resizing the input embeddings,
pruning heads etc.)

This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module)
subclass. Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to
general usage and behavior.

Parameters:
    config ([`VecoConfig`]): Model configuration class with all the parameters of the
        model. Initializing with a config file does not load the weights associated with the model, only the
        configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model
        weights.

This class overrides [`RobertaModel`]. Please check the superclass for the appropriate
documentation alongside usage examples.
c                 b   > [         TU ]  " UR                  40 UD6  [         [        U ]  U5        g )N)super__init__name_or_pathr   )selfconfigkwargs	__class__s      c/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/modelscope/models/nlp/veco/backbone.pyr   VecoModel.__init__:   s*    ,,77eT#F+    c           	         > SUS'   [         [        U ]
  " U0 UD6n[        UR                  UR
                  UR                  UR                  UR                  UR                  S9$ )u  
Returns:
    Returns `modelscope.outputs.AttentionBackboneModelOutputWithEmbedding`

Examples:
    >>> from modelscope.models import Model
    >>> from modelscope.preprocessors import Preprocessor
    >>> model = Model.from_pretrained('damo/nlp_veco_fill-mask-large', task='backbone')
    >>> preprocessor = Preprocessor.from_pretrained('damo/nlp_veco_fill-mask-large')
    >>> print(model(**preprocessor('这是个测试')))

Treturn_dict)last_hidden_statepooler_outputpast_key_valueshidden_states
attentionscross_attentions)
r   r   forwardr   r   r   r    r!   r"   r#   )r   argsr   outputsr   s       r   r$   VecoModel.forward>   sh     !%}t,d=f=+%77!//#33!//))$55
 	
r   c                 ~   > UR                  SS 5      nUc  [        S0 UD6nU " U5      nU$ [        [        U ]  US9nU$ )N	model_dir)pretrained_model_name_or_path )popr   r   r   from_pretrained)clsr   r)   ponet_configmodelr   s        r   _instantiateVecoModel._instantiateV   s[    JJ{D1	%//L%E
  %CL_M  r   r+   )__name__
__module____qualname____firstlineno____doc__r   config_classr   r$   classmethodr1   __static_attributes____classcell__)r   s   @r   r   r   "   s-    ( L,
0 	 	r   r   N)r7   transformersr   modelscope.metainfor   modelscope.modelsr   r   modelscope.models.builderr   modelscope.outputsr   modelscope.utilsr	   loggingmodelscope.utils.constantr
   configurationr   
get_logger"VECO_PRETRAINED_MODEL_ARCHIVE_LISTregister_modulebackbonevecor   r+   r   r   <module>rJ      sj   " Z % & / , ; . + %				%' " FKK@=
L = A=r   