
    3Ki                     R    S r SSKJr   " S S5      r " S S\R                  5      rg)z3Functionality for Python <-> C++ frontend inter-op.    )nnc                   l    \ rS rSrSrSS jr\S 5       rS rS r	S	 r
S
 rS\4S jrS\4S jrS rSrg)OrderedDictWrapper   a  A wrapper around a C++ OrderedDict.

It dynamically evaluates the OrderedDict getter on a bound C++ module, such
that new changes on the C++ side are picked up. Otherwise accessing e.g.
``cpp_module._parameters`` just once would get a frozen copy of the parameters
at the time of access. ``torch.nn.Module`` accesses ``_parameters`` et al. via ``self.__dict__``
so using properties does not work.
returnNc                     Xl         X l        g N)
cpp_moduleattr)selfr
   r   s      N/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/torch/nn/cpp.py__init__OrderedDictWrapper.__init__   s    $	    c                 B    [        U R                  U R                  5      $ r	   )getattrr
   r   r   s    r   cpp_dictOrderedDictWrapper.cpp_dict   s    t		22r   c                 6    U R                   R                  5       $ r	   )r   itemsr   s    r   r   OrderedDictWrapper.items   s    }}""$$r   c                 6    U R                   R                  5       $ r	   )r   keysr   s    r   r   OrderedDictWrapper.keys   s    }}!!##r   c                 6    U R                   R                  5       $ r	   )r   valuesr   s    r   r   OrderedDictWrapper.values"   s    }}##%%r   c                 6    U R                   R                  5       $ r	   )r   __iter__r   s    r   r    OrderedDictWrapper.__iter__%   s    }}%%''r   c                 6    U R                   R                  5       $ r	   )r   __len__r   s    r   r#   OrderedDictWrapper.__len__(   s    }}$$&&r   c                 8    U R                   R                  U5      $ r	   )r   __contains__r   keys     r   r&   OrderedDictWrapper.__contains__+   s    }}))#..r   c                 8    U R                   R                  U5      $ r	   )r   __getitem__r'   s     r   r+   OrderedDictWrapper.__getitem__.   s    }}((--r   )r   r
   r   N)__name__
__module____qualname____firstlineno____doc__r   propertyr   r   r   r   r    intr#   boolr&   r+   __static_attributes__ r   r   r   r      sQ     3 3%$&(' '/4 /.r   r   c                      ^  \ rS rSrSrS
U 4S jjrSS jr\S 5       r\R                  S
S j5       rS\
4S jrS	rU =r$ )ModuleWrapper2   z\A subclass of ``torch.nn.Module`` that wraps a C++ frontend module and delegates all access.r   c           	      (  > Xl         [        TU ]	  5         [        US5      U l        [        US5      U l        [        US5      U l        [        U5       H;  nUR                  S5      (       a  M  [        X[        U R                   U5      5        M=     g )N_parameters_buffers_modules_)r
   superr   r   r<   r=   r>   dir
startswithsetattrr   )r   r
   r   	__class__s      r   r   ModuleWrapper.__init__5   sr     %-j-H,>z:,V,>z:,V
OD??3''GDOOT$BC $r   c                 2   U R                  5        HT  nU" UR                  5      Ul        UR                  c  M)  U" UR                  R                  5      UR                  l        MV     U R                  5        H  nU" UR                  5      Ul        M     U $ r	   )
parametersdata_gradbuffers)r   fnrecurseparambufs        r   _applyModuleWrapper._applyB   sq    __&E EJJEJ{{&#%ekk&6&6#7  ' <<>C#((|CH " r   c                 .    U R                   R                  $ r	   )r
   trainingr   s    r   rR   ModuleWrapper.trainingP   s     '''r   c                 :    U R                   R                  U5        g r	   )r
   train)r   modes     r   rR   rS   U   s    d#r   c                 6    U R                   R                  5       $ r	   )r
   __repr__r   s    r   rX   ModuleWrapper.__repr__Y   s    ''))r   )r=   r>   r<   r
   r-   )T)r.   r/   r0   r1   r2   r   rO   r3   rR   setterstrrX   r6   __classcell__)rD   s   @r   r9   r9   2   sN    fD ( ( __$ $*# * *r   r9   N)r2   torchr   r   Moduler9   r7   r   r   <module>r_      s&    9 (. (.V(*BII (*r   