Ë
    3êñi¬W  ã                  ó„  — U d dl mZ d dlZd dlmZ d dlmZmZmZmZm	Z	 d dl
mZmZmZ d dlZd dlmZ erd dlmZ dd	lmZ g d
¢Z ed«      Z ed«      Z eej0                  d«      s] ed«      ej0                  j2                  d<    ed«      ej0                  j2                  d<    ed«      ej0                  j2                  d<   d dlmZmZmZ dd„Zd d„Z G d„ de«      Z  G d„ d«      Z!e	dede"f   f   Z#de$d<   e	 	 	 d!	 	 	 	 	 	 	 	 	 	 	 d"d„«       Z%e	 	 	 d!	 	 	 	 	 	 	 	 	 	 	 d#d„«       Z%	 	 	 d!	 	 	 	 	 	 	 	 	 	 	 d$d„Z%y)%é    )ÚannotationsN)ÚCallable)ÚOptionalÚoverloadÚTYPE_CHECKINGÚ	TypeAliasÚUnion)Ú	ParamSpecÚSelfÚTypeVar)ÚTensor)Ú_POOL_HANDLEé   )Ú_dummy_type)Úis_current_stream_capturingÚgraph_pool_handleÚXPUGraphÚgraphÚmake_graphed_callablesÚ_RÚ_PÚ_XpuStreamBaseÚ	_XPUGraphÚ_xpu_graph_pool_handleÚ_xpu_isCurrentStreamCapturing)r   r   r   c                 ó   — t        «       S )zÉReturn True if XPU graph capture is underway on the current XPU stream, False otherwise.

    If a XPU context does not exist on the current device, returns False without initializing the context.
    )r   © ó    úR/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/torch/xpu/graphs.pyr   r   )   s   € ô
 )Ó*Ð*r   c                 óP   — t         j                  j                  t        «       «      S )zBReturn an opaque token representing the id of a graph memory pool.)ÚtorchÚxpur   r   r   r   r   r   r   1   s   € ä�9‰9×!Ñ!Ô"8Ó":Ó;Ð;r   c                  ó    ‡ — e Zd ZdZddˆ fd„Zddˆ fd„Zdˆ fd„Zdˆ fd„Zdˆ fd„Zdˆ fd„Z	dˆ fd„Z
dˆ fd	„Zdˆ fd
„Zdˆ fd„Zdˆ fd„Zˆ xZS )r   a  Wrapper around a XPU graph.

    Arguments:
        keep_graph (bool, optional): If ``keep_graph=False``, the
            executable command graph will be instantiated on GPU at the end of
            ``capture_end`` and the underlying modifiable command graph will be
            destroyed. Note that the executable command graph will not be
            instantiated at the end of ``capture_end`` in this
            case. Instead, it will be instantiated via an explicit called
            to ``instantiate`` or automatically on the first call to
            ``replay`` if ``instantiate`` was not already called. Calling
            ``instantiate`` manually before ``replay`` is recommended to
            prevent increased latency on the first call to ``replay``.

    c                ó$   •— t         ‰| �  | |«      S ©N)ÚsuperÚ__new__)ÚclsÚ
keep_graphÚ	__class__s     €r   r'   zXPUGraph.__new__G   s   ø€ Ü‰w‰˜s JÓ/Ð/r   c                ó&   •— t         ‰| �  |¬«       y)aÙ  Begin capturing XPU work on the current xpu stream.

        Typically, you shouldn't call ``capture_begin`` yourself.
        Use :class:`~torch.xpu.graph`, which call ``capture_begin`` internally.

        Arguments:
            pool (optional): Token (returned by :func:`~torch.xpu.graph_pool_handle` or
                :meth:`other_Graph_instance.pool()<torch.xpu.XPUGraph.pool>`) that hints this graph may share memory
                with the indicated pool.
        ©ÚpoolN)r&   Úcapture_begin)Úselfr-   r*   s     €r   r.   zXPUGraph.capture_beginJ   s   ø€ ô 	‰Ñ 4ÐÕ(r   c                ó"   •— t         ‰| �  «        y)a  End XPU graph capture on the current stream.

        After ``capture_end``, ``replay`` may be called on this instance.

        Typically, you shouldn't call ``capture_end`` yourself.
        Use :class:`~torch.xpu.graph`, which call ``capture_end`` internally.
        N)r&   Úcapture_end©r/   r*   s    €r   r1   zXPUGraph.capture_endW   s   ø€ ô 	‰ÑÕr   c                ó"   •— t         ‰| �  «        y)a/  Instantiate the XPU graph. Will be called by
        ``capture_end`` if ``keep_graph=False``, or by ``replay`` if
        ``keep_graph=True`` and ``instantiate`` has not already been
        explicitly called. Does not destroy the xpu modify command graph returned
        by ``raw_xpu_graph``.
        N)r&   Úinstantiater2   s    €r   r4   zXPUGraph.instantiatea   s   ø€ ô 	‰ÑÕr   c                ó"   •— t         ‰| �  «        y)z+Replay the XPU work captured by this graph.N)r&   Úreplayr2   s    €r   r6   zXPUGraph.replayj   s   ø€ ä‰‰Õr   c                ó"   •— t         ‰| �  «        y)z1Delete the graph currently held by this instance.N)r&   Úresetr2   s    €r   r8   zXPUGraph.resetn   s   ø€ ä‰‰�r   c                ó    •— t         ‰| �  «       S )zäReturn an opaque token representing the id of this graph's memory pool.

        This id can optionally be passed to another graph's ``capture_begin``,
        which hints the other graph may share the same memory pool.
        )r&   r-   r2   s    €r   r-   zXPUGraph.poolr   s   ø€ ô ‰w‰|‹~Ðr   c                ó    •— t         ‰| �  «       S )z.Enable debugging mode for XPUGraph.debug_dump.)r&   Úenable_debug_moder2   s    €r   r;   zXPUGraph.enable_debug_modez   s   ø€ ä‰wÑ(Ó*Ð*r   c                ó"   •— t         ‰| �  |«      S )zÕ
        Arguments:
            debug_path (required): Path to dump the graph to.

        Calls a debugging function to dump the graph if the debugging is
        enabled via XPUGraph.enable_debug_mode()
        )r&   Ú
debug_dump)r/   Ú
debug_pathr*   s     €r   r=   zXPUGraph.debug_dump~   s   ø€ ô ‰wÑ! *Ó-Ð-r   c                ó    •— t         ‰| �  «       S )z…Returns the underlying xpuGraph_t. ``keep_graph`` must be True.

        XPU doesn't provide APIs to manipulate this object.
        )r&   Úraw_xpu_graphr2   s    €r   r@   zXPUGraph.raw_xpu_graphˆ   s   ø€ ô
 ‰wÑ$Ó&Ð&r   c                ó    •— t         ‰| �  «       S )a®  Returns the underlying xpuGraphExec_t. ``instantiate`` must have been called if ``keep_graph`` is True, or ``capture_end`` must have been called if ``keep_graph`` is False. If you call ``instantiate()`` after ``raw_xpu_graph_exec()``, the previously returned xpuGraphExec_t will be destroyed. It is your responsibility not to use this object after destruction.

        XPU doesn't provide APIs to manipulate this object.
        )r&   Úraw_xpu_graph_execr2   s    €r   rB   zXPUGraph.raw_xpu_graph_exec�   s   ø€ ô
 ‰wÑ)Ó+Ð+r   )F)r)   ÚboolÚreturnr   r%   )r-   úOptional[_POOL_HANDLE]rD   ÚNone©rD   rF   ©rD   r   )r>   ÚstrrD   rF   )rD   Úint)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r'   r.   r1   r4   r6   r8   r-   r;   r=   r@   rB   Ú__classcell__)r*   s   @r   r   r   6   sD   ø„ ñö 0ö)õõõõõõ+õ.õ'÷,ñ ,r   r   c                  óH   — e Zd ZU dZdZded<   	 	 d	 	 	 	 	 d	d„Zd
d„Zdd„Zy)r   aŠ  Context-manager that captures XPU work into a :class:`torch.xpu.XPUGraph` object for later replay.

    Arguments:
        xpu_graph (torch.xpu.XPUGraph): Graph object used for capture.
        pool (optional): Opaque token (returned by a call to :func:`~torch.xpu.graph_pool_handle()` or
            :meth:`other_Graph_instance.pool()<torch.xpu.XPUGraph.pool>`) hinting this graph's capture
            may share memory from the specified pool.
        stream (torch.xpu.Stream, optional): If supplied, will be set as the current stream in the context.
            If not supplied, ``graph`` sets its own internal side stream as the current stream in the context.

    .. note::
        For effective memory sharing, if you pass a ``pool`` used by a previous capture and the previous capture
        used an explicit ``stream`` argument, you should pass the same ``stream`` argument to this capture.

    NúOptional[torch.xpu.Stream]Údefault_capture_streamc                ó>  — | j                   j                  €-t        j                  j	                  «       | j                   _        |€dn|f| _        |�|n| j                   j                  | _        | j                  €t        d«      ‚| j                  | _        || _	        y )Nr   zcapture_stream must not be None)
r*   rR   r!   r"   ÚStreamr-   Úcapture_streamÚAssertionErrorÚ
stream_ctxÚ	xpu_graph)r/   rX   r-   Ústreams       r   Ú__init__zgraph.__init__ª   s�   € ð �>‰>×0Ñ0Ð8Ü49·I±I×4DÑ4DÓ4FˆD�N‰NÔ1ð �,‰B T Gð 	Œ	ð Ð(‰F¨d¯n©n×.SÑ.Sð 	Ôð ×ÑÐ&Ü Ð!BÓCÐCØ×-Ñ-ˆŒØ"ˆ�r   c                óö   — t         j                  j                  «        t         j                  j                  «        | j                  j                  «         | j                  j                  | j                  Ž  y r%   )	r!   r"   ÚsynchronizeÚempty_cacherW   Ú	__enter__rX   r.   r-   )r/   s    r   r^   zgraph.__enter__Á   sJ   € ä�	‰	×ÑÔä�	‰	×ÑÔØ�‰×!Ñ!Ô#à$ˆ�‰×$Ñ$ d§i¡iÒ0r   c                ój   — | j                   j                  «         | j                  j                  |Ž  y r%   )rX   r1   rW   Ú__exit__)r/   Úargss     r   r`   zgraph.__exit__Ê   s&   € Ø�‰×"Ñ"Ô$Ø ˆ�‰× Ñ  $Ò'r   )NN)rX   r   r-   rE   rY   rQ   rG   )ra   ÚobjectrD   rF   )	rK   rL   rM   rN   rR   Ú__annotations__rZ   r^   r`   r   r   r   r   r   —   sH   … ñð  :>ÐÐ6Ó=ð
 (,Ø-1ð	#àð#ð %ð#ð +ó	#ó.1ô(r   r   útorch.nn.Module.r   Ú_ModuleOrCallablec                 ó   — y r%   r   ©Ú	callablesÚsample_argsÚnum_warmup_itersÚallow_unused_inputr-   s        r   r   r   Ò   s   € ð r   c                 ó   — y r%   r   rg   s        r   r   r   Ü   s   € ð %(r   c                ó|  — t        j                  «       rt        j                  «       rt        d«      ‚d}t	        | t
        «      s*d}| f} t        j                  t
        t        df   |«      f}n,t        j                  t
        t
        t        df   df   |«      }g }t        | |«      D �]  \  }}	t	        |t         j                  j                  «      r~t        |j                  «      dk(  r0t        |j                  «      dk(  rt        |j                  «      dk(  st        d«      ‚t!        d„ |j#                  «       D «       «      st        d«      ‚t        j$                  j&                  j(                  |	Ž }
|j+                  t        |
«      «       t!        d	„ |
D «       «      rŒüt-        d
«      ‚ |D �	cg c]  }	t        |	«      ‘Œ }}	| D �cg c]A  }t	        |t         j                  j                  «      rt        |j/                  «       «      nd‘ŒC }}t1        t        | «      «      D �cg c]  }||   ||   z   ‘Œ }}t1        t        | «      «      D �cg c]   }t         j2                  j5                  «       ‘Œ" }}t1        t        | «      «      D �cg c]   }t         j2                  j5                  «       ‘Œ" }}|€
t7        «       n|}t         j2                  j9                  «        t         j2                  j;                  t         j2                  j=                  «       «      5  t        | ||«      D ]¸  \  }}	}d\  }}}t1        |«      D ]“  }t         j$                  j&                  j?                   ||	Ž «      }t        d„ |D «       «      }t        |«      dkD  sŒPt         j@                  jC                  |t        d„ |D «       «      t        d„ |D «       «      d|¬«      }Œ• |||fD ]  }~Œ Œº 	 ddd«       t         j2                  j9                  «        g }g }t        | ||«      D ]Œ  \  }}	}t         j2                  jE                  ||¬«      5   ||	Ž }ddd«       t         j$                  j&                  jG                  «      \  }}|j+                  t        |«      «       |j+                  |«       ŒŽ g }g } t        tI        |«      tI        |«      tI        |«      «      D �]  \  }}!}"t        d„ |!D «       «      }#t        d„ |!D «       «      }d}t        |«      dkD  rnt         j2                  jE                  |"|¬«      5  t         j@                  jC                  |t        d„ |D «       «      t        d„ |#D «       «      d|¬«      }ddd«       g }$d}%|D ];  }&|&jJ                  r|�|$j+                  ||%   «       |%dz  }%Œ+|$j+                  d«       Œ= t        |$«      }$|j+                  |#«       | j+                  |$«       �Œ |jM                  «        | jM                  «        	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„}'g }(tO        | «      D ]©  \  }} |'||   ||   ||   ||   ||   ||   ||   ||   | |   «	      })t	        |t         j                  j                  «      rD	 	 	 	 	 	 	 	 	 	 dd„}* |*||jP                  |)|jR                  «      |_)        |(j+                  |«       Œ™|(j+                  |)«       Œ« |r|(d   S t        |(«      S c c}	w c c}w c c}w c c}w c c}w # 1 sw Y   �Œ.xY w# 1 sw Y   �ŒÖxY w# 1 sw Y   �Œ´xY w)a¯  Accept callables (functions or :class:`nn.Module<torch.nn.Module>`\ s) and returns graphed versions.

    Each graphed callable's forward pass runs its source callable's
    forward XPU work as a XPU graph inside a single autograd node.

    The graphed callable's forward pass also appends
    a backward node to the autograd graph. During backward, this node runs the
    callable's backward work as a XPU graph.

    Therefore, each graphed callable should be a drop-in replacement for its source callable
    in an autograd-enabled training loop.

    See :ref:`Partial-network capture<partial-network-capture>` for detailed use and constraints.

    If you pass a tuple of several callables, their captures will use the same memory pool.

    Arguments:
        callables (torch.nn.Module or Python function, or tuple of these): Callable or callables to graph.
            If you pass a tuple of callables, their order in the tuple must be the same order they'll run
            in the live workload.
        sample_args (tuple of Tensors, or tuple of tuples of Tensors): Samples args for each callable.
            If a single callable was passed, ``sample_args`` must be a single tuple of argument Tensors.
            If a tuple of callables was passed, ``sample_args`` must be tuple of tuples of argument Tensors.
        num_warmup_iters (int): The number of warmup iterations. Currently, ``DataDistributedParallel`` needs
            11 iterations for warm up. Default: ``3``.
        allow_unused_input (bool): If False, specifying inputs that were not used when computing outputs
            (and therefore their grad is always zero) is an error. Defaults to False.
        pool (optional): Token (returned by :func:`~torch.xpu.graph_pool_handle` or
            :meth:`other_Graph_instance.pool()<torch.xpu.XPUGraph.pool>`) that hints this graph may share memory
            with the indicated pool.
    .. note::
        The ``requires_grad`` state of each Tensor in ``sample_args`` must match the state
        that's expected for the corresponding real input in the training loop.

    .. warning::
        This API is in beta and may change in future releases.

    .. warning::
        ``sample_args`` for each callable must contain only Tensors. Other types are not allowed.

    .. warning::
        Returned callables do not support higher order differentiation (e.g., double backward).

    .. warning::
        In any :class:`~torch.nn.Module` passed to :func:`~make_graphed_callables`, only parameters
        may be trainable. Buffers must have ``requires_grad=False``.

    .. warning::
        After you pass a :class:`torch.nn.Module` through :func:`~make_graphed_callables`,
        you may not add or remove any of that Module's parameters or buffers.

    .. warning::
        :class:`torch.nn.Module`\s passed to :func:`~torch.xpu.make_graphed_callables` must not have module hooks
        registered on them at the time they are passed. However, registering hooks on modules *after* passing them
        through :func:`~torch.xpu.make_graphed_callables` is allowed.

    .. warning::
        When running a graphed callable, you must pass its arguments in the same order and format
        they appeared in that callable's ``sample_args``.

    .. warning::
        The automatic mixed precision is supported in :func:`~torch.xpu.make_graphed_callables` only with disabled
        caching. The context manager `torch.amp.autocast()` must have `cache_enabled=False`.
    z_make_graphed_callables does not support the autocast caching. Please set `cache_enabled=False`.FT.r   z§Modules must not have hooks registered at the time they are passed. However, registering hooks on modules after passing them through make_graphed_callables is allowed.c              3  ó8   K  — | ]  }|j                   d u –— Œ y­w)FN©Úrequires_grad©Ú.0Úbs     r   ú	<genexpr>z)make_graphed_callables.<locals>.<genexpr>I  s   è ø€ ÒE°A�q—‘¨%Ô/ÑEùs   ‚zœIn any :class:`~torch.nn.Module` passed to :func:`~make_graphed_callables`, only parameters may be trainable. All buffers must have ``requires_grad=False``.c              3  óP   K  — | ]  }t        |t        j                  «      –— Œ  y ­wr%   )Ú
isinstancer!   r   )rr   Úargs     r   rt   z)make_graphed_callables.<locals>.<genexpr>Q  s   è ø€ ÒH°S”:˜c¤5§<¡<×0ÑHùs   ‚$&zfIn the beta API, sample_args for each callable must contain only Tensors. Other types are not allowed.r   N)NNNc              3  ó:   K  — | ]  }|j                   sŒ|–— Œ y ­wr%   ro   ©rr   Úos     r   rt   z)make_graphed_callables.<locals>.<genexpr>q  s   è ø€ Ò$K¨1¸1¿?»?¤QÑ$Kùó   ‚”c              3  ó:   K  — | ]  }|j                   sŒ|–— Œ y ­wr%   ro   ©rr   Úis     r   rt   z)make_graphed_callables.<locals>.<genexpr>u  s   è ø€ ò %Ø"#¸q¿»œAñ%ùr{   c              3  ó`   K  — | ]&  }|j                   sŒt        j                  |«      –— Œ( y ­wr%   ©rp   r!   Ú
empty_likery   s     r   rt   z)make_graphed_callables.<locals>.<genexpr>x  s&   è ø€ ò +Ø45ÀAÇOÃOœE×,Ñ,¨Q×/ñ+ùs   ‚.”.)ÚoutputsÚinputsÚgrad_outputsÚonly_inputsÚallow_unusedr,   c              3  ób   K  — | ]'  }|j                   rt        j                  |«      nd –— Œ) y ­wr%   r€   ry   s     r   rt   z)make_graphed_callables.<locals>.<genexpr>—  s+   è ø€ ò $
ØAB 1§?¢?ŒE×Ñ˜QÔ¸Ó<ñ$
ùs   ‚-/c              3  ó:   K  — | ]  }|j                   sŒ|–— Œ y ­wr%   ro   ry   s     r   rt   z)make_graphed_callables.<locals>.<genexpr>›  s   è ø€ ÒJ 1¸!¿/»/œQÑJùr{   c              3  ó:   K  — | ]  }|j                   sŒ|–— Œ y ­wr%   ro   r}   s     r   rt   z)make_graphed_callables.<locals>.<genexpr>¡  s   è ø€ Ò T qÀAÇOÃO¤Ñ Tùr{   c              3  ó&   K  — | ]	  }|€Œ|–— Œ y ­wr%   r   ry   s     r   rt   z)make_graphed_callables.<locals>.<genexpr>¢  s   è ø€ Ò&W¨QÈÉ¤qÑ&Wùs   ‚Šé   c	           	     ó€   ‡ ‡‡‡‡‡‡‡‡‡
—  G ˆˆ ˆˆˆˆˆfd„dt         j                  j                  «      Š
dˆ
ˆˆfd„}	|	S )Nc                  óŠ   •— e Zd Zedˆˆˆˆfd„«       Zeej                  j                  j                  dˆ ˆˆfd„«       «       Z	y)úOmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphedc                ó  •— t        ‰«      D ]A  }‰|   j                  «       ||   j                  «       k7  sŒ+‰|   j                  ||   «       ŒC ‰j                  «        t	        ‰t
        «      st        d«      ‚t        d„ ‰D «       «      S )Nzstatic_outputs must be a tuplec              3  ó<   K  — | ]  }|j                  «       –— Œ y ­wr%   ©Údetachry   s     r   rt   zjmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.forward.<locals>.<genexpr>Î  s   è ø€ Ò@¨A˜QŸX™XŸZÑ@ùs   ‚)ÚrangeÚdata_ptrÚcopy_r6   rv   ÚtupleÚRuntimeError)Úctxrƒ   r~   Ú	fwd_graphÚlen_user_argsÚstatic_input_surfaceÚstatic_outputss      €€€€r   ÚforwardzWmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.forwardÄ  sŠ   ø€ ô ˜}Ó-ò A�AØ+¨AÑ.×7Ñ7Ó9¸VÀA¹Y×=OÑ=OÓ=QÓQØ,¨QÑ/×5Ñ5°f¸Q±iÕ@ðAð × Ñ Ô"Ü! .´%Ô8Ü&Ð'GÓHÐHÜÑ@°Ô@Ó@Ð@r   c                ó†  •— t        |«      t        ‰«      k7  r#t        dt        ‰«      › dt        |«      › �«      ‚t        ‰|«      D ];  \  }}|€Œ	|j                  «       |j                  «       k7  sŒ+|j	                  |«       Œ= ‰j                  «        t        ‰t        «      st        d«      ‚t        d„ ‰D «       «      S )Nz	Expected z gradients but got z"static_grad_inputs must be a tuplec              3  óD   K  — | ]  }|�|j                  «       n|–— Œ y ­wr%   r‘   rq   s     r   rt   zkmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.backward.<locals>.<genexpr>à  s)   è ø€ ò ð ð #$ -�A—H‘H”J°QÓ6ñùs   ‚ )Úlenr—   Úzipr”   r•   r6   rv   r–   )r˜   ÚgradsÚgÚgradÚ	bwd_graphÚstatic_grad_inputsÚstatic_grad_outputss       €€€r   ÚbackwardzXmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.backwardÐ  sÆ   ø€ ô �u“:¤Ð%8Ó!9Ò9Ü&Ø#¤CÐ(;Ó$<Ð#=Ð=PÔQTÐUZÓQ[ÐP\Ð]óð ô  #Ð#6¸Ó>ò *‘G�A�tØ‘}ØŸ:™:›<¨4¯=©=«?Ó:ØŸG™G D�Mð*ð × Ñ Ô"ä!Ð"4´eÔ<Ü&Ð'KÓLÐLÜñ ð 0ôó ð r   N)r˜   rb   rƒ   r   rD   útuple[Tensor, ...])r˜   rb   r¢   r   rD   r©   )
rK   rL   rM   Ústaticmethodr�   r!   ÚautogradÚfunctionÚonce_differentiabler¨   )r¥   r™   rš   r¦   r§   r›   rœ   s   €€€€€€€r   ÚGraphedrŽ   Ã  sC   ø„ Ø÷Aó ðAð Ø�^‰^×$Ñ$×8Ñ8öó 9ó ñr   r®   c                 óÚ   •— t        j                  j                  j                  | Ž } ‰j                  t        |«      ‰z   Ž }t         j                  j                  j                  |‰«      S r%   )r!   ÚutilsÚ_pytreeÚarg_tree_leavesÚapplyr–   Útree_unflatten)Ú	user_argsÚflatten_user_argsÚoutr®   Úmodule_paramsÚoutput_unflatten_specs      €€€r   ÚfunctionalizedzVmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.functionalizedæ  sW   ø€ ä %§¡× 3Ñ 3× CÑ CÀYÐ OÐØ�'—-‘-¤%Ð(9Ó":¸]Ñ"JÐLˆCÜ—;‘;×&Ñ&×5Ñ5°cÐ;PÓQÐQr   )rµ   rb   rD   rb   )r!   r«   ÚFunction)r™   r¥   r¸   rš   r¹   r›   rœ   r§   r¦   rº   r®   s   ````````` @r   Úmake_graphed_autograd_functionz>make_graphed_callables.<locals>.make_graphed_autograd_function¸  s.   ÿù€ ÷!	ô !	”e—n‘n×-Ñ-ô !	÷F	Rð Ðr   c                ó    ‡ ‡‡‡— dˆ ˆˆˆfd„}|S )Nc                 óB   •— ‰j                   ‰k(  r ‰| i |¤ŽS  ‰| i |¤ŽS r%   )Útraining)rµ   Úuser_kwargsÚfuncÚgraph_training_stateÚgraphedÚorig_fwds     €€€€r   Únew_fwdzEmake_graphed_callables.<locals>.make_graphed_forward.<locals>.new_fwd  s0   ø€ Ø—}‘}Ð(<Ò<Ù&¨	ÐA°[ÑAÐAá'¨ÐB°kÑBÐBr   )rµ   z_P.argsrÀ   z	_P.kwargsrD   r   r   )rÁ   rÂ   rÃ   rÄ   rÅ   s   ```` r   Úmake_graphed_forwardz4make_graphed_callables.<locals>.make_graphed_forwardþ  s   û€ ÷Cð Cð �r   )r™   r   r¥   r   r¸   ztuple[torch.nn.Parameter, ...]rš   rJ   r¹   ztorch.utils._pytree.TreeSpecr›   r©   rœ   r©   r§   ztuple[Optional[Tensor], ...]r¦   r©   rD   zCallable[..., object])
rÁ   rd   rÂ   rC   rÃ   úCallable[_P, _R]rÄ   rÇ   rD   rÇ   )*r!   Úis_autocast_enabledÚis_autocast_cache_enabledr—   rv   r–   ÚtypingÚcastr   r¡   ÚnnÚModuler    Ú_backward_hooksÚ_forward_hooksÚ_forward_pre_hooksÚallÚbuffersr°   r±   r²   ÚappendÚ	TypeErrorÚ
parametersr“   r"   r   r   r\   rY   rT   Útree_leavesr«   r¤   r   Útree_flattenÚreversedrp   ÚreverseÚ	enumerater¿   r�   )+rh   ri   rj   rk   r-   Újust_one_callableÚ_sample_argsÚflatten_sample_argsÚcra   Úflatten_argÚper_callable_len_user_argsÚper_callable_module_paramsr~   Ú"per_callable_static_input_surfacesÚ_Ú
fwd_graphsÚ
bwd_graphsÚmempoolrÁ   r›   Úgrad_inputsr‚   Úoutputs_gradÚvÚper_callable_static_outputsÚ"per_callable_output_unflatten_specr™   Úfunc_outputsÚflatten_outputsÚspecÚ per_callable_static_grad_outputsÚper_callable_static_grad_inputsrœ   r¥   r§   r¦   Úgrad_idxrw   r¼   ÚretrÃ   rÆ   s+                                              r   r   r   æ   ss  € ôN × Ñ Ô"¤u×'FÑ'FÔ'HÜØmó
ð 	
ð Ðô �i¤Ô'Ø ÐØ�Lˆ	ÜŸ™¤E¬&°#¨+Ñ$6¸ÓDÐF‰ä—{‘{¤5¬¬v°s¨{Ñ);¸SÐ)@Ñ#AÀ;ÓOˆàÐä�y ,Ó/ó ‰ˆˆ4Ü�aœŸ™Ÿ™Ô)ä�A×%Ñ%Ó&¨!Ò+Ü˜×(Ñ(Ó)¨QÒ.Ü˜×,Ñ,Ó-°Ò2ä"ðaóð ô ÑE¸¿¹»ÔEÔEÜ"ð1óð ô
 —k‘k×)Ñ)×9Ñ9¸4Ð@ˆØ×"Ñ"¤5¨Ó#5Ô6ÜÑH¸KÔHÕHÜð^óð ð)ð6 9LÖ!L°¤# d¥)Ð!LÐÐ!Lð ö"àô ",¨A¬u¯x©x¯©Ô!?Œˆa�l‰l‹nÔÀRÑGð"Ðð "ô ”s˜9“~Ó&ö*àð 	˜AÑÐ!;¸AÑ!>Ó>ð*Ð&ð *ô
 16´c¸)³nÓ0EÖF¨1”%—)‘)×$Ñ$Õ&ÐF€JÐFÜ05´c¸)³nÓ0EÖF¨1”%—)‘)×$Ñ$Õ&ÐF€JÐFà%) \ÔÔ!°t€Gô 
‡I�I×ÑÔÜ	�‰×	Ñ	œ%Ÿ)™)×*Ñ*Ó,Ó	-ñ Ü03Ø�|Ð%Gó1
ò 	Ñ,ˆD�$Ð,ð 2BÑ.ˆK˜ ,ÜÐ+Ó,ò �ÜŸ+™+×-Ñ-×9Ñ9¹$À¸+ÓF�Ü$Ñ$K°Ô$KÓK�Ü�|Ó$ qÓ(Ü"'§.¡.×"5Ñ"5Ø ,Ü$ñ %Ø';ô%ó  ô &+ñ +Ø9@ô+ó &ð %)Ø%7ð #6ó 
#‘Kð	ð ˜|¨[Ð9ò �Ùññ'	÷ô. 
‡I�I×ÑÔð #%ÐØ)+Ð&Ü!$ Y°¸jÓ!Iò 8Ñˆˆd�Iä�Y‰Y�_‰_˜Y¨Wˆ_Ó5ñ 	'Ù ˜;ˆL÷	'ô !&§¡× 3Ñ 3× @Ñ @ÀÓ NÑˆ˜Ø#×*Ñ*¬5°Ó+AÔBØ*×1Ñ1°$Õ7ð8ð (*Ð$Ø&(Ð#Ü;>ÜÐ3Ó4ÜÐ,Ó-Ü�Óó<ó  CÑ7Ð˜n¨iô
 $ñ $
ØFTô$
ó 
Ðô ÑJ¨ÔJÓJˆØˆÜˆ|Ó˜qÒ Ü—‘—‘ °�Ó9ñ Ü#Ÿn™n×1Ñ1Ø(Ü Ñ TÐ,@Ô TÓTÜ!&Ñ&WÐ2EÔ&WÓ!WØ $Ø!3ð 2ó �÷ð  ÐØˆØ'ò 	0ˆCØ× Ò  [Ð%<Ø"×)Ñ)¨+°hÑ*?Ô@Ø˜A‘‘à"×)Ñ)¨$Õ/ð	0ô #Ð#5Ó6Ðà(×/Ñ/Ð0CÔDØ'×.Ñ.Ð/AÖBðA CðF %×,Ñ,Ô.Ø#×+Ñ+Ô-ð4Øð4àð4ð 6ð4ð ð	4ð
  <ð4ð 1ð4ð +ð4ð :ð4ð /ð4ð 
ó4ðl $&€CÜ˜YÓ'ò " ‰ˆˆ4Ù0Ø�q‰MØ�q‰MØ& qÑ)Ø& qÑ)Ø.¨qÑ1Ø.¨qÑ1Ø'¨Ñ*Ø,¨QÑ/Ø+¨AÑ.ó

ˆô �dœEŸH™HŸO™OÔ,ðØ%ðà&*ðð *ðð +ð	ð
 "óñ 0Ø�d—m‘m W¨d¯l©lóˆDŒLð �J‰J�tÕà�J‰J�wÕðE" ñH Ø�1‰vˆä�‹:Ðùò{ "Mùò"ùò*ùò
 GùÚF÷ñ ú÷<	'ñ 	'ú÷,ñ úsL   Æ6[>ÇA\È,\É%\Ê%\Ì!A5\ÎA\Ñ
\$Ô:A\1Ü\!Ü$\.	Ü1\;	)rD   rC   rH   )é   FN)rh   re   ri   r©   rj   rJ   rk   rC   r-   rE   rD   re   )rh   útuple[_ModuleOrCallable, ...]ri   ztuple[tuple[Tensor, ...], ...]rj   rJ   rk   rC   r-   rE   rD   rô   )rh   ú7Union[_ModuleOrCallable, tuple[_ModuleOrCallable, ...]]ri   z9Union[tuple[Tensor, ...], tuple[tuple[Tensor, ...], ...]]rj   rJ   rk   rC   r-   rE   rD   rõ   )&Ú
__future__r   rÊ   Úcollections.abcr   r   r   r   r   r	   Útyping_extensionsr
   r   r   r!   r   Ú	torch.xpur   Ú_utilsr   Ú__all__r   r   ÚhasattrÚ_CÚ__dict__Útorch._Cr   r   r   r   r   r   r   rb   re   rc   r   r   r   r   ú<module>r      sñ  ðÞ "ã Ý $ß FÕ Fß 6Ñ 6ã Ý ñ Ý&å  ò€ñ ˆTƒ]€Ùˆtƒ_€áˆu�x‰xÐ)Ô*á%0°Ó%=€E‡H�H×Ñ�kÑ"Ù2=Ð>VÓ2W€E‡H�H×ÑÐ.Ñ/Ù9DØ'ó:€E‡H�H×ÑÐ5Ñ6÷
 VÑ Uó+ó<ô
^,ˆyô ^,÷B5(ñ 5(ðp  %Ð%6¸ÀÀfÀÑ8MÐ%MÑNÐ �9Ó Nð 
ð Ø$Ø#'ðØ ðà#ðð ðð ð	ð
 !ðð òó 
ðð 
ð Ø$Ø#'ð(Ø,ð(à/ð(ð ð(ð ð	(ð
 !ð(ð #ò(ó 
ð(ð Ø$Ø#'ðpØFðpàJðpð ðpð ð	pð
 !ðpð =ôpr   