
    [Th4S                     L   % S SK r S SKrS SKrS SKrS SKrS SKrS SKJrJrJrJ	r	J
r
Jr  S SKrS SKJr  S SKJrJr  SSKJr  \(       a  SSKJr  / SQr\" S	S
9 " S S\	5      5       r0 r\\\\R6                     4   \S'   S r\" 5       \\R<                  '    " S S5      r\R@                  \RB                  \RD                  \RF                  \RH                  RJ                  \ RL                  \RN                  \" 5       \(" S5      \RR                  \RT                  " S5      S.r+\," \5       H  r-\." \\-5      \+\-'   M     SSS\4S jr/S\R`                  Rb                  S\R6                  4S jr20 r3\\4\5\54   \R6                  4   \S'   S\R`                  Rb                  S\R6                  4S jr6\" S	S
9S\S\4S   S\\5S4   4S  j5       r7\" S	S
9S1S!\S"\84S# jj5       r9\" S	S
9S$ 5       r:\" S	S
9S%\S&\4S' j5       r;\" S	S
9    S2S\S\4\S(4   S\
\\5\4      S)\
\4\      S*\
\\5\4      S+\8S\
\   4S, jj5       r<\" S	S
9  S3S-\Rz                  R|                  S\5S\4\   S\
\\5\4      S+\8S\
\   4S. jj5       r?S/\R6                  S\4\S(4   S\\5\4   S+\8S\
\   4
S0 jr@g)4    N)AnyCallablecast
NamedTupleOptionalTYPE_CHECKING)boolean_dispatched)
OpOverloadOpOverloadPacket   )compatibility)Argument)ArgsKwargsPaircheck_for_mutable_operationget_signature_for_torch_opcreate_type_hinttype_matchesnormalize_functionnormalize_moduleF)is_backward_compatiblec                   B    \ rS rSr% Sr\\S4   \S'   \\	\4   \S'   Sr
g)r      z4
Simple named tuple for wrapping args/kwargs pairs.
.argskwargs N)__name__
__module____qualname____firstlineno____doc__tupler   __annotations__dictstr__static_attributes__r       Q/var/www/auris/envauris/lib/python3.13/site-packages/torch/fx/operator_schemas.pyr   r      s%     S/cNr&   r   _manual_overridesc                      / n S nU R                  [        R                  " U5      5        S[        4S jnU R                  [        R                  " U5      5        U $ )Nc                     g Nr   )selfs    r'   nonzero!_nonzero_schemas.<locals>.nonzero/       r&   as_tuplec                    g r+   r   )r,   r0   s     r'   r-   r.   4   r/   r&   )appendinspect	signaturebool)
signaturesr-   s     r'   _nonzero_schemasr7   ,   sT    J g''014  g''01r&   c                       \ rS rSrS rSrg)_FakeGlobalNamespace?   c                 0    US:X  a  [         $ [        S5      e)Ntorchz!Expected a torch namespace lookup)r<   RuntimeError)r,   names     r'   __getattr__ _FakeGlobalNamespace.__getattr__@   s    7?L>??r&   r   N)r   r   r   r   r?   r%   r   r&   r'   r9   r9   ?   s    @r&   r9   t)TensorDeviceLayoutnumberFutureAnyEnumTypeQScheme	__torch__NoneTypeStoragerA   ts_typeztorch._C.JitTypereturnc                 6    [        U R                  [        5      $ )z
Convert a TorchScript type to a Python type (including subtypes) via
eval'ing the annotation_str. _type_eval_globals sets up expressions
like "List" and "Future" to map to actual types (typing.List and jit.Future)
)evalannotation_str_type_eval_globals)rL   s    r'    _torchscript_type_to_python_typerR   W   s     &&(:;;r&   	ts_schemac           
      z   SSK Jn  / nU R                   GH)  n[        UR                  5      nUR                  5       (       a  UR                  OUR                  nUR                  S:w  a  UR                  OSnUR                  (       a  UR                  OUR                  nUS:X  a  XqR                  :X  d   eUR                  n[        U5       HT  u  pU	R                  UR                  :X  d   eU" U	R                  UR                  U	R                  U	R                   S9X('   MV     UR#                  U" XgXTS95        GM,     U R$                   V
s/ s H  n
[        U
R                  5      PM     nn
['        U5      S:X  a  S nO ['        U5      S:X  a  US   nO[)        U5      n[         R*                  " X,S9$ s  sn
f )	Nr   )	Parameterr,   inputfrom)r>   kinddefault
annotationr   )return_annotation)r3   rU   	argumentsrR   typehas_default_valuedefault_valueemptyr>   
kwarg_onlyKEYWORD_ONLYPOSITIONAL_OR_KEYWORDPOSITIONAL_ONLY	enumeraterX   rY   rZ   r2   returnslenr!   	Signature)rS   rU   
parametersargarg_typerY   r>   rX   idxpretreturn_typesreturn_types                r'   %_torchscript_schema_to_signature_implrq   `   s    ""$J""3CHH='*'<'<'>'>###IOO 88v-sxx7 ~~ ""00 	 6>::::: ,,D#J/vv!@!@@@@"+"22II ||	#
 0 	4GQ	
; #B ?H>O>O>Os(2>O   <A	\	a	"1oL)ZGGs   F8_SCHEMA_TO_SIGNATURE_CACHEc                     U R                   U R                  4n[        R                  U5      nUb  U$ [	        U 5      nU[        U'   U$ r+   )r>   overload_namerr   getrq   )rS   	cache_key	cache_valress       r'    _torchscript_schema_to_signaturery      sN     	 7 77I*..y9I
/	
:C,/y)Jr&   targetr   )r   .r   r   c                 8   [        U SS9u  p4U(       av  U(       an  / n[        X45       H*  u  pg UR                  " U0 UD6  UR                  Xg45        M,     S n[        U5      S:X  a  g [        U5      S:X  a  US   u  pU" U
5        g g g g ! [         a     Mp  f = f)NT)return_schemasc                 D    U R                   (       a  [        SU  S35      eg )Nz!Tried to trace mutable operation z|. FX only supports functional code, so operations that mutate operands in-place (e.g. via `out` arguments) are not supported)
is_mutabler=   )schemas    r'   throw_if_mutable5check_for_mutable_operation.<locals>.throw_if_mutable   s/      "7x @( )  !r&   r   r   )r   zipbindr2   	TypeErrorrg   )rz   r   r   r6   schemasmatched_schemascandidate_signaturer   r   _schema_to_checks              r'   r   r      s     5VDQJg
 ,/z+C'#(($9&9&&(;'DE ,D	 1$!Q&!0!3A_- ? z  s   $B
BBopr|   c                 :   [        U [        5      (       a  U R                  /nO[        U [        5      (       a4  U R	                  5        Vs/ s H  n[        X5      R                  PM     nnO[        R                  U 5      nU(       a  U(       a  US4$ S$ [        R                  R                  R                  U 5      nUc  U(       a  S$ S$ [        R                  R                  U5      nU Vs/ s H  n[        U5      PM     nnU(       a  Xr4$ U$ s  snf s  snf )aX  
Given an operator on the `torch` namespace, return a list of `inspect.Signature`
objects corresponding to the overloads of that op.. May return `None` if a signature
could not be retrieved.

Args:
    op (Callable): An operator on the `torch` namespace to look up a signature for

Returns:
    Optional[List[inspect.Signature]]: A list of signatures for the overloads of this
        operator, or None if the operator signatures could not be retrieved. If
        return_schemas=True, returns a tuple containing the optional Python signatures
        and the optional TorchScript Function signature
N)NN)
isinstancer
   _schemar   	overloadsgetattrr(   ru   r<   jit	_builtins_find_builtin_C_jit_get_schemas_for_operatorry   )r   r|   r   overloadoverrideaten_fnr   r6   s           r'   r   r      s      "j!!::,	B(	)	)ACPX72(00P$((,'5Hd#?4?))%%33B7?#1<;t;((88AIPQv26:JQ$2J B
B Q Rs   D0Dc                     [        U [        [        45      (       a  [        U [        5      (       a  S nOS n[        U 5      S:X  a  U" [        5      $ U S   nU  H5  n[        X25      (       a  M  [        X#5      (       a  UnM)  U" [        5      s  $    U" U5      $  U $ ! [         a    [        R                  " SU  35         U $ f = f)a  
Produces a type hint for the given argument.

The :func:`create_type_hint` looks for a type hint compatible with the input argument `x`.

If `x` is a `list` or `tuple`, it looks for an object in the list whose type is a superclass
of the rest, and uses that as `base_type` for the `List` or `Tuple` to be returned.
If no such object is found, it defaults to `List[Any]`.

If `x` is neither a `list` nor a `tuple`, it returns `x`.
c                     [         U    $ r+   )listxs    r'   ret_type"create_type_hint.<locals>.ret_type  s    7Nr&   c                     [         U S4   $ )N.)r!   r   s    r'   r   r     s     C=(r&   r   z@We were not able to successfully create type hint from the type )	r   r   r!   rg   r   
issubclass	Exceptionwarningswarn)r   r   	base_typerA   s       r'   r   r      s    
a$''!T""#
) 1v{}$!Ia++	-- !I#C=(  I&&- (8 H  
NqcR	
 H
s   AB =B 	B #CCsignature_typeargument_typec                   ^^ [        U SU 5      nU TL a  gU[        R                  L a'  U T:w  a!  U R                  n[	        U4S jU 5       5      $ [        U SS 5      [
        L a  U R                  S   mT[        L a
  T[        L a  g[        R                  " T5      (       d  [        R                  " SU  S35        g[        TSS 5      [
        L a  [        TR                  S   T5      $ U4S jnU" T5      $ U [        L a  T[        R                  L a  gU [        R                  L a  T[        [         1;   a  g[        R                  " T5      (       a'  [        R                  " U 5      (       a  [        TU 5      $ g)	N
__origin__Tc              3   <   >#    U  H  n[        UT5      v   M     g 7fr+   )r   ).0cr   s     r'   	<genexpr>type_matches.<locals>.<genexpr>'  s     I=a<=11=s   r   z.Does not support nested parametric types, got z. Please file a bug.Fc                    > [        U SS 5      [        La  gU R                  nU R                  S:X  a  g[        U4S jU 5       5      $ )Nr   F)r   Tc              3   X   >#    U  H  o[         L =(       d    [        UT5      v   M!     g 7fr+   )Ellipsisr   )r   r   sig_el_types     r'   r   =type_matches.<locals>.is_homogeneous_tuple.<locals>.<genexpr>>  s"     XiXD*Q*DDis   '*)r   r!   __args__all)rA   	containedr   s     r'   is_homogeneous_tuple*type_matches.<locals>.is_homogeneous_tuple8  s@    q,-U:

IzzU"XiXXXr&   )r   typingUnionr   anyr   intr3   isclassr   r   r   r<   dtypenumbersNumberfloat)r   r   sig_origin_typesig_containedr   r   s    `   @r'   r   r     sK   nlNKO& &,,&>]+J&//I=III~|T2d:$--a0 CK3$6{++MM@@PPde =,5=m44Q7EE	Y $M22 %++!='Mc5\,I}%%'//.*I*I-88r&   .	arg_typeskwarg_typesnormalize_to_only_use_kwargsc                 X   Uc  0 nSn[        U [        R                  5      (       d  [        U [        [        45      (       d  U nU [
        ;   an  [        U [        5      (       a   e[
        U    nUS   US   p[        R                  " U	5      R                  [        R                  " U
5      R                  :w  a  gU	n[        U5      (       d   e[        R                  " [        R                  " U5      5      n[        XX%5      nU$ [        U 5      (       d   e[        U 5      n/ nU(       GaY  U H'  n UR                  " U0 UD6  UR                  U5        M)     [#        U5      S:X  a   U$ [#        U5      S:X  a  [        US   XU5      nU$ Uc  Ub  U(       a  UO[%        [&        [(           S5      nU(       a  UO0 nU H  nSn UR                  " U0 UD6nUR*                  R-                  5        H4  u  nnUR                  U   nU=(       a    [/        UR0                  U5      nM6     U(       d  Ms  [        UUUU5      n  U$     U$ S	R3                  S
 U 5       5      n[5        S[6        R8                  " U 5       SU 35      eU$ ! [          a     GMg  f = f! [          a    Sn N~f = f)a  
Returns normalized arguments to PyTorch functions. This means that
`args/kwargs` will be matched up to the functional's
signature and return exclusively kwargs in positional order if
`normalize_to_only_use_kwargs` is True.
Also populates default values. Does not support positional-only
parameters or varargs parameters (*args, **kwargs). Does not support modules.

May require `arg_types` and `kwarg_types` in order to disambiguate overloads.

Args:
    target (Callable): Function that we are normalizing
    args (Tuple[Any]): Tuple of args to the function
    kwargs (Optional[Dict[str, Any]]): Dict of kwargs to the function
    arg_types (Optional[Tuple[Any]]): Tuple of arg types for the args
    kwarg_types (Optional[Dict[str, Any]]): Dict of arg types for the kwargs
    normalize_to_only_use_kwargs (bool): Whether to normalize to only use kwargs.

Returns:

    Returns normalized_args_and_kwargs, or `None` if not successful.
Nif_trueif_falser   r   r   TF
c              3   8   #    U  H  n[        U5      v   M     g 7fr+   )r$   )r   r   s     r'   r   %normalize_function.<locals>.<genexpr>  s      12AF/s   z Tried to normalize arguments to zy but the schema match was ambiguous! Please provide argument types to the normalize_arguments() call. Available schemas:
)r   typesBuiltinFunctionTyper   r
   r	   r$   r3   r4   ri   callableunwrap&_args_kwargs_to_normalized_args_kwargsr   r   r2   r   rg   r   r!   r   r\   itemsr   rZ   joinr=   r<   typename)rz   r   r   r   r   r   new_args_and_kwargstarget_for_analysis
dispatchedr   r   sigtorch_op_schemasr   r   sig_matchesbound_typesarg_namerk   paramschema_printoutss                        r'   r   r   O  s   > ~fe77886,j9::$''
 "&#....+F3J *9 5z*7MX!!'*55$$X.99: ")+,,,,/B CDDv
B { 5f= (8#',,d=f=#**+>? (8 ?#q(Z Y _%*&L#A&6R'#T M (K,C-6	DsR<PI1<+"K/?+&*
0*=*B*B!*+.9+K 7B6K6K6Q6Q6S 2((;(F(Fx(P.9 /"l$)$4$4h?" 7T '; F$7$($*$@	!" 0 " G 0@F  (,yy 12A1 ($ ':5>>&;Q:R SOO_N`b  e ! 4  ) 0*/K0s%   3#JA$J
JJJ)(J)rootc                     U R                  U5      n[        UR                  S5      (       a  UR                  R
                  n[        [        R                  US5      UR                  :X  aG  [        R                  " [        R                  " UR                  5      5      nUc  0 n[        XX45      n	U	$ g! [         a  n[        SU S35      UeSnAff = f)a  
Returns normalized arguments to PyTorch modules. This means that
`args/kwargs` will be matched up to the functional's
signature and return exclusively kwargs in positional order if
`normalize_to_only_use_kwargs` is True.
Also populates default values. Does not support positional-only
parameters or varargs parameters (*args, **kwargs).

Args:
    root (nn.Module): root module upon which we query modules
    target (Callable): Function that we are normalizing
    args (Tuple[Any]): Tuple of args to the function
    kwargs (Optional[Dict[str, Any]]): Dict of kwargs to the function
    normalize_to_only_use_kwargs (bool): Whether to normalize to only use kwargs.

Returns:

    Returns normalized_args_and_kwargs, or `None` if not successful.
z$Tried to normalize node with target z# but root did not have that target!Nr   )get_submoduleAttributeErrorr=   hasattr	__class__r   r   r<   nnr3   r4   r   forwardr   )
r   rz   r   r   r   submode	classnamer   r   s
             r'   r   r     s    6##F+ v,,$$--	588Y-1A1AA##GNN6>>$BCC~"H6# '&  26( ;  !
 	s   B5 5
C?CCr   c                 d  ^	 [         R                  R                  [         R                  R                  1m	[	        U	4S jU R
                  R                  5        5       5      (       a*  [        U R
                  R                  5       5      / SQ:w  a  gU R                  " U0 UD6nUR                  5         0 n/ n[        U R
                  5       HL  u  pxU(       d/  U[        U5      :  a   UR                  UR                  U   5        M;  UR                  U   XX'   MN     [        [!        U5      U5      $ )aU  
Given a call target, args, and kwargs, return the arguments normalized into
an ArgsKwargsPair, or None if the type signature is not supported by
this normalization.

Args:

    sig (inspect.Signature): Signature object for the target
    args (Tuple): Arguments that appear at the callsite for `target`
    kwargs (Dict): Keyword arguments that appear at the callsite for `target`
    normalize_to_only_use_kwargs (bool): Whether to normalize to only use kwargs.

Returns:

    Optional[ArgsKwargsPair]: Normalized args and kwargs for `target`, or `None` if
        this target is not supported.
c              3   @   >#    U  H  oR                   T;  v   M     g 7fr+   )rX   )r   rm   supported_parameter_typess     r'   r   9_args_kwargs_to_normalized_args_kwargs.<locals>.<genexpr>  s     
T<Sq6622<Ss   )rV   rW   to	generatorN)r3   rU   rc   rb   r   ri   valuesr   keysr   apply_defaultsre   rg   r2   r\   r   r!   )
r   r   r   r   
bound_args
new_kwargsnew_argsir   r   s
            @r'   r   r     s    6 	//&&! 
TCNN<Q<Q<S
TTT
 ##%&*NN4*6*J!#JHcnn-+CIOOJ0078 * 4 4U ;J	 . %/:66r&   )F)NNNF)NF)Aenumr3   r   r   r   r   r   r   r   r   r   r   r<   torch._jit_internalr	   
torch._opsr
   r   _compatibilityr   noder   __all__r   r(   r#   r   rh   r"   r7   r-   r9   rB   devicelayoutr   r   rF   Enumqschemer]   UntypedStorageTypeVarrQ   dirkr   rR   r   FunctionSchemarq   rr   r!   r$   ry   r   r5   r   r   r   r   r   Moduler   r   r   r&   r'   <module>r     s         K K  2 3 )  e,Z  - >@ 4$w'8'8"99: ?  $4#5 %--  @ @ llllllnnii99}}%'T
##		  
VA#FA.q 
<.@ <S <0Hxx&&0H0Hf HJ DsCx'2C2C!CD Ixx&& e,$$!/2$<@j<Q$ -$N e,C8 CT C -CD e,) -)X e,/ /S / -/d e, (,&*,0).ww
S/w T#s(^$w c
#	w
 $sCx.)w #'w nw -wt e,
 (,).+
((//++ *+ T#s(^$	+
 #'+ n+ -+\17			17
S/17 cN17 #'	17
 n17r&   