U
    0-e                     @   s6   d dl Z edddZdd Zddd	ZdddZdS )    N)returnc                 C   s2   |   } | dkrdS | dkr dS td|  dS )z
    Converts a string representation of truth to `True` (1) or `False` (0).

    True values are `y`, `yes`, `t`, `true`, `on`, and `1`; False value are `n`, `no`, `f`, `false`, `off`, and `0`;
    )yyesttrueon1   )nnoffalseoff0r   zinvalid truth value N)lower
ValueError)value r   ]/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/accelerate/utils/environment.pystr_to_bool   s    r   c                 C   s0   | D ]&}t tj|d}|dkr|  S q|S )zQReturns the first positive env value found in the `env_keys` list or the default.r   )intosenvironget)Zenv_keysdefaultevalr   r   r   get_int_from_env!   s
    
r   Fc                 C   s   t j| t|}t|dkS )zJReturns truthy value for `key` from the env if available else the default.r	   )r   r   r   strr   keyr   r   r   r   r   parse_flag_from_env*   s    r"   r   c                 C   s   t j| t|}|S )N)r   r   r   r   r    r   r   r   parse_choice_from_env0   s    r#   )F)r   )r   r   r   r   r"   r#   r   r   r   r   <module>   s   	
