
    ~Wh7                        d Z ddlZddlZddlZddlmc mZ  e	ed          rej
        Z
n ej        dg d          Z
 e	ed          rej        Zn ej        dg d          Zd Z e	ed          rej        Zd	 Zn
ej        Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd$dZd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d  Z%d! Z&d%d#Z'dS )&z6TFDecorator-aware replacements for the inspect module.    NArgSpecargsvarargskeywordsdefaultsFullArgSpecr   r   varkwr   
kwonlyargskwonlydefaultsannotationsc           	          t          | t                    r| S t          | j        | j        | j        | j        g d i           S )Nr
   )
isinstancer	   r   r   r   r   )argspecs    \/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/keras/utils/tf_inspect.py%_convert_maybe_argspec_to_fullargspecr   4   sO    ';'' \!       getfullargspecc                 r    t          |           }t          |j        |j        |j        |j                  }|S )a  A python3 version of getargspec.

        Calls `getfullargspec` and assigns args, varargs,
        varkw, and defaults to a python 2/3 compatible `ArgSpec`.

        The parameter name 'varkw' is changed to 'keywords' to fit the
        `ArgSpec` struct.

        Args:
          target: the target object to inspect.

        Returns:
          An ArgSpec with args, varargs, keywords, and defaults parameters
          from FullArgSpec.
        r   )r   r   r   r   r   r   )targetfullargspecsargspecss      r   _getargspecr   E   sD      &f--" (!'!*	
 
 
 r   c                 :    t          t          |                     S )zA python2 version of getfullargspec.

        Args:
          target: the target object to inspect.

        Returns:
          A FullArgSpec with empty kwonlyargs, kwonlydefaults and annotations.
        )r   
getargspec)r   s    r   _getfullargspecr   a   s     5Z5G5GHHHr   c                  @    t          j                    d         d         S )z7TFDecorator-aware replacement for inspect.currentframe.   r   _inspectstack r   r   currentframer$   m   s    >Aq!!r   c                    t          | t          j                  rt          |           S t          j        j                            |           \  }}t          d |D             d          }|r|S 	 t          |          S # t          $ r Y nw xY wt          |t                    rJ	 t          |j                  S # t          $ r Y nw xY w	 t          |j                  S # t          $ r Y nw xY wt          t          |          j                  S )ad  TFDecorator-aware replacement for `inspect.getargspec`.

    Note: `getfullargspec` is recommended as the python 2/3 compatible
    replacement for this function.

    Args:
      obj: A function, partial function, or callable object, possibly decorated.

    Returns:
      The `ArgSpec` that describes the signature of the outermost decorator that
      changes the callable's signature, or the `ArgSpec` that describes
      the object if not decorated.

    Raises:
      ValueError: When callable's signature can not be expressed with
        ArgSpec.
      TypeError: For objects of unsupported types.
    c              3   2   K   | ]}|j         	|j         V  d S N)decorator_argspec).0ds     r   	<genexpr>zgetargspec.<locals>.<genexpr>   s:       	
 	
". ....	
 	
r   N)r   	functoolspartial_get_argspec_for_partialtf__internal__	decoratorunwrapnextr   	TypeErrortype__init____new____call__)obj
decoratorsr   specs       r   r   r   r   sM   & #y()) -',,,299#>>J	
 	
	
 	
 	

 	 D  6"""    &$ 		v/// 	 	 	D		v~... 	 	 	D	
 tF||,---s6   0A? ?
BB%B9 9
CC
C 
C+*C+c           
         t          | j                  }| j        pi }t          | j                  \  }}}|d         t                      gt                    z  }|r||t          |           d<   |                                D ]5\  }}|v r                    |          }	|||	<   $|st          d          6t          fdt          |          D             d          t          ||d          S fdt          |          D             }
|
rt          d|
 d          t          ||t          |d                             S )zImplements `getargspec` for `functools.partial` objects.

    Args:
      obj: The `functools.partial` object
    Returns:
      An `inspect.ArgSpec`
    Raises:
      ValueError: When callable's signature can not be expressed with
        ArgSpec.
    NzSFunction does not have **kwargs parameter, but contains an unknown partial keyword.c              3   *   K   | ]\  }}|u	|V  d S r'   r#   )r)   idxx
no_defaults      r   r+   z+_get_argspec_for_partial.<locals>.<genexpr>   s1      JJaaz6I6I6I6I6I6IJJr   c                 :    g | ]\  }}|u 	|k    |         S r#   r#   )r)   ijr   first_defaultr@   s      r   
<listcomp>z,_get_argspec_for_partial.<locals>.<listcomp>   s>       Aq
??q=00 	Q000r   zSome arguments z| do not have default value, but they are positioned after those with default values. This can not be expressed with ArgSpec.)lenr   r   r   funcobjectitemsindex
ValueErrorr3   	enumerater   tuple)r9   n_prune_argspartial_keywordsr   r   r   all_defaultskwdefaultr>   invalid_default_valuesr   rD   r@   s              @@@r   r.   r.      s   T sx==L|)r(238(<(<%D'8X D
 J<#d))+L 2)1c(mm^%%& (--//  G::**R..C 'L 	7  	 JJJJ9\22JJJD M
 tWh555     l++    
F4 F F F
 
 	
 4(E,}~~2N,O,OPPPr   c                     t           j        j                            |           \  }}|D ]}|j        t          |j                  c S  t          |          S )a  TFDecorator-aware replacement for `inspect.getfullargspec`.

    This wrapper emulates `inspect.getfullargspec` in[^)]* Python2.

    Args:
      obj: A callable, possibly decorated.

    Returns:
      The `FullArgSpec` that describes the signature of
      the outermost decorator that changes the callable's signature. If the
      callable is not decorated, `inspect.getfullargspec()` will be called
      directly on the callable.
    )r/   r0   r1   r2   r(   r   r   )r9   r:   r   r*   s       r   r   r     se     299#>>J N N*89LMMMMM +6"""r   c                  j   | d         }| dd         }t          |          }|                                t          |dd          pt          |dd          }t          |          r|r|f|z   }fd|j        D             }                    t          t          ||                               |j        sdnt          |j                  }|r2t          |j        | d         |j                  D ]\  }}	|vr|	|<   |j
        (|j
                                        D ]\  }
}|
vr||
<   S )an  TFDecorator-aware replacement for inspect.getcallargs.

    Args:
      *func_and_positional: A callable, possibly decorated, followed by any
        positional arguments that would be passed to `func`.
      **named: The named argument dictionary that would be passed to `func`.

    Returns:
      A dictionary mapping `func`'s named arguments to the values they would
      receive if `func(*positional, **named)` were called.

    `getcallargs` will use the argspec from the outermost decorator that
    provides it. If no attached decorators modify argspec, the final unwrapped
    target's argspec will be used.
    r   r   Nim_self__self__c                     g | ]}|v|	S r#   r#   )r)   arg	call_argss     r   rE   zgetcallargs.<locals>.<listcomp>8  s*       s)';';';';';r   )r   copygetattrismethodr   updatedictzipr   rF   r   rI   )func_and_positionalnamedrG   
positionalr   thisremaining_positionalsdefault_countrY   valuekvrZ   s               @r   getcallargsrj   !  sz     q!D$QRR(JT""G

I4D))LWT:t-L-LD~~ *$ *Wz)
   |   T#3Z@@AABBB$-HAA3w7G3H3HM 'glM>??;W=MNN 	' 	'JC)##!&	#)*0022 	! 	!DAq	!! 	!r   c                  $    t          j        | i |S r'   )r!   getframeinfo)r   kwargss     r   rl   rl   H  s     $1&111r   c                 *    t          j        |           S )a3  TFDecorator-aware replacement for inspect.getdoc.

    Args:
      obj: An object, possibly decorated.

    Returns:
      The docstring associated with the object.

    The outermost-decorated object is intended to have the most complete
    documentation, so the decorated parameter is not unwrapped.
    )r!   getdocr9   s    r   ro   ro   L  s     ?3r   c                     t           j        j                            |           d         }t	          |d          rd|j        v r|j        d         S t          j        |          S )z2TFDecorator-aware replacement for inspect.getfile.r   	f_globals__file__)r/   r0   r1   r2   hasattrrr   r!   getfile)r9   unwrapped_objects     r   ru   ru   [  sd    077<<Q? 	 +..6*444)*55,---r   c                 ,    t          j        | |          S )z5TFDecorator-aware replacement for inspect.getmembers.)r!   
getmembers)r9   	predicates     r   rx   rx   k  s    sI...r   c                 *    t          j        |           S )z4TFDecorator-aware replacement for inspect.getmodule.)r!   	getmodulerp   s    r   r{   r{   p  s    c"""r   c                 *    t          j        |           S )z1TFDecorator-aware replacement for inspect.getmro.)r!   getmro)clss    r   r}   r}   u  s    ?3r   c                 z    t          j        t          j        j                            |           d                   S )z4TFDecorator-aware replacement for inspect.getsource.r   )r!   	getsourcer/   r0   r1   r2   rp   s    r   r   r   z  +    bo7>>sCCAFGGGr   c                 z    t          j        t          j        j                            |           d                   S )z8TFDecorator-aware replacement for inspect.getsourcefile.r   )r!   getsourcefiler/   r0   r1   r2   rp   s    r   r   r     s+    !"/";"B"B3"G"G"JKKKr   c                 z    t          j        t          j        j                            |           d                   S )z9TFDecorator-aware replacement for inspect.getsourcelines.r   )r!   getsourcelinesr/   r0   r1   r2   rp   s    r   r   r     s+    "2?#<#C#CC#H#H#KLLLr   c                 z    t          j        t          j        j                            |           d                   S )z4TFDecorator-aware replacement for inspect.isbuiltin.r   )r!   	isbuiltinr/   r0   r1   r2   rp   s    r   r   r     r   r   c                 z    t          j        t          j        j                            |           d                   S )z2TFDecorator-aware replacement for inspect.isclass.r   )r!   isclassr/   r0   r1   r2   rp   s    r   r   r     +    BO5<<SAA!DEEEr   c                 z    t          j        t          j        j                            |           d                   S )z5TFDecorator-aware replacement for inspect.isfunction.r   )r!   
isfunctionr/   r0   r1   r2   rp   s    r   r   r     s+    r8??DDQGHHHr   c                 z    t          j        t          j        j                            |           d                   S z3TFDecorator-aware replacement for inspect.ismodule.r   )r!   isframer/   r0   r1   r2   rp   s    r   r   r     r   r   c                 z    t          j        t          j        j                            |           d                   S )z6TFDecorator-aware replacement for inspect.isgenerator.r   )r!   isgeneratorr/   r0   r1   r2   rp   s    r   r   r     s+     9 @ @ E Ea HIIIr   c                 z    t          j        t          j        j                            |           d                   S )z>TFDecorator-aware replacement for inspect.isgeneratorfunction.r   )r!   isgeneratorfunctionr/   r0   r1   r2   rp   s    r   r   r     s2    '
!((--a0  r   c                 z    t          j        t          j        j                            |           d                   S )z3TFDecorator-aware replacement for inspect.ismethod.r   )r!   r]   r/   r0   r1   r2   rp   s    r   r]   r]     +    R_6==cBB1EFFFr   c                 z    t          j        t          j        j                            |           d                   S r   )r!   ismoduler/   r0   r1   r2   rp   s    r   r   r     r   r   c                 z    t          j        t          j        j                            |           d                   S )z4TFDecorator-aware replacement for inspect.isroutine.r   )r!   	isroutiner/   r0   r1   r2   rp   s    r   r   r     r   r   r   c                 :    t          j        |           dd         S )z0TFDecorator-aware replacement for inspect.stack.r   Nr    )contexts    r   r"   r"     s    >'""122&&r   r'   )r   )(__doc__collectionsr,   inspectr!   tensorflow.compat.v2compatv2r/   rt   r   
namedtupler	   r   r   r   r   r   r$   r.   rj   rl   ro   ru   rx   r{   r}   r   r   r   r   r   r   r   r   r   r]   r   r   r"   r#   r   r   <module>r      s   = <             ! ! ! ! ! ! ! ! !
78Y GG$k$	
 	
 	
 G 78]## &KK(+(	
 	
 	
 K   78%&& (I-O   4 %K	I 	I 	I" " "
6. 6. 6.r]Q ]Q ]Q@# # #,$ $ $N2 2 2     . . . / / / /
# # #
     
H H H
L L L
M M M
H H H
F F F
I I I
F F F
J J J
  G G G
G G G
H H H
' ' ' ' ' 'r   