
    #hi                        U d dl Z d dlZddlmZmZmZ d dlmZ d dlm	Z	m
Z
mZmZmZmZmZ d dlZd dlZd dlmZ d dlZd dlZd dlZ	 d dlZdZn# e$ r dZY nw xY w ej                    Zi Zeeej         f         e!d<    ed	d
          Z" G d d          Z#d Z$ G d dej%        j&        e#          Z'd Z(ee#_)        ee#_*        ee#_+         ed          d             Z, ed          d             Z-d Z.d Z/da0d Z1d Z2d(dZ3d Z4de5fdZ6 G d d           Z7ej8        e7j)        _8        ej8        e7j*        _8        ej8        e7j+        _8         G d! d"e)          Z9 G d# d$e7e9%          Z:d&e5fd'Z;dS ))    N   )_type_cuda_hpu)Storage)castAnyDictOptionalTypeVarTypeUnion)	lru_cacheT_share_memory_mapTz!Union[_StorageBase, TypedStorage])boundc                   j    e Zd ZU eed<   dZeed<   dZeed<   ej	        ed<   d Z
defdZd	 Zd
 ZdXdedee         defdZdefdZdefdZdefdZdYdee         dedefdZdYdefdZdYdefdZdefdZdefdZdefdZd Zd Zedee         dedefd            Z edee         dedefd            Z!edee         defd            Z"eddd dee         defd!            Z#edee         defd"            Z$edee         defd#            Z%defd$Z&d% Z'defd&Z(defd'Z)d( Z*d) Z+d* Z,defd+Z-edee         defd,            Z.d- Z/ed.             Z0e1d/             Z2e1d0             Z3edefd1            Z4edefd2            Z5d3 Z6dee         fd4Z7d5 Z8d6 Z9d7 Z:d8 Z;d9 Z<d: Z= fd;Z>d< Z?d= Z@d> ZAd? ZBd@ ZCdA ZDdB ZEdC ZFdD ZGdE ZdF ZHdG ZIdH ZJdI ZdJ ZKdK ZLdL ZMdM ZNdN ZOdZdePeej	        f         fdPZQdZdePeej	        f         fdQZRdR ZSedSdTdU            ZTdV ZUdW ZV xZWS )[_StorageBase_cdataF	is_sparseis_sparse_csrdevicec                     d S N selfargskwargss      M/var/www/html/auto_sub_bot/venv/lib/python3.11/site-packages/torch/storage.py__init__z_StorageBase.__init__             returnc                     d S r   r   r   s    r    __len__z_StorageBase.__len__   r"   r#   c                     d S r   r   r   idxs     r    __getitem__z_StorageBase.__getitem__   r"   r#   c                     d S r   r   r   s      r    __setitem__z_StorageBase.__setitem__    r"   r#   Nsourcenon_blockingc                     d S r   r   r   r.   r/   s      r    copy_z_StorageBase.copy_!   r"   r#   c                     d S r   r   r&   s    r    newz_StorageBase.new"   r"   r#   c                     d S r   r   r&   s    r    nbytesz_StorageBase.nbytes#   r"   r#   c                 *    |                                  S r   )r6   r&   s    r    sizez_StorageBase.size%   s    {{}}r#   dtypec                     d S r   r   )r   r9   r/   s      r    typez_StorageBase.type(   r"   r#   c                     d S r   r   r   r   r/   r   s       r    cudaz_StorageBase.cuda)   r"   r#   c                     d S r   r   r=   s       r    hpuz_StorageBase.hpu*   r"   r#   c                     d S r   r   r&   s    r    element_sizez_StorageBase.element_size+   r"   r#   c                     | j         j        S r   )r   indexr&   s    r    
get_devicez_StorageBase.get_device-   s    {  r#   c                     d S r   r   r&   s    r    data_ptrz_StorageBase.data_ptr0   r"   r#   c                     d S r   r   r   s      r    _share_filename_cpu_z!_StorageBase._share_filename_cpu_3   r"   r#   c                     d S r   r   r   s      r    _share_fd_cpu_z_StorageBase._share_fd_cpu_4   r"   r#   clsr8   c                     d S r   r   rL   r8   s     r    _new_using_filename_cpuz$_StorageBase._new_using_filename_cpu5   s    ?Bsr#   c                     d S r   r   rN   s     r    _new_using_fd_cpuz_StorageBase._new_using_fd_cpu7       9<r#   c                     d S r   r   rL   r   r   s      r    from_bufferz_StorageBase.from_buffer9   rR   r#   )r   r9   c                    d S r   r   )rL   managerobjr8   r   r9   s         r    _new_shared_filename_cpuz%_StorageBase._new_shared_filename_cpu;   s    ehehr#   c                     d S r   r   rT   s      r    _release_ipc_counter_cudaz&_StorageBase._release_ipc_counter_cuda=   s    GJsr#   c                     d S r   r   rT   s      r    _new_with_weak_ptrz_StorageBase._new_with_weak_ptr?   s    @Cr#   c                     d S r   r   r&   s    r    _shared_decrefz_StorageBase._shared_decrefA   r"   r#   c                     d S r   r   r   s      r    _write_filez_StorageBase._write_fileB   r"   r#   c                     d S r   r   r   r8   s     r    resize_z_StorageBase.resize_C   r"   r#   c                     d S r   r   r   s      r    	_weak_refz_StorageBase._weak_refD   r"   r#   c                     d S r   r   r   s      r    _set_from_filez_StorageBase._set_from_fileE   r"   r#   c                     d S r   r   r   s      r    
_set_cdataz_StorageBase._set_cdataF   r"   r#   c                     d S r   r   r   s      r    _share_cuda_z_StorageBase._share_cuda_G   r"   r#   c                     d S r   r   r&   s    r    	is_sharedz_StorageBase.is_sharedH   r"   r#   c                     d S r   r   rT   s      r    _new_shared_cudaz_StorageBase._new_shared_cudaI   s    >Acr#   c                     d S r   r   r   s      r    _shared_increfz_StorageBase._shared_increfK   r"   r#   c                     d S r   r   rT   s      r    _free_weak_refz_StorageBase._free_weak_refL   s    .1cr#   c                     d S r   r   r&   s    r    is_cudaz_StorageBase.is_cudaN   s    sr#   c                     d S r   r   r&   s    r    is_hpuz_StorageBase.is_hpuP   s    cr#   c                     d S r   r   )rL   filenamesharedr6   s       r    	from_filez_StorageBase.from_fileR   s    7:sr#   c                     d S r   r   rT   s      r    _expiredz_StorageBase._expiredT   s    -0Sr#   c                     d S r   r   r   s      r    	_byteswapz_StorageBase._byteswapV   r"   r#   c                     d S r   r   r   s      r    _get_filenamez_StorageBase._get_filenameW   r"   r#   c                 $    dt          j                    d j         dt                      d} j        j        dk    rd|z   S dd                     fd	t                                                     D                       z   }|d
z   |z   S )N[z(device=
) of size ]meta...
 
 c              3   B   K   | ]}t          |                   V  d S r   str.0ir   s     r    	<genexpr>z'_StorageBase.__str__.<locals>.<genexpr>`   -      'Q'QDG'Q'Q'Q'Q'Q'Qr#   
)torchtypenamer   lenr;   joinranger8   r   info_strdata_strs   `  r    __str__z_StorageBase.__str__Y   s    $t$$ $ $dk $ $4yy$ $ $ 	 ;v%%X%%UZZ'Q'Q'Q'QeDIIKK>P>P'Q'Q'QQQQHd?X--r#   c                      t          |           S r   r   r&   s    r    __repr__z_StorageBase.__repr__c   s    4yyr#   c                 x     t           fdt                                                     D                       S )Nc              3   (   K   | ]}|         V  d S r   r   r   s     r    r   z(_StorageBase.__iter__.<locals>.<genexpr>g   '      88DG888888r#   )iterr   r8   r&   s   `r    __iter__z_StorageBase.__iter__f   s6    8888U499;;%7%7888888r#   c                 *    |                                  S r   )cloner&   s    r    __copy__z_StorageBase.__copy__i   s    zz||r#   c                     |                     di           }| j        |v r|| j                 S |                                 }||| j        <   |S )Nr   )
setdefaultr   r   )r   memonew_storages      r    __deepcopy__z_StorageBase.__deepcopy__l   sN    w++;$$$jjll'T[r#   c                     t          j                    }t          j        | |d           t          |                                ffS NF)_use_new_zipfile_serializationioBytesIOr   save_load_from_bytesgetvaluer   bs     r    
__reduce__z_StorageBase.__reduce__t   9    JLL
45AAAA 1::<</22r#   c                 n    t                                                      |                                 z   S r   )super
__sizeof__r8   r   	__class__s    r    r   z_StorageBase.__sizeof__y   s&    ww!!##diikk11r#   c                      t          |           |                                 | j                                      |           S )Return a copy of this storage.r   )r;   r6   r   r2   r&   s    r    r   z_StorageBase.clone|   s5    tDzz$++--<<<BB4HHHr#   c                      t          |           S z6Return a list containing the elements of this storage.)listr&   s    r    tolistz_StorageBase.tolist   s    Dzzr#   c                     | j         j        dk    r:t          j        |                                                               | d          S | S )AReturn a CPU copy of this storage if it's not already on the CPU.cpuFr   r;   r   UntypedStorager8   r2   r&   s    r    r   z_StorageBase.cpu   s@    ;u$$'		44::4GGGKr#   c                     | j         j        dk    r<t          j        |                                 d                              | d          S | S )zAReturn a MPS copy of this storage if it's not already on the MPS.mpsr   Fr   r&   s    r    r   z_StorageBase.mps   sE    ;u$$'		EBBBHHuUUUKr#   c                    t          |t          j                  st          dt	          |                     t          j        g t          j        | j                                      t          t          |                                         |                                          }|                                |                                 k    r|                                }|S Nz*Argument 'dtype' must be torch.dtype, not r9   r   )
isinstancer   r9   	TypeErrorr;   tensoruint8r   set_r   r   to_typed_storagerG   r   r   r9   storages      r    _toz_StorageBase._to   s    %-- 	XVeVVWWW,rT[IIINNtT[]aObObccffglmm||~~00mmooGr#   c                 @    |                      t          j                  S z"Casts this storage to double type.)r   r   doubler&   s    r    r   z_StorageBase.double       xx%%%r#   c                 @    |                      t          j                  S z!Casts this storage to float type.)r   r   floatr&   s    r    r   z_StorageBase.float       xx$$$r#   c                 @    |                      t          j                  S z Casts this storage to half type.)r   r   halfr&   s    r    r   z_StorageBase.half       xx
###r#   c                 @    |                      t          j                  S z Casts this storage to long type.)r   r   longr&   s    r    r   z_StorageBase.long   r   r#   c                 @    |                      t          j                  S zCasts this storage to int type.)r   r   intr&   s    r    r   z_StorageBase.int   s    xx	"""r#   c                 @    |                      t          j                  S z!Casts this storage to short type.)r   r   shortr&   s    r    r   z_StorageBase.short   r   r#   c                 @    |                      t          j                  S z Casts this storage to char type.)r   r   int8r&   s    r    charz_StorageBase.char   r   r#   c                 @    |                      t          j                  S z Casts this storage to byte type.)r   r   r   r&   s    r    bytez_StorageBase.byte   r   r#   c                 @    |                      t          j                  S z Casts this storage to bool type.)r   r   boolr&   s    r    r   z_StorageBase.bool   r   r#   c                 @    |                      t          j                  S z$Casts this storage to bfloat16 type.)r   r   bfloat16r&   s    r    r   z_StorageBase.bfloat16   s    xx'''r#   c                 @    |                      t          j                  S z*Casts this storage to complex double type.)r   r   cdoubler&   s    r    complex_doublez_StorageBase.complex_double   s    xx&&&r#   c                 @    |                      t          j                  S z)Casts this storage to complex float type.)r   r   cfloatr&   s    r    complex_floatz_StorageBase.complex_float   r   r#   c                 @    |                      t          j                  S z&Casts this storage to float8_e5m2 type)r   r   float8_e5m2r&   s    r    r  z_StorageBase.float8_e5m2   s    xx)***r#   c                 @    |                      t          j                  S z(Casts this storage to float8_e4m3fn type)r   r   float8_e4m3fnr&   s    r    r  z_StorageBase.float8_e4m3fn   s    xx+,,,r#   r>   c                     t          j        g t           j        | j                                      t          t          |                                         |          S )zDetermine whether the CPU storage is already pinned on device.

        Args:
            device (str or torch.device): The device to pin memory on. Default: ``'cuda'``.

        Returns:
            A boolean variable.
        r   )r   r   r   r   r   r   r   	is_pinnedr   r   s     r    r
  z_StorageBase.is_pinned   sK     |Bek$+FFFKK$! !!*6!2!2	3r#   c                 R   | j         j        dk    r%t          d|                                  d          t          j        g t          j        | j                                       t          t          |                     	                    |          }|
                                S )zCopy 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'``.

        Returns:
            A pinned CPU storage.
        r   zcannot pin 'z' only CPU memory can be pinnedr   )r   r;   r   r   r   r   r   r   r   
pin_memoryuntyped_storage)r   r   pinned_tensors      r    r  z_StorageBase.pin_memory   s     ;u$$W499;;WWWXXXRu{4;OOOTT$! !!+F!3!3 	,,...r#   c                     ddl m} | j        j        dt          j                                        fv rn7 |            dk    r|                                  n|                                  | S ).See :meth:`torch.UntypedStorage.share_memory_`r   get_sharing_strategyr>   file_system)	torch.multiprocessingr  r   r;   r   _C_get_privateuse1_backend_namerI   rK   )r   r  s     r    share_memory_z_StorageBase.share_memory_   sz    >>>>>>;(N(N(P(PQQQ!!##}44%%''''!!!r#   r   r   c                   ddl m} t          j        |          }|j        dt          j                                        fv r | ||          S  |            dk    r|                     |          S |                     |          S )>Create a new storage in shared memory with the same data type.r   r  r>   r   r  )	r  r  r   r   r;   r  r  rO   rQ   )rL   r8   r   r  s       r    _new_sharedz_StorageBase._new_shared   s     	?>>>>>f%%;658#I#I#K#KLLL3tF++++!!##}44..t444((...r#   c                     | S r   r   r&   s    r    untypedz_StorageBase.untyped  s    r#   c                     t           j                            |          }|j        r t	          t          |dz            d          }|                     |           dS )zSwap bytes in underlying data.   r   N)r   _utils_element_size
is_complexmaxr   r   )r   r9   	elem_sizes      r    byteswapz_StorageBase.byteswap  sU    L..u55	 	3C	A..22Iy!!!!!r#   r   NFr>   )X__name__
__module____qualname__r	   __annotations__r   r   r   r   r   r!   r   r'   r+   r-   r   	_Optionalr2   r4   r6   r8   r   r;   r>   r@   rB   rE   rG   rI   rK   classmethodr   rO   rQ   rU   rY   r[   r]   r_   ra   rd   rf   rh   rj   rl   rn   rp   rr   rt   propertyrv   rx   r|   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r   r
  r  r  r  r  r%  __classcell__r   s   @r    r   r      s        KKKItM4L,,,!!!!!###///NNANYt_NNNNNQ     c     WV)C.VtVPQVVVVGGGGGGFFFFFF&c&&&&!C ! ! ! ! ##"""" 988222BT!WBCBABBB [B<tAw<c<a<<< [<<a<a<<< [<MQY]hhhd1ghbchhh [hJtAwJAJJJ [JCQCQCCC [C&&&&&///%C%%%%2A2222222...000$4$$$$Ad1gA1AAA [A22211 [1 X X:A::: [:0!000 [0---C	#CCCC. . .  9 9 9    3 3 3
2 2 2 2 2I I I        & & &% % %$ $ $$ $ $# # #% % %$ $ $% % %$ $ $( ( (' ' '& & &+ + +- - -
3 
3c5<&7 8 
3 
3 
3 
3/ /sEL'8!9 / / / / 	 	 	 ). 	/ 	/ 	/ 	/ [	/  " " " " " " "r#   r   c                 F     t          j                    fd            }|S )Nc                    d }d }t           5  | j        }|t          v rt          |         }n<t          j                    t          |<   t          |                                          |}d d d            n# 1 swxY w Y   ||5  	 d d d            n# 1 swxY w Y   	  | g|R i ||T| j        |k    sJ t           5  t          |                                          t          |= d d d            S # 1 swxY w Y   S S # |T| j        |k    sJ t           5  t          |                                          t          |= d d d            w # 1 swxY w Y   w w xY wr   )_share_memory_lockr   r   	threadingRLockacquirerelease)r   r   r   to_freeto_waitkeyfns         r    wrapperz-_share_memory_lock_protected.<locals>.wrapper  s    	 	+C'''+C0)2):):!#&!#&..000	 	 	 	 	 	 	 	 	 	 	 	 	 	 	                 	32d,T,,,V,, " {g----' 3 3%g.66888)'23 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3	 #w" {g----' 3 3%g.66888)'23 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3	 #sf   AA44A8;A8BBBC? >(C22C6	9C6	?E(E
>E
EEEE)	functoolswraps)r;  r<  s   ` r    _share_memory_lock_protectedr?    s8    _R3 3 3 3 3< Nr#   c                        e Zd Z fdZed             Zed             Zedee         fd            Z	e
 fd            Ze
 fd            Ze
 fd            Z xZS )	r   c                 t    | j         j        dk    rt          d           t                      j        |i |S )Nr   $Not available for 'meta' device type)r   r;   NotImplementedErrorr   r+   r   r   r   r   s      r    r+   zUntypedStorage.__getitem__4  s>    ;v%%%&LMMM"uww"D3F333r#   c                 "    | j         j        dk    S Nr>   r   r;   r&   s    r    rv   zUntypedStorage.is_cuda9  s    {6))r#   c                 "    | j         j        dk    S Nr@   rG  r&   s    r    rx   zUntypedStorage.is_hpu=  s    {5((r#   r$   c                 *    |                                  S 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&   s    r    rz   zUntypedStorage.filenameA  s     !!###r#   c                 6     t                      j        |i |S )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   r  rD  s      r    r  zUntypedStorage.share_memory_G  s"    B %uww$d5f555r#   c                 6     t                      j        |i |S r   )r   rK   rD  s      r    rK   zUntypedStorage._share_fd_cpu_j  s    %uww%t6v666r#   c                 6     t                      j        |i |S r   )r   rI   rD  s      r    rI   z#UntypedStorage._share_filename_cpu_n  s    +uww+T<V<<<r#   )r(  r)  r*  r+   r.  rv   rx   r,  r   rz   r?  r  rK   rI   r/  r0  s   @r    r   r   3  s       4 4 4 4 4
 * * X* ) ) X) $)C. $ $ $ X$
 " 6  6  6  6 "! 6D "7 7 7 7 "!7 "= = = = "!= = = = =r#   r   c                 N    t          j        t          j        |                     S r   )r   loadr   r   )r   s    r    r   r   r  s    :bjmm$$$r#   )maxsizec                     i t           j        dt           j        dt           j        dt           j        dt           j        dt           j        dt           j        dt           j        dt           j	        d	t           j
        d
t           j        dt           j        dt           j        dt           j        dt           j        dt           j        dt           j        dS )NDoubleStorageFloatStorageHalfStorageLongStorage
IntStorageShortStorageCharStorageByteStorageBoolStorageBFloat16StorageComplexDoubleStorageComplexFloatStorageQInt8StorageQInt32StorageQUInt8StorageQUInt4x2StorageQUInt2x4Storage)r   r   r   r   r   r   int16r   r   r   r   r   r  qint8qint32quint8quint4x2quint2x4r   r#   r    _dtype_to_storage_type_maprj  {  s    o^ 	
M 	
M	
 		< 	^ 	
M 	] 	
M 	) 	- 	+ 	^ 	o 	o  	)!" 	)# r#   c                  Z    d t                                                      D             } | S )Nc                     i | ]\  }}||	S r   r   )r   r:  vals      r    
<dictcomp>z._storage_type_to_dtype_map.<locals>.<dictcomp>  s1     G G GS#SG G Gr#   )rj  items)	dtype_maps    r    _storage_type_to_dtype_maprq    s=    G G!;!=!=!C!C!E!EG G GIr#   c           
         |t           j        t           j        t           j        t           j        t           j        fv rt           j        t           j        t           j        t           j        t           j        t           j        t           j        t           j        t           j        t           j        i}t          j	        | ||         |          }nt          j	        | ||          }|
                                j        S )Nr   )r   rg  rh  ri  rf  re  r   int32r   r   r   _untyped_storage)sequencer9   r   interpret_dtypes
tmp_tensors        r    _get_storage_from_sequencerx    s    u~u~u|U[YYYL%+NEKNEKL%+K
 \"5)  

 \  

 $$&&77r#   c                 |    t           r!t          | t          t          j        f          S t          | t                    S r   )	HAS_NUMPYr   r   npinteger)xs    r    _isintr~    s1     "!c2:.///!S!!!r#   Fc                      t           S r   )"_always_warn_typed_storage_removalr   r#   r    &_get_always_warn_typed_storage_removalr    s    --r#   c                 8    t          | t                    sJ | ad S r   )r   r   r  )always_warns    r    &_set_always_warn_typed_storage_removalr    s$    k4((((()4&&&r#   r  c                     d }t                      s
 |            r2d}t          j        |t          | dz              dt          j        d<   d S d S )Nc                  V    t          t          d          sdS t          j        d          S )N
has_warnedT)hasattr_warn_typed_storage_removal__dict__r   r#   r    is_first_timez2_warn_typed_storage_removal.<locals>.is_first_time  s,    2LAA 	J4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    s{    J J J .// B==?? BQ 	 	g{zA~FFFF=A#,\:::B Br#   c                  $    dt           j        d<   d S )NFr  )r  r  r   r#   r    !_reset_warn_typed_storage_removalr    s    9>(666r#   modulec                     |                      d          d         dt          j                                        fv r|                      d          d         S dS )N.r>   r   )splitr   r  r  )r  s    r    _get_device_from_moduler    sM    ||C)O)O)Q)Q RRR||C  $$ur#   c            	           e Zd ZU dZej        ed<   ed             Zede	e
         fd            Zd Zddddd fd	
Zddddd
dZed             Zed             Zd Zd Zd ZdadZd Zd Zd Zd Zdbdede	e         fdZd Zd Zdcde	e
         dedeee
f         fdZdcdefdZ dcdefdZ!d Z"d Z#de$fd Z%d! Z&d" Z'd# Z(d$ Z)d% Z*d& Z+ fd'Z,d( Z-d) Z.d* Z/ddd,ee
ej0        f         fd-Z1ddd,ee
ej0        f         fd.Z2d/ Z3d0 Z4dd1d2Z5ed3             Z6ed4             Z0d5 Z7d6 Z8d7 Z9d8 Z:d9 Z;d: Z<d; Z=d< Z>d= Z?e@d>             ZAd? ZBe@d@             ZCe@dddAdB            ZDdC ZEdD ZFdE ZGdF ZHdG ZIdH Z$dI ZJdJ ZKdK ZLdL ZdM ZMdN ZNdO ZOdP ZPdQ ZQe@dR             ZRe@dS             ZSdT ZTdU ZUdV ZVdW ZWdX ZXdY ZYe@dZ             ZZd[ Z[d\ Z\e@dd1d]            Z]d^ Z^d_ Z_d` Z` xZaS )eTypedStorageFr9   c                     | j         S r   )r9   r&   s    r    _dtypezTypedStorage._dtype  s
    zr#   r$   c                     | j         j        S rK  )rt  rz   r&   s    r    rz   zTypedStorage.filename  s     $--r#   c                     t                       |                     t          d|                                           |           | S )Nr   )r  _setitemslice_size)r   values     r    fill_zTypedStorage.fill_  s9    #%%%eAtzz||,,e444r#   N)wrap_storager9   r   	_internalc                   |st                       | t          j        j        k    rt	          d          | t
          k    r!t                                          |           S |  d}|t	          |dz             |t	          |dz             |t          |          dk    rt	          |dz             t          |          dk    rbt          |d                   sMt          |d         t          j        j                  s(t          |dt          |d                    z             t          || j        t#          | j                  d	d
S t          |          dk    rt	          |dz             t          |t          j                  s"t          |dt          |           z             t#          | j                  }|j        j        |k    r"t	          |d| d|j        j         z             t          ||| j        d	dS )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)r9   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  r9   r  )r  r   r   _LegacyStorageRuntimeErrorr  r   __new__r   r~  r   collectionsabcSequencer   r;   r  r  r)  r   r   r9   )	rL   r  r9   r   r  r   arg_error_msg
cls_devicer   s	           r    r  zTypedStorage.__new__  s    	*')))%-...YZZZ,77??3'''  6 6 6  !"!EFG G G  "!DEF F F #t99q==&%9:; ; ; t99>>&a//>*TRSWVaVeVnBoBo>#%J4Q==JJKL L L $*23>BB"	$ $ $ $ t99>>&%))* * *
 ",0DEE k#%iUYZfUgUgiijk k k 5S^DD
&+z99&%@j @ @%1%8%=@ @@A A A
 $!-)"	$ $ $ $r#   )r   r9   r  r  c                ,   |st                       d}|t          |          dk    rt          |dz             |t          |dz             t          |t          j                  s"t          |dt          |           z             |t          |dz             || _        t          |t          j                  s"t          |dt          |           z             || _	        d S |t	          j
                    n|| _        t	          j        |dn|          }| j        t          j        t          j        t          j        t          j        t          j        fv r|j        d	k    rt          d
          t          |          dk    rt	          j        |          | _	        d S t          |          dk    rt#          |d                   rEt	          j        t%          |d                   |                                 z  |          | _	        d S t          |d         t(          j        j                  r#t/          |d         | j        |          | _	        d S t          |dt          |d                    z             t          |dz             )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   r>   /Cannot create CUDA storage with quantized dtyper   r   r  r  )r  r   r  r   r   r9   r   r;   r   rt  get_default_dtyper   rg  rh  ri  rf  re  r~  r   r!  r  r  r  rx  )r   r   r9   r  r  r   r  s          r    r!   zTypedStorage.__init__:  s    	*')))E 	 #4yyA~~"!%%& & &
 }"!:;< < < eU[11 R!P4;;PPQR R R !"!^_` ` ` DJlE,@AA g!eQUVbQcQceefg g g %1D!!! 7<m0222DJ\6>%%vFFFzelENENELZ_Zefff;&((&'XYYY4yyA~~(-(<F(K(K(K%%%Ta$q'?? L,1,@T!WPTPbPbPdPdAdms,t,t,tD)))Q)ABB L,FtAwPTPZ\b,c,cD)))#%J4Q==JJKL L L
 #!567 7 7r#   c                 H    t                       | j        j        j        dk    S rF  r  rt  r   r;   r&   s    r    rv   zTypedStorage.is_cuda~  s"    #%%%$+0F::r#   c                 H    t                       | j        j        j        dk    S rI  r  r&   s    r    rx   zTypedStorage.is_hpu  s"    #%%%$+0E99r#   c                 ,    t                       | j        S )z2Return the internal :class:`torch.UntypedStorage`.)r  rt  r&   s    r    r  zTypedStorage.untyped  s    #%%%$$r#   c                     t          |          t          j        k    sJ t          |           t          k    rt          || j        d          S  t          |           |          S )NTr  r  )r;   r   r   r  r9   )r   r  s     r    _new_wrapped_storagez!TypedStorage._new_wrapped_storage  sl    O$$(<<<<<::%%,j       
 4::?;;;;r#   c                 F    t                       |                                 S r   r  r  r&   s    r    r'   zTypedStorage.__len__      #%%%zz||r#   c                    ||r|                                  S dS t          |          t          k    r/t          dt          |            dt          |                     |rw||                                  k    s||                                   k     r't	          d| d|                                            |dk    r|S ||                                  z  S ||                                  k    s||                                   k     r't	          d| d|                                            ||                                  z  S )Nr   can't index a  with zindex z" out of range for storage of size )r  r;   r   r   
IndexErrorr8   )r   r*   is_stops      r    _maybe_wrap_indexzTypedStorage._maybe_wrap_index  sS   ; zz||#q CyyCBT$ZZBBtCyyBBD D D *$**,,&&C4::<<-,?,?$UUU		UUW W W77J--4::<<''SDJJLL=-@-@$UUU		UUW W WTZZ\\))r#   c                 J    t                       |                     ||          S r   )r  r  )r   r*   r  s      r    r-   zTypedStorage.__setitem__  s"    #%%%}}S%(((r#   c           
         t          |t          t          f          s/t          dt	          |            dt	          |                     t          j        |          rt          dt	          |                     | j        t
          j        t
          j	        t
          j
        t
          j        t
          j        fv rt
          j        t
          j        t
          j	        t
          j        t
          j
        t
          j        t
          j        t
          j        t
          j        t
          j        i}|| j                 }t          j        g || j        j                  }|                    t)          | j        |d                     n9t          j        g | j        | j        j                                      |           }|||<   d S )Nr  r  z cannot set item with value type r   Tr  )r   r   r  r  r;   r   
is_storager9   rg  rh  ri  rf  re  r   rs  r   r   rt  r   r   r  )r   r*   r  rv  	tmp_dtyperw  s         r    r  zTypedStorage._setitem  sl   #U|,, 	OMT

MM$s))MMNNNE"" 	QO$u++OOPPP:%,V[VabbbekekUZ  )4Ib	$BWB^___JOOL!2      ! ! ! !
 b
4CXC_```eefjkkJ
3r#   c                 H    t                       |                     |          S r   )r  _getitemr)   s     r    r+   zTypedStorage.__getitem__  s     #%%%}}S!!!r#   c           
         | j         j        j        dk    rt          d          t	          |t
                    rt          d          t	          |t                    s/t          dt          |            dt          |                     | j        t          j
        t          j        t          j        t          j        t          j        fv rt          j
        t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j        i}t%          | j         || j                 d                              |          S |                     |          }t          j        g | j        | j         j                                      |           }||                                         S )	Nr   rB  z7slices are only supported in UntypedStorage.__getitem__r  r  Tr  r   )rt  r   r;   rC  r   r  r  r   r9   r   rg  rh  ri  rf  re  r   rs  r   r  r  r  r   r   item)r   r*   rv  idx_wrappedrw  s        r    r  zTypedStorage._getitem  sr    ',66%&LMMM c5!! 	OXYYYC%% 	OMT

MM$s))MMNNN:%,V[VabbbekekUZ   !2&tz2      !).
 ,,S11\"DJt?T?[\\\aabfgg
+&++---r#   r.   r/   c                     t                       t          |t                    r!| j                            |j        |           n| j                            ||           | S r   )r  r   r  rt  r2   r1   s      r    r2   zTypedStorage.copy_  s]    #%%%fl++ 	>!''(?NNNN!''===r#   c                 F    t                       |                                 S r   )r  _nbytesr&   s    r    r6   zTypedStorage.nbytes  s    #%%%||~~r#   c                 4    | j                                         S r   )rt  r6   r&   s    r    r  zTypedStorage._nbytes   s    $++---r#   c                    t                       |V|                                 }||j        dz   |j        z   S d                    | j        t          |           j        g          S | j                            ||          S )Nr  )r  _get_legacy_storage_classr)  r(  r   r;   rt  )r   r9   r/   legacy_classs       r    r;   zTypedStorage.type  s}    #%%%=99;;L'#.4|7LLL88T_d4jj.ABCCC (--e\BBBr#   c                    t                       | j        t          j        t          j        t          j        t          j        t          j        fv rt          d           | j	        j
        ||fi |}|                     |          S )Nr  )r  r9   r   rg  rh  ri  rf  re  r  rt  r>   r  )r   r   r/   r   cuda_storages        r    r>   zTypedStorage.cuda  sv    #%%%:%,V[VabbbPQQQ-GT-B-GP\-g-g`f-g-g((666r#   c                    t                       | j        t          j        t          j        t          j        t          j        t          j        fv rt          d           | j	        j
        ||fi |}|                     |          S )Nz.Cannot create HPU storage with quantized dtype)r  r9   r   rg  rh  ri  rf  re  r  rt  r@   r  )r   r   r/   r   hpu_storages        r    r@   zTypedStorage.hpu  su    #%%%:%,V[VabbbOPPP,ED,A,Efl,e,e^d,e,e((555r#   c                 F    t                       |                                 S r   )r  r!  r&   s    r    rB   zTypedStorage.element_size  s     #%%%!!###r#   c                 J    t           j                            | j                  S r   )r   r   r!  r9   r&   s    r    r!  zTypedStorage._element_size#  s    |))$*555r#   c                 P    t                       | j                                        S r   )r  rt  rE   r&   s    r    rE   zTypedStorage.get_device&  s#    #%%%$//111r#   c           
      P    t                       dt          j                    d j         d j         dt                      d	} j        j        dk    rd|z   S dd	                     fd
t           	                                          D                       z   }|dz   |z   S )Nr   z(dtype=z	, device=r   r   r   r   r   r   c              3   B   K   | ]}t          |                   V  d S r   r   r   s     r    r   z'TypedStorage.__str__.<locals>.<genexpr>2  r   r#   r   )
r  r   r   r9   r   r   r;   r   r   r8   r   s   `  r    r   zTypedStorage.__str__*  s    #%%%:t$$ : :TZ : :k: :-0YY: : : 	 ;v%%X%%UZZ'Q'Q'Q'QeDIIKK>P>P'Q'Q'QQQQHd?X--r#   c                 <    t                       t          |           S r   )r  r   r&   s    r    r   zTypedStorage.__repr__5  s    #%%%4yyr#   c                      t                       t           fdt                                                     D                       S )Nc              3   (   K   | ]}|         V  d S r   r   r   s     r    r   z(TypedStorage.__iter__.<locals>.<genexpr>;  r   r#   )r  r   r   r8   r&   s   `r    r   zTypedStorage.__iter__9  sB    #%%%8888U499;;%7%7888888r#   c                 v    t                       |                     t          j        | j                            S r   )r  r  copyrt  r&   s    r    r   zTypedStorage.__copy__=  s/    #%%%((43H)I)IJJJr#   c                 H    t                       |                     |          S r   )r  	_deepcopyr   r   s     r    r   zTypedStorage.__deepcopy__A  s     #%%%~~d###r#   c                 \    |                      t          j        | j        |                    S r   )r  r  deepcopyrt  r  s     r    r  zTypedStorage._deepcopyF  s%    ((t7Ld)S)STTTr#   c                     t                       t                                                      |                                 z   S r   )r  r   r   r6   r   s    r    r   zTypedStorage.__sizeof__I  s2    #%%%ww!!##dkkmm33r#   c                 v    t                       |                     | j                                                  S )r   )r  r  rt  r   r&   s    r    r   zTypedStorage.cloneM  s1    #%%%(()>)D)D)F)FGGGr#   c                 <    t                       t          |           S r   )r  r   r&   s    r    r   zTypedStorage.tolistR  s    #%%%Dzzr#   c                 v    t                       |                     | j                                                  S )r   )r  r  rt  r   r&   s    r    r   zTypedStorage.cpuW  s1    #%%%(()>)B)B)D)DEEEr#   r>   r   c                 R    t                       | j                            |          S )zDetermine whether the CPU TypedStorage is already pinned on device.

        Args:
            device (str or torch.device): The device to pin memory on. Default: ``'cuda'``

        Returns:
            A boolean variable.
        )r  rt  r
  r  s     r    r
  zTypedStorage.is_pinned\  s'     	$%%%$..v666r#   c                 z    t                       |                     | j                            |                    S )zCopy 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'``.

        Returns:
            A pinned CPU storage.
        r   )r  r  rt  r  r  s     r    r  zTypedStorage.pin_memoryh  s9     	$%%%(()>)I)IQW)I)X)XYYYr#   c                 F    t                       |                                 S )r  )r  _share_memory_r&   s    r    r  zTypedStorage.share_memory_t  s     #%%%""$$$r#   c                 8    | j                                          | S r   )rt  r  r&   s    r    r  zTypedStorage._share_memory_z  s    ++---r#   r   c                    |d}t          j        |          }t           j                            ||                                 z  |          }t          || j        d          S )r  Nr   r   Tr  )r   r   r   r  r!  r  r9   )r   r8   r   r  s       r    r  zTypedStorage._new_shared~  sj    >Ff%%.::4$BTBTBVBV;V_e:ff(*   	r#   c                     | j         j        S r   )rt  r   r&   s    r    r   zTypedStorage._cdata  s    $++r#   c                 6    t                       | j        j        S r   )r  rt  r   r&   s    r    r   zTypedStorage.device  s    #%%%$++r#   c                 F    t                       |                                 S r   r  r&   s    r    r8   zTypedStorage.size  r  r#   c                 ^    | j                                         |                                 z  S r   )rt  r6   r!  r&   s    r    r  zTypedStorage._size  s*     $++--1C1C1E1EEEr#   c                 F    t                       |                                 S r   )r  _pickle_storage_typer&   s    r    pickle_storage_typez TypedStorage.pickle_storage_type  s     #%%%((***r#   c                     	 t                      | j                 S # t          $ r}t          d| j         d          |d }~ww xY w)Nzdtype z is not recognized)rj  r9   KeyError)r   es     r    r  z!TypedStorage._pickle_storage_type  s\    	K-//
;; 	K 	K 	KBDJBBBCCJ	Ks    
A>Ac                     t          j                    }t          j        | |d           t          |                                ffS r   r   r   s     r    r   zTypedStorage.__reduce__  r   r#   c                 F    t                       |                                 S r   )r  	_data_ptrr&   s    r    rG   zTypedStorage.data_ptr  s    #%%%~~r#   c                 4    | j                                         S r   )rt  rG   r&   s    r    r   zTypedStorage._data_ptr  s    $--///r#   c                 L    t                       |                     |           d S r   )r  _resize_rc   s     r    rd   zTypedStorage.resize_  s&    #%%%dr#   c                 d    | j                             ||                                 z             d S r   )rt  rd   r!  rc   s     r    r  zTypedStorage._resize_  s0    %%dT-?-?-A-A&ABBBBBr#   c                 $    t          j        |i |S r   )r   rt   rT   s      r    rt   zTypedStorage._free_weak_ref  s    ,d=f===r#   c                 &     | j         j        |i |S r   )rt  rf   r   s      r    rf   zTypedStorage._weak_ref  s    .t$.????r#   c                 8    t                        | j        |i |S r   )r  _from_bufferrT   s      r    rU   zTypedStorage.from_buffer  s&    #%%%s0000r#   r   c                   | t           k    rj|t          j                    n|}t          j        |dn|          }|j        dk    rt          d|j                   t          j        j        |d|i|}nT|t          |          dk    rt          d          |t          d          | j	        }t          j        j        |d|i|}t          ||d          S )	Nr   z3TypedStorage.from_buffer: Not available for device r9      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  r   r  r   r;   r  r   rU   r   r  )rL   r9   r   r   r   r  s         r    r  zTypedStorage._from_buffer  s    ,16E+---EE\6>%%vFFF{e##"#fY_Yd#f#fggg494H4TVZ4rbg4rkq4r4rOO  CIINN"NO O O !"NO O O JE#2>\E\U[\\O(   	r#   c                    t          |t          j                  st          dt	          |                     t          j        g | j        | j                                      |                               |          	                                }|
                                | 
                                k    r|                                }|S r   )r   r   r9   r   r;   r   r   r   r   r   rG   r   r   s      r    r   zTypedStorage._to  s    %-- 	XVeVVWWW,rDKHHHMMdSSVVW\]]llnn00mmooGr#   c                 \    t                       |                     t          j                  S r   )r  r   r   r   r&   s    r    r   zTypedStorage.double  "    #%%%xx%%%r#   c                 \    t                       |                     t          j                  S r   )r  r   r   r   r&   s    r    r   zTypedStorage.float  "    #%%%xx$$$r#   c                 \    t                       |                     t          j                  S r   )r  r   r   r   r&   s    r    r   zTypedStorage.half  "    #%%%xx
###r#   c                 \    t                       |                     t          j                  S r   )r  r   r   r   r&   s    r    r   zTypedStorage.long  r  r#   c                 \    t                       |                     t          j                  S r   )r  r   r   r   r&   s    r    r   zTypedStorage.int  s"    #%%%xx	"""r#   c                 \    t                       |                     t          j                  S r   )r  r   r   r   r&   s    r    r   zTypedStorage.short  r  r#   c                 \    t                       |                     t          j                  S r   )r  r   r   r   r&   s    r    r   zTypedStorage.char	  r  r#   c                 \    t                       |                     t          j                  S r   )r  r   r   r   r&   s    r    r   zTypedStorage.byte  r  r#   c                 \    t                       |                     t          j                  S r   )r  r   r   r   r&   s    r    r   zTypedStorage.bool  r  r#   c                 \    t                       |                     t          j                  S r   )r  r   r   r   r&   s    r    r   zTypedStorage.bfloat16  s"    #%%%xx'''r#   c                 \    t                       |                     t          j                  S r   )r  r   r   r   r&   s    r    r   zTypedStorage.complex_double  s"    #%%%xx&&&r#   c                 \    t                       |                     t          j                  S r   )r  r   r   r  r&   s    r    r  zTypedStorage.complex_float"  r  r#   c                 \    t                       |                     t          j                  S r  )r  r   r   r  r&   s    r    r  zTypedStorage.float8_e5m2'  s#    #%%%xx)***r#   c                 \    t                       |                     t          j                  S r  )r  r   r   r  r&   s    r    r  zTypedStorage.float8_e4m3fn,  s#    #%%%xx+,,,r#   c                     t                       | t          k    rt          d          t                              |||t
          j                            | j                  z            } | |          }|S )a  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 classesr  )	r  r  r  r   r|   r   r   r!  r9   )rL   rz   r{   r8   r  r   s         r    r|   zTypedStorage.from_file1  sx    ( 	$%%%,PQQQ*8*B*B5<--ci888+: +: #?333r#   c                 $    t          j        |i |S r   )r   r~   rT   s      r    r~   zTypedStorage._expiredO  s    &7777r#   c                 &     | j         j        |i |S r   )rt  ra   r   s      r    ra   zTypedStorage._write_fileS  s    0t$0$A&AAAr#   c                 &     | j         j        |i |S r   )rt  rh   r   s      r    rh   zTypedStorage._set_from_fileV      3t$3TDVDDDr#   c                 &     | j         j        |i |S r   )rt  rj   r   s      r    rj   zTypedStorage._set_cdataY  s    /t$/@@@@r#   c                 &     | j         j        |i |S r   )rt  rl   r   s      r    rl   zTypedStorage._share_cuda_\  s    1t$14B6BBBr#   c                 F    t                       |                                 S r   )r  
_is_sharedr&   s    r    rn   zTypedStorage.is_shared_  s    #%%%   r#   c                 4    | j                                         S r   )rt  rn   r&   s    r    r%  zTypedStorage._is_sharedd  s    $..000r#   c                 .    t          j        j        |i |S r   )r   r   rp   rT   s      r    rp   zTypedStorage._new_shared_cudag  s    #4dEfEEEr#   c                 b     | j         j        |i |\  }}}||||                                 z  fS r   )rt  rI   r!  )r   r   r   manager_handlestorage_handler8   s         r    rI   z!TypedStorage._share_filename_cpu_k  sC    /Yt/D/Y[_/jci/j/j,~tt7I7I7K7K/KKKr#   c                 8    | j                                          | S r   )rt  r_   r&   s    r    r_   zTypedStorage._shared_decrefo  s    ,,...r#   c                .    t          j        j        |i |S r   r   r   r[   )rL   r   r   r   s       r    _release_ipc_counterz!TypedStorage._release_ipc_counters      #=tNvNNNr#   c                 &     | j         j        |i |S r   )rt  rr   r   s      r    rr   zTypedStorage._shared_increfw  r!  r#   c                 ^     | j         j        |i |\  }}|||                                 z  fS r   )rt  rK   r!  )r   r   r   fdr8   s        r    rK   zTypedStorage._share_fd_cpu_z  s<    74(7HHHD44--/////r#   c                 p   | j         t                      vrd S t                      | j                  }| j        j        ddt          j                                        fvrd S | j        j        dk    rt          nt          t          | j        j                  }	 t          ||          S # t          $ r Y d S w xY w)Nr   r>   )	r9   rj  r   r;   r   r  r  getattrAttributeError)r   storage_namer  s      r    r  z&TypedStorage._get_legacy_storage_class~  s    :799994133DJ?;E6583Y3Y3[3[#\\\4+*e33HX9Y9Y	6<000 	 	 	44	s   B' '
B54B5)Fr   r&  r'  )br(  r)  r*  r   r   r9   r+  r.  r  r,  r   rz   r  r  r!   rv   rx   r  r  r'   r  r-   r  r+   r  r   r   r2   r6   r  r   r;   r>   r@   rB   r!  r   rE   r   r   r   r   r   r  r   r   r   r   r   r
  r  r  r  r  r   r8   r  r  r  r   rG   r   rd   r  r-  rt   rf   rU   r  r   r   r   r   r   r   r   r   r   r   r  r  r  r|   r~   ra   rh   rj   rl   rn   r%  rp   rI   r_   r.  rr   rK   r  r/  r0  s   @r    r  r    s<        I;  X .)C. . . . X.
  
 *.T$RW F$ F$ F$ F$ F$ F$ F$P &*DTY B7 B7 B7 B7 B7H ; ; X; : : X:% % %
	< 	< 	<  * * * *2) ) )     0" " ". . .< A Yt_      
. . .C C)C. Ct CPUVWY\V\P] C C C C7 7 7 7 7 76 6 6 6 6 6$ $ $
6 6 62C 2 2 2 2	. 	. 	.  9 9 9K K K$ $ $
U U U4 4 4 4 4H H H
  
F F F

7 
7c5<&7 8 
7 
7 
7 
7
Z 
ZsEL'8!9 
Z 
Z 
Z 
Z% % %   +/ 	 	 	 	 	 , , X, , , X,  
F F F
+ + +
K K K3 3 3
     
0 0 0  
C C C > > [>@ @ @ 1 1 [1 '+D     [4  & & &
% % %
$ $ $
$ $ $
# # #
% % %
$ $ $
% % %
$ $ $
( ( (
' ' '
& & &
+ + +
- - -
   [: 8 8 [8B B BE E EA A AC C C! ! !
1 1 1 F F [FL L L   04 O O O O [OE E E0 0 0      r#   r  c                   *    e Zd ZU ej        ed<   d ZdS )_LegacyStorageMetar9   c                     t          |          t          k    r4t          | j                  }||j        j         k    o| j        |j        k    S dS r&  )r;   r  r  r)  r   r9   )rL   instancer  s      r    __instancecheck__z$_LegacyStorageMeta.__instancecheck__  sE    >>\))0@@J(/"66YSY(.=XYur#   N)r(  r)  r*  r   r9   r+  r;  r   r#   r    r8  r8    s3         ;    r#   r8  c                   P    e Zd Zed             Zed             Zed             ZdS )r  c                     t           j                            | |                                             z            } | |          S )r  r  )r   r   r  r!  )rL   r8   r  s      r    r  z_LegacyStorage._new_shared  sD      .::4##%%BUBUBWBW;WXXs0000r#   c                 .    t          j        j        |i |S r   r-  rT   s      r    r.  z#_LegacyStorage._release_ipc_counter  r/  r#   c                     |t           j                            | j                  z  } | t           j                            |||                    S )Nr  )r   r   r!  r9   r   rY   )rL   rW   rX   r8   
bytes_sizes        r    _new_shared_filenamez#_LegacyStorage._new_shared_filename  sH    EL66syAAA
s 4 M MgWZ\f g ghhhhr#   N)r(  r)  r*  r-  r  r.  rA  r   r#   r    r  r    sk        1 1 [1
 O O [O i i [i i ir#   r  )	metaclassr  c                 x    	 t                      |          S # t          $ r}t          d|  d          |d }~ww xY w)Nzpickle storage type "z" is not recognized)rq  r  )r  r  s     r    #_get_dtype_from_pickle_storage_typerD    sd    U)++,?@@ U U UL$7LLLN NST	UUs    
949)r  )<r   r   r   r   r   r   torch.typesr   typingr   r	   r
   _Dictr   r,  r   r   r   r  r  r=  r   r  r4  numpyr{  rz  ModuleNotFoundErrorLockr3  r   r   r5  r+  r   r   r?  r  StorageBaser   r   r;   r>   r@   rj  rq  rx  r~  r  r  r  r  r  r   r  r  __doc__r8  r  rD  r   r#   r    <module>rM     s   					  & & & & & & & & & &       X X X X X X X X X X X X X X X X X X                    II   	BBB $Y^%% 13 5io-. 3 3 3GC:;;;w" w" w" w" w" w" w" w"t     D== == == == ==UX)< == == ==~% % %     4  4 4  
8 8 8," " " &+ ". . .5 5 5
B B B B&? ? ?C    n
 n
 n
 n
 n
 n
 n
 n
` "M  !M  <         i i i i i\-? i i i i US U U U U U Us   A AA