L i6 UddlZddlZddlZddlZddlZddlmZmZddlm Z m Z ddl m Z m Z mZmZmZmZddlmZddlZddlmZmZmZddlmZddlmZmZdd lmZdd lm Z m!Z!gd Z"ee#ed fefZ$ed dZ%GddedddgZ&dZ' eZ(e)e*e fe+d<eZ,e)e*e fe+d<eZ-e)e*e fe+d<GddZ. eZ/e)e*e fe+d<eZ0e)e*e fe+d<da1ee2e+d<eZ3e)e*e fe+d<eZ4e)e*e fe+d<eZ5e)e*e2fe+d <eZ6e)e*e2fe+d!<d"Z7d#Z8d$e d%d&e!fd'Z9d$e d%d&e!fd(Z:d$e d%d&e!fd)Z;d$e d%d&e!fd*Zd$e de$gede$ffd&e!fd1Z?d$e de$e$gede$ffd&e!fd2Z@d3e d&dfd4ZAGd5dZBy)6N) namedtuple OrderedDict)IteratorMapping)AnyCallableOptionaloverloadTypeVarUnion)Self)devicedtypeTensor)DeviceLikeType)Buffer Parameter)is_traceable_wrapper_subclass) BackwardHookRemovableHandle) register_module_forward_pre_hookregister_module_forward_hook®ister_module_full_backward_pre_hookregister_module_backward_hook"register_module_full_backward_hook(register_module_buffer_registration_hook(register_module_module_registration_hook+register_module_parameter_registration_hookModule.Trboundc,eZdZdZdeffd ZeZxZS)_IncompatibleKeysreturncR|js |jsyt| S)Nz) missing_keysunexpected_keyssuper__repr__)self __class__s ]/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/nn/modules/module.pyr+z_IncompatibleKeys.__repr__-s%  )=)=4w!!)__name__ __module__ __qualname__ __slots__strr+__str__ __classcell__r-s@r.r$r$(sI"#" Gr/r$IncompatibleKeysr(r)c|jd}t|dk(r|S|jd}|Dcgc] }|dz|z }}dj|}|dz|z}|Scc}w)N r )splitlenpopjoin)s_ numSpacessfirstlines r. _addindentrF5sm A 1v{ EE!HE./0d)c/T !0A0 ! A  qA H 1sA#!_global_buffer_registration_hooks!_global_module_registration_hooks$_global_parameter_registration_hookscTeZdZd dededddfdZdededefd Zdefd Z d efd Z y) _WrappedHookNhookmodulerr&c||_tj||d|_|"t j ||_d|_yy)NFT)rL functoolsupdate_wrapper with_moduleweakrefrefrM)r,rLrMs r.__init__z_WrappedHook.__init__IsD"   t,!&  9@V9LDK#D  r/argskwargsc|jr3|j}| td|j|g|i|S|j|i|S)Nz1You are trying to call the hook of a dead Module!)rQrM RuntimeErrorrL)r,rUrVrMs r.__call__z_WrappedHook.__call__SsX   [[]F~"#VWW499V5d5f5 5tyy$)&))r/cv|j|jd}|jr|j|d<|S)N)rLrQrM)rLrQrM)r,results r. __getstate__z_WrappedHook.__getstate__[s4))D4D4DE   #{{}F8  r/statec|d|_|d|_|jr.|d tdtj|d|_yy)NrLrQrMz3You are trying to revive the hook of a dead Module!)rLrQrXrRrSrMr,r]s r. __setstate__z_WrappedHook.__setstate__bsX&M  /   X&"I"++eHo6DK r/N) r0r1r2rr rTrrYdictr\r`r%r/r.rKrKHsS$X$x/A$T$*c*S*S*d 7$ 7r/rK_global_backward_pre_hooks_global_backward_hooks_global_is_full_backward_hook_global_forward_pre_hooks_global_forward_hooks#_global_forward_hooks_always_called!_global_forward_hooks_with_kwargsc^txs&txstxstxstxst Sra)rcrdrfrgrhrir%r/r._has_any_global_hookrkzs8" - ! - $ - ! - /  - - r/ _extra_staterL).Nr&cJtt}|t|j<|S)a=Register a buffer registration hook common to all modules. .. warning :: This adds global state to the `nn.Module` module The hook will be called every time :func:`register_buffer` is invoked. It should have the following signature:: hook(module, name, buffer) -> None or new buffer The hook can modify the input or return a single modified value in the hook. Returns: :class:`torch.utils.hooks.RemovableHandle`: a handle that can be used to remove the added hook by calling ``handle.remove()`` )rrGidrLhandles r.rr#*> ?F37%fii0 Mr/cJtt}|t|j<|S)aCRegister a module registration hook common to all modules. .. warning :: This adds global state to the `nn.Module` module The hook will be called every time :func:`register_module` is invoked. It should have the following signature:: hook(module, name, submodule) -> None or new submodule The hook can modify the input or return a single modified value in the hook. Returns: :class:`torch.utils.hooks.RemovableHandle`: a handle that can be used to remove the added hook by calling ``handle.remove()`` )rrHrnros r.rrrqr/cJtt}|t|j<|S)aERegister a parameter registration hook common to all modules. .. warning :: This adds global state to the `nn.Module` module The hook will be called every time :func:`register_parameter` is invoked. It should have the following signature:: hook(module, name, param) -> None or new parameter The hook can modify the input or return a single modified value in the hook. Returns: :class:`torch.utils.hooks.RemovableHandle`: a handle that can be used to remove the added hook by calling ``handle.remove()`` )rrIrnros r.rrs#*A BF6:(3 Mr/cJtt}|t|j<|S)aRegister a forward pre-hook common to all modules. .. warning :: This adds global state to the `nn.module` module and it is only intended for debugging/profiling purposes. The hook will be called every time before :func:`forward` is invoked. It should have the following signature:: hook(module, input) -> None or modified input The input contains only the positional arguments given to the module. Keyword arguments won't be passed to the hooks and only to the ``forward``. The hook can modify the input. User can either return a tuple or a single modified value in the hook. We will wrap the value into a tuple if a single value is returned(unless that value is already a tuple). This hook has precedence over the specific module hooks registered with ``register_forward_pre_hook``. Returns: :class:`torch.utils.hooks.RemovableHandle`: a handle that can be used to remove the added hook by calling ``handle.remove()`` )rrfrnros r.rrs#66 7F+/fii( Mr/F) with_kwargs always_callrurvcttt}|t|j<|rdt|j<|rdt|j<|S)aRegister a global forward hook for all the modules. .. warning :: This adds global state to the `nn.module` module and it is only intended for debugging/profiling purposes. The hook will be called every time after :func:`forward` has computed an output. It should have the following signature:: hook(module, input, output) -> None or modified output The input contains only the positional arguments given to the module. Keyword arguments won't be passed to the hooks and only to the ``forward``. You can optionally modify the output of the module by returning a new value that will replace the output from the :func:`forward` function. Parameters: hook (Callable): The user defined hook to be registered. always_call (bool): If ``True`` the ``hook`` will be run regardless of whether an exception is raised while calling the Module. Default: ``False`` Returns: :class:`torch.utils.hooks.RemovableHandle`: a handle that can be used to remove the added hook by calling ``handle.remove()`` This hook will be executed before specific module hooks registered with ``register_forward_hook``.  extra_dictT)rrgrhrnri)rLrurvrps r.rrsOH*MF(,&))$7;)&))49=+FII6 Mr/cttdur tddatt}|t|j<|S)aRegister a backward hook common to all the modules. This function is deprecated in favor of :func:`torch.nn.modules.module.register_module_full_backward_hook` and the behavior of this function will change in future versions. Returns: :class:`torch.utils.hooks.RemovableHandle`: a handle that can be used to remove the added hook by calling ``handle.remove()`` TtCannot use both regular backward hooks and full backward hooks as a global Module hook. Please use only one of them.FrerXrrdrnros r.rr%sE %, ?  %*! 3 4F(,699% Mr/cJtt}|t|j<|S)aRegister a backward pre-hook common to all the modules. .. warning :: This adds global state to the `nn.module` module and it is only intended for debugging/profiling purposes. Hooks registered using this function behave in the same way as those registered by :meth:`torch.nn.Module.register_full_backward_pre_hook`. Refer to its documentation for more details. Hooks registered using this function will be called before hooks registered using :meth:`torch.nn.Module.register_full_backward_pre_hook`. Returns: :class:`torch.utils.hooks.RemovableHandle`: a handle that can be used to remove the added hook by calling ``handle.remove()`` )rrcrnros r.rrBs#,7 8F,0vyy) Mr/cttdur tddatt}|t|j<|S)aRegister a backward hook common to all the modules. .. warning :: This adds global state to the `nn.module` module and it is only intended for debugging/profiling purposes. Hooks registered using this function behave in the same way as those registered by :meth:`torch.nn.Module.register_full_backward_hook`. Refer to its documentation for more details. Hooks registered using this function will be called before hooks registered using :meth:`torch.nn.Module.register_full_backward_hook`. Returns: :class:`torch.utils.hooks.RemovableHandle`: a handle that can be used to remove the added hook by calling ``handle.remove()`` Fr{Tr|ros r.rr]sE.%- ?  %)! 3 4F(,699% Mr/inputcFtdt|jd)aDefine the computation performed at every call. Should be overridden by all subclasses. .. note:: Although the recipe for forward pass needs to be defined within this function, one should call the :class:`Module` instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them. zModule [z,] is missing the required "forward" function)NotImplementedErrortyper0)r,rs r._forward_unimplementedrs)  4:&&''ST r/c eZdZUdZdZeed<dZeed< eed<e e e e fed<e e e e fed<ee ed <e eefed <e eefed <e eed <e eefed <e eefed<e eefed<e eefed<e eefed<e eefed<e eefed<e eefed<e eefed<e e e dfed<dZeed<dZe eed<dfd ZeZedefed< dde d e e d!eddfd"Zde d#e e ddfd$Zde d%e dddfd&Zde d%e dddfd'Zd(e ddfd)Z dd(e d%dd*eddfd+Zd(e dd,fd-Zd(e dd.fd/Zdefd0Zd1eddfd2Zdd3Z d4edgdfde!fd5Z"dd6e e#ee$fde!fd7Z%dd6e e#ee$fde!fd8Z&dd6e e#ee$fde!fd9Z'dd6e e#ee$fde!fd:Z(de!fd;Z)dZ,de!fd?Z-de!fd@Z.de!fdAZ/ddBd6e e0dCede!fdDZ1e2 dd6e e0dEe e*dFede!fdGZ3e2ddEe*dFede!fdHZ3e2dd e dFede!fdIZ3dJZ3 ddKede4ge#de4ffdLede5fdMZ6dKede4e4ge#de4ffde5fdNZ7 ddKede4e4ge#de4ffdLede5fdOZ8dPZ9dQZ:ddRZ;dddSdKe#eeddddVdKe#ee None: super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x)) Submodules assigned in this way will be registered, and will also have their parameters converted when you call :meth:`to`, etc. .. note:: As per the example above, an ``__init__()`` call to the parent class must be made before assignment on the child. :ivar training: Boolean represents whether this module is in training or evaluation mode. :vartype training: bool F dump_patchesr;_versiontraining _parameters_buffers_non_persistent_buffers_set_backward_pre_hooks_backward_hooks_is_full_backward_hook_forward_hooks_forward_hooks_with_kwargs_forward_hooks_always_called_forward_pre_hooks_forward_pre_hooks_with_kwargs_state_dict_hooks_load_state_dict_pre_hooks_state_dict_pre_hooks_load_state_dict_post_hooks_modulescall_super_initN_compiled_call_implr&c tjjd|jdurAt |r6t t |jdtt|d|jdur;t |r0t t |jdt|dzd t|1dd t|1d it|1d it|1d tt|1d tt|1dtt|1ddt|1dtt|1dtt|1dtt|1dtt|1dtt|1dtt|1dtt|1dtt|1dtt|1di|jrt|<|i|yy)zLInitialize internal Module state, shared by both nn.Module and ScriptModule.zpython.nn_moduleFz0.__init__() got an unexpected keyword argument ''z,.__init__() takes 1 positional argument but r;z were givenrTrrrrrrNrrrrrrrrrr)torch_C_log_api_usage_oncerbool TypeErrorrr0nextiterr>r* __setattr__setrrT)r,rUrVr-s r.rTzModule.__init__s $$%78   5 (T&\:&&''WX\]abh]iXjWkl    5 (T$Z:&&''STWX\T]`aTaSbc   J- M2. J+ 935A 1;=A -{}= 4d; ,km< 8+-H :KMJ 0+-@ >> # xdoctest: +SKIP("undefined vars") >>> self.register_buffer('running_mean', torch.zeros(num_features)) Fz4ScriptModule does not support non-persistent buffersrz2cannot assign buffer before Module.__init__() callz$buffer name should be a string. Got .zbuffer name can't contain "."z$buffer name can't be empty string "" attribute '' already existsN__torch_function__cannot assign 'z' object to buffer 'z!' (torch Tensor or None required)) isinstancerjit ScriptModulerX__dict__AttributeErrorr4rtypenameKeyErrorhasattrrrrGvaluesrdiscardadd)r,rrrrLoutputs r.register_bufferzModule.register_buffer s|>  :dEII4J4J#KUV V T]] * !UV VD#&6u~~d7K6LM D[;< < RZBC C T4 T%>[.>?@ @   vu|| ,@T0U!%.."8!99MdVT22  :@@B $dD&1%#F $#)DMM$ 0088>0044T:r/paramc`d|jvr tdt|ts!t dt j |d|vr td|dk(r tdt||r||jvrtd|d |d |j|<y t|ts%t d t j |d |d |jrtd|d|dtjD]}||||}||}||j|<y )a)Add a parameter to the module. The parameter can be accessed as an attribute using given name. Args: name (str): name of the parameter. The parameter can be accessed from this module using the given name param (Parameter or None): parameter to be added to the module. If ``None``, then operations that run on parameters, such as :attr:`cuda`, are ignored. If ``None``, the parameter is **not** included in the module's :attr:`state_dict`. rz5cannot assign parameter before Module.__init__() callz'parameter name should be a string. Got rz parameter name can't contain "."rz'parameter name can't be empty string ""rrNrz' object to parameter 'z'' (torch.nn.Parameter or None required)z,Cannot assign non-leaf Tensor to parameter 'z<'. Model parameters must be created explicitly. To express 'zM' as a function of another Tensor, compute the value in the forward() method.)rrrr4rrrrrrrgrad_fn ValueErrorrIr)r,rrrLrs r.register_parameterzModule.register_parameterMsj  - G D#&9%..:N9OP D[>? ? RZEF F T4 T1A1A%A[.>?@ @ =%)D  T "E9-!%.."7!88OPTvV88 ]]>tfEFFJVL(( =CCE #dD%0%"E #&+D  T "r/rMct|ts#|!ttj|dt|t s!tdtj|t ||r||jvrtd|dd|vrtd||dk(r td tjD]}||||}||}||j|<y) aYAdd a child module to the current module. The module can be accessed as an attribute using the given name. Args: name (str): name of the child module. The child module can be accessed from this module using the given name module (Module): child module to be added to the module. Nz is not a Module subclassz$module name should be a string. Got rrrz$module name can't contain ".", got: rz$module name can't be empty string "") rrrrrr4rrrrHr)r,rrMrLrs r. add_modulezModule.add_modules&&)f.@u~~f566OPQ QD#&6u~~d7K6LM T4 T%>[.>?@ @ D[B4&IJ J RZBC C5<<> D$f-F! % dr/c(|j||y)zAlias for :func:`add_module`.N)r)r,rrMs r.register_modulezModule.register_modules f%r/targetc&|dk(r|S|jd}|}|D]q}t||s"t|jdz|zdzt ||}t |t jjrbtd|zdz|S)a?Return the submodule given by ``target`` if it exists, otherwise throw an error. For example, let's say you have an ``nn.Module`` ``A`` that looks like this: .. code-block:: text A( (net_b): Module( (net_c): Module( (conv): Conv2d(16, 33, kernel_size=(3, 3), stride=(2, 2)) ) (linear): Linear(in_features=100, out_features=200, bias=True) ) ) (The diagram shows an ``nn.Module`` ``A``. ``A`` which has a nested submodule ``net_b``, which itself has two submodules ``net_c`` and ``linear``. ``net_c`` then has a submodule ``conv``.) To check whether or not we have the ``linear`` submodule, we would call ``get_submodule("net_b.linear")``. To check whether we have the ``conv`` submodule, we would call ``get_submodule("net_b.net_c.conv")``. The runtime of ``get_submodule`` is bounded by the degree of module nesting in ``target``. A query against ``named_modules`` achieves the same result, but it is O(N) in the number of transitive modules. So, for a simple check to see if some submodule exists, ``get_submodule`` should always be used. Args: target: The fully-qualified string name of the submodule to look for. (See above example for how to specify a fully-qualified string.) Returns: torch.nn.Module: The submodule referenced by ``target`` Raises: AttributeError: If at any point along the path resulting from the target string the (sub)path resolves to a non-existent attribute name or an object that is not an instance of ``nn.Module``. rr has no attribute ``` is not an nn.Module) r=rr _get_namegetattrrrnnr)r,ratomsmoditems r. get_submodulezModule.get_submodules\ R<K!<<,# KD3%$MMO&;;dBSH#t$Cc588??3$S4Z2I%IJJ K r/strictcf|dk(r td|jd}t|tjj stddt |zt|dk(r|}n%dj|dd}|j|}|r4t||ds%t|jd z|dzd zt||drGt||d}t|tjj std |dzd zt||d|y) a Set the submodule given by ``target`` if it exists, otherwise throw an error. .. note:: If ``strict`` is set to ``False`` (default), the method will replace an existing submodule or create a new submodule if the parent module exists. If ``strict`` is set to ``True``, the method will only attempt to replace an existing submodule and throw an error if the submodule does not exist. For example, let's say you have an ``nn.Module`` ``A`` that looks like this: .. code-block:: text A( (net_b): Module( (net_c): Module( (conv): Conv2d(3, 3, 3) ) (linear): Linear(3, 3) ) ) (The diagram shows an ``nn.Module`` ``A``. ``A`` has a nested submodule ``net_b``, which itself has two submodules ``net_c`` and ``linear``. ``net_c`` then has a submodule ``conv``.) To override the ``Conv2d`` with a new submodule ``Linear``, you could call ``set_submodule("net_b.net_c.conv", nn.Linear(1, 1))`` where ``strict`` could be ``True`` or ``False`` To add a new submodule ``Conv2d`` to the existing ``net_b`` module, you would call ``set_submodule("net_b.conv", nn.Conv2d(1, 1, 1))``. In the above if you set ``strict=True`` and call ``set_submodule("net_b.conv", nn.Conv2d(1, 1, 1), strict=True)``, an AttributeError will be raised because ``net_b`` does not have a submodule named ``conv``. Args: target: The fully-qualified string name of the submodule to look for. (See above example for how to specify a fully-qualified string.) module: The module to set the submodule to. strict: If ``False``, the method will replace an existing submodule or create a new submodule if the parent module exists. If ``True``, the method will only attempt to replace an existing submodule and throw an error if the submodule doesn't already exist. Raises: ValueError: If the ``target`` string is empty or if ``module`` is not an instance of ``nn.Module``. AttributeError: If at any point along the path resulting from the ``target`` string the (sub)path resolves to a non-existent attribute name or an object that is not an instance of ``nn.Module``. rz/Cannot set the submodule without a target name!rz`modulez` is not an nn.Module, found r;Nrrr)rr=rrrrrr>r@rrrrrsetattr)r,rrMrrparent parent_keyrs r. set_submodulezModule.set_submodules'r R<NO O!<<,&%((//2#@f!OO  u:?&*F%*-J'' 3F '&%)4   "%::U2YFL  659 %&%),Cc588??3$S59_7N%NOOb 6*r/rc0|jd\}}}|j|}t||s"t|j dz|zdzt ||}t |tjjstd|zdz|S)aReturn the parameter given by ``target`` if it exists, otherwise throw an error. See the docstring for ``get_submodule`` for a more detailed explanation of this method's functionality as well as how to correctly specify ``target``. Args: target: The fully-qualified string name of the Parameter to look for. (See ``get_submodule`` for how to specify a fully-qualified string.) Returns: torch.nn.Parameter: The Parameter referenced by ``target`` Raises: AttributeError: If the target string references an invalid path or resolves to something that is not an ``nn.Parameter`` rrrz` is not an nn.Parameter) rpartitionrrrrrrrrr)r,r module_path_ param_namerrs r. get_parameterzModule.get_parameter1s(&,%6%6s%;" Q #11+>sJ'  "77*DsJ %,C$<%!3!34 z!14N!NO O r/rc|jd\}}}|j|}t||s"t|j dz|zdzt ||}||j vrtd|zdz|S)aReturn the buffer given by ``target`` if it exists, otherwise throw an error. See the docstring for ``get_submodule`` for a more detailed explanation of this method's functionality as well as how to correctly specify ``target``. Args: target: The fully-qualified string name of the buffer to look for. (See ``get_submodule`` for how to specify a fully-qualified string.) Returns: torch.Tensor: The buffer referenced by ``target`` Raises: AttributeError: If the target string references an invalid path or resolves to something that is not a buffer rrrz` is not a buffer)rrrrrrr)r,rrr buffer_namerbuffers r. get_bufferzModule.get_bufferUs('-&7&7&<# Q #11+>sK(  "77+EK  'sK8 cll * {!25H!HI I r/ctd)aReturn any extra state to include in the module's state_dict. Implement this and a corresponding :func:`set_extra_state` for your module if you need to store extra state. This function is called when building the module's `state_dict()`. Note that extra state should be picklable to ensure working serialization of the state_dict. We only provide backwards compatibility guarantees for serializing Tensors; other objects may break backwards compatibility if their serialized pickled form changes. Returns: object: Any extra state to store in the module's state_dict zReached a code path in Module.get_extra_state() that should never be called. Please file an issue at https://github.com/pytorch/pytorch/issues/new?template=bug-report.yml to report this bug.rXr,s r.get_extra_statezModule.get_extra_stateys "  r/r]ctd)aSet extra state contained in the loaded `state_dict`. This function is called from :func:`load_state_dict` to handle any extra state found within the `state_dict`. Implement this function and a corresponding :func:`get_extra_state` for your module if you need to store extra state within its `state_dict`. Args: state (dict): Extra state from the `state_dict` zReached a code path in Module.set_extra_state() that should never be called. Please file an issue at https://github.com/pytorch/pytorch/issues/new?template=bug-report.yml to report this bug.rr_s r.set_extra_statezModule.set_extra_states "  r/c |r&|jD]}|j|dtfd}tjj }|j jD]\}}| tj5||}ddd||} ddl m } |xst|xs t|| } |j} | rX | d|_ tjj||j }tj"j%|||}nQ| r ||_|}nEt|tsJ|j.sJt||j }||j |<| tj5|| }ddd|| }| rE|j1| j  tj"j%| || |_ |r!|jJ||j_| j.sJ|j1| j |_ |j2jD]\}}| |||j2|<|S#1swYxYw#t&$r.} | | |_ t)d|j+d|| d} ~ wwxYw#1swY1xYw#t&$r&} t)d|j+d|d| d} ~ wwxYw) Nr&cntj||rtjj SyNF)r!_has_compatible_shallow_copy_type __future__)get_overwrite_module_params_on_conversion)rtensor_applieds r.compute_should_use_set_dataz2Module._apply..compute_should_use_set_datas/66v~N!++UUWWWr/r) FakeTensor requires_gradz_apply(): Couldn't swap rz.grad)children_applyrrr$get_swap_module_params_on_conversionritemsno_gradtorch._subclasses.fake_tensorrrrgradrrrutils swap_tensors ExceptionrXrdatais_leafrequires_grad_r)r,fnrecurserMrshould_use_swap_tensorskeyr param_appliedp_should_use_set_datarp_should_use_swap_tensors param_grade out_param grad_appliedg_should_use_set_databufs r.rz Module._applys  --/ " b! " 4     A A C **002D JC} * "5  *$?}$U ! @(10?1eZ0 & J(!-&* $)HH$6$6%U5H5H%7%MKK,,UMB" &* ! !%333}}$}%mU5H5HI (1  %%]]_2#%j>L2(C )%- // 0H0HI! 00\J &0IN*$>>555*6INN'%----%1%@%@"00&INED L ++- -HC%'W c" - I * *0!!-%/ &24>>3C2DAcUK"22%!*6t~~7G6H#eT !!sI JAJ K  KJ  K )KK  K  L #!LL rcb|jD]}|j||||S)aApply ``fn`` recursively to every submodule (as returned by ``.children()``) as well as self. Typical use includes initializing the parameters of a model (see also :ref:`nn-init-doc`). Args: fn (:class:`Module` -> None): function to be applied to each submodule Returns: Module: self Example:: >>> @torch.no_grad() >>> def init_weights(m): >>> print(m) >>> if type(m) == nn.Linear: >>> m.weight.fill_(1.0) >>> print(m.weight) >>> net = nn.Sequential(nn.Linear(2, 2), nn.Linear(2, 2)) >>> net.apply(init_weights) Linear(in_features=2, out_features=2, bias=True) Parameter containing: tensor([[1., 1.], [1., 1.]], requires_grad=True) Linear(in_features=2, out_features=2, bias=True) Parameter containing: tensor([[1., 1.], [1., 1.]], requires_grad=True) Sequential( (0): Linear(in_features=2, out_features=2, bias=True) (1): Linear(in_features=2, out_features=2, bias=True) ) )rapply)r,rrMs r.rz Module.applys2Hmmo F LL   4 r/rc,|jfdS)aMove all model parameters and buffers to the GPU. This also makes associated parameters and buffers different objects. So it should be called before constructing the optimizer if the module will live on GPU while being optimized. .. note:: This method modifies the module in-place. Args: device (int, optional): if specified, all parameters will be copied to that device Returns: Module: self c&|jSra)cudatrs r.zModule.cuda..<QVVF^r/rr,rs `r.rz Module.cuda+"{{344r/c,|jfdS)aMove all model parameters and buffers to the IPU. This also makes associated parameters and buffers different objects. So it should be called before constructing the optimizer if the module will live on IPU while being optimized. .. note:: This method modifies the module in-place. Arguments: device (int, optional): if specified, all parameters will be copied to that device Returns: Module: self c&|jSra)ipurs r.rzModule.ipu..OQUU6]r/rrs `r.rz Module.ipu>"{{233r/c,|jfdS)aMove all model parameters and buffers to the XPU. This also makes associated parameters and buffers different objects. So it should be called before constructing optimizer if the module will live on XPU while being optimized. .. note:: This method modifies the module in-place. Arguments: device (int, optional): if specified, all parameters will be copied to that device Returns: Module: self c&|jSra)xpurs r.rzModule.xpu..brr/rrs `r.r!z Module.xpuQrr/c,|jfdS)aMove all model parameters and buffers to the MTIA. This also makes associated parameters and buffers different objects. So it should be called before constructing the optimizer if the module will live on MTIA while being optimized. .. note:: This method modifies the module in-place. Arguments: device (int, optional): if specified, all parameters will be copied to that device Returns: Module: self c&|jSra)mtiars r.rzModule.mtia..urr/rrs `r.r$z Module.mtiadrr/c&|jdS)zMove all model parameters and buffers to the CPU. .. note:: This method modifies the module in-place. Returns: Module: self c"|jSra)cpurs r.rzModule.cpu..s QUUWr/rrs r.r'z Module.cpuws{{,--r/dst_typec,|jfdS)zCasts all parameters and buffers to :attr:`dst_type`. .. note:: This method modifies the module in-place. Args: dst_type (type or string): the desired type Returns: Module: self c&|jSra)r)rr)s r.rzModule.type..sQVVH%5r/r)r,r)s `r.rz Module.types{{566r/c&|jdS)zCasts all floating point parameters and buffers to ``float`` datatype. .. note:: This method modifies the module in-place. Returns: Module: self cF|jr|jS|Sra)is_floating_pointfloatr(s r.rzModule.float..s!2E2E2GQWWYQr/rrs r.r/z Module.floats{{NOOr/c&|jdS)zCasts all floating point parameters and buffers to ``double`` datatype. .. note:: This method modifies the module in-place. Returns: Module: self cF|jr|jS|Sra)r.doubler(s r.rzModule.double..s13F3F3HQXXZar/rrs r.r2z Module.doubles{{OPPr/c&|jdS)zCasts all floating point parameters and buffers to ``half`` datatype. .. note:: This method modifies the module in-place. Returns: Module: self cF|jr|jS|Sra)r.halfr(s r.rzModule.half..s1D1D1FQVVXAr/rrs r.r5z Module.halfs{{MNNr/c&|jdS)zCasts all floating point parameters and buffers to ``bfloat16`` datatype. .. note:: This method modifies the module in-place. Returns: Module: self cF|jr|jS|Sra)r.bfloat16r(s r.rz!Module.bfloat16..sQ5H5H5JQZZ\PQr/rrs r.r8zModule.bfloat16s{{QRRr/rrc0|jfd|S)aMove the parameters and buffers to the specified device without copying storage. Args: device (:class:`torch.device`): The desired device of the parameters and buffers in this module. recurse (bool): Whether parameters and buffers of submodules should be recursively moved to the specified device. Returns: Module: self c2tj|S)N)r)r empty_likers r.rz!Module.to_empty..se&&q8r/r9r)r,rrs ` r.to_emptyzModule.to_emptys {{ 8'  r/r non_blockingcyrar%)r,rrr>s r.toz Module.tos r/cyrar%)r,rr>s r.r@z Module.tosBEr/cyrar%)r,rr>s r.r@z Module.tosDGr/c*tjjj|i|\Gjsj st dj rtjdfd}|j|S)a Move and/or cast the parameters and buffers. This can be called as .. function:: to(device=None, dtype=None, non_blocking=False) :noindex: .. function:: to(dtype, non_blocking=False) :noindex: .. function:: to(tensor, non_blocking=False) :noindex: .. function:: to(memory_format=torch.channels_last) :noindex: Its signature is similar to :meth:`torch.Tensor.to`, but only accepts floating point or complex :attr:`dtype`\ s. In addition, this method will only cast the floating point or complex parameters and buffers to :attr:`dtype` (if given). The integral parameters and buffers will be moved :attr:`device`, if that is given, but with dtypes unchanged. When :attr:`non_blocking` is set, it tries to convert/move asynchronously with respect to the host if possible, e.g., moving CPU Tensors with pinned memory to CUDA devices. See below for examples. .. note:: This method modifies the module in-place. Args: device (:class:`torch.device`): the desired device of the parameters and buffers in this module dtype (:class:`torch.dtype`): the desired floating point or complex dtype of the parameters and buffers in this module tensor (torch.Tensor): Tensor whose dtype and device are the desired dtype and device for all parameters and buffers in this module memory_format (:class:`torch.memory_format`): the desired memory format for 4D parameters and buffers in this module (keyword only argument) Returns: Module: self Examples:: >>> # xdoctest: +IGNORE_WANT("non-deterministic") >>> linear = nn.Linear(2, 2) >>> linear.weight Parameter containing: tensor([[ 0.1913, -0.3420], [-0.5113, -0.2325]]) >>> linear.to(torch.double) Linear(in_features=2, out_features=2, bias=True) >>> linear.weight Parameter containing: tensor([[ 0.1913, -0.3420], [-0.5113, -0.2325]], dtype=torch.float64) >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_CUDA1) >>> gpu1 = torch.device("cuda:1") >>> linear.to(gpu1, dtype=torch.half, non_blocking=True) Linear(in_features=2, out_features=2, bias=True) >>> linear.weight Parameter containing: tensor([[ 0.1914, -0.3420], [-0.5112, -0.2324]], dtype=torch.float16, device='cuda:1') >>> cpu = torch.device("cpu") >>> linear.to(cpu) Linear(in_features=2, out_features=2, bias=True) >>> linear.weight Parameter containing: tensor([[ 0.1914, -0.3420], [-0.5112, -0.2324]], dtype=torch.float16) >>> linear = nn.Linear(2, 2, bias=None).to(torch.cdouble) >>> linear.weight Parameter containing: tensor([[ 0.3741+0.j, 0.2382+0.j], [ 0.5593+0.j, -0.4443+0.j]], dtype=torch.complex128) >>> linear(torch.ones(3, 2, dtype=torch.cdouble)) tensor([[0.6122+0.j, 0.1150+0.j], [0.6122+0.j, 0.1150+0.j], [0.6122+0.j, 0.1150+0.j]], dtype=torch.complex128) zRnn.Module.to only accepts floating point or complex dtypes, but got desired dtype=aAComplex modules are a new feature under active development whose design may change, and some modules might not work as expected when using complex tensors as parameters or buffers. Please file an issue at https://github.com/pytorch/pytorch/issues/new?template=bug-report.yml if a complex module does not work as expected.cn I|jdvr7|j|js|jrndS|j|js|jrSdS#t$r#}t |dk(rt |ddd}~wwxYw)N)) memory_formatz(Cannot copy out of meta tensor; no data!zz Please use torch.nn.Module.to_empty() instead of torch.nn.Module.to() when moving module from meta to a different device.)dimr@r. is_complexrr4)rr convert_to_formatrrr>s r.convertzModule.to..convertDs $0QUUW5F44!"!4!4!6!,,.d$&7   tt002allnE JN  ' q6GG-#NO   s$A B2BB B4B//B4) rr_nn _parse_tor.rIrwarningswarnr)r,rUrVrKrJrrr>s @@@@r.r@z Module.tosl:?9O9O : : 6|%6  ++u/?/?55:G= E .{{7##r/rLprependct|j}||j|j<|r'|jj|jd|S)aRegister a backward pre-hook on the module. The hook will be called every time the gradients for the module are computed. The hook should have the following signature:: hook(module, grad_output) -> tuple[Tensor] or None The :attr:`grad_output` is a tuple. The hook should not modify its arguments, but it can optionally return a new gradient with respect to the output that will be used in place of :attr:`grad_output` in subsequent computations. Entries in :attr:`grad_output` will be ``None`` for all non-Tensor arguments. For technical reasons, when this hook is applied to a Module, its forward function will receive a view of each Tensor passed to the Module. Similarly the caller will receive a view of each Tensor returned by the Module's forward function. .. warning :: Modifying inputs inplace is not allowed when using backward hooks and will raise an error. Args: hook (Callable): The user-defined hook to be registered. prepend (bool): If true, the provided ``hook`` will be fired before all existing ``backward_pre`` hooks on this :class:`torch.nn.Module`. Otherwise, the provided ``hook`` will be fired after all existing ``backward_pre`` hooks on this :class:`torch.nn.Module`. Note that global ``backward_pre`` hooks registered with :func:`register_module_full_backward_pre_hook` will fire before all hooks registered by this method. Returns: :class:`torch.utils.hooks.RemovableHandle`: a handle that can be used to remove the added hook by calling ``handle.remove()`` Flast)rrrn move_to_endr,rLrPrps r.register_full_backward_pre_hookz&Module.register_full_backward_pre_hook]sNV!!9!9:.2  +   $ $ 0 0 0 G r/c|jdur tdd|_t|j}||j|j<|S)aRegister a backward hook on the module. This function is deprecated in favor of :meth:`~torch.nn.Module.register_full_backward_hook` and the behavior of this function will change in future versions. Returns: :class:`torch.utils.hooks.RemovableHandle`: a handle that can be used to remove the added hook by calling ``handle.remove()`` ToCannot use both regular backward hooks and full backward hooks on a single Module. Please use only one of them.F)rrXrrrnr,rLrps r.register_backward_hookzModule.register_backward_hooksW  & &$ .>  ',# !5!56*.VYY' r/c|jdur tdd|_t|j}||j|j<|r'|jj |jd|S)a Register a backward hook on the module. The hook will be called every time the gradients with respect to a module are computed, and its firing rules are as follows: 1. Ordinarily, the hook fires when the gradients are computed with respect to the module inputs. 2. If none of the module inputs require gradients, the hook will fire when the gradients are computed with respect to module outputs. 3. If none of the module outputs require gradients, then the hooks will not fire. The hook should have the following signature:: hook(module, grad_input, grad_output) -> tuple(Tensor) or None The :attr:`grad_input` and :attr:`grad_output` are tuples that contain the gradients with respect to the inputs and outputs respectively. The hook should not modify its arguments, but it can optionally return a new gradient with respect to the input that will be used in place of :attr:`grad_input` in subsequent computations. :attr:`grad_input` will only correspond to the inputs given as positional arguments and all kwarg arguments are ignored. Entries in :attr:`grad_input` and :attr:`grad_output` will be ``None`` for all non-Tensor arguments. For technical reasons, when this hook is applied to a Module, its forward function will receive a view of each Tensor passed to the Module. Similarly the caller will receive a view of each Tensor returned by the Module's forward function. .. warning :: Modifying inputs or outputs inplace is not allowed when using backward hooks and will raise an error. Args: hook (Callable): The user-defined hook to be registered. prepend (bool): If true, the provided ``hook`` will be fired before all existing ``backward`` hooks on this :class:`torch.nn.Module`. Otherwise, the provided ``hook`` will be fired after all existing ``backward`` hooks on this :class:`torch.nn.Module`. Note that global ``backward`` hooks registered with :func:`register_module_full_backward_hook` will fire before all hooks registered by this method. Returns: :class:`torch.utils.hooks.RemovableHandle`: a handle that can be used to remove the added hook by calling ``handle.remove()`` FrXTrR)rrXrrrnrTrUs r.register_full_backward_hookz"Module.register_full_backward_hooksxh  & &% />  '+# !5!56*.VYY'   , ,VYYU , C r/c:g}tdur|tjz }|jdur||jjz }g}tdur|tjz }|jdur||jjz }||fS)zReturn the backward hooks for use in the call function. It returns two lists, one with the full backward hooks and one with the non-full backward hooks. TF)rerdrrr)r,full_backward_hooksnon_full_backward_hookss r._get_backward_hookszModule._get_backward_hookss /1 (D 0 #9#@#@#B B   & &$ . 4#7#7#>#>#@ @ 24 (E 1 #'='D'D'F F #  & &% / #t';';'B'B'D D #"$;;;r/crg}|tjz }||jjz }|Sra)rcrr)r,backward_pre_hookss r._get_backward_pre_hookszModule._get_backward_pre_hookss=-/8??AAd66==??!!r/cvt|tjs?t|trt d|Ds t j dtdy|f}t|tjs?t|trt d|Ds t j dtdy|f}|Dchc]}|j|j}}t|dk(st|dk(r!||vrt j d tdyt|dkDrt j d tdy|Dchc]}|j|j}}|jDchc]}|d } }|| k7rt j d tdyycc}wcc}wcc}w) Nc3PK|]}t|tj ywrarrr).0rs r. z. D 1ell3D$&aUsing non-full backward hooks on a Module that does not return a single Tensor or a tuple of Tensors is deprecated and will be removed in future versions. This hook will be missing some of the grad_output. Please use register_full_backward_hook to get the documented behavior. stacklevelc3PK|]}t|tj ywrarf)rgis r.riz.rjrkaUsing non-full backward hooks on a Module that does not take as input a single Tensor or a tuple of Tensors is deprecated and will be removed in future versions. This hook will be missing some of the grad_input. Please use register_full_backward_hook to get the documented behavior.rr;zUsing a non-full backward hook when outputs are nested in python data structure is deprecated and will be removed in future versions. This hook will be missing some grad_output.zUsing a non-full backward hook when outputs are generated by different autograd Nodes is deprecated and will be removed in future versions. This hook will be missing some grad_output. Please use register_full_backward_hook to get the documented behavior.zUsing a non-full backward hook when the forward contains multiple autograd Nodes is deprecated and will be removed in future versions. This hook will be missing some grad_input. Please use register_full_backward_hook to get the documented behavior.) rrrtupleallrNrO FutureWarningrr>next_functions) r,inputsr[rrh out_grad_fnrpinputs_grad_fnnrts r."_maybe_warn_non_full_backward_hookz)Module._maybe_warn_non_full_backward_hooks&%,,/65)DVDD ]" YF&%,,/65)DVDD ]" YF+1JQAII4IqyyJ J { q   !g[&@ MM$    ! MMk  28QA199;PaiiQNQ,3,B,BCqadCNC/  " 03K*RCs=F,F, F1F1; F6)rPruruct|j|j}||j|j<|rd|j|j<|r'|jj |jd|S)aRegister a forward pre-hook on the module. The hook will be called every time before :func:`forward` is invoked. If ``with_kwargs`` is false or not specified, the input contains only the positional arguments given to the module. Keyword arguments won't be passed to the hooks and only to the ``forward``. The hook can modify the input. User can either return a tuple or a single modified value in the hook. We will wrap the value into a tuple if a single value is returned (unless that value is already a tuple). The hook should have the following signature:: hook(module, args) -> None or modified input If ``with_kwargs`` is true, the forward pre-hook will be passed the kwargs given to the forward function. And if the hook modifies the input, both the args and kwargs should be returned. The hook should have the following signature:: hook(module, args, kwargs) -> None or a tuple of modified input and kwargs Args: hook (Callable): The user defined hook to be registered. prepend (bool): If true, the provided ``hook`` will be fired before all existing ``forward_pre`` hooks on this :class:`torch.nn.Module`. Otherwise, the provided ``hook`` will be fired after all existing ``forward_pre`` hooks on this :class:`torch.nn.Module`. Note that global ``forward_pre`` hooks registered with :func:`register_module_forward_pre_hook` will fire before all hooks registered by this method. Default: ``False`` with_kwargs (bool): If true, the ``hook`` will be passed the kwargs given to the forward function. Default: ``False`` Returns: :class:`torch.utils.hooks.RemovableHandle`: a handle that can be used to remove the added hook by calling ``handle.remove()`` rxTFrR)rrrrnrT)r,rLrPrurps r.register_forward_pre_hookz Module.register_forward_pre_hookLsrn!  # #0S0S .2 * =AD / / :   # # / /  / F r/)rPrurvrvcPt|j|j|jg}||j|j<|rd|j|j<|rd|j|j<|r'|jj |jd|S)afRegister a forward hook on the module. The hook will be called every time after :func:`forward` has computed an output. If ``with_kwargs`` is ``False`` or not specified, the input contains only the positional arguments given to the module. Keyword arguments won't be passed to the hooks and only to the ``forward``. The hook can modify the output. It can modify the input inplace but it will not have effect on forward since this is called after :func:`forward` is called. The hook should have the following signature:: hook(module, args, output) -> None or modified output If ``with_kwargs`` is ``True``, the forward hook will be passed the ``kwargs`` given to the forward function and be expected to return the output possibly modified. The hook should have the following signature:: hook(module, args, kwargs, output) -> None or modified output Args: hook (Callable): The user defined hook to be registered. prepend (bool): If ``True``, the provided ``hook`` will be fired before all existing ``forward`` hooks on this :class:`torch.nn.Module`. Otherwise, the provided ``hook`` will be fired after all existing ``forward`` hooks on this :class:`torch.nn.Module`. Note that global ``forward`` hooks registered with :func:`register_module_forward_hook` will fire before all hooks registered by this method. Default: ``False`` with_kwargs (bool): If ``True``, the ``hook`` will be passed the kwargs given to the forward function. Default: ``False`` always_call (bool): If ``True`` the ``hook`` will be run regardless of whether an exception is raised while calling the Module. Default: ``False`` Returns: :class:`torch.utils.hooks.RemovableHandle`: a handle that can be used to remove the added hook by calling ``handle.remove()`` rxTFrR)rrrrrnrT)r,rLrPrurvrps r.register_forward_hookzModule.register_forward_hooksj!   //11 *.FII& 9=D + +FII 6 ;?D - -fii 8     + +FIIE + B r/cZtjj}|r.t|jtjj r|j|i|Stj jjdu}|re|tj jjvr'tj jj|nd}|r|j|nd} |j|i|}|r|j|S#|r|jwwxYwr) rr_get_tracing_staterr ScriptMethodr_trace_trace_module_map push_scope pop_scope)r,rrV tracing_staterecording_scopesrr[s r. _slow_forwardzModule._slow_forwards335  4<<9N9N O4<<1&1 1 99++==TI  599++===   2248  ((.#(  *!T\\53F3F'')  '') s /DD*cb|j|j|i|S|j|i|Sra)r _call_implr,rUrVs r._wrapped_call_implzModule._wrapped_call_impls<  # # /+4++T.inner..Cs"ZjELL>Y1"Zs))r)$rrcrcrrdr`rfrrrrrqr>rXrsetup_input_hookrgrrrhrrrirrrNrOrsetup_output_hookrbrrr register_hookrKry)r^r_rbhook_idrLargs_kwargs_result args_resultbw_hook hook_resultvarrrUcalled_always_called_hooks forward_callrVr[r,s r.innerz Module._call_impl..inners<>r!8 !# ''+E%)%A%A%C"##'=?C?W?W?Y<#%<(D,C,C&.446&,,224&/MGT$"E"EE-1$f-E*-9)* ".!,- !&5<<*?@MM#337<.#BC!226:'$S%,,7!#t,""Zcjjl"ZZ!!f %S%,,7 ++& 7H--l4.FGH;;D&'RMr/zglobal module forward hook with ``always_call=True`` raised an exception that was silenced as another error was raised in forward: z|module forward hook with ``always_call=True`` raised an exception that was silenced as another error was raised in forward: )rrrrrrrrrrcrdrgrfrcompiler is_compilingrrrhrNrOr4rr) r,rUrVrrrLrr rrr[s ``` @@@r.rzModule._call_impls.3hh.I.I.K**QUQ]Q] $$(@(@DDWDW[_[r[r-1G(,E00 0%(U"M M l >> & & (7N 7N "7! ! AAgUoFo!&*4v&> &2%0F$! 'ccfghcibj'lm ! !"&!4!4!:!:!< ! d???GSmDm !"d&E&EE*.tT66*JK*.tT6*BK&2%0F$! 'ccfghcibj'lm ! ! ; sl C,G"=G"DG" E!E<G"E2G"9G"?(F('G"( G1!GG"GG"rYc^|jj}|jdd|S)Nr)rcopyr?r_s r.r\zModule.__getstate__|s( ""$ '. r/c|jj|d|jvrt|_d|jvrt|_d|jvrt|_d|jvrt|_d|jvrt|_d|jvrt|_d|jvrt|_ d|jvrt|_ d |jvrt|_ d |jvrd|_ d |jvrt|_yy) Nrrrrrrrrrrr)rupdaterrrrrrrrrrrrrr_s r.r`zModule.__setstate__s  U# t}} 4&1mD # +4== @2=-D / 't}} <.9mD + ) >0; D - dmm 3%0]D " "$-- 7)4D & 't}} <.9mD + ( =/:}D , ( =/2uD , #4== 8*.D '  5'2}D $ 6r/c0d|jvr|jd}||vr||Sd|jvr|jd}||vr||Sd|jvr|jd}||vr||Stdt|jd|d)Nrrrrz' object has no attribute ')rrrr0)r,rrrmoduless r. __getattr__zModule.__getattr__s DMM )-- 6K{""4((  &}}Z0Hx~%  &mmJ/Gwt}$T ##$$?vQ G  r/valuecNdfd }|jjd}t|trS| t d||j|j |j |j|j|y|>|vr:|%tdtj|dd|j|y|jjd}t|trn| t d||j|j|j |jtjD]}|||}||}||<y|Y|vrU|%tdtj|d d tjD]}|||}||}||<y|jjd }t|t s|-|vr(|Kt|tj"s1t%|d s%tdtj|d dt|t r |j&} n|jv} t)|j*ddtj,jj*ur|j+|| yt/j0|j*} d| j2vr|j+|| y| s t5d|j+|yt6 |q|y)Nch|D],}|vst|tr|=|j.yra)rrbr) dicts_or_setsdrs r. remove_fromz'Module.__setattr__..remove_froms5" (19!!T*dG $  (r/rz6cannot assign parameters before Module.__init__() callrz' as parameter 'z'' (torch.nn.Parameter or None expected)rz2cannot assign module before Module.__init__() callz' as child module 'z$' (torch.nn.Module or None expected)rrz ' as buffer 'z2' (torch.nn.Buffer, torch.Tensor or None expected)__func__rzRegistering a non-persistent buffer on a Module subclass that implements register_buffer() without the persistent argument is not allowed.r&N)rgetrrrrrrrrrrrrrHrrrrrrrrinspect signature parametersrXr*r) r,rrrparamsrrLrbuffersrsignr-s ` r.rzModule.__setattr__s5 (""=1 eY '~$L    00    # #D% 0  DFN %ennU&;%<DDF'D!$e4F) &'!& $$#)%..*?)@@STXSYZ==>DDF'D!$e4F) &'!& --++J7eV,0CPW("5%,,7"5*>?'-ennU.C-DMRVQWXOO"%0%*%5%5 %)1Q1Q%Q   4 4j$G 88??::;,,T5*E&001E1EF'4??: 00ujI#-&2%?'"!"!00u=G'e4r/c||jvr|j|=y||jvr)|j|=|jj|y||jvr|j|=yt ||yra)rrrrrr* __delattr__)r,rr-s r.rzModule.__delattr__sp 4## #  & T]] " d#  , , 4 4T : T]] " d# G  %r/ct|ddr tdt|j}||j|j<|S)aRegister a post-hook for the :meth:`~torch.nn.Module.state_dict` method. It should have the following signature:: hook(module, state_dict, prefix, local_metadata) -> None or state_dict The registered hooks can modify the ``state_dict`` inplace or return a new one. If a new ``state_dict`` is returned, it will only be respected if it is the root module that :meth:`~nn.Module.state_dict` is called from. _from_public_apiFz~Cannot register the same function as the state dict post hook that was previously registered via register_state_dict_post_hook)rrXrrrnrYs r._register_state_dict_hookz Module._register_state_dict_hook$sO 4+U 3J !!7!78,0vyy) r/cpd|_t|j}||j|j<|S)a Register a post-hook for the :meth:`~torch.nn.Module.state_dict` method. It should have the following signature:: hook(module, state_dict, prefix, local_metadata) -> None The registered hooks can modify the ``state_dict`` inplace. T)rrrrnrYs r.register_state_dict_post_hookz$Module.register_state_dict_post_hook7s5&!% !7!78,0vyy) r/cbt|j}||j|j<|S)a*Register a pre-hook for the :meth:`~torch.nn.Module.state_dict` method. It should have the following signature:: hook(module, prefix, keep_vars) -> None The registered hooks can be used to perform pre-processing before the ``state_dict`` call is made. )rrrnrYs r.register_state_dict_pre_hookz#Module.register_state_dict_pre_hookOs-!!;!;<04""699- r/c|jjD]"\}}| |r|n|j|||z<$|jjD]1\}}| ||jvs|r|n|j|||z<3|t z}t |jdtjtjur|j||<yy)a+Save module state to the `destination` dictionary. The `destination` dictionary will contain the state of the module, but not its descendants. This is called on every submodule in :meth:`~torch.nn.Module.state_dict`. In rare cases, subclasses can achieve class-specific behavior by overriding this method with custom logic. Args: destination (dict): a dict where state will be stored prefix (str): the prefix for parameters and buffers used in this module Nr) rrdetachrr_EXTRA_STATE_KEY_SUFFIXrr-rr)r, destinationprefix keep_varsrrr extra_state_keys r._save_to_state_dictzModule._save_to_state_dict\s ++113 TKD% 6?UU\\^ FTM* T,,. PID#4t/O/O#O4=S3::< FTM* P!#:: DNN$5v7M7M N)) *,0+?+?+AK ( *r/ T_destinationr!)rrrrrcyrar%)r,rrrs r. state_dictzModule.state_dict|sr/cyrar%)r,rrs r.rzModule.state_dicts r/rrrrct|dkDrRtjdtd||d}t|dkDr |dk(r|d}t|dkDr |dur|d}|t }t |_t |j }t|d r||j |dd <|jjD] }|||||j||||jjD]"\}}| |j|||zd z| $|jjD]-}|||||} t!|dds| | }!| $t#d|S)aReturn a dictionary containing references to the whole state of the module. Both parameters and persistent buffers (e.g. running averages) are included. Keys are corresponding parameter and buffer names. Parameters and buffers set to ``None`` are not included. .. note:: The returned object is a shallow copy. It contains references to the module's parameters and buffers. .. warning:: Currently ``state_dict()`` also accepts positional arguments for ``destination``, ``prefix`` and ``keep_vars`` in order. However, this is being deprecated and keyword arguments will be enforced in future releases. .. warning:: Please avoid the use of argument ``destination`` as it is not designed for end-users. Args: destination (dict, optional): If provided, the state of module will be updated into the dict and the same object is returned. Otherwise, an ``OrderedDict`` will be created and returned. Default: ``None``. prefix (str, optional): a prefix added to parameter and buffer names to compose the keys in state_dict. Default: ``''``. keep_vars (bool, optional): by default the :class:`~torch.Tensor` s returned in the state dict are detached from autograd. If it's set to ``True``, detaching will not be performed. Default: ``False``. Returns: dict: a dictionary containing a whole state of the module Example:: >>> # xdoctest: +SKIP("undefined vars") >>> module.state_dict().keys() ['bias', 'weight'] rzPositional args are being deprecated, use kwargs instead. Refer to https://pytorch.org/docs/main/generated/torch.nn.Module.html#torch.nn.Module.state_dict for details.rlrmNr;rF)version _metadatarrrrz%state_dict post-hook must return None)r>rNrOrsrrrbrrrrrrrrrrrX) r,rrrrUlocal_metadatarLrrMrs r.rzModule.state_dictsZ t9q= MM   ""1g 4y1}2a4y1}e!3 G  %-K$/MK !dmm4 ; ,1?K ! !&"+ ...557 *D vy ) *   fi@ MM//1 LD&!!! +!D=3.'" **113 PDt[&.IK4!3U;*"-K*&'NOO Pr/c~t|j}t||r|nd|j|j<|S)a|See :meth:`~torch.nn.Module.register_load_state_dict_pre_hook` for details. A subtle difference is that if ``with_module`` is set to ``False``, then the hook will not take the ``module`` as the first argument whereas :meth:`~torch.nn.Module.register_load_state_dict_pre_hook` always takes the ``module`` as the first argument. Arguments: hook (Callable): Callable hook that will be invoked before loading the state dict. with_module (bool, optional): Whether or not to pass the module instance to the hook as the first parameter. N)rrrKrn)r,rLrQrps r."_register_load_state_dict_pre_hookz)Module._register_load_state_dict_pre_hooks=!!@!@A5A +$46 '' 2 r/c(|j|dS)aRegister a pre-hook to be run before module's :meth:`~nn.Module.load_state_dict` is called. It should have the following signature:: hook(module, state_dict, prefix, local_metadata, strict, missing_keys, unexpected_keys, error_msgs) -> None # noqa: B950 Arguments: hook (Callable): Callable hook that will be invoked before loading the state dict. T)rQ)r)r,rLs r.!register_load_state_dict_pre_hookz(Module.register_load_state_dict_pre_hooks66t6NNr/cbt|j}||j|j<|S)aRegister a post-hook to be run after module's :meth:`~nn.Module.load_state_dict` is called. It should have the following signature:: hook(module, incompatible_keys) -> None The ``module`` argument is the current module that this hook is registered on, and the ``incompatible_keys`` argument is a ``NamedTuple`` consisting of attributes ``missing_keys`` and ``unexpected_keys``. ``missing_keys`` is a ``list`` of ``str`` containing the missing keys and ``unexpected_keys`` is a ``list`` of ``str`` containing the unexpected keys. The given incompatible_keys can be modified inplace if needed. Note that the checks performed when calling :func:`load_state_dict` with ``strict=True`` are affected by modifications the hook makes to ``missing_keys`` or ``unexpected_keys``, as expected. Additions to either set of keys will result in an error being thrown when ``strict=True``, and clearing out both missing and unexpected keys will avoid an error. Returns: :class:`torch.utils.hooks.RemovableHandle`: a handle that can be used to remove the added hook by calling ``handle.remove()`` )rrrnrYs r."register_load_state_dict_post_hookz)Module.register_load_state_dict_post_hook s-2!!A!AB6:((3 r/cd |jjD]}|||||||||jjD cic]\} } | |jvr| | } } } t j |jj| j} | D cic] \} } |  | |  } } } |jdd}tjj}| jD]\}}||z}||vr||}tjj|s!|jd|dt|Vtj j"j%|}|s5t'|j(dk(rt'|j(dk(r|d}|sJ|j(|j(k7r1|jd|d |j(d |j(d |j*r'|j*s|st-j.d |d  tj05|r|j3||}t5|t5|k(st5|t5|k(r t7dt9|tj j:rkt9|tj j:s,tj j;||j<}n|j?|j<tj@jC||~n|rt9|tj j:rkt9|tj j:s,tj j;||j<}n|j?|j<tE|||n|jG|ddd|s|j||tNz}tQ|jRdtTjVtTjVur-||vr|jW||n+|r)|j|n|r||vr|j||r|jYD]}|j[|s||k7s|t'|dj]d d}t'|dkDr$|d|j^vsY|j|k|d| vss|j|yycc} } wcc} } w#1swYLxYw#tH$rX}|rdnd}|jd|d|d|jKd|jKd|jLd Yd}~d}~wwxYw)aFCopy parameters and buffers from :attr:`state_dict` into only this module, but not its descendants. This is called on every submodule in :meth:`~torch.nn.Module.load_state_dict`. Metadata saved for this module in input :attr:`state_dict` is provided as :attr:`local_metadata`. For state dicts without metadata, :attr:`local_metadata` is empty. Subclasses can achieve class-specific backward compatible loading using the version number at `local_metadata.get("version", None)`. Additionally, :attr:`local_metadata` can also contain the key `assign_to_params_buffers` that indicates whether keys should be assigned their corresponding tensor in the state_dict. .. note:: :attr:`state_dict` is not the same object as the input :attr:`state_dict` to :meth:`~torch.nn.Module.load_state_dict`. So it can be modified. Args: state_dict (dict): a dict containing parameters and persistent buffers. prefix (str): the prefix for parameters and buffers used in this module local_metadata (dict): a dict containing the metadata for this module. See strict (bool): whether to strictly enforce that the keys in :attr:`state_dict` with :attr:`prefix` match the names of parameters and buffers in this module missing_keys (list of str): if ``strict=True``, add missing keys to this list unexpected_keys (list of str): if ``strict=True``, add unexpected keys to this list error_msgs (list of str): error messages should be added to this list, and will be reported together in :meth:`~torch.nn.Module.load_state_dict` Nassign_to_params_buffersFz#While copying the parameter named "zL", expected torch.Tensor or Tensor-like object from checkpoint but received rr;zsize mismatch for z: copying a param with shape z0 from checkpoint, the shape in current model is rzfor a : copying from a non-meta parameter in the checkpoint to a meta parameter in the current model, which is a no-op. (Did you mean to pass `assign=True` to assign items in the state dictionary to their corresponding key in the module instead of copying them in place?))assignztmodule_load returned one of self or other, please .detach() the result if returning one of the inputs in module_loadrswappingcopyingzWhile z the parameter named "z%", whose dimensions in the model are z, and whose dimensions in the checkpoint are z, an exception occurred : r)0rrrrr itertoolschainrrrrr overridesis_tensor_likeappendrr parameteris_lazyr>shapeis_metarNrOr module_loadrnrXrrrrrrrcopy_rsizerUrrr-rrkeys startswithr=r)r,rrrrr(r) error_msgsrLkrpersistent_bufferslocal_name_params local_stateruse_swap_tensorsrrr input_param is_param_lazynew_input_paramexactionr input_names r._load_from_state_dictzModule._load_from_state_dict% sqZ33::< D    ++- 1888 qD  &OO    " " $&8&>&>&@ ):K1Q]q!tK K#1#5#56PRW#X  ++PPR&,,.X )KD%4-Cj (o 55kB%%=cUC$$($5#68  !& 2 2 : :5 A &EKK(A-K--.!3"-a.K$):):ekk)I%%,SE1N{O`O`Nab99> QHMM'//4MMse$]]*!5+.3.?.? +4L/@/O "/2boE /J!#EJ+'3%_'"!" *%1C1CD'1/588CUCU'V6;hh6H6H(76;6I6I7I7&O %4$B$B5CVCV$W!KK44UOL /5)%1C1CD'1+uxx?Q?Q'R27((2D2D(35CVCV3E3&K%0$>$>u?R?R$S#D$ <!KK 4C!5T##C(qX )t!#:: DNN$5v7M7M N)) **,$$Z%@A##O4 J6  " "? 3 !( 4>>&)c_.D!$S[]!3!9!9#q!AJ:*%a= =+2237#Ak9'..s3 4 e Lb!5!5D!+;ZF%% (>seD==BZZ\NKBBMBRBRBTAUV33577)1>sD T5* T;5T;3UF0U7UU U V/A V**V/rrc t|tstdt|dgggt |ddt |}|_ddfd |||rtdkDr7jddjdjd DtdkDr7jdd jdjd DtdkDr>td j|jjd jtS)aCopy parameters and buffers from :attr:`state_dict` into this module and its descendants. If :attr:`strict` is ``True``, then the keys of :attr:`state_dict` must exactly match the keys returned by this module's :meth:`~torch.nn.Module.state_dict` function. .. warning:: If :attr:`assign` is ``True`` the optimizer must be created after the call to :attr:`load_state_dict` unless :func:`~torch.__future__.get_swap_module_params_on_conversion` is ``True``. Args: state_dict (dict): a dict containing parameters and persistent buffers. strict (bool, optional): whether to strictly enforce that the keys in :attr:`state_dict` match the keys returned by this module's :meth:`~torch.nn.Module.state_dict` function. Default: ``True`` assign (bool, optional): When set to ``False``, the properties of the tensors in the current module are preserved whereas setting it to ``True`` preserves properties of the Tensors in the state dict. The only exception is the ``requires_grad`` field of :class:`~torch.nn.Parameter` for which the value from the module is preserved. Default: ``False`` Returns: ``NamedTuple`` with ``missing_keys`` and ``unexpected_keys`` fields: * ``missing_keys`` is a list of str containing any keys that are expected by this module but missing from the provided ``state_dict``. * ``unexpected_keys`` is a list of str containing the keys that are not expected by this module but present in the provided ``state_dict``. Note: If a parameter or buffer is registered as ``None`` and its corresponding key exists in :attr:`state_dict`, :meth:`load_state_dict` will raise a ``RuntimeError``. z)Expected state_dict to be dict-like, got rrNc inj|ddi} r |d<|j|||d|jjD]N\}}| ||zdz}|jDcic]\}}|j |r||} }}|| |Pt } |j jD]} | || } | Jdycc}}w)NrrTrzHooks registered with ``register_load_state_dict_post_hook`` are notexpected to return new values, if incompatible_keys need to be modified,it should be done inplace.)rrrrrr$rr)rMlocal_state_dictrrrchild child_prefixrrchild_state_dictincompatible_keysrLoutrrloadmetadatar(r)s r.rz$Module.load_state_dict..load s+#+#3RfSbkSU9VN=C9:  ( (   &446 @ e$#)D=3#6L%5$:$:$<( Aq<< 51($(  0,? @!2, P ::AAC 6#45{1{ (s7C"rz%Unexpected key(s) in state_dict: {}. z, c3(K|] }d|d yw"Nr%rgrs r.riz)Module.load_state_dict..9 s!DqAaS(!Dz"Missing key(s) in state_dict: {}. c3(K|] }d|d ywrr%rs r.riz)Module.load_state_dict..@ s!AqAaS(!Arz*Error(s) in loading state_dict for {}: {}z )rr)rrrrrrrr>insertformatr@rXr-r0r$) r,rrrrrrr(r)s `@@@@@r.load_state_dictzModule.load_state_dict sSL*g.;DEENN++V[[-D  !??r/remove_duplicatec#Kt}|r|j||n||fg}|D]C\}}||} | D]1\} } | | |vr |r|j| ||rdndz| z} | | f3Eyw)z.Help yield various names + members of modules.)rrNrr)r named_modulesr) r,get_members_fnrrrmemor module_prefixrMmembersrrrs r._named_memberszModule._named_membersL su   f?O  P4.!  &-  !M6$V,G 19T #HHQK$}"EIAg   sA.A0c#HK|j|D] \}}| yw)aReturn an iterator over module parameters. This is typically passed to an optimizer. Args: recurse (bool): if True, then yields parameters of this module and all submodules. Otherwise, yields only parameters that are direct members of this module. Yields: Parameter: module parameter Example:: >>> # xdoctest: +SKIP("undefined vars") >>> for param in model.parameters(): >>> print(type(param), param.size()) (20L,) (20L, 1L, 5L, 5L) r9N)named_parameters)r,r_namers r.rzModule.parameters` s.,!11'1B LE5K  "c#PK|jd|||}|Ed{y7w)aUReturn an iterator over module parameters, yielding both the name of the parameter as well as the parameter itself. Args: prefix (str): prefix to prepend to all parameter names. recurse (bool): if True, then yields parameters of this module and all submodules. Otherwise, yields only parameters that are direct members of this module. remove_duplicate (bool, optional): whether to remove the duplicated parameters in the result. Defaults to True. Yields: (str, Parameter): Tuple containing the name and parameter Example:: >>> # xdoctest: +SKIP("undefined vars") >>> for name, param in self.named_parameters(): >>> if name in ['bias']: >>> print(param.size()) c6|jjSra)rrrMs r.rz)Module.named_parameters.. s6--335r/rrrNrr,rrrgens r.rzModule.named_parametersy s20!! 5- "   &$&c#HK|j|D] \}}| yw)a@Return an iterator over module buffers. Args: recurse (bool): if True, then yields buffers of this module and all submodules. Otherwise, yields only buffers that are direct members of this module. Yields: torch.Tensor: module buffer Example:: >>> # xdoctest: +SKIP("undefined vars") >>> for buf in model.buffers(): >>> print(type(buf), buf.size()) (20L,) (20L, 1L, 5L, 5L) r9N) named_buffers)r,rrr s r.rzModule.buffers s.((((9 FAsI rc#PK|jd|||}|Ed{y7w)aLReturn an iterator over module buffers, yielding both the name of the buffer as well as the buffer itself. Args: prefix (str): prefix to prepend to all buffer names. recurse (bool, optional): if True, then yields buffers of this module and all submodules. Otherwise, yields only buffers that are direct members of this module. Defaults to True. remove_duplicate (bool, optional): whether to remove the duplicated buffers in the result. Defaults to True. Yields: (str, torch.Tensor): Tuple containing the name and buffer Example:: >>> # xdoctest: +SKIP("undefined vars") >>> for name, buf in self.named_buffers(): >>> if name in ['running_var']: >>> print(buf.size()) c6|jjSra)rrrs r.rz&Module.named_buffers.. s6??002r/rNrrs r.rzModule.named_buffers s2.!! 2- "  rc#DK|jD] \}}| yw)zpReturn an iterator over immediate children modules. Yields: Module: a child module N)named_children)r,rrMs r.rzModule.children s) "002 ME6L  c#Kt}|jjD]$\}}| ||vs|j|||f&yw)aReturn an iterator over immediate children modules, yielding both the name of the module as well as the module itself. Yields: (str, Module): Tuple containing a name and child module Example:: >>> # xdoctest: +SKIP("undefined vars") >>> for name, module in model.named_children(): >>> if name in ['conv4', 'conv5']: >>> print(module) N)rrrr)r,r rrMs r.r zModule.named_children sRu MM//1 #LD&!fD&8 Fl" #s-AAAc#DK|jD] \}}| yw)aReturn an iterator over all modules in the network. Yields: Module: a module in the network Note: Duplicate modules are returned only once. In the following example, ``l`` will be returned only once. Example:: >>> l = nn.Linear(2, 2) >>> net = nn.Sequential(l, l) >>> for idx, m in enumerate(net.modules()): ... print(idx, '->', m) 0 -> Sequential( (0): Linear(in_features=2, out_features=2, bias=True) (1): Linear(in_features=2, out_features=2, bias=True) ) 1 -> Linear(in_features=2, out_features=2, bias=True) N)r )r,rrMs r.rzModule.modules s)0++- IAvL r!r c#K| t}||vrf|r|j|||f|jjD]/\}}| ||rdndz|z}|j |||Ed{1yy7w)a<Return an iterator over all modules in the network, yielding both the name of the module as well as the module itself. Args: memo: a memo to store the set of modules already added to the result prefix: a prefix that will be added to the name of the module remove_duplicate: whether to remove the duplicated module instances in the result or not Yields: (str, Module): Tuple of name and module Note: Duplicate modules are returned only once. In the following example, ``l`` will be returned only once. Example:: >>> l = nn.Linear(2, 2) >>> net = nn.Sequential(l, l) >>> for idx, m in enumerate(net.named_modules()): ... print(idx, '->', m) 0 -> ('', Sequential( (0): Linear(in_features=2, out_features=2, bias=True) (1): Linear(in_features=2, out_features=2, bias=True) )) 1 -> ('0', Linear(in_features=2, out_features=2, bias=True)) Nrr)rrrrr )r,r rrrrMsubmodule_prefixs r.r zModule.named_modules sF <5D t $,  $ 3 3 5  f>#)FS#Cd#J !//*,<   sA/A<1A:2 A<modect|ts td||_|j D]}|j ||S)aSet the module in training mode. This has an effect only on certain modules. See the documentation of particular modules for details of their behaviors in training/evaluation mode, i.e., whether they are affected, e.g. :class:`Dropout`, :class:`BatchNorm`, etc. Args: mode (bool): whether to set training mode (``True``) or evaluation mode (``False``). Default: ``True``. Returns: Module: self z'training mode is expected to be boolean)rrrrrtrain)r,r&rMs r.r(z Module.train8 sG$%FG G mmo F LL   r/c$|jdS)aDSet the module in evaluation mode. This has an effect only on certain modules. See the documentation of particular modules for details of their behaviors in training/evaluation mode, i.e. whether they are affected, e.g. :class:`Dropout`, :class:`BatchNorm`, etc. This is equivalent with :meth:`self.train(False) `. See :ref:`locally-disable-grad-doc` for a comparison between `.eval()` and several similar mechanisms that may be confused with it. Returns: Module: self F)r(rs r.evalz Module.evalN s zz%  r/rcR|jD]}|j||S)aChange if autograd should record operations on parameters in this module. This method sets the parameters' :attr:`requires_grad` attributes in-place. This method is helpful for freezing part of the module for finetuning or training parts of a model individually (e.g., GAN training). See :ref:`locally-disable-grad-doc` for a comparison between `.requires_grad_()` and several similar mechanisms that may be confused with it. Args: requires_grad (bool): whether autograd should record operations on parameters in this module. Default: ``True``. Returns: Module: self )rr)r,rps r.rzModule.requires_grad_` s-&" ,A  ] + , r/ set_to_noneclt|ddrtjd|jD]}|j|rd|_|jj |jj n|jjd|jjy)a1Reset gradients of all model parameters. See similar function under :class:`torch.optim.Optimizer` for more context. Args: set_to_none (bool): instead of setting to zero, set the grads to None. See :meth:`torch.optim.Optimizer.zero_grad` for details. _is_replicaFaGCalling .zero_grad() from a module created with nn.DataParallel() has no effect. The parameters are copied (in a differentiable manner) from the original module. This means they are not leaf nodes in autograd and so don't accumulate gradients. If you need gradients in your forward method, consider using autograd.grad instead.N) rrNrOrrrdetach_rzero_)r,r-r,s r. zero_gradzModule.zero_gradw s 4 . MMf " #Avv!!AFvv~~1(--e4FFLLN #r/c&|jdS)z'See :meth:`torch.Tensor.share_memory_`.c"|jSra) share_memory_r(s r.rz%Module.share_memory.. s Q__%6r/rrs r. share_memoryzModule.share_memory s{{677r/c.|jjSra)r-r0rs r.rzModule._get_name s~~&&&r/cy)zReturn the extra representation of the module. To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable. rr%rs r. extra_reprzModule.extra_repr sr/cg}|j}|r|jd}g}|jjD]6\}}t |}t |d}|j d|zdz|z8||z}|jdz}|r3t|dk(r |s ||dz }n|ddj|zdzz }|dz }|S) Nr:rl(z): r;rz )) r9r=rrreprrFrrr>r@) r, extra_linesr9 child_linesrrMmod_strlinesmain_strs r.r+zModule.__repr__ s __& $**40K ==..0 >#c) ;1$[KN*FV[[%77$>>Cr/ct|j}t|jj }t|j j }t|j j }t|jj }||z|z|z|z}|Dcgc]}|djr|}}t|Scc}w)Nr) dirr-listrrrrrisdigitsorted)r, module_attrsattrsrrrrrs r.__dir__zModule.__dir__ s4>>* T]]'')*$**//12 t}}))+,t}}))+,e#j07:WD $<3q6>>+;<<d|=s 4C Cc|jt|}|jj|_i|_|j j|_|j j|_d|_|S)NT)__new__rrrrrrr/)r,replicas r._replicate_for_data_parallelz#Module._replicate_for_data_parallel sn,,tDz*==--/!"++002"++002"r/cTtj|jg|i||_y)a Compile this Module's forward using :func:`torch.compile`. This Module's `__call__` method is compiled and all arguments are passed as-is to :func:`torch.compile`. See :func:`torch.compile` for details on the arguments for this function. N)rcompilerrrs r.rPzModule.compile s#$)==#R4#R6#R r/r)T)Fra)...).)TF)rTT)NrT)lr0r1r2__doc__rr__annotations__rintrbr4r rrrrrrrTrrrrrrrrrrrrrrr rr rrrr!r$r'rrr/r2r5r8rr=r r@_grad_trrVrZr\r`rcryr rqr{r}rrrrYr\r`rrrrrrrr rrrrrrrrrrrrrrrr rr r(r*rr2r6rr9r+rJrNrPr6r7s@r.rrsw BL$Hc Nc8I..//3(())!$S)c8m,,#x-(($TN*h''!%S$Y/"&sDy/1S(]++%)dO3CM** $S(] 33X ..!%c8m!443**++!OT!.2(+2*.X#9GXc3h 8GK>;>;!)&!1>;?C>; >;@0+s0+8I3F0+40+d%s%HX,>%4%8&C&(1C&&?C?H?D=BO+O+#+O+59O+ O+b"C"K"H"""H  * S T "aF'(T!12't'R58E#v+$67545&4(5f#564$4&4(5f#564$4&58E#v+$67545& .T . 7U5#:. 74 7 Pt P Q Q Od O S$ SDH !.1 <@  $,/!$ (   EETEDEE GGtGdGG$H/'*E$-,@@A//  /bh95w;OOP :@'73U4=5IIJ@@  @D<("Eb!@ asCx)8C=8 9 E#s(OT#s(^4sDcN2346   @@@ @R!!C asCx#. = > asCx$sCx.#> M N P CCCC CJ04DN$6HhsCx 5 5<  fh.>(? "g5g5E&(2B,Cg5g5R &&0 B<O4S>BM  #        c3h -1uWr( O:s4 s4lRWp@!#s(+p@59p@JNp@fQUIM($(92E4PT)-HL %Y' (@tx/?0PT)-HL %V $ %>(8,#sH})= >#((+:)-!% /s8}%// /b$$,!d!$DD.#T#T#88d8'C#2   Sr/)CrOrrrNrR collectionsrrcollections.abcrrtypingrrr r r r typing_extensionsr rrrrtorch._prims_commonrtorch.nn.parameterrrtorch.utils._python_dispatchrtorch.utils.hooksrr__all__rqrTr r$rFrGrbrSrRrHrIrKrcrdrerrfrgrhrirkrrrrrrrrrrrr%r/r.r^s/-DD" ''.0F;  fck"F* + Cx  !N4E#FG   ,9D!4X #6F9D!4X #6F-Dh/?.9mS(]+;04x~41<4X .>-8]tCM*:7B}#T#t)_D5@]!4T ?B) 9 4 9 4 9 48I+>?F , 9 ,, ,  ,^ Hgw/tW}1EE F: Hg&dGm(<< =6! Hgw/tW}1EE F!!N    K)SK)Sr/