Ë
    S²jÐV  ã                  ó   — U d dl mZ d dlZd dlmZ d dl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j,                  d«      s] ed«      ej,                  j.                  d<    ed«      ej,                  j.                  d<    ed«      ej,                  j.                  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j@                  jB                  ede"f   z  Z#de$d<   e	 	 	 d 	 	 	 	 	 	 	 	 	 	 	 d!d„«       Z%e	 	 	 d 	 	 	 	 	 	 	 	 	 	 	 d"d„«       Z%	 	 	 d 	 	 	 	 	 	 	 	 	 	 	 d#d„Z%y)$é    )ÚannotationsN)ÚCallable)ÚoverloadÚTYPE_CHECKINGÚ	TypeAlias)Ú	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   © ó    úO/var/www/html/ia-enhanced/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   0   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__F   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_beginI   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   r/   zXPUGraph.capture_endV   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$   Úinstantiater0   s    €r   r2   zXPUGraph.instantiate`   s   ø€ ô 	‰ÑÕr   c                ó"   •— t         ‰| �  «        y)z+Replay the XPU work captured by this graph.N)r$   Úreplayr0   s    €r   r4   zXPUGraph.replayi   s   ø€ ä‰‰Õr   c                ó"   •— t         ‰| �  «        y)z1Delete the graph currently held by this instance.N)r$   Úresetr0   s    €r   r6   zXPUGraph.resetm   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+   r0   s    €r   r+   zXPUGraph.poolq   s   ø€ ô ‰w‰|‹~Ðr   c                ó    •— t         ‰| �  «       S )z.Enable debugging mode for XPUGraph.debug_dump.)r$   Úenable_debug_moder0   s    €r   r9   zXPUGraph.enable_debug_modey   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_graphr0   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_execr0   s    €r   r@   zXPUGraph.raw_xpu_graph_execŽ   s   ø€ ô
 ‰wÑ)Ó+Ð+r   )F)r'   ÚboolÚreturnr	   r#   )r+   ú_POOL_HANDLE | NonerB   ÚNone©rB   rD   ©rB   r   )r<   ÚstrrB   rD   )rB   Úint)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r%   r,   r/   r2   r4   r6   r+   r9   r;   r>   r@   Ú__classcell__)r(   s   @r   r   r   5   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útorch.xpu.Stream | NoneÚ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(   rP   r   r    ÚStreamr+   Úcapture_streamÚAssertionErrorÚ
stream_ctxÚ	xpu_graph)r-   rV   r+   Ústreams       r   Ú__init__zgraph.__init__©   s†   € ð �>‰>×0Ñ0Ð8Ü49·I±I×4DÑ4DÓ4FˆD�N‰NÔ1à;?¸<±RÈdÈWˆŒ	àÐ(‰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_cacherU   Ú	__enter__rV   r,   r+   )r-   s    r   r\   zgraph.__enter__¾   sJ   € ä�	‰	×ÑÔä�	‰	×ÑÔØ�‰×!Ñ!Ô#à$ˆ�‰×$Ñ$ d§i¡iÒ0r   c                ój   — | j                   j                  «         | j                  j                  |Ž  y r#   )rV   r/   rU   Ú__exit__)r-   Úargss     r   r^   zgraph.__exit__Ç   s&   € Ø�‰×"Ñ"Ô$Ø ˆ�‰× Ñ  $Ò'r   )NN)rV   r   r+   rC   rW   rO   rE   )r_   ÚobjectrB   rD   )	rI   rJ   rK   rL   rP   Ú__annotations__rX   r\   r^   r   r   r   r   r   –   sH   … ñð  7;ÐÐ3Ó:ð
 %)Ø*.ð	#àð#ð "ð#ð (ó	#ó*1ô(r   r   .r   Ú_ModuleOrCallablec                 ó   — y r#   r   ©Ú	callablesÚsample_argsÚnum_warmup_itersÚallow_unused_inputr+   s        r   r   r   Ï   s   € ð r   c                 ó   — y r#   r   rd   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>F  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   )ro   Úargs     r   rq   z)make_graphed_callables.<locals>.<genexpr>N  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#   rl   ©ro   Úos     r   rq   z)make_graphed_callables.<locals>.<genexpr>n  s   è ø€ Ò$K¨1¸1¿?»?¤QÑ$Kùó   ‚”c              3  ó:   K  — | ]  }|j                   sŒ|–— Œ y ­wr#   rl   ©ro   Úis     r   rq   z)make_graphed_callables.<locals>.<genexpr>r  s   è ø€ ò %Ø"#¸q¿»œAñ%ùrx   c              3  ó`   K  — | ]&  }|j                   sŒt        j                  |«      –— Œ( y ­wr#   ©rm   r   Ú
empty_likerv   s     r   rq   z)make_graphed_callables.<locals>.<genexpr>u  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}   rv   s     r   rq   z)make_graphed_callables.<locals>.<genexpr>”  s+   è ø€ ò $
ØAB 1§?¢?ŒE×Ñ˜QÔ¸Ó<ñ$
ùs   ‚-/c              3  ó:   K  — | ]  }|j                   sŒ|–— Œ y ­wr#   rl   rv   s     r   rq   z)make_graphed_callables.<locals>.<genexpr>˜  s   è ø€ ÒJ 1¸!¿/»/œQÑJùrx   c              3  ó:   K  — | ]  }|j                   sŒ|–— Œ y ­wr#   rl   rz   s     r   rq   z)make_graphed_callables.<locals>.<genexpr>ž  s   è ø€ Ò T qÀAÇOÃO¤Ñ Tùrx   c              3  ó&   K  — | ]	  }|€Œ|–— Œ y ­wr#   r   rv   s     r   rq   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#   ©Údetachrv   s     r   rq   zjmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.forward.<locals>.<genexpr>Ë  s   è ø€ Ò@¨A˜QŸX™XŸZÑ@ùs   ‚)ÚrangeÚdata_ptrÚcopy_r4   rs   Ú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Ž   rn   s     r   rq   zkmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.backward.<locals>.<genexpr>Ý  s$   è ø€ ò Ø;< ! -�A—H‘H”J°QÓ6ñùs   ‚ )Úlenr”   Úzipr‘   r’   r4   rs   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Üñ Ø@Rôó ð r   N)r•   r`   r€   r   rB   útuple[Tensor, ...])r•   r`   rŸ   r   rB   r¦   )
rI   rJ   rK   Ú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²   r`   rB   r`   )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×-Ñ-ô 	÷B	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.kwargsrB   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—   rH   r¶   ztorch.utils._pytree.TreeSpecr˜   r¦   r™   r¦   r¤   ztuple[Tensor | None, ...]r£   r¦   rB   zCallable[..., object])
r¾   ztorch.nn.Moduler¿   rA   rÀ   úCallable[_P, _R]rÁ   rÄ   rB   rÄ   )*r   Úis_autocast_enabledÚis_autocast_cache_enabledr”   rs   r“   ÚtypingÚcastr   rž   ÚnnÚModuler�   Ú_backward_hooksÚ_forward_hooksÚ_forward_pre_hooksÚallÚbuffersr­   r®   r¯   ÚappendÚ	TypeErrorÚ
parametersr�   r    r   r   rZ   rW   rR   Útree_leavesr¨   r¡   r   Útree_flattenÚreversedrm   ÚreverseÚ	enumerater¼   rš   )+re   rf   rg   rh   r+   Újust_one_callableÚ_sample_argsÚflatten_sample_argsÚcr_   Ú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_idxrt   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 %×,Ñ,Ô.Ø#×+Ñ+Ô-ð2Øð2àð2ð 6ð2ð ð	2ð
  <ð2ð 1ð2ð +ð2ð 7ð2ð /ð2ð 
ó2ðh $&€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ˆä�‹:Ðùòw "Mùò"ùò*ùò
 GùÚF÷ñ ú÷<	'ñ 	'ú÷,ñ úsL   Æ6[>ÇA\È,\É%\Ê%\Ì!A5\ÎA\Ñ
\$Ô:A\1Ü\!Ü$\.	Ü1\;	)rB   rA   rF   )é   FN)re   rb   rf   r¦   rg   rH   rh   rA   r+   rC   rB   rb   )re   útuple[_ModuleOrCallable, ...]rf   ztuple[tuple[Tensor, ...], ...]rg   rH   rh   rA   r+   rC   rB   rñ   )re   ú1_ModuleOrCallable | tuple[_ModuleOrCallable, ...]rf   z3tuple[Tensor, ...] | tuple[tuple[Tensor, ...], ...]rg   rH   rh   rA   r+   rC   rB   rò   )&Ú
__future__r   rÇ   Úcollections.abcr   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   rÉ   rÊ   r`   rb   ra   r   r   r   r   ú<module>rý      só  ðÞ "ã Ý $ß 5Ñ 5ß 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3(ñ 3(ðl  %Ÿx™xŸ™°¸#¸v¸+Ñ1FÑFÐ �9Ó Fð 
ð Ø$Ø $ðØ ðà#ðð ðð ð	ð
 ðð òó 
ðð 
ð Ø$Ø $ð(Ø,ð(à/ð(ð ð(ð ð	(ð
 ð(ð #ò(ó 
ð(ð Ø$Ø $ðnØ@ðnàDðnð ðnð ð	nð
 ðnð 7ônr   