o
    ߥiI                     @   sN   d Z ddlmZmZmZ ddlZddlZddlZee	Z
G dd deZdS )zPyTorch BERT configuration.    )absolute_importdivisionprint_functionNc                   @   s^   e Zd ZdZ											dd
dZedd Zedd Zdd Zdd Z	dd Z
dS )SpaceTCnConfigzIConfiguration class to store the configuration of a `SpaceTCnModel`.
             gelu皙?      {Gz?c                 C   s   t |tr3t|ddd}t| }W d   n1 sw   Y  | D ]	\}}|| j|< q'dS t |tr[|| _	|| _
|| _|| _|| _|| _|| _|| _|	| _|
| _|| _dS td)a  Constructs SpaceTCnConfig.

        Args:
            vocab_size_or_config_json_file: Vocabulary size of `inputs_ids` in `SpaceTCnConfig`.
            hidden_size: Size of the encoder layers and the pooler layer.
            num_hidden_layers: Number of hidden layers in the Transformer encoder.
            num_attention_heads: Number of attention heads for each attention layer in
                the Transformer encoder.
            intermediate_size: The size of the "intermediate" (i.e., feed-forward)
                layer in the Transformer encoder.
            hidden_act: The non-linear activation function (function or string) in the
                encoder and pooler. If string, "gelu", "relu" and "swish" are supported.
            hidden_dropout_prob: The dropout probability for all fully connected
                layers in the embeddings, encoder, and pooler.
            attention_probs_dropout_prob: The dropout ratio for the attention
                probabilities.
            max_position_embeddings: The maximum sequence length that this model might
                ever be used with. Typically set this to something large just in case
                (e.g., 512 or 1024 or 2048).
            type_vocab_size: The vocabulary size of the `token_type_ids` passed into `SpaceTCnConfig`.
            initializer_range: The stdev of the truncated_normal_initializer for
                initializing all weight matrices.
        rutf-8encodingNzhFirst argument must be either a vocabulary size (int)or the path to a pretrained model config file (str))
isinstancestropenjsonloadsreaditems__dict__int
vocab_sizehidden_sizenum_hidden_layersnum_attention_heads
hidden_actintermediate_sizehidden_dropout_probattention_probs_dropout_probmax_position_embeddingstype_vocab_sizeinitializer_range
ValueError)selfvocab_size_or_config_json_filer   r   r   r    r   r!   r"   r#   r$   r%   readerjson_configkeyvalue r-   b/home/ubuntu/.local/lib/python3.10/site-packages/modelscope/models/nlp/space_T_cn/configuration.py__init__   s4   
#

zSpaceTCnConfig.__init__c                 C   s*   t dd}| D ]	\}}||j|< q	|S )zEConstructs a `SpaceTCnConfig` from a Python dictionary of parameters.)r(   )r   r   r   )clsjson_objectconfigr+   r,   r-   r-   r.   	from_dictZ   s   
zSpaceTCnConfig.from_dictc                 C   sF   t |ddd}| }W d   n1 sw   Y  | t|S )z=Constructs a `SpaceTCnConfig` from a json file of parameters.r   r   r   N)r   r   r4   r   r   )r1   	json_filer)   textr-   r-   r.   from_json_fileb   s   
zSpaceTCnConfig.from_json_filec                 C   s   t |  S )N)r   to_json_stringr'   r-   r-   r.   __repr__i   s   zSpaceTCnConfig.__repr__c                 C   s   t | j}|S )z0Serializes this instance to a Python dictionary.)copydeepcopyr   )r'   outputr-   r-   r.   to_dictl   s   zSpaceTCnConfig.to_dictc                 C   s   t j|  dddd S )z*Serializes this instance to a JSON string.r   T)indent	sort_keys
)r   dumpsr>   r9   r-   r-   r.   r8   q   s   zSpaceTCnConfig.to_json_stringN)
r   r   r   r   r	   r
   r
   r   r   r   )__name__
__module____qualname____doc__r/   classmethodr4   r7   r:   r>   r8   r-   r-   r-   r.   r      s(    
;

r   )rF   
__future__r   r   r   r;   loggingr   	getLoggerrC   loggerobjectr   r-   r-   r-   r.   <module>   s   
