
    #Ki                    l   % S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKrS SKJ	r	J
r
JrJr  S SKJr  S SKrS SKJrJr  S SKJrJrJr  \(       a  S SKJr  SS	/r S SKrS
r\R<                  " 5       r0 r S\!S'   \" SSS9r" " S S5      r#S r$ " S S	\RJ                  RL                  \#5      r'S r(\RR                  S 5       r*\RR                  S 5       r+\RR                  S 5       r,S r-S r.Sq/S r0S r1S'S jr2S r3S(S jr4 " S  S5      r5\Rl                  \5Rn                  l6        \#Rp                  Rl                  \5Rp                  l6        \#Rr                  Rl                  \5Rr                  l6        \Rl                  \5Rt                  l6         " S! S"\75      r; " S# S$\5\;S%9r<S)S& jr=g! \ a    SrSr GNRf = f)*    )annotationsN)AnycastTYPE_CHECKINGTypeVar)Self)_to_type)_bool_intStorage)DeviceLikeTypeTypedStorageUntypedStorageTFzdict[int, threading.RLock]_share_memory_mapT_StorageBase | TypedStorage)boundc                  z  ^  \ rS rSr% S\S'   SrS\S'   SrS\S'   S\S	'   S
rS\S'   S
rS\S'   S r	S_S jr
S rS rS`SaS jjrSbS jrS_S jrS_S jr Sc     SdS jjrScSbS jjrScSbS jjrS_S jrS_S jrS_S jrSeS jrS rS r\SfS  j5       r\SfS! j5       r\SgS" j5       r\S
S
S#. SgS$ jj5       r\S
S%.S& j5       r\SgS' j5       r \SgS( j5       r!SbS) jr"S* r#ShS+ jr$SbS, jr%S- r&S. r'S/ r(SeS0 jr)\SgS1 j5       r*S2 r+\S3 5       r,\-S4 5       r.\-S5 5       r/\SbS6 j5       r0\SbS7 j5       r1S8 r2SiS9 jr3S: r4S; r5S< r6S= r7S> r8U 4S? jr9S@ r:SA r;SB r<SC r=SD r>SSE.SjSF jjr?SG r@SH rASI rBSJ rCSK rDSL rESM rFSN rGSO rHSP rISQ rJSR rKSS rLST rMSU rNSV rOSkSlSW jjrPSkSlSX jjrQSY rR\SZS%.S[ j5       rSS\ rTS] rUS^rVU =rW$ )m_StorageBase)   r   _cdataFr   	is_sparseis_sparse_csrztorch.devicedeviceNtorch.device | None_fake_devicez
int | None_checkpoint_offsetc                    g N selfargskwargss      O/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/torch/storage.py__init___StorageBase.__init__5   s        c                    [         er    NotImplementedErrorr#   s    r&   __len___StorageBase.__len__8       !!r)   c                    [         er    r+   r#   idxs     r&   __getitem___StorageBase.__getitem__;   r0   r)   c                    [         er    r+   r"   s      r&   __setitem___StorageBase.__setitem__>   r0   r)   c                    [         er    r+   r#   sourcenon_blockings      r&   copy__StorageBase.copy_A   r0   r)   c                    [         er    r+   r-   s    r&   new_StorageBase.newD   r0   r)   c                    [         er    r+   r-   s    r&   nbytes_StorageBase.nbytesG   r0   r)   c                "    U R                  5       $ r    )rC   r-   s    r&   size_StorageBase.sizeJ   s    {{}r)   c                    [        XU5      $ r    )r
   )r#   dtyper<   s      r&   type_StorageBase.typeM   s     T,//r)   c                    U(       a  [         R                  " SU5      O[         R                  " S5      nU R                  X2S9$ )a  Returns a copy of this object in CUDA memory.

If this object is already in CUDA memory and on the correct device, then
no copy is performed and the original object is returned.

Args:
    device (int): The destination GPU id. Defaults to the current device.
    non_blocking (bool): If ``True`` and the source is in pinned memory,
        the copy will be asynchronous with respect to the host. Otherwise,
        the argument has no effect.
cudar   r<   torchr   tor#   r   r<   device2s       r&   rM   _StorageBase.cudaR   s2     39%,,vv.ell6>RwwgwAAr)   c                    U(       a  [         R                  " SU5      O[         R                  " S5      nU R                  X2S9$ )a  Returns a copy of this object in HPU memory.

If this object is already in HPU memory and on the correct device, then
no copy is performed and the original object is returned.

Args:
    device (int): The destination HPU id. Defaults to the current device.
    non_blocking (bool): If ``True`` and the source is in pinned memory,
        the copy will be asynchronous with respect to the host. Otherwise,
        the argument has no effect.
hpurN   rO   rR   s       r&   rV   _StorageBase.hpua   s2     28%,,uf-U\\%=PwwgwAAr)   c                    [         er    r+   r-   s    r&   element_size_StorageBase.element_sizep   r0   r)   c                .    U R                   R                  $ r    )r   indexr-   s    r&   
get_device_StorageBase.get_devices   s    {{   r)   c                    [         er    r+   r-   s    r&   data_ptr_StorageBase.data_ptrv   r0   r)   c                    [         er    r+   r-   s    r&   	resizable_StorageBase.resizabley   r0   r)   c                    [         er    r+   r"   s      r&   _share_filename_cpu_!_StorageBase._share_filename_cpu_}   r0   r)   c                    [         er    r+   r"   s      r&   _share_fd_cpu__StorageBase._share_fd_cpu_   r0   r)   c                    [         er    r+   clsrF   s     r&   _new_using_filename_cpu$_StorageBase._new_using_filename_cpu       !!r)   c                    [         er    r+   rl   s     r&   _new_using_fd_cpu_StorageBase._new_using_fd_cpu   rp   r)   c                    [         er    r+   rm   r$   r%   s      r&   from_buffer_StorageBase.from_buffer   rp   r)   )r   rI   c                   [         er    r+   )rm   managerobjrF   r   rI   s         r&   _new_shared_filename_cpu%_StorageBase._new_shared_filename_cpu   s
     "!r)   r   c               &    U R                   " U0 UD6$ r    )_release_ipc_counter_cudarm   r   r$   r%   s       r&   _release_ipc_counter!_StorageBase._release_ipc_counter   s    ,,d=f==r)   c                    [         er    r+   ru   s      r&   r   &_StorageBase._release_ipc_counter_cuda   rp   r)   c                    [         er    r+   ru   s      r&   _new_with_weak_ptr_StorageBase._new_with_weak_ptr   rp   r)   c                    [         er    r+   r-   s    r&   _shared_decref_StorageBase._shared_decref   r0   r)   c                    [         er    r+   r"   s      r&   _write_file_StorageBase._write_file   r0   r)   c                    [         er    r+   r#   rF   s     r&   resize__StorageBase.resize_   r0   r)   c                    [         er    r+   r"   s      r&   	_weak_ref_StorageBase._weak_ref   r0   r)   c                    [         er    r+   r"   s      r&   _set_from_file_StorageBase._set_from_file   r0   r)   c                    [         er    r+   r"   s      r&   
_set_cdata_StorageBase._set_cdata   r0   r)   c                    [         er    r+   r"   s      r&   _share_cuda__StorageBase._share_cuda_   r0   r)   c                    [         er    r+   r-   s    r&   	is_shared_StorageBase.is_shared   r0   r)   c                    [         er    r+   ru   s      r&   _new_shared_cuda_StorageBase._new_shared_cuda   rp   r)   c                    [         er    r+   r"   s      r&   _shared_incref_StorageBase._shared_incref   r0   r)   c                    [         er    r+   ru   s      r&   _free_weak_ref_StorageBase._free_weak_ref   rp   r)   c                    [         er    r+   r-   s    r&   is_cuda_StorageBase.is_cuda   rp   r)   c                    [         er    r+   r-   s    r&   is_hpu_StorageBase.is_hpu   rp   r)   c                    [         er    r+   )rm   filenamesharedrC   s       r&   	from_file_StorageBase.from_file   rp   r)   c                    [         er    r+   ru   s      r&   _expired_StorageBase._expired   rp   r)   c                    [         er    r+   r"   s      r&   	_byteswap_StorageBase._byteswap   r0   r)   c                    [         er    r+   r"   s      r&   _get_filename_StorageBase._get_filename   r0   r)   c                "  ^  S[         R                  " T 5       ST R                   S[        T 5       S3nT R                  R                  S:X  a  SU-   $ SSR                  U 4S	 j[        T R                  5       5       5       5      -   nUS
-   U-   $ )N[z(device=
) of size ]meta...
 
 c              3  @   >#    U  H  n[        TU   5      v   M     g 7fr    str.0ir#   s     r&   	<genexpr>(_StorageBase.__repr__.<locals>.<genexpr>   s     #M:LQCQLL:L   
)rP   typenamer   lenrJ   joinrangerF   r#   info_strdata_strs   `  r&   __repr___StorageBase.__repr__   s    u~~d+,HT[[MCPTI;VWX;;v%X%%#M%		:L#MMM$))r)   c                \   ^  [        U 4S j[        T R                  5       5       5       5      $ )Nc              3  .   >#    U  H
  nTU   v   M     g 7fr    r!   r   s     r&   r   (_StorageBase.__iter__.<locals>.<genexpr>        8%7DG%7   )iterr   rF   r-   s   `r&   __iter___StorageBase.__iter__   s    8U499;%7888r)   c                "    U R                  5       $ r    )cloner-   s    r&   __copy___StorageBase.__copy__   s    zz|r)   c                    UR                  S0 5      nU R                  U;   a  XR                     $ U R                  5       nX!U R                  '   U$ )NrP   )
setdefaultr   r   )r#   memonew_storages      r&   __deepcopy___StorageBase.__deepcopy__   sH    w+;;$$$jjl'T[[r)   c                    [         R                  " 5       n[        R                  " XSS9  [        UR                  5       44$ NF)_use_new_zipfile_serializationioBytesIOrP   save_load_from_bytesgetvaluer#   bs     r&   
__reduce___StorageBase.__reduce__   .    JJL

45A 1::</22r)   c                B   > [         TU ]  5       U R                  5       -   $ r    )super
__sizeof__rF   r#   	__class__s    r&   r   _StorageBase.__sizeof__   s    w!#diik11r)   c                p    [        U 5      " U R                  5       U R                  S9R                  U 5      $ )Return a copy of this storage.r}   )rJ   rC   r   r=   r-   s    r&   r   _StorageBase.clone   s(    Dz$++-<BB4HHr)   c                    [        U 5      $ z6Return a list containing the elements of this storage.)listr-   s    r&   tolist_StorageBase.tolist  s    Dzr)   c                    U R                   R                  S:w  a4  [        R                  " U R	                  5       5      R                  U S5      $ U $ )AReturn a CPU copy of this storage if it's not already on the CPU.cpuFr   rJ   rP   r   rF   r=   r-   s    r&   r	  _StorageBase.cpu  s=    ;;u$''		4::4GGr)   c                    U R                   R                  S:w  a3  [        R                  " U R	                  5       SS9R                  U S5      $ U $ )zAReturn a MPS copy of this storage if it's not already on the MPS.mpsr}   Fr
  r-   s    r&   r  _StorageBase.mps  s?    ;;u$''		EBHHuUUr)   c                   [        U[        R                  5      (       d  [        S[	        U5       35      e[        R
                  " / [        R                  U R                  S9R                  [        [        U 5      5      R                  U5      R                  5       nUR                  5       U R                  5       :X  a  UR                  5       nU$ Nz*Argument 'dtype' must be torch.dtype, not rI   r   )
isinstancerP   rI   	TypeErrorrJ   tensoruint8r   set_r   r   rQ   _typed_storager`   r   r#   rI   storages      r&   r	   _StorageBase._to  s    %--HeVWWLL5;;t{{CT$w%&RY^	 	 0mmoGr)   r<   c                   [        U[        R                  5      (       d  [        R                  " U5      n[        XU5      $ r    )r  rP   r   r	   )r#   r   r<   s      r&   rQ   _StorageBase.to  s.    &%,,//\\&)F4..r)   c                @    U R                  [        R                  5      $ z"Casts this storage to double type.)r	   rP   doubler-   s    r&   r   _StorageBase.double#      xx%%r)   c                @    U R                  [        R                  5      $ z!Casts this storage to float type.)r	   rP   floatr-   s    r&   r%  _StorageBase.float'      xx$$r)   c                @    U R                  [        R                  5      $ z Casts this storage to half type.)r	   rP   halfr-   s    r&   r*  _StorageBase.half+      xx

##r)   c                @    U R                  [        R                  5      $ z Casts this storage to long type.)r	   rP   longr-   s    r&   r/  _StorageBase.long/  r,  r)   c                @    U R                  [        R                  5      $ zCasts this storage to int type.)r	   rP   intr-   s    r&   r3  _StorageBase.int3  s    xx		""r)   c                @    U R                  [        R                  5      $ z!Casts this storage to short type.)r	   rP   shortr-   s    r&   r7  _StorageBase.short7  r'  r)   c                @    U R                  [        R                  5      $ z Casts this storage to char type.)r	   rP   int8r-   s    r&   char_StorageBase.char;  r,  r)   c                @    U R                  [        R                  5      $ z Casts this storage to byte type.)r	   rP   r  r-   s    r&   byte_StorageBase.byte?  r'  r)   c                @    U R                  [        R                  5      $ z Casts this storage to bool type.)r	   rP   boolr-   s    r&   rD  _StorageBase.boolC  r,  r)   c                @    U R                  [        R                  5      $ z$Casts this storage to bfloat16 type.)r	   rP   bfloat16r-   s    r&   rH  _StorageBase.bfloat16G  s    xx''r)   c                @    U R                  [        R                  5      $ z*Casts this storage to complex double type.)r	   rP   cdoubler-   s    r&   complex_double_StorageBase.complex_doubleK  s    xx&&r)   c                @    U R                  [        R                  5      $ z)Casts this storage to complex float type.)r	   rP   cfloatr-   s    r&   complex_float_StorageBase.complex_floatO  r"  r)   c                @    U R                  [        R                  5      $ z&Casts this storage to float8_e5m2 type)r	   rP   float8_e5m2r-   s    r&   rV  _StorageBase.float8_e5m2S  s    xx))**r)   c                @    U R                  [        R                  5      $ z(Casts this storage to float8_e4m3fn type)r	   rP   float8_e4m3fnr-   s    r&   rZ  _StorageBase.float8_e4m3fnW  s    xx++,,r)   c                @    U R                  [        R                  5      $ z*Casts this storage to float8_e5m2fnuz type)r	   rP   float8_e5m2fnuzr-   s    r&   r^  _StorageBase.float8_e5m2fnuz[      xx--..r)   c                @    U R                  [        R                  5      $ z*Casts this storage to float8_e4m3fnuz type)r	   rP   float8_e4m3fnuzr-   s    r&   rc  _StorageBase.float8_e4m3fnuz_  r`  r)   c                    [         R                  " / [         R                  U R                  S9R	                  [        [        U 5      5      R                  U5      $ )zDetermine whether the CPU storage is already pinned on device.

Args:
    device (str or torch.device): The device to pin memory on (default: ``'cuda'``).
        This argument is discouraged and subject to deprecated.

Returns:
    A boolean variable.
r  )rP   r  r  r   r  r   r   	is_pinnedr#   r   s     r&   rf  _StorageBase.is_pinnedc  s<     LL5;;t{{CT$w%&Yv	
r)   c                D   U R                   R                  S:w  a  [        SU R                  5        S35      e[        R                  " / [        R
                  U R                   S9R                  [        [        U 5      5      R                  U5      nUR                  5       $ )a  Copy the CPU storage to pinned memory, if it's not already pinned.

Args:
    device (str or torch.device): The device to pin memory on (default: ``'cuda'``).
        This argument is discouraged and subject to deprecated.

Returns:
    A pinned CPU storage.
r	  zcannot pin 'z' only CPU memory can be pinnedr  )r   rJ   r  rP   r  r  r  r   r   
pin_memoryuntyped_storage)r#   r   pinned_tensors      r&   rj  _StorageBase.pin_memorys  s|     ;;u$l499;-7VWXX LL5;;t{{CT$w%&Z 	
 ,,..r)   c                    SSK Jn  U R                  R                  S[        R
                  R                  5       4;   a   U $ U" 5       S:X  a  U R                  5         U $ U R                  5         U $ ).See :meth:`torch.UntypedStorage.share_memory_`r   get_sharing_strategyrM   file_system)	torch.multiprocessingrq  r   rJ   rP   _C_get_privateuse1_backend_namerf   ri   )r#   rq  s     r&   share_memory__StorageBase.share_memory_  sf    >;;(N(N(PQQ
 	 "#}4%%'  !r)   r	  c                   SSK Jn  [        R                  " U5      nUR                  S[        R
                  R                  5       S4;   a  U " XS9$ U" 5       S:X  a  U R                  U5      $ U R                  U5      $ )>Create a new storage in shared memory with the same data type.r   rp  rM   rV   r}   rr  )	rs  rq  rP   r   rJ   rt  ru  rn   rr   )rm   rF   r   rq  s       r&   _new_shared_StorageBase._new_shared  sm     	?f%;;6588#I#I#KUSSt++!#}4..t44((..r)   c                    U $ r    r!   r-   s    r&   untyped_StorageBase.untyped  s    r)   c                    [         R                  R                  U5      nUR                  (       a  [	        [        US-  5      S5      nU R                  U5        g)zSwap bytes in underlying data.      N)rP   _utils_element_size
is_complexmaxr3  r   )r#   rI   	elem_sizes      r&   byteswap_StorageBase.byteswap  s@    LL..u5	C	A.2Iy!r)   r!   returnr   r    )r;   r   r<   z_bool | Noner  r   )r  r   NF)rI   
str | Noner<   r   r  r   )r  r   )rF   r   r  r   r  r   )rF   r   r  r  )r   r   r<   r   rM   r   zstr | torch.device)X__name__
__module____qualname____firstlineno____annotations__r   r   r   r   r'   r.   r4   r7   r=   r@   rC   rF   rJ   rM   rV   rY   r]   r`   rc   rf   ri   classmethodrn   rr   rv   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   propertyr   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r  r	   rQ   r   r%  r*  r/  r3  r7  r<  r@  rD  rH  rM  rR  rV  rZ  r^  rc  rf  rj  rv  rz  r}  r  __static_attributes____classcell__r   s   @r&   r   r   )   s   KIu M5  )-L%,%)
)"""""" ?D006;0	$0
BB"!"""" " " " " " "  	" 
	" 	" 04 > > " " " """"""""" " "" " " " " " " " " " """*93
2I CH /
&%$$#%$%$('&+-//
 /(
 ). 
/ 
/" "r)   r   c                F   ^  [         R                  " T 5      U 4S j5       nU$ )Nc                  > S nS n[            U R                  nU[        ;   a
  [        U   nO5[        R                  " 5       [        U'   [        U   R                  5         UnS S S 5        Ub  U    S S S 5         T" U /UQ70 UD6Ub@  U R                  U:X  d   e[            [        U   R                  5         [        U	 S S S 5        $ $ ! , (       d  f       Nm= f! , (       d  f       No= f! , (       d  f       $ = f! UbQ  U R                  U:X  d   e[            [        U   R                  5         [        U	 S S S 5        f ! , (       d  f       f = ff = fr    )_share_memory_lockr   r   	threadingRLockacquirerelease)r#   r$   r%   to_freeto_waitkeyfns         r&   wrapper-_share_memory_lock_protected.<locals>.wrapper  s,   ++C''+C0)2):!#&!#&..0    	3d,T,V, " {{g---'%g.668)'2 ('	 #)    ('	 " {{g---'%g.668)'2 (''	 #sH   AC	/C:C<  C+	
C
C(+
C9	<EE 7	E 
E
E)	functoolswraps)r  r  s   ` r&   _share_memory_lock_protectedr    s%    __R3 3> Nr)   c                     ^  \ rS rSrU 4S jr\S 5       r\S 5       r\S
S j5       r\	U 4S j5       r
\	U 4S j5       r\	U 4S j5       rS	rU =r$ )r   i  c                n   > U R                   R                  S:X  a  [        S5      e[        TU ]  " U0 UD6$ )Nr   $Not available for 'meta' device type)r   rJ   r,   r   r4   r#   r$   r%   r   s      r&   r4   UntypedStorage.__getitem__  s6    ;;v%%&LMMw"D3F33r)   c                4    U R                   R                  S:H  $ NrM   r   rJ   r-   s    r&   r   UntypedStorage.is_cuda  s    {{6))r)   c                4    U R                   R                  S:H  $ NrV   r  r-   s    r&   r   UntypedStorage.is_hpu  s    {{5((r)   c                "    U R                  5       $ )zReturns the file name associated with this storage.

The file name will be a string if the storage is on CPU and was created via
:meth:`~torch.from_file()` with ``shared`` as ``True``. This attribute is ``None`` otherwise.
)r   r-   s    r&   r   UntypedStorage.filename  s     !!##r)   c                $   > [         TU ]  " U0 UD6$ )a  
Moves the storage to shared memory.

This is a no-op for storages already in shared memory and for CUDA
storages, which do not need to be moved for sharing across processes.
Storages in shared memory cannot be resized.

Note that to mitigate issues like `this <https://github.com/pytorch/pytorch/issues/95606>`_
it is thread safe to call this function from multiple threads on the same object.
It is NOT thread safe though to call any other function on self without proper
synchronization. Please see :doc:`/notes/multiprocessing` for more details.

.. note::
    When all references to a storage in shared memory are deleted, the associated shared memory
    object will also be deleted. PyTorch has a special cleanup process to ensure that this happens
    even if the current process exits unexpectedly.

    It is worth noting the difference between :meth:`share_memory_` and :meth:`from_file` with ``shared = True``

    #. ``share_memory_`` uses `shm_open(3) <https://man7.org/linux/man-pages/man3/shm_open.3.html>`_ to create a
       POSIX shared memory object while :meth:`from_file` uses
       `open(2) <https://man7.org/linux/man-pages/man2/open.2.html>`_ to open the filename passed by the user.
    #. Both use an `mmap(2) call <https://man7.org/linux/man-pages/man2/mmap.2.html>`_ with ``MAP_SHARED``
       to map the file/object into the current virtual address space
    #. ``share_memory_`` will call ``shm_unlink(3)`` on the object after mapping it to make sure the shared memory
       object is freed when no process has the object open. ``torch.from_file(shared=True)`` does not unlink the
       file. This file is persistent and will remain until it is deleted by the user.

Returns:
    ``self``
)r   rv  r  s      r&   rv  UntypedStorage.share_memory_  s    B w$d5f55r)   c                $   > [         TU ]  " U0 UD6$ r    )r   ri   r  s      r&   ri   UntypedStorage._share_fd_cpu_
  s    w%t6v66r)   c                $   > [         TU ]  " U0 UD6$ r    )r   rf   r  s      r&   rf   #UntypedStorage._share_filename_cpu_  s    w+T<V<<r)   r!   r  )r  r  r  r  r4   r  r   r   r   r  rv  ri   rf   r  r  r  s   @r&   r   r     s    4
 * * ) ) $ $ " 6 " 6D "7 "7 "= "=r)   c                T    [         R                  " [        R                  " U 5      SS9$ )NF)weights_only)rP   loadr   r   )r   s    r&   r   r     s    ::bjjm%88r)   c                    [         R                  [         R                  [         R                  [         R                  [         R
                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  1$ r    )rP   rV  rZ  r^  rc  float8_e8m0fnufloat4_e2m1fn_x2bits8bits16bits1x8bits2x4bits4x2	complex32uint16uint32uint64r!   r)   r&   _new_dtypesr    s    
 	 r)   c                 H   0 [         R                  S_[         R                  S_[         R                  S_[         R                  S_[         R
                  S_[         R                  S_[         R                  S_[         R                  S_[         R                  S	_[         R                  S
_[         R                  S_[         R                  S_[         R                  S_[         R                  S_[         R                  S_[         R                   S_[         R"                  S_$ )NDoubleStorageFloatStorageHalfStorageLongStorage
IntStorageShortStorageCharStorageByteStorageBoolStorageBFloat16StorageComplexDoubleStorageComplexFloatStorageQInt8StorageQInt32StorageQUInt8StorageQUInt4x2StorageQUInt2x4Storage)rP   r   r%  r*  r/  r3  int16r;  r  rD  rH  rL  rQ  qint8qint32quint8quint4x2quint2x4r!   r)   r&   _dtype_to_storage_type_mapr  .  s   o^ 	

M 	

M	
 			< 	^ 	

M 	] 	

M 	) 	- 	+ 	^ 	o 	o  	)!" 	)# r)   c                 j    [        5       R                  5        V Vs0 s H  u  pX_M	     nn nU$ s  snn f r    )r  items)r  val	dtype_maps      r&   _storage_type_to_dtype_mapr  J  s4    *D*F*L*L*NO*Nhc*NIO Ps   /c           
     d   U[         R                  [         R                  [         R                  [         R                  [         R
                  4;   a  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R
                  [         R                  0n[         R                  " XU   US9nO[         R                  " XUS9nUR                  5       R                  $ )Nr  )rP   r  r  r  r  r  r  int32r;  r  r  _untyped_storage)sequencerI   r   interpret_dtypes
tmp_tensors        r&   _get_storage_from_sequencer  P  s      LL%++NNEKKNNEKKLL%++KK
 \\U3F


 \\(G
$$&777r)   c                x    [         (       a   [        U [        [        R                  45      $ [        U [        5      $ r    )	HAS_NUMPYr  r3  npinteger)xs    r&   _isintr  i  s*    y!c2::.//!S!!r)   c                     [         $ r    )"_always_warn_typed_storage_removalr!   r)   r&   &_get_always_warn_typed_storage_removalr  s  s    --r)   c                6    [        U [        5      (       d   eU qg r    )r  rD  r  )always_warns    r&   &_set_always_warn_typed_storage_removalr  w  s    k4(((()4&r)   c                    S n[        5       (       d  U" 5       (       a3  Sn[        R                  " U[        U S-   S9  S[        R
                  S'   g g )Nc                 ^    [        [        S5      (       d  g[        R                  S   (       + $ )N
has_warnedT)hasattr_warn_typed_storage_removal__dict__r!   r)   r&   is_first_time2_warn_typed_storage_removal.<locals>.is_first_time  s'    2LAA2;;LIIIr)   a  TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly.  To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage()r  )
stacklevelTr  )r  warningswarnUserWarningr  r  )r  r  messages      r&   r  r  }  sQ    J .//=??Q 	 	g{zA~F=A#,,\: 4Cr)   c                 *    S[         R                  S'   g )NFr  )r  r  r!   r)   r&   !_reset_warn_typed_storage_removalr    s    9>((6r)   c                |    U R                  SS5      S   nUS[        R                  R                  5       S4;   a  U$ g)N.r  rM   rV   r	  )rsplitrP   rt  ru  )module	last_parts     r&   _get_device_from_moduler    s<    c1%b)IVUXXCCEuMMr)   c                  r  ^  \ rS rSr% SrS\S'   SrS\S'   S\S	'   \S
 5       r\ShS j5       r	S r
SSSSS.U 4S jjrSSSSS.S jr\S 5       r\S 5       rS rSiS jrS rSjS jrS rS rS rS rSkSlS jjrS rS r  Sm     SnS jjrSmSiS jjrSmSiS  jjrSS!.SoS" jjrS# rS$ rSpS% jr S& r!S' r"S( r#S) r$S* r%S+ r&U 4S, jr'S- r(S. r)S/ r*SqSrS0 jjr+SqSrS1 jjr,S2 r-S3 r.SS4.S5 jr/\S6 5       r0\S7 5       r1S8 r2S9 r3S: r4S; r5S< r6S= r7S> r8S? r9S@ r:SA r;\<SB 5       r=SC r>\<SD 5       r?\<SSSE.SF j5       r@SG rASH rBSI rCSJ rDSK rESL rFSM rGSN rHSO rISP rJSQ rKSR rLSS rMST rNSU rOSV rPSW rQ\<SX 5       rR\<SY 5       rSSZ rTS[ rUS\ rVS] rWS^ rXS_ rY\<S` 5       rZSa r[Sb r\\<SS4.Sc j5       r]Sd r^Se r_Sf r`SgraU =rb$ )sr   i  Fr   r   Nr   r   torch.dtyperI   c                    U R                   $ r    )rI   r-   s    r&   _dtypeTypedStorage._dtype  s    zzr)   c                .    U R                   R                  $ )zReturns the file name associated with this storage if the storage was memory mapped from a file.
or ``None`` if the storage was not created by memory mapping a file.)r  r   r-   s    r&   r   TypedStorage.filename  s     $$---r)   c                n    [        5         U R                  [        SU R                  5       5      U5        U $ )Nr   )r  _setitemslice_size)r#   values     r&   fill_TypedStorage.fill_  s(    #%eAtzz|,e4r)   )wrap_storagerI   r   	_internalc                 > U(       d
  [        5         U [        R                  R                  :X  a  [	        S5      eU [
        :X  a  [        TU ]  U 5      $ U  S3nUb  [	        US-   5      eUb  [	        US-   5      eUc  [        U5      S:  a  [	        US-   5      e[        U5      S:X  a\  [        US   5      (       dI  [        US   [        R                  R                  5      (       d  [        US[        US   5       3-   5      e[        UU R                   [#        U R$                  5      S	S
.6$ [        U5      S:w  a  [	        US-   5      e[        U[        R&                  5      (       d  [        US[        U5       3-   5      e[#        U R$                  5      nUR(                  R                  U:w  a(  [	        USU SUR(                  R                   3-   5      e[        UUU R*                  S	S.6$ )Nz8Only child classes of _LegacyStorage can be instantiatedz.__new__ received an invalid combination of arguments. Expected one of:
 * no arguments
 * (int size)
 * (Sequence data)
 * (*, UntypedStorage wrap_storage)z.
Keyword argument 'device' cannot be specifiedz-
Keyword argument 'dtype' cannot be specifiedr  
Too many positional argumentsr   
Argument type not recognized: T)rI   r   r%  B
No positional arguments should be given when using 'wrap_storage'9
Argument 'wrap_storage' must be UntypedStorage, but got z"
Device of 'wrap_storage' must be z
, but got r$  rI   r%  )r  rP   r  _LegacyStorageRuntimeErrorr   r   __new__r   r  r  collectionsabcSequencer  rJ   r  r  r  r   r   rI   )	rm   r$  rI   r   r%  r$   arg_error_msg
cls_devicer   s	           r&   r.  TypedStorage.__new__  s'    ')%--...J  ,7?3'' % 6 6  !"!$UU   "!$TT  #t9q=&%(II 
 IN"47OO&tAw0H0HII#%<T$q']OLM 
 $**23>>B"	  t9>&%))  ",0D0DEE#%VW[\hWiVjkl 
 5S^^D
&&++z9&%?
|$\%8%8%=%=$>@@  $!-))"	 r)   )r   rI   r$  r%  c                  U(       d
  [        5         SnUb  [        U5      S:w  a  [        US-   5      eUc  [        US-   5      e[        U[        R
                  5      (       d  [        US[        U5       3-   5      eUb  [        US-   5      eX l        [        U[        R                  5      (       d  [        US[        U5       3-   5      eX0l	        g Uc  [        R                  " 5       OUU l        [        R                  " Uc  SOU5      nU R
                  [        R                  [        R                  [        R                  [        R                  [        R                   4;   a  UR                  S	:X  a  [        S
5      e[        U5      S:X  a  [        R                  " US9U l	        g [        U5      S:X  a  [#        US   5      (       a8  [        R                  " [%        US   5      U R'                  5       -  US9U l	        g [        US   [(        R*                  R,                  5      (       a   [/        US   U R
                  U5      U l	        g [        US[        US   5       3-   5      e[        US-   5      e)Na1  TypedStorage.__init__ received an invalid combination of arguments. Expected one of:
 * (*, torch.device device, torch.dtype dtype)
 * (int size, *, torch.device device, torch.dtype dtype)
 * (Sequence data, *, torch.device device, torch.dtype dtype)
 * (*, UntypedStorage wrap_storage, torch.dtype dtype)r   r)  z#
Argument 'dtype' must be specifiedz+
Argument 'dtype' must be torch.dtype, not zG
Argument 'device' should not be specified when 'wrap_storage' is givenr*  r	  rM   /Cannot create CUDA storage with quantized dtyper}   r  r(  r'  )r  r   r-  r  rP   rI   r  rJ   r   r  get_default_dtyper   r  r  r  r  r  r  r3  r  r/  r0  r1  r  )r#   r   rI   r$  r%  r$   r2  s          r&   r'   TypedStorage.__init__  s^    ')E 	 #4yA~"!%%  }"!$JJ  eU[[11!DT%[MRS 
 !"!`a 
 JlE,@,@AA!RSWXdSeRfgh 
 %1! 7<m002DJ\\6>%vFFzz  ;;&(&I  4yA~(-(<(<F(K%Ta$q'??,1,@,@DGt'9'9';;F-D)  Q)A)ABB,FQV-D) $%<T$q']OLM  #=3T#TUUr)   c                \    [        5         U R                  R                  R                  S:H  $ r  r  r  r   rJ   r-   s    r&   r   TypedStorage.is_cudaj  s%    #%$$++00F::r)   c                \    [        5         U R                  R                  R                  S:H  $ r  r:  r-   s    r&   r   TypedStorage.is_hpuo  s%    #%$$++00E99r)   c                .    [        5         U R                  $ )z2Return the internal :class:`torch.UntypedStorage`.)r  r  r-   s    r&   r}  TypedStorage.untypedt  s    #%$$$r)   c           	         [        U5      [        R                  L d   e[        U 5      [        L a"  [	        [
        [        XR                  SS95      $ [        U 5      " US9$ )NTr+  r$  )rJ   rP   r   r   r   r   rI   )r#   rk  s     r&   _new_wrapped_storage!TypedStorage._new_wrapped_storagey  sY    O$(<(<<<<:%!0

d  :?;;r)   c                6    [        5         U R                  5       $ r    r  r   r-   s    r&   r.   TypedStorage.__len__      #%zz|r)   c                    Uc  U(       a  U R                  5       $ g[        U5      [        La#  [        S[        U 5       S[        U5       35      eU(       a`  XR                  5       :  d  XR                  5       * :  a  [	        SU SU R                  5        35      eUS:  a  U$ XR                  5       -  $ XR                  5       :  d  XR                  5       * :  a  [	        SU SU R                  5        35      eXR                  5       -  $ )Nr   can't index a  with zindex z" out of range for storage of size )r   rJ   r3  r  
IndexErrorrF   )r#   r3   is_stops      r&   _maybe_wrap_indexTypedStorage._maybe_wrap_index  s    ;zz|# Cy#.dF49+ NOO**,&C::<-,?$ %G		}U  7J--::<'SJJL=-@$ %G		}U  ZZ\))r)   c                8    [        5         U R                  X5      $ r    )r  r  )r#   r3   r!  s      r&   r7   TypedStorage.__setitem__  s    #%}}S((r)   c           
        [        U[        [        45      (       d#  [        S[	        U 5       S[	        U5       35      e[
        R                  " U5      (       a  [        S[	        U5       35      eU R                  [
        R                  [
        R                  [
        R                  [
        R                  [
        R                  4;   a  [
        R                  [
        R                  [
        R                  [
        R                  [
        R                  [
        R                  [
        R                  [
        R                  [
        R                  [
        R                  0nX0R                     n[
        R                   " / X@R"                  R$                  S9nUR'                  [)        U R"                  USS95        OC[
        R                   " / U R                  U R"                  R$                  S9R'                  U 5      nX%U'   g )NrI  rJ  z cannot set item with value type r  Tr+  )r  r3  r  r-  rJ   rP   
is_storagerI   r  r  r  r  r  r  r  r;  r  r  r   r  r   )r#   r3   r!  r  	tmp_dtyper  s         r&   r  TypedStorage._setitem  sg   #U|,,T
|6$s)MNNE""!A$u+OPP::LLNNNNLLKK
 
 ekkekkUZZ  )4I),A,A,H,HJ OO!%!6!6iSW $**T-B-B-I-Id4j   3r)   c                8    [        5         U R                  U5      $ r    )r  _getitemr2   s     r&   r4   TypedStorage.__getitem__  s    #%}}S!!r)   c           
     r   U R                   R                  R                  S:X  a  [        S5      e[	        U[
        5      (       a  [        S5      e[	        U[        5      (       d#  [        S[        U 5       S[        U5       35      eU R                  [        R                  [        R                  [        R                  [        R                  [        R                  4;   a  [        R                  [        R                  [        R                  [        R                  [        R                  [        R                  [        R                  [        R                   [        R                  [        R"                  0n[%        U R                   X R                     SS9R'                  U5      $ U R)                  U5      nSS	KJn  U" 5          [        R.                  " / U R                  U R                   R                  S
9R1                  U 5      nXS   R3                  5       sS S S 5        $ ! , (       d  f       g = f)Nr   r  z7slices are only supported in UntypedStorage.__getitem__rI  rJ  Tr+  r   )unset_fake_temporarilyr  )r  r   rJ   r,   r  r  r-  r3  rI   rP   r  r  r  r  r  r  r  r;  r   rV  rM  torch._subclasses.fake_tensorrY  r  r  item)r#   r3   r  idx_wrappedrY  r  s         r&   rV  TypedStorage._getitem  s     '',,6%&LMM c5!!I  C%%T
|6$s)MNN::LLNNNNLLKK
 
 ekkekkUZZ   !22&zz2 hsm	 ,,S1H#%$**T-B-B-I-Id4j  *//1	 &%%s   	AH((
H6c                    [        5         [        U[        5      (       a(  U R                  R	                  UR                  U5        U $ U R                  R	                  X5        U $ r    )r  r  r   r  r=   r:   s      r&   r=   TypedStorage.copy_  sS    #%fl++!!''(?(?N  !!''=r)   c                6    [        5         U R                  5       $ r    )r  _nbytesr-   s    r&   rC   TypedStorage.nbytes  s    #%||~r)   c                6    U R                   R                  5       $ r    )r  rC   r-   s    r&   ra  TypedStorage._nbytes  s    $$++--r)   c                   [        5         Uc_  U R                  5       nUb  UR                  S-   UR                  -   $ SR	                  U R                  [        U 5      R                  /5      $ U R                  R                  X5      $ )Nr  )r  _get_legacy_storage_classr  r  r   rJ   r  )r#   rI   r<   legacy_classs       r&   rJ   TypedStorage.type  sz    
 	$%=99;L'#..4|7L7LLL88T__d4j.A.ABCC ((--eBBr)   c                :   [        5         U R                  [        R                  [        R                  [        R
                  [        R                  [        R                  4;   a  [        S5      eU R                  R                  X5      nU R                  U5      $ )Nr6  )r  rI   rP   r  r  r  r  r  r-  r  rM   rB  )r#   r   r<   cuda_storages       r&   rM   TypedStorage.cuda  sq    #%::LLNNNNLLKK
 
 PQQ,,11&G((66r)   c                :   [        5         U R                  [        R                  [        R                  [        R
                  [        R                  [        R                  4;   a  [        S5      eU R                  R                  X5      nU R                  U5      $ )Nz.Cannot create HPU storage with quantized dtype)r  rI   rP   r  r  r  r  r  r-  r  rV   rB  )r#   r   r<   hpu_storages       r&   rV   TypedStorage.hpu)  sq    #%::LLNNNNLLKK
 
 OPP++//E((55r)   r  c                  [        5         [        U[        R                  5      (       d  [        R                  " U5      nU R                  [        R
                  [        R                  [        R                  [        R                  [        R                  4;   a'  [        SUR                  R                  5        S35      eU R                  R                  XS9nU R                  U5      $ )NzCannot create z storage with quantized dtyperN   )r  r  rP   r   rI   r  r  r  r  r  r-  rJ   upperr  rQ   rB  )r#   r   r<   
to_storages       r&   rQ   TypedStorage.to6  s    #%&%,,//\\&)F::LLNNNNLLKK
 
  !2!2!4 55RS  **--V-W
((44r)   c                6    [        5         U R                  5       $ r    )r  r  r-   s    r&   rY   TypedStorage.element_sizeG  s    #%!!##r)   c                T    [         R                  R                  U R                  5      $ r    )rP   r  r  rI   r-   s    r&   r  TypedStorage._element_sizeL  s    ||))$**55r)   c                J    [        5         U R                  R                  5       $ r    )r  r  r]   r-   s    r&   r]   TypedStorage.get_deviceO  s    #%$$//11r)   c           
     P  ^  [        5         S[        R                  " T 5       ST R                   ST R                   S[        T 5       S3	nT R                  R                  S:X  a  SU-   $ SS	R                  U 4S
 j[        T R                  5       5       5       5      -   nUS-   U-   $ )Nr   z(dtype=z	, device=r   r   r   r   r   r   c              3  @   >#    U  H  n[        TU   5      v   M     g 7fr    r   r   s     r&   r   'TypedStorage.__str__.<locals>.<genexpr>\  s     'Q>PDG>Pr   r   )
r  rP   r   rI   r   r   rJ   r   r   rF   r   s   `  r&   __str__TypedStorage.__str__S  s    #%t$%WTZZL 9kk]*SYKq: 	 ;;v%X%%UZZ'QeDIIK>P'QQQHd?X--r)   c                ,    [        5         [        U 5      $ r    )r  r   r-   s    r&   r   TypedStorage.__repr___  s    #%4yr)   c                p   ^  [        5         [        U 4S j[        T R                  5       5       5       5      $ )Nc              3  .   >#    U  H
  nTU   v   M     g 7fr    r!   r   s     r&   r   (TypedStorage.__iter__.<locals>.<genexpr>e  r   r   )r  r   r   rF   r-   s   `r&   r   TypedStorage.__iter__c  s%    #%8U499;%7888r)   c                t    [        5         U R                  [        R                  " U R                  5      5      $ r    )r  rB  copyr  r-   s    r&   r   TypedStorage.__copy__g  s(    #%((43H3H)IJJr)   c                8    [        5         U R                  U5      $ r    )r  	_deepcopyr#   r   s     r&   r   TypedStorage.__deepcopy__k  s    #%~~d##r)   c                b    U R                  [        R                  " U R                  U5      5      $ r    )rB  r  deepcopyr  r  s     r&   r  TypedStorage._deepcopyp  s$    ((t7L7Ld)STTr)   c                V   > [        5         [        TU ]	  5       U R                  5       -   $ r    )r  r   r   rC   r   s    r&   r   TypedStorage.__sizeof__s  s"    #%w!#dkkm33r)   c                h    [        5         U R                  U R                  R                  5       5      $ )r   )r  rB  r  r   r-   s    r&   r   TypedStorage.clonew  s(    #%(()>)>)D)D)FGGr)   c                ,    [        5         [        U 5      $ r  )r  r  r-   s    r&   r  TypedStorage.tolist|  s    #%Dzr)   c                h    [        5         U R                  U R                  R                  5       5      $ )r  )r  rB  r  r	  r-   s    r&   r	  TypedStorage.cpu  s(    #%(()>)>)B)B)DEEr)   c                L    [        5         U R                  R                  U5      $ )a  Determine whether the CPU TypedStorage is already pinned on device.

Args:
    device (str or torch.device): The device to pin memory on (default: ``'cuda'``).
        This argument is discouraged and subject to deprecated.

Returns:
    A boolean variable.
)r  r  rf  rg  s     r&   rf  TypedStorage.is_pinned  s!     	$%$$..v66r)   c                f    [        5         U R                  U R                  R                  US95      $ )a  Copy the CPU TypedStorage to pinned memory, if it's not already pinned.

Args:
    device (str or torch.device): The device to pin memory on (default: ``'cuda'``).
        This argument is discouraged and subject to deprecated.

Returns:
    A pinned CPU storage.
r}   )r  rB  r  rj  rg  s     r&   rj  TypedStorage.pin_memory  s4     	$%((!!,,F,;
 	
r)   c                6    [        5         U R                  5       $ )ro  )r  _share_memory_r-   s    r&   rv  TypedStorage.share_memory_  s    #%""$$r)   c                :    U R                   R                  5         U $ r    )r  rv  r-   s    r&   r  TypedStorage._share_memory_  s    ++-r)   r}   c                   Uc  Sn[         R                  " U5      n[         R                  R                  XR	                  5       -  US9n[        X0R                  SS9$ )ry  r	  r}   Tr+  )rP   r   r   rz  r  r   rI   )r#   rF   r   rk  s       r&   rz  TypedStorage._new_shared  s^    >Ff%..::%%'' ; 
 (

d
 	
r)   c                .    U R                   R                  $ r    )r  r   r-   s    r&   r   TypedStorage._cdata  s    $$+++r)   c                B    [        5         U R                  R                  $ r    )r  r  r   r-   s    r&   r   TypedStorage.device  s    #%$$+++r)   c                6    [        5         U R                  5       $ r    rE  r-   s    r&   rF   TypedStorage.size  rG  r)   c                X    U R                   R                  5       U R                  5       -  $ r    )r  rC   r  r-   s    r&   r   TypedStorage._size  s'     $$++-1C1C1EEEr)   c                6    [        5         U R                  5       $ r    )r  _pickle_storage_typer-   s    r&   pickle_storage_type TypedStorage.pickle_storage_type  s    #%((**r)   c                     [        5       U R                     $ ! [         a  n[        SU R                   S35      UeS nAff = f)Nzdtype z is not recognized)r  rI   KeyError)r#   es     r&   r  !TypedStorage._pickle_storage_type  sG    	K-/

;; 	KVDJJ</ABCJ	Ks    
A=Ac                    [         R                  " 5       n[        R                  " XSS9  [        UR                  5       44$ r   r   r   s     r&   r   TypedStorage.__reduce__  r   r)   c                6    [        5         U R                  5       $ r    )r  	_data_ptrr-   s    r&   r`   TypedStorage.data_ptr  s    #%~~r)   c                6    U R                   R                  5       $ r    )r  r`   r-   s    r&   r  TypedStorage._data_ptr  s    $$--//r)   c                J    [        5         U R                  R                  5       $ r    )r  r  rc   r-   s    r&   rc   TypedStorage.resizable  s    #%$$..00r)   c                :    [        5         U R                  U5        g r    )r  _resize_r   s     r&   r   TypedStorage.resize_  s    #%dr)   c                Z    U R                   R                  XR                  5       -  5        g r    )r  r   r  r   s     r&   r  TypedStorage._resize_  s"    %%d-?-?-A&ABr)   c                .    [         R                  " U0 UD6$ r    )r   r   ru   s      r&   r   TypedStorage._free_weak_ref  s    ,,d=f==r)   c                :    U R                   R                  " U0 UD6$ r    )r  r   r"   s      r&   r   TypedStorage._weak_ref  s    $$..???r)   c                :    [        5         U R                  " U0 UD6$ r    )r  _from_bufferru   s      r&   rv   TypedStorage.from_buffer  s    #%000r)   r  c                  U [         :X  a  Uc  [        R                  " 5       OUn[        R                  " Uc  SOU5      nUR                  S:w  a  [        SUR                   35      e[        R                  R                  " USU0UD6nOYUc  [        U5      S:X  a  [        S5      eUb  [        S5      eU R                  n[        R                  R                  " USU0UD6n[        XQSS9$ )	Nr	  z3TypedStorage.from_buffer: Not available for device rI      zefrom_buffer: 'dtype' can only be specified in UntypedStorage.from_buffer and TypedStorage.from_bufferzffrom_buffer: 'device' can only be specified in UntypedStorage.from_buffer and TypedStorage.from_bufferTr+  )
r   rP   r7  r   rJ   r-  r   rv   r   r  )rm   rI   r   r$   r%   rk  s         r&   r  TypedStorage._from_buffer  s   ,16E++-EE\\6>%vFF{{e#"I&++W  5:4H4H4T4T5"5&,5O
  CIN"N  !"N 
 JJE#22>>"&,O QUVVr)   c                   [        U[        R                  5      (       d  [        S[	        U5       35      e[        R
                  " / U R                  U R                  S9R                  U 5      R                  U5      R                  5       nUR                  5       U R                  5       :X  a  UR                  5       nU$ r  )r  rP   rI   r  rJ   r  r   r  rQ   r  r`   r   r  s      r&   r	   TypedStorage._to  s    %--HeVWWLL4::dkkBT$ZRY^	 	 0mmoGr)   c                T    [        5         U R                  [        R                  5      $ r  )r  r	   rP   r   r-   s    r&   r   TypedStorage.double(      #%xx%%r)   c                T    [        5         U R                  [        R                  5      $ r$  )r  r	   rP   r%  r-   s    r&   r%  TypedStorage.float-      #%xx$$r)   c                T    [        5         U R                  [        R                  5      $ r)  )r  r	   rP   r*  r-   s    r&   r*  TypedStorage.half2      #%xx

##r)   c                T    [        5         U R                  [        R                  5      $ r.  )r  r	   rP   r/  r-   s    r&   r/  TypedStorage.long7  r  r)   c                T    [        5         U R                  [        R                  5      $ r2  )r  r	   rP   r3  r-   s    r&   r3  TypedStorage.int<  s    #%xx		""r)   c                T    [        5         U R                  [        R                  5      $ r6  )r  r	   rP   r7  r-   s    r&   r7  TypedStorage.shortA  r  r)   c                T    [        5         U R                  [        R                  5      $ r:  )r  r	   rP   r;  r-   s    r&   r<  TypedStorage.charF  r  r)   c                T    [        5         U R                  [        R                  5      $ r?  )r  r	   rP   r  r-   s    r&   r@  TypedStorage.byteK  r  r)   c                T    [        5         U R                  [        R                  5      $ rC  )r  r	   rP   rD  r-   s    r&   rD  TypedStorage.boolP  r  r)   c                T    [        5         U R                  [        R                  5      $ rG  )r  r	   rP   rH  r-   s    r&   rH  TypedStorage.bfloat16U  s    #%xx''r)   c                T    [        5         U R                  [        R                  5      $ rK  )r  r	   rP   rL  r-   s    r&   rM  TypedStorage.complex_doubleZ  s    #%xx&&r)   c                T    [        5         U R                  [        R                  5      $ rP  )r  r	   rP   rQ  r-   s    r&   rR  TypedStorage.complex_float_  r  r)   c                T    [        5         U R                  [        R                  5      $ rU  )r  r	   rP   rV  r-   s    r&   rV  TypedStorage.float8_e5m2d  s    #%xx))**r)   c                T    [        5         U R                  [        R                  5      $ rY  )r  r	   rP   rZ  r-   s    r&   rZ  TypedStorage.float8_e4m3fni  s    #%xx++,,r)   c                T    [        5         U R                  [        R                  5      $ r]  )r  r	   rP   r^  r-   s    r&   r^  TypedStorage.float8_e5m2fnuzn      #%xx--..r)   c                T    [        5         U R                  [        R                  5      $ rb  )r  r	   rP   rc  r-   s    r&   rc  TypedStorage.float8_e4m3fnuzs  r  r)   c                    [        5         U [        :X  a  [        S5      e[        R	                  XU[
        R                  R                  U R                  5      -  5      nU " US9nU$ )aJ  from_file(filename, shared=False, size=0) -> Storage

Creates a CPU storage backed by a memory-mapped file.

If ``shared`` is ``True``, then memory is shared between all processes.
All changes are written to the file. If ``shared`` is ``False``, then the changes on
the storage do not affect the file.

``size`` is the number of elements in the storage. If ``shared`` is ``False``,
then the file must contain at least ``size * sizeof(Type)`` bytes
(``Type`` is the type of storage). If ``shared`` is ``True`` the file will be created if needed.

Args:
    filename (str): file name to map
    shared (bool): whether to share memory (whether ``MAP_SHARED`` or ``MAP_PRIVATE`` is passed to the
                    underlying `mmap(2) call <https://man7.org/linux/man-pages/man2/mmap.2.html>`_)
    size (int): number of elements in the storage
z/from_file can only be called on derived classesrA  )	r  r   r-  r   r   rP   r  r  rI   )rm   r   r   rF   rk  r  s         r&   r   TypedStorage.from_filex  s\    ( 	$%,PQQ(22dU\\%?%?		%JJ
 ?3r)   c                .    [         R                  " U0 UD6$ r    )r   r   ru   s      r&   r   TypedStorage._expired  s    &&777r)   c                :    U R                   R                  " U0 UD6$ r    )r  r   r"   s      r&   r   TypedStorage._write_file  s    $$00$A&AAr)   c                :    U R                   R                  " U0 UD6$ r    )r  r   r"   s      r&   r   TypedStorage._set_from_file      $$33TDVDDr)   c                :    U R                   R                  " U0 UD6$ r    )r  r   r"   s      r&   r   TypedStorage._set_cdata  s    $$//@@@r)   c                :    U R                   R                  " U0 UD6$ r    )r  r   r"   s      r&   r   TypedStorage._share_cuda_  s    $$114B6BBr)   c                6    [        5         U R                  5       $ r    )r  
_is_sharedr-   s    r&   r   TypedStorage.is_shared  s    #%  r)   c                6    U R                   R                  5       $ r    )r  r   r-   s    r&   r  TypedStorage._is_shared  s    $$..00r)   c                B    [         R                  R                  " U0 UD6$ r    )rP   r   r   ru   s      r&   r   TypedStorage._new_shared_cuda  s    ##44dEfEEr)   c                j    U R                   R                  " U0 UD6u  nnnX4XPR                  5       -  4$ r    )r  rf   r  )r#   r$   r%   manager_handlestorage_handlerF   s         r&   rf   !TypedStorage._share_filename_cpu_  sB    
 !!66GG		
t7I7I7K/KKKr)   c                :    U R                   R                  5         U $ r    )r  r   r-   s    r&   r   TypedStorage._shared_decref  s    ,,.r)   c               B    [         R                  R                  " U0 UD6$ r    rP   r   r   r   s       r&   r   !TypedStorage._release_ipc_counter      ##==tNvNNr)   c                :    U R                   R                  " U0 UD6$ r    )r  r   r"   s      r&   r   TypedStorage._shared_incref  r  r)   c                f    U R                   R                  " U0 UD6u  p4X4U R                  5       -  4$ r    )r  ri   r  )r#   r$   r%   fdrF   s        r&   ri   TypedStorage._share_fd_cpu_  s6    ((77HH4--////r)   c                   U R                   [        5       ;  a  g [        5       U R                      nU R                  R                  SSS[        R
                  R                  5       4;  a  g U R                  R                  S:X  a  [        O#[        [        U R                  R                  5      n [        X!5      $ ! [         a     g f = f)Nr	  rM   rV   )	rI   r  r   rJ   rP   rt  ru  getattrAttributeError)r#   storage_namer  s      r&   rf  &TypedStorage._get_legacy_storage_class  s    ::79913DJJ?;;HH224	$
 
  [[%%.EGE4;;CSCS4T 		600 		s   1
B< <
C	C	)r  rI   r  r  )Fr    )r;   r   r<   zbool | Noner  )rI   r  r<   rD  r  z!_StorageBase | TypedStorage | str)r   r   r<   rD  r  r   r  r  r  )cr  r  r  r  r   r  r   r  r  r   r"  r.  r'   r   r   r}  rB  r.   rM  r7   r  r4   rV  r=   rC   ra  rJ   rM   rV   rQ   rY   r  r]   r|  r   r   r   r   r  r   r   r  r	  rf  rj  rv  r  rz  r   r   rF   r   r  r  r   r`   r  rc   r   r  r  r   r   rv   r  r	   r   r%  r*  r/  r3  r7  r<  r@  rD  rH  rM  rR  rV  rZ  r^  rc  r   r   r   r   r   r   r   r  r   rf   r   r   r   ri   rf  r  r  r  s   @r&   r   r     s   Iu(,L%,  . .
 Z Z~ YVv ; ; : :%
<*4)! F"*2X
.
 !"CC C 
+	C"76 BG 5"$
62
.9K$
U4H

F
7
% +/ 

 , , , ,
F
+
K3
 
01
C > >@ 1 1 '+D W W>&
%
$
$
#
%
$
%
$
(
'
&
+
-
/
/
  8 8 8BEAC!
1 F FL 04 O OE0 r)   c                  &    \ rS rSr% S\S'   S rSrg)_LegacyStorageMetai  r  rI   c                    [        U5      [        L aM  [        U R                  5      nX!R                  R                   :H  =(       a    U R
                  UR
                  :H  $ gr  )rJ   r   r  r  r   rI   )rm   instancer3  s      r&   __instancecheck__$_LegacyStorageMeta.__instancecheck__  sK    >\)0@J//"6"66 		X^^+ r)   r!   N)r  r  r  r  r  r  r  r!   r)   r&   r  r    s    r)   r  c                  D    \ rS rSr\S 5       r\S 5       r\S 5       rSrg)r,  i  c                v    [         R                  R                  X" 5       R                  5       -  5      nU " US9$ )ry  rA  )rP   r   rz  r  )rm   rF   rk  s      r&   rz  _LegacyStorage._new_shared  s5      ..::4#%BUBUBW;WX00r)   c                B    [         R                  R                  " U0 UD6$ r    r
  ru   s      r&   r   #_LegacyStorage._release_ipc_counter  r  r)   c                    U[         R                  R                  U R                  5      -  nU " [         R                  R                  XU5      S9$ )NrA  )rP   r  r  rI   r   r{   )rm   ry   rz   rF   
bytes_sizes        r&   _new_shared_filename#_LegacyStorage._new_shared_filename  sE    ELL66syyAA
--FFj
 	
r)   r!   N)	r  r  r  r  r  rz  r   r$  r  r!   r)   r&   r,  r,    s>    1 1
 O O 
 
r)   r,  )	metaclassc                b     [        5       U    $ ! [         a  n[        SU  S35      UeS nAff = f)Nzpickle storage type "z" is not recognized)r  r  )r  r  s     r&   #_get_dtype_from_pickle_storage_typer(    sE    )+,?@@ #$7#88KL
	s    
.).)r  )r  r   )r  r   )>
__future__r   r/  r  r  r   r  r	  typingr   r   r   r   typing_extensionsr   rP   torch._utilsr	   r
   torch.typesr   r   r   torch._prims_commonr   __all__numpyr  r  ModuleNotFoundErrorLockr  r   r  r   r   r  rt  StorageBaser   r   cacher  r  r  r  r  r  r  r  r  r  r  r   __doc__rJ   rM   rV   rQ   r  r,  r(  r!   r)   r&   <module>r6     s   #    	   4 4 "  # , , 2 +
,I ^^% 02 - 2C45@" @"F!H@=UXX))< @=F9  ,  6  
82" &+ ".5B(?@ @F "MM   (--55   '++33   ++ 	 	
\-? 
*S/  I	Bs   F% %
F32F3