
    9i                    t   % 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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\RB                  " 5       r"0 r#S\$S'   \" SSS9r% " S S5      r&S r' " S S	\RP                  RR                  \&5      r*S r+\RX                  S 5       r-\RX                  S 5       r.\RX                  S 5       r/S r0S r1Sq2S r3S r4S'S jr5S r6S(S jr7 " S  S5      r8\Rr                  \8Rt                  l9        \&Rv                  Rr                  \8Rv                  l9        \&Rx                  Rr                  \8Rx                  l9        \Rr                  \8Rz                  l9         " S! S"\:5      r> " S# S$\8\>S%9r?S)S& jr@g! \  a    SrSr GNRf = f)*    )annotationsN)AnycastOptionalTYPE_CHECKINGTypeVarUnion)Self)_to_type)_bool_intStorage)DeviceLikeTypeTypedStorageUntypedStorageTFzdict[int, threading.RLock]_share_memory_mapT!Union[_StorageBase, TypedStorage])boundc                  ~  ^  \ 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 Sc SbS 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_Optional[torch.device]_fake_devicez_Optional[int]_checkpoint_offsetc                    g N selfargskwargss      M/var/www/html/land-doc-ocr/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__;   r2   r+   c                    [         er"   r-   r$   s      r(   __setitem___StorageBase.__setitem__>   r2   r+   c                    [         er"   r-   r%   sourcenon_blockings      r(   copy__StorageBase.copy_A   r2   r+   c                    [         er"   r-   r/   s    r(   new_StorageBase.newD   r2   r+   c                    [         er"   r-   r/   s    r(   nbytes_StorageBase.nbytesG   r2   r+   c                "    U R                  5       $ r"   )rE   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(   rO   _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.
hpurP   rQ   rT   s       r(   rX   _StorageBase.hpuc   s2     28%,,uf-U\\%=PwwgwAAr+   c                    [         er"   r-   r/   s    r(   element_size_StorageBase.element_sizer   r2   r+   c                .    U R                   R                  $ r"   )r   indexr/   s    r(   
get_device_StorageBase.get_deviceu   s    {{   r+   c                    [         er"   r-   r/   s    r(   data_ptr_StorageBase.data_ptrx   r2   r+   c                    [         er"   r-   r/   s    r(   	resizable_StorageBase.resizable{   r2   r+   c                    [         er"   r-   r$   s      r(   _share_filename_cpu_!_StorageBase._share_filename_cpu_   r2   r+   c                    [         er"   r-   r$   s      r(   _share_fd_cpu__StorageBase._share_fd_cpu_   r2   r+   c                    [         er"   r-   clsrH   s     r(   _new_using_filename_cpu$_StorageBase._new_using_filename_cpu       !!r+   c                    [         er"   r-   rn   s     r(   _new_using_fd_cpu_StorageBase._new_using_fd_cpu   rr   r+   c                    [         er"   r-   ro   r&   r'   s      r(   from_buffer_StorageBase.from_buffer   rr   r+   )r   rK   c                   [         er"   r-   )ro   managerobjrH   r   rK   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ro   r   r&   r'   s       r(   _release_ipc_counter!_StorageBase._release_ipc_counter   s    ,,d=f==r+   c                    [         er"   r-   rw   s      r(   r   &_StorageBase._release_ipc_counter_cuda   rr   r+   c                    [         er"   r-   rw   s      r(   _new_with_weak_ptr_StorageBase._new_with_weak_ptr   rr   r+   c                    [         er"   r-   r/   s    r(   _shared_decref_StorageBase._shared_decref   r2   r+   c                    [         er"   r-   r$   s      r(   _write_file_StorageBase._write_file   r2   r+   c                    [         er"   r-   r%   rH   s     r(   resize__StorageBase.resize_   r2   r+   c                    [         er"   r-   r$   s      r(   	_weak_ref_StorageBase._weak_ref   r2   r+   c                    [         er"   r-   r$   s      r(   _set_from_file_StorageBase._set_from_file   r2   r+   c                    [         er"   r-   r$   s      r(   
_set_cdata_StorageBase._set_cdata   r2   r+   c                    [         er"   r-   r$   s      r(   _share_cuda__StorageBase._share_cuda_   r2   r+   c                    [         er"   r-   r/   s    r(   	is_shared_StorageBase.is_shared   r2   r+   c                    [         er"   r-   rw   s      r(   _new_shared_cuda_StorageBase._new_shared_cuda   rr   r+   c                    [         er"   r-   r$   s      r(   _shared_incref_StorageBase._shared_incref   r2   r+   c                    [         er"   r-   rw   s      r(   _free_weak_ref_StorageBase._free_weak_ref   rr   r+   c                    [         er"   r-   r/   s    r(   is_cuda_StorageBase.is_cuda   rr   r+   c                    [         er"   r-   r/   s    r(   is_hpu_StorageBase.is_hpu   rr   r+   c                    [         er"   r-   )ro   filenamesharedrE   s       r(   	from_file_StorageBase.from_file   rr   r+   c                    [         er"   r-   rw   s      r(   _expired_StorageBase._expired   rr   r+   c                    [         er"   r-   r$   s      r(   	_byteswap_StorageBase._byteswap   r2   r+   c                    [         er"   r-   r$   s      r(   _get_filename_StorageBase._get_filename   r2   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   
)rR   typenamer   lenrL   joinrangerH   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   rH   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$ )NrR   )
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BytesIOrR   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__rH   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   )rL   rE   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   rL   rR   r   rH   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 rK   r   )
isinstancerR   rK   	TypeErrorrL   tensoruint8r   set_r   r   rS   _typed_storagerb   r   r%   rK   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  rR   r   r   )r%   r   r>   s      r(   rS   _StorageBase.to   s.    &%,,//\\&)F4..r+   c                @    U R                  [        R                  5      $ z"Casts this storage to double type.)r   rR   doubler/   s    r(   r"  _StorageBase.double%      xx%%r+   c                @    U R                  [        R                  5      $ z!Casts this storage to float type.)r   rR   floatr/   s    r(   r'  _StorageBase.float)      xx$$r+   c                @    U R                  [        R                  5      $ z Casts this storage to half type.)r   rR   halfr/   s    r(   r,  _StorageBase.half-      xx

##r+   c                @    U R                  [        R                  5      $ z Casts this storage to long type.)r   rR   longr/   s    r(   r1  _StorageBase.long1  r.  r+   c                @    U R                  [        R                  5      $ zCasts this storage to int type.)r   rR   intr/   s    r(   r5  _StorageBase.int5  s    xx		""r+   c                @    U R                  [        R                  5      $ z!Casts this storage to short type.)r   rR   shortr/   s    r(   r9  _StorageBase.short9  r)  r+   c                @    U R                  [        R                  5      $ z Casts this storage to char type.)r   rR   int8r/   s    r(   char_StorageBase.char=  r.  r+   c                @    U R                  [        R                  5      $ z Casts this storage to byte type.)r   rR   r  r/   s    r(   byte_StorageBase.byteA  r)  r+   c                @    U R                  [        R                  5      $ z Casts this storage to bool type.)r   rR   boolr/   s    r(   rF  _StorageBase.boolE  r.  r+   c                @    U R                  [        R                  5      $ z$Casts this storage to bfloat16 type.)r   rR   bfloat16r/   s    r(   rJ  _StorageBase.bfloat16I  s    xx''r+   c                @    U R                  [        R                  5      $ z*Casts this storage to complex double type.)r   rR   cdoubler/   s    r(   complex_double_StorageBase.complex_doubleM  s    xx&&r+   c                @    U R                  [        R                  5      $ z)Casts this storage to complex float type.)r   rR   cfloatr/   s    r(   complex_float_StorageBase.complex_floatQ  r$  r+   c                @    U R                  [        R                  5      $ z&Casts this storage to float8_e5m2 type)r   rR   float8_e5m2r/   s    r(   rX  _StorageBase.float8_e5m2U  s    xx))**r+   c                @    U R                  [        R                  5      $ z(Casts this storage to float8_e4m3fn type)r   rR   float8_e4m3fnr/   s    r(   r\  _StorageBase.float8_e4m3fnY  s    xx++,,r+   c                @    U R                  [        R                  5      $ z*Casts this storage to float8_e5m2fnuz type)r   rR   float8_e5m2fnuzr/   s    r(   r`  _StorageBase.float8_e5m2fnuz]      xx--..r+   c                @    U R                  [        R                  5      $ z*Casts this storage to float8_e4m3fnuz type)r   rR   float8_e4m3fnuzr/   s    r(   re  _StorageBase.float8_e4m3fnuza  rb  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  )rR   r  r  r   r  r   r   	is_pinnedr%   r   s     r(   rh  _StorageBase.is_pinnede  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   rL   r  rR   r  r  r  r   r   
pin_memoryuntyped_storage)r%   r   pinned_tensors      r(   rl  _StorageBase.pin_memoryu  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_strategyrO   file_system)	torch.multiprocessingrs  r   rL   rR   _C_get_privateuse1_backend_namerh   rk   )r%   rs  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   rr  rO   rX   r   rt  )	ru  rs  rR   r   rL   rv  rw  rp   rt   )ro   rH   r   rs  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)rR   _utils_element_size
is_complexmaxr5  r   )r%   rK   	elem_sizes      r(   byteswap_StorageBase.byteswap  s@    LL..u5	C	A.2Iy!r+   r#   returnr   r"   )r=   r   r>   z_Optional[_bool]r  r   )r  r   NF)rK   _Optional[str]r>   r   r  r   )r  r   )rH   r   r  r
   r  r
   )rH   r   r  r  )r   r   r>   r   rO   r   zUnion[str, torch.device])X__name__
__module____qualname____firstlineno____annotations__r   r   r   r    r)   r0   r6   r9   r?   rB   rE   rH   rL   rO   rX   r[   r_   rb   re   rh   rk   classmethodrp   rt   rx   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   rS   r"  r'  r,  r1  r5  r9  r>  rB  rF  rJ  rO  rT  rX  r\  r`  re  rh  rl  rx  r|  r  r  __static_attributes____classcell__r   s   @r(   r   r   )   s   KIu M5  -1L)0)--"""""" CH0#0:?0	*0 ).B	*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   rL   r.   r   r6   r%   r&   r'   r   s      r(   r6   UntypedStorage.__getitem__  s6    ;;v%%&LMMw"D3F33r+   c                4    U R                   R                  S:H  $ NrO   r   rL   r/   s    r(   r   UntypedStorage.is_cuda  s    {{6))r+   c                4    U R                   R                  S:H  $ NrX   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   rx  r  s      r(   rx  UntypedStorage.share_memory_  s    B w$d5f55r+   c                $   > [         TU ]  " U0 UD6$ r"   )r   rk   r  s      r(   rk   UntypedStorage._share_fd_cpu_  s    w%t6v66r+   c                $   > [         TU ]  " U0 UD6$ r"   )r   rh   r  s      r(   rh   #UntypedStorage._share_filename_cpu_  s    w+T<V<<r+   r#   r  )r  r  r  r  r6   r  r   r   r   r  rx  rk   rh   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)rR   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"   )rR   rX  r\  r`  re  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)rR   r"  r'  r,  r1  r5  int16r=  r  rF  rJ  rN  rS  qint8qint32quint8quint4x2quint2x4r#   r+   r(   _dtype_to_storage_type_mapr  0  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  L  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  )rR   r  r  r  r  r  r  int32r=  r  r  _untyped_storage)sequencerK   r   interpret_dtypes
tmp_tensors        r(   _get_storage_from_sequencer  R  s      LL%++NNEKKNNEKKLL%++KK
 \\U3F


 \\(G
$$&777r+   c                x    [         (       a   [        U [        [        R                  45      $ [        U [        5      $ r"   )	HAS_NUMPYr  r5  npinteger)xs    r(   _isintr  k  s*    y!c2::.//!S!!r+   c                     [         $ r"   )"_always_warn_typed_storage_removalr#   r+   r(   &_get_always_warn_typed_storage_removalr  u  s    --r+   c                6    [        U [        5      (       d   eU qg r"   )r  rF  r  )always_warns    r(   &_set_always_warn_typed_storage_removalr  y  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  rO   rX   r  )rsplitrR   rv  rw  )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.dtyperK   c                    U R                   $ r"   )rK   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_storagerK   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)rK   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&  rK   r'  )r  rR   r  _LegacyStorageRuntimeErrorr   r   __new__r   r  r  collectionsabcSequencer  rL   r  r  r  r   r   rK   )	ro   r&  rK   r   r'  r&   arg_error_msg
cls_devicer   s	           r(   r0  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   rK   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  rO   /Cannot create CUDA storage with quantized dtyper   r  r*  r)  )r  r   r/  r  rR   rK   r  rL   r   r  get_default_dtyper   r  r  r  r  r  r  r5  r  r1  r2  r3  r  )r%   r   rK   r&  r'  r&   r4  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   rL   r/   s    r(   r   TypedStorage.is_cudal  s%    #%$$++00F::r+   c                \    [        5         U R                  R                  R                  S:H  $ r  r<  r/   s    r(   r   TypedStorage.is_hpuq  s%    #%$$++00E99r+   c                .    [        5         U R                  $ )z2Return the internal :class:`torch.UntypedStorage`.)r  r  r/   s    r(   r  TypedStorage.untypedv  s    #%$$$r+   c           	         [        U5      [        R                  :X  d   e[        U 5      [        :X  a"  [	        [
        [        XR                  SS95      $ [        U 5      " US9$ )NTr-  r&  )rL   rR   r   r   r   r
   rK   )r%   rm  s     r(   _new_wrapped_storage!TypedStorage._new_wrapped_storage{  sY    O$(<(<<<<:%!0

d  :?;;r+   c                6    [        5         U R                  5       $ r"   r  r"  r/   s    r(   r0   TypedStorage.__len__      #%zz|r+   c                "   Uc  U(       a  U R                  5       $ g[        U5      [        :w  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"  rL   r5  r  
IndexErrorrH   )r%   r5   is_stops      r(   _maybe_wrap_indexTypedStorage._maybe_wrap_index  s    ;zz|# CyC.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%   r5   r#  s      r(   r9   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 )NrK  rL  z cannot set item with value type r  Tr-  )r  r5  r!  r/  rL   rR   
is_storagerK   r  r  r  r  r  r  r  r=  r  r  r   r  r   )r%   r5   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  _getitemr4   s     r(   r6   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__rK  rL  Tr-  r   )unset_fake_temporarilyr  )r  r   rL   r.   r  r!  r/  r5  rK   rR   r  r  r  r  r  r  r  r=  r   rX  rO  torch._subclasses.fake_tensorr[  r  r  item)r%   r5   r  idx_wrappedr[  r  s         r(   rX  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(   rE   TypedStorage.nbytes  s    #%||~r+   c                6    U R                   R                  5       $ r"   )r  rE   r/   s    r(   rc  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   rL   r  )r%   rK   r>   legacy_classs       r(   rL   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      $ )Nr8  )r  rK   rR   r  r  r  r  r  r/  r  rO   rD  )r%   r   r>   cuda_storages       r(   rO   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  rK   rR   r  r  r  r  r  r/  r  rX   rD  )r%   r   r>   hpu_storages       r(   rX   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 dtyperP   )r  r  rR   r   rK   r  r  r  r  r  r/  rL   upperr  rS   rD  )r%   r   r>   
to_storages       r(   rS   TypedStorage.to8  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(   r[   TypedStorage.element_sizeI  s    #%!!##r+   c                T    [         R                  R                  U R                  5      $ r"   )rR   r  r  rK   r/   s    r(   r  TypedStorage._element_sizeN  s    ||))$**55r+   c                J    [        5         U R                  R                  5       $ r"   )r  r  r_   r/   s    r(   r_   TypedStorage.get_deviceQ  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  rR   r   rK   r   r   rL   r   r   rH   r   s   `  r(   __str__TypedStorage.__str__U  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__a  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>g  r   r   )r  r   r   rH   r/   s   `r(   r   TypedStorage.__iter__e  s%    #%8U499;%7888r+   c                t    [        5         U R                  [        R                  " U R                  5      5      $ r"   )r  rD  copyr  r/   s    r(   r   TypedStorage.__copy__i  s(    #%((43H3H)IJJr+   c                8    [        5         U R                  U5      $ r"   )r  	_deepcopyr%   r   s     r(   r   TypedStorage.__deepcopy__m  s    #%~~d##r+   c                b    U R                  [        R                  " U R                  U5      5      $ r"   )rD  r  deepcopyr  r  s     r(   r  TypedStorage._deepcopyr  s$    ((t7L7Ld)STTr+   c                V   > [        5         [        TU ]	  5       U R                  5       -   $ r"   )r  r   r   rE   r   s    r(   r   TypedStorage.__sizeof__u  s"    #%w!#dkkm33r+   c                h    [        5         U R                  U R                  R                  5       5      $ )r  )r  rD  r  r   r/   s    r(   r   TypedStorage.cloney  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  rD  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  rh  ri  s     r(   rh  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  rD  r  rl  ri  s     r(   rl  TypedStorage.pin_memory  s4     	$%((!!,,F,;
 	
r+   c                6    [        5         U R                  5       $ )rq  )r  _share_memory_r/   s    r(   rx  TypedStorage.share_memory_  s    #%""$$r+   c                :    U R                   R                  5         U $ r"   )r  rx  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$ )r{  r  r   Tr-  )rR   r   r   r|  r  r   rK   )r%   rH   r   rm  s       r(   r|  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"   rG  r/   s    r(   rH   TypedStorage.size  rI  r+   c                X    U R                   R                  5       U R                  5       -  $ r"   )r  rE   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  rK   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(   rb   TypedStorage.data_ptr  s    #%~~r+   c                6    U R                   R                  5       $ r"   )r  rb   r/   s    r(   r  TypedStorage._data_ptr  s    $$--//r+   c                J    [        5         U R                  R                  5       $ r"   )r  r  re   r/   s    r(   re   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   rw   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_bufferrw   s      r(   rx   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 rK      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   rR   r9  r   rL   r/  r   rx   r   r  )ro   rK   r   r&   r'   rm  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  rR   rK   r  rL   r  r   r  rS   r  rb   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   rR   r"  r/   s    r(   r"  TypedStorage.double*      #%xx%%r+   c                T    [        5         U R                  [        R                  5      $ r&  )r  r   rR   r'  r/   s    r(   r'  TypedStorage.float/      #%xx$$r+   c                T    [        5         U R                  [        R                  5      $ r+  )r  r   rR   r,  r/   s    r(   r,  TypedStorage.half4      #%xx

##r+   c                T    [        5         U R                  [        R                  5      $ r0  )r  r   rR   r1  r/   s    r(   r1  TypedStorage.long9  r  r+   c                T    [        5         U R                  [        R                  5      $ r4  )r  r   rR   r5  r/   s    r(   r5  TypedStorage.int>  s    #%xx		""r+   c                T    [        5         U R                  [        R                  5      $ r8  )r  r   rR   r9  r/   s    r(   r9  TypedStorage.shortC  r  r+   c                T    [        5         U R                  [        R                  5      $ r<  )r  r   rR   r=  r/   s    r(   r>  TypedStorage.charH  r  r+   c                T    [        5         U R                  [        R                  5      $ rA  )r  r   rR   r  r/   s    r(   rB  TypedStorage.byteM  r  r+   c                T    [        5         U R                  [        R                  5      $ rE  )r  r   rR   rF  r/   s    r(   rF  TypedStorage.boolR  r  r+   c                T    [        5         U R                  [        R                  5      $ rI  )r  r   rR   rJ  r/   s    r(   rJ  TypedStorage.bfloat16W  s    #%xx''r+   c                T    [        5         U R                  [        R                  5      $ rM  )r  r   rR   rN  r/   s    r(   rO  TypedStorage.complex_double\  s    #%xx&&r+   c                T    [        5         U R                  [        R                  5      $ rR  )r  r   rR   rS  r/   s    r(   rT  TypedStorage.complex_floata  r  r+   c                T    [        5         U R                  [        R                  5      $ rW  )r  r   rR   rX  r/   s    r(   rX  TypedStorage.float8_e5m2f  s    #%xx))**r+   c                T    [        5         U R                  [        R                  5      $ r[  )r  r   rR   r\  r/   s    r(   r\  TypedStorage.float8_e4m3fnk  s    #%xx++,,r+   c                T    [        5         U R                  [        R                  5      $ r_  )r  r   rR   r`  r/   s    r(   r`  TypedStorage.float8_e5m2fnuzp      #%xx--..r+   c                T    [        5         U R                  [        R                  5      $ rd  )r  r   rR   re  r/   s    r(   re  TypedStorage.float8_e4m3fnuzu  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 classesrC  )	r  r   r/  r   r   rR   r  r  rK   )ro   r   r   rH   rm  r  s         r(   r   TypedStorage.from_filez  s\    ( 	$%,PQQ(22dU\\%?%?		%JJ
 ?3r+   c                .    [         R                  " U0 UD6$ r"   )r   r   rw   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"   )rR   r   r   rw   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  rh   r  )r%   r&   r'   manager_handlestorage_handlerH   s         r(   rh   !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"   rR   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  rk   r  )r%   r&   r'   fdrH   s        r(   rk   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  rO   rX   )	rK   r  r   rL   rR   rv  rw  getattrAttributeError)r%   storage_namer  s      r(   rh  &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  rK   r  r  )Fr"   )r=   r   r>   z_Optional[bool]r  )rK   r  r>   rF  r  z&Union[_StorageBase, TypedStorage, str])r   r   r>   rF  r  r
   r  r  r  )cr  r  r  r  r   r  r   r  r  r   r$  r0  r)   r   r   r  rD  r0   rO  r9   r   r6   rX  r?   rE   rc  rL   rO   rX   rS   r[   r  r_   r~  r   r   r   r   r  r   r   r  r  rh  rl  rx  r  r|  r   r   rH   r"  r  r  r   rb   r  re   r   r  r  r   r   rx   r  r   r"  r'  r,  r1  r5  r9  r>  rB  rF  rJ  rO  rT  rX  r\  r`  re  r   r   r   r   r   r   r   r  r   rh   r   r   r   rk   rh  r  r  r  s   @r(   r   r     s   Iu,0L)0  . .
 Z Z~ YVv ; ; : :%
<*4)! F"*2X
.
 !%"CC C 
0	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  rK   c                    [        U5      [        :X  aM  [        U R                  5      nX!R                  R                   :H  =(       a    U R
                  UR
                  :H  $ gr  )rL   r   r  r  r   rK   )ro   instancer5  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$ )r{  rC  )rR   r   r|  r  )ro   rH   rm  s      r(   r|  _LegacyStorage._new_shared  s5      ..::4#%BUBUBW;WX00r+   c                B    [         R                  R                  " U0 UD6$ r"   r  rw   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$ )NrC  )rR   r  r  rK   r   r}   )ro   r{   r|   rH   
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  r|  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   )A
__future__r   r1  r  r  r   r  r  typingr   r   r   	_Optionalr   r   r	   typing_extensionsr
   rR   torch._utilsr   r   torch.typesr   r   r   torch._prims_commonr   __all__numpyr  r  ModuleNotFoundErrorLockr  r   r  r   r   r  rv  StorageBaser   r   cacher  r  r  r  r  r  r  r  r  r  r  r   __doc__rL   rO   rX   rS   r  r.  r*  r#   r+   r(   <module>r9     s   #    	   R R "  # , , 2 +
,I ^^% 02 - 2C:;B" B"J!H@=UXX))< @=F9  ,  6  
82" &+ ".5B(?@ @F "MM   (--55   '++33   ++ 	 	
\-? 
*W/  I	Bs   F) )
F76F7