
    YTh                         S SK r S SKJr  S SKJr  S SKJr  S SKrS SK	J
r
JrJrJrJrJrJrJrJrJrJrJr  S SKJrJr  S SKJrJrJr  S SKJr  S S	KJ r J!r!J"r"  S S
K#J$r$J%r%J&r&J'r'  S SK(J)r)  S SK*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2J3r3J4r4J5r5J6r6  S SK7J8r8J9r9J:r:J;r;  S SK<J=r=J>r>J?r?J@r@JArAJBrBJCrCJDrDJErEJFrFJGrGJHrH  S SKIJJrJ  / SQrK\rL\rM\'rNS rO\R                  R                  rR\J" \RS5        S\RlS        S\RlT        S rUS rVS rW " S S5      rX\S\S   4S j5       rYS\Z4S jr[S r\C\R                  R                  5       (       d  \^" S5      eg)    N)Iterator)contextmanager)Any)_Await_drop_IgnoreContextManager_isinstance	_overload_overload_methodexportFinalFutureignoreis_scriptingunused)forkwait)
_awaitable_awaitable_nowait_awaitable_wait)_register_decomposition)freezeoptimize_for_inferencerun_frozen_optimizations)fuserlast_executed_optimized_graphoptimized_executionset_fusion_strategy)_InsertPoint)_ScriptProfile_unwrap_optional	AttributeCompilationUnit	interfaceRecursiveScriptClassRecursiveScriptModulescriptscript_methodScriptFunctionScriptModuleScriptWarning)jit_module_from_flatbufferloadsavesave_jit_module_to_flatbuffer)_flatten_get_trace_graph_script_if_tracing_unique_state_dict
is_tracingONNXTracedModuleTopLevelTracedModuletracetrace_moduleTracedModuleTracerWarningTracingCheckError)
set_module)r"   r#   Errorr   r)   r*   annotateenable_onednn_fusionr   export_opnamesr   r   r$   r   
isinstancer-   onednn_fusion_enabledr   r.   r'   script_if_tracingr   strict_fusionr7   r8   r   r   c                 T    [         R                  R                  U R                  5      $ )z
Generate new bytecode for a Script module.

Returns what the op list would be for a Script Module based off the current code base.

If you have a LiteScriptModule and want to get the currently present
list of ops call _export_operator_list instead.
)torch_C_export_opnames_c)ms    J/var/www/auris/envauris/lib/python3.13/site-packages/torch/jit/__init__.pyr@   r@   l   s     88##ADD))    z	torch.jitr=   c                     U$ )a  Use to give type of `the_value` in TorchScript compiler.

This method is a pass-through function that returns `the_value`, used to hint TorchScript
compiler the type of `the_value`. It is a no-op when running outside of TorchScript.

Though TorchScript can infer correct type for most Python expressions, there are some cases where
type inference can be wrong, including:

- Empty containers like `[]` and `{}`, which TorchScript assumes to be container of `Tensor`
- Optional types like `Optional[T]` but assigned a valid value of type `T`, TorchScript would assume
  it is type `T` rather than `Optional[T]`

Note that `annotate()` does not help in `__init__` method of `torch.nn.Module` subclasses because it
is executed in eager mode. To annotate types of `torch.nn.Module` attributes,
use :meth:`~torch.jit.Attribute` instead.

Example:

.. testcode::

    import torch
    from typing import Dict

    @torch.jit.script
    def fn():
        # Telling TorchScript that this empty dictionary is a (str -> int) dictionary
        # instead of default dictionary type of (str -> Tensor).
        d = torch.jit.annotate(Dict[str, int], {})

        # Without `torch.jit.annotate` above, following statement would fail because of
        # type mismatch.
        d["name"] = 20

.. testcleanup::

    del fn

Args:
    the_type: Python type that should be passed to TorchScript compiler as type hint for `the_value`
    the_value: Value or expression to hint type for.

Returns:
    `the_value` is passed back as return value.
 )the_type	the_values     rK   r>   r>      s    Z rL   c                     [        U 5      $ )a  
Compiles ``fn`` when it is first called during tracing.

``torch.jit.script`` has a non-negligible start up time when it is first called due to
lazy-initializations of many compiler builtins. Therefore you should not use
it in library code. However, you may want to have parts of your library work
in tracing even if they use control flow. In these cases, you should use
``@torch.jit.script_if_tracing`` to substitute for
``torch.jit.script``.

Args:
    fn: A function to compile.

Returns:
    If called during tracing, a :class:`ScriptFunction` created by `torch.jit.script` is returned.
    Otherwise, the original function `fn` is returned.
)r2   )fns    rK   rC   rC      s    $ b!!rL   c                     [        X5      $ )a  
Provide container type refinement in TorchScript.

It can refine parameterized containers of the List, Dict, Tuple, and Optional types. E.g. ``List[str]``,
``Dict[str, List[torch.Tensor]]``, ``Optional[Tuple[int,str,int]]``. It can also
refine basic types such as bools and ints that are available in TorchScript.

Args:
    obj: object to refine the type of
    target_type: type to try to refine obj to
Returns:
    ``bool``: True if obj was successfully refined to the type of target_type,
        False otherwise with no new type refinement


Example (using ``torch.jit.isinstance`` for type refinement):
.. testcode::

    import torch
    from typing import Any, Dict, List

    class MyModule(torch.nn.Module):
        def __init__(self) -> None:
            super().__init__()

        def forward(self, input: Any): # note the Any type
            if torch.jit.isinstance(input, List[torch.Tensor]):
                for t in input:
                    y = t.clamp(0, 0.5)
            elif torch.jit.isinstance(input, Dict[str, str]):
                for val in input.values():
                    print(val)

    m = torch.jit.script(MyModule())
    x = [torch.rand(3,3), torch.rand(4,3)]
    m(x)
    y = {"key1":"val1","key2":"val2"}
    m(y)
)r	   )objtarget_types     rK   rA   rA      s    P s((rL   c                   B    \ rS rSrSrSS jrS rS\S\S	\SS4S
 jrSr	g)rD      a  
Give errors if not all nodes have been fused in inference, or symbolically differentiated in training.

Example:
Forcing fusion of additions.

.. code-block:: python

    @torch.jit.script
    def foo(x):
        with torch.jit.strict_fusion():
            return x + x + x

returnNc                 x    [         R                  R                  5       (       d  [        R                  " S5        g g )NzOnly works in script mode)rF   _jit_internalr   warningswarnselfs    rK   __init__strict_fusion.__init__  s)    ""//11MM56 2rL   c                     g NrN   r]   s    rK   	__enter__strict_fusion.__enter__      rL   typevaluetbc                     g rb   rN   )r^   rf   rg   rh   s       rK   __exit__strict_fusion.__exit__	  re   rL   rN   )rX   N)
__name__
__module____qualname____firstlineno____doc__r_   rc   r   rj   __static_attributes__rN   rL   rK   rD   rD      s2    7S  # $ rL   rD   rX   c               #   ^  #    [         R                  R                  R                  n  [         R                  R                  R	                  S5        S v   [         R                  R                  R	                  U 5        g ! [         R                  R                  R	                  U 5        f = f7f)NF)rF   rG   Graphglobal_print_source_rangesset_global_print_source_ranges)old_enable_source_rangess    rK   _hide_source_rangesrw     sf     $xx~~HHP55e<556NO556NOs   %B--A? *B-?+B**B-enabledc                 B    [         R                  R                  U 5        g)zFEnable or disables onednn JIT fusion based on the parameter `enabled`.N)rF   rG   _jit_set_llga_enabled)rx   s    rK   r?   r?     s    	HH""7+rL   c                  >    [         R                  R                  5       $ )z,Return whether onednn JIT fusion is enabled.)rF   rG   _jit_llga_enabledrN   rL   rK   rB   rB     s    88%%''rL   zJIT initialization failed)_r[   collections.abcr   
contextlibr   typingr   torch._CrF   torch._jit_internalr   r   r   r	   r
   r   r   r   r   r   r   r   torch.jit._asyncr   r   torch.jit._awaitr   r   r   torch.jit._decomposition_utilsr   torch.jit._freezer   r   r   torch.jit._fuserr   r   r   r   torch.jit._ir_utilsr   torch.jit._scriptr    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   torch.jit._serializationr,   r-   r.   r/   torch.jit._tracer0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   torch.utilsr<   __all___fork_wait_set_fusion_strategyr@   rG   JITExceptionr=   rl   rn   r>   rC   rA   rD   rw   boolr?   rB   	_jit_initRuntimeErrorrN   rL   rK   <module>r      sA    $ %      ( K K B V V  -        #> 	* 	* 	 
5+  -`",()V < PXd^ P P,$ ,
(
 xx
2
33 rL   