o
    2h	                     @   s&   d dl mZ G dd dZdd ZdS )    )global_statec                   @   s,   e Zd ZdZ	d
ddZdd Zdd	 ZdS )
name_scopea  Creates a sub-namespace for variable paths.

    Args:
        name: Name of the current scope (string).
        caller: Optional ID of a caller object (e.g. class instance).
        deduplicate: If `True`, if `caller` was passed,
            and the previous caller matches the current caller,
            and the previous name matches the current name,
            do not reenter a new namespace.
        override_parent: Can be used to provide an absolute path
            which would override any previously opened name scopes.
    NTc                 C   sf   t |tr	d|v rtd| || _|| _|| _|| _|d u r.|r.t|dd d ur.|j| _d| _	d S )N/zRArgument `name` must be a string and cannot contain character `/`. Received: name=_parent_pathF)

isinstancestr
ValueErrornamecallerdeduplicateoverride_parentgetattrr   _pop_on_exit)selfr	   r
   r   r    r   ^/var/www/html/chatgem/venv/lib/python3.10/site-packages/keras/src/backend/common/name_scope.py__init__   s    
zname_scope.__init__c                 C   sd   t jdg dd}| jr(|r(|d j}|d j}| jd ur(| j|u r(| j|kr(| S ||  d| _| S )Nname_scope_stackT)defaultset_to_default)r   get_global_attributer   r
   r	   appendr   )r   r   parent_callerparent_namer   r   r   	__enter__'   s   






zname_scope.__enter__c                 O   s    | j rtd}|  d S d S )Nr   )r   r   r   pop)r   argskwargsr   r   r   r   __exit__8   s   zname_scope.__exit__)NTN)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r      s    
r   c                  C   sZ   t d} | d u rdS g }| D ]}|jd ur!dd |jdD }||j qd|S )Nr    c                 S   s   g | ]}|r|qS r   r   ).0pr   r   r   
<listcomp>G   s    z current_path.<locals>.<listcomp>r   )r   r   r   splitr   r	   join)r   partsentryr   r   r   current_path@   s   


r,   N)keras.src.backend.commonr   r   r,   r   r   r   r   <module>   s    <