
    <hV                     V    S SK r S SKrS SKrS SKJr  S SKJrJr  \ " S S5      5       rg)    N)	dataclass)AnyUnionc                       \ rS rSr% SrSr\\S'   \S 5       r	S\
\\R                  4   4S jrS\\\4   4S	 jrS
 rS rS rS rSrg)DistributedConfig   z$
Base class for distributed configs
Fenable_expert_parallelc                     U " S0 UD6n/ nUR                  5        H4  u  pV[        X55      (       d  M  [        X5U5        UR                  U5        M6     U H  nUR	                  US5        M     U$ )aK  
Constructs a DistributedConfig instance from a dictionary of parameters.
Args:
    config_dict (Dict[str, Any]): Dictionary containing configuration parameters.
    **kwargs: Additional keyword arguments to override dictionary values.
Returns:
    DistributedConfig: Instance of DistributedConfig constructed from the dictionary.
N )itemshasattrsetattrappendpop)clsconfig_dictkwargsconfig	to_removekeyvalues          d/var/www/html/shao/venv/lib/python3.13/site-packages/transformers/distributed/configuration_utils.py	from_dictDistributedConfig.from_dict   sj     #{#	 ,,.JCv##U+  % ) CJJsD!     json_file_pathc                     [        USSS9 nU R                  5       n[        R                  " USSS9S-   nUR	                  U5        SSS5        g! , (       d  f       g= f)	a  
Save this instance to a JSON file.
Args:
    json_file_path (`str` or `os.PathLike`):
        Path to the JSON file in which this configuration instance's parameters will be saved.
    use_diff (`bool`, *optional*, defaults to `True`):
        If set to `True`, only the difference between the config instance and the default
        `QuantizationConfig()` is serialized to JSON file.
wzutf-8)encoding   T)indent	sort_keys
N)opento_dictjsondumpswrite)selfr   writerr   json_strings        r   to_json_fileDistributedConfig.to_json_file4   sL     .#8F,,.K**[dKdRKLL%	 988s   ;A
Areturnc                 B    [         R                  " U R                  5      $ )z
Serializes this instance to a Python dictionary. Returns:
    `Dict[str, Any]`: Dictionary of all the attributes that make up this configuration instance.
)copydeepcopy__dict__r)   s    r   r%   DistributedConfig.to_dictD   s    
 }}T]]++r   c              #      #    [         R                  " U R                  5      R                  5        H
  u  pX4v   M     g7f)zTallows `dict(obj)` for situations where obj may be a dict or QuantizationConfigMixinN)r0   r1   r2   r   )r)   attrr   s      r   __iter__DistributedConfig.__iter__L   s0     ==7==?KD+ @s   >A c                 T    U R                   R                   SU R                  5        3$ )N )	__class____name__to_json_stringr3   s    r   __repr__DistributedConfig.__repr__R   s(    ..))*!D,?,?,A+BCCr   c                 F    [         R                  " U R                  SS9S-   $ )z
Serializes this instance to a JSON formatted string.
Returns:
    str: JSON formatted string representing the configuration instance.
r    )r!   r#   )r&   r'   r2   r3   s    r   r=    DistributedConfig.to_json_stringU   s     zz$--2T99r   c                     / nUR                  5        H4  u  p4[        X5      (       d  M  [        XU5        UR                  U5        M6     UR                  5        VVs0 sH  u  p4X2;  d  M  X4_M     nnnU$ s  snnf )am  
Updates attributes of this class instance with attributes from `kwargs` if they match existing attributes,
returning all the unused kwargs.
Args:
    kwargs (`Dict[str, Any]`):
        Dictionary of attributes to tentatively update this class.
Returns:
    `Dict[str, Any]`: Dictionary containing all the key-value pairs that were not used to update the instance.
)r   r   r   r   )r)   r   r   r   r   unused_kwargss         r   updateDistributedConfig.update]   sq     	 ,,.JCt!!5)  % ) 7=lln]n
H\n] ^s   
A7,A7r   N)r<   
__module____qualname____firstlineno____doc__r	   bool__annotations__classmethodr   r   strosPathLiker,   dictr   r%   r7   r>   r=   rD   __static_attributes__r   r   r   r   r      sk     $)D(  (&5bkk1A+B & ,c3h ,D:r   r   )	r0   r&   rN   dataclassesr   typingr   r   r   r   r   r   <module>rT      s2      	 !  X X Xr   