
    9i                         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  \R                  " \R                   \R"                  S	9 " S
 S\\5      5       rg)    )RobertaForMaskedLM)Models)Model
TorchModel)MODELS)AttentionFillMaskModelOutput)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$ )VecoForMaskedLM   a  Veco Model transformer with a masked language model head on top (a linear layer on top of the
pooled output).

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.

Preprocessor:
    This is the fill_mask model of StructBERT, the preprocessor of this model
    is `modelscope.preprocessors.FillMaskTransformersPreprocessor`.

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 [`RobertaForMaskedLM`]. 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      d/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/modelscope/models/nlp/veco/fill_mask.pyr   VecoForMaskedLM.__init__9   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S   S9$ )u  
Returns:
    Returns `modelscope.outputs.AttentionFillMaskModelOutput`

Examples:
    >>> from modelscope.models import Model
    >>> from modelscope.preprocessors import Preprocessor
    >>> model = Model.from_pretrained('damo/nlp_veco_fill-mask-large')
    >>> preprocessor = Preprocessor.from_pretrained('damo/nlp_veco_fill-mask-large')
    >>> # Call the model, return some tensors
    >>> print(model(**preprocessor('你师父差得动你，你师父可<mask>不动我。')))
    >>> # Call the pipeline
    >>> from modelscope.pipelines import pipeline
    >>> pipeline_ins = pipeline('fill-mask', model=model, preprocessor=preprocessor)
    >>> print(pipeline_ins('你师父差得动你，你师父可<mask>不动我。'))
Treturn_dict	input_ids)losslogitshidden_states
attentionsr   )r   r   forwardr   r   r   r    r!   )r   argsr   outputsr   s       r   r"   VecoForMaskedLM.forward=   sZ    $ !%}t,d=f=+>>!//))[)
 	
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VecoForMaskedLM._instantiateY   s[    JJ{D1	%//L%E
  %CL_M  r   r)   )__name__
__module____qualname____firstlineno____doc__r   config_classr   r"   classmethodr/   __static_attributes____classcell__)r   s   @r   r   r      s-    2 L,
8 	 	r   r   N)transformersr   modelscope.metainfor   modelscope.modelsr   r   modelscope.models.builderr   modelscope.outputsr   modelscope.utils.constantr	   configurationr   register_module	fill_maskvecor   r)   r   r   <module>rD      sS   $ , & / , ; + % V[[AFj"4 F BFr   