
    bi6                         d dl Z  G d de j                        Z G d de      Z G d de      Z G d d	e j
                        Z G d
 de j                        Zy)    Nc                   *     e Zd ZdZ fdZddZ xZS )_StoreActionzS
    Custom action that allows for `-` or `_` to be passed in for an argument.
    c                     t        |   |i | g }| j                  D ]<  }|j                  |       d|dd  v s|j                  |j	                  dd             > || _        y )N_   -)super__init__option_stringsappendreplace)selfargskwargsnew_option_stringsoption_string	__class__s        T/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/accelerate/commands/utils.pyr
   z_StoreAction.__init__   st    $)&)!00 	KM%%m4mAB''"))-*?*?S*IJ		K
 1    c                     t        || j                  |       t        |d      st               |_        |j                  j                  | j                         y )N
nondefault)setattrdesthasattrsetr   add)r   parser	namespacevaluesr   s        r   __call__z_StoreAction.__call__!   s>    	499f-y,/#&5I   +r   N__name__
__module____qualname____doc__r
   r    __classcell__r   s   @r   r   r      s    1,r   r   c                   0     e Zd ZdZd fd	Zd fd	Z xZS )_StoreConstActionzR
    Same as `argparse._StoreConstAction` but uses the custom `_StoreAction`.
    c           	      2    t         |   ||d||||       y )Nr   )r   r   nargsconstdefaultrequiredhelpr	   r
   )r   r   r   r-   r.   r/   r0   r   s          r   r
   z_StoreConstAction.__init__-   s*    ) 	 	
r   c                 >    t         |   ||| j                  |       y r!   )r	   r    r-   )r   r   r   r   r   r   s        r   r    z_StoreConstAction.__call__8   s    DJJFr   NFNr!   r"   r(   s   @r   r*   r*   (   s    	
G Gr   r*   c                   *     e Zd ZdZ	 	 	 d fd	Z xZS )_StoreTrueActionzV
    Same as `argparse._StoreTrueAction` but uses the custom `_StoreConstAction`.
    c                 0    t         |   ||d|||       y )NT)r   r   r-   r.   r/   r0   r1   )r   r   r   r.   r/   r0   r   s         r   r
   z_StoreTrueAction.__init__A   s&     	)D'\dko 	 	
r   r3   )r#   r$   r%   r&   r
   r'   r(   s   @r   r5   r5   <   s     

 

r   r5   c                   "     e Zd ZdZ fdZ xZS )CustomArgumentGroupz
    Custom argument group that allows for the use of `-` or `_` in arguments passed and overrides the help for each
    when applicable.
    c           	      r   t        |      }t        |t        j                        rt        |d   |d   |d   |d   |d         }nbt        |t        j                        r#t	        |d   |d   |d   |d   |d   |d         }n%t        |t        j
                        rt        di |}t        |   |      }|S )Nr   r   r.   r/   r0   r-    )vars
isinstanceargparser5   r*   r   r	   _add_action)r   actionr   r   s      r   r>   zCustomArgumentGroup._add_actionT   s    F|fh778%%&Vd9otJGWY]^dYeF  : :;&%&VWYZ VF  5 56!)D)F$V,r   )r#   r$   r%   r&   r>   r'   r(   s   @r   r8   r8   N   s    
 r   r8   c                   (     e Zd ZdZ fdZd Z xZS )CustomArgumentParserz
    Custom argument parser that allows for the use of `-` or `_` in arguments passed and overrides the help for each
    when applicable.
    c                 b    d|v r|d   dk(  rt         |d<   n	t        |d<   t        |   |i | y )Nr?   
store_true)r5   r   r	   add_argument)r   r   r   r   s      r   rD   z!CustomArgumentParser.add_argumento   s>    vh</#3x +F8d-f-r   c                 Z    t        | g|i |}| j                  j                  |       |S r!   )r8   _action_groupsr   )r   r   r   groups       r   add_argument_groupz'CustomArgumentParser.add_argument_groupx   s/    #D:4:6:""5)r   )r#   r$   r%   r&   rD   rH   r'   r(   s   @r   rA   rA   i   s    
.r   rA   )	r=   Actionr   r*   r5   _ArgumentGroupr8   ArgumentParserrA   r:   r   r   <module>rL      sY    ,8?? ,,G G(
( 
$(11 6822 r   