
    IЦi                       % 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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"\RH                  " 5       r%0 r&S\'S'   \" SSS9r( " S S5      r)S r* " S S	\RV                  RX                  \)5      r-S r.\R^                  " SS9S 5       r0\R^                  " SS9S 5       r1\R^                  " SS9S 5       r2S r3S r4Sq5S r6S r7S(S jr8S r9S)S  jr: " S! S5      r;\Rx                  \;Rz                  l<        \)R|                  Rx                  \;R|                  l<        \)R~                  Rx                  \;R~                  l<        \Rx                  \;R                  l<         " S" S#\=5      rA " S$ S%\;\AS&9rBS*S' jrCg! \# a    Sr"Sr! GN^f = f)+    )annotationsN)AnycastDictOptionalType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 jr	S r
S rS]S^S jjrS_S jrS\S jrS\S jr S`     SaS jjr S` S_S jjrS`S_S jjrS\S jrS\S jrS\S jrSbS jrS rS r\ScS j5       r\ScS j5       r\SdS  j5       r\S
S
S!.   SdS" jj5       r\SdS# j5       r\SdS$ j5       rS_S% jr S& r!SeS' jr"S_S( jr#S) r$S* r%S+ r&SbS, jr'\SdS- j5       r(S. r)\S/ 5       r*\+S0 5       r,\+S1 5       r-\S_S2 j5       r.\S_S3 j5       r/S4 r0SfS5 jr1S6 r2S7 r3S8 r4S9 r5S: r6U 4S; jr7S< r8S= r9S> r:S? r;S@ r<SSA.SgSB jjr=SC r>SD r?SE r@SF rASG rBSH rCSI rDSJ rESK rFSL rGSM rHSN rISO rJSP rKSQ rLSR rMShSiSS jjrNShSiST jjrOSU rP\SVSW.SX j5       rQSY rRSZ rSS[rTU =rU$ )j_StorageBase2   r   _cdataFr   	is_sparseis_sparse_csrztorch.devicedeviceN_Optional[torch.device]_fake_devicec                    g N selfargskwargss      L/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/torch/storage.py__init___StorageBase.__init__:   s        c                    [         er#   NotImplementedErrorr&   s    r)   __len___StorageBase.__len__=       !!r,   c                    [         er#   r.   r&   idxs     r)   __getitem___StorageBase.__getitem__@   r3   r,   c                    [         er#   r.   r%   s      r)   __setitem___StorageBase.__setitem__C   r3   r,   c                    [         er#   r.   r&   sourcenon_blockings      r)   copy__StorageBase.copy_F   r3   r,   c                    [         er#   r.   r0   s    r)   new_StorageBase.newI   r3   r,   c                    [         er#   r.   r0   s    r)   nbytes_StorageBase.nbytesL   r3   r,   c                "    U R                  5       $ r#   )rF   r0   s    r)   size_StorageBase.sizeO   s    {{}r,   c                    [        XU5      $ r#   )r   )r&   dtyper?   s      r)   type_StorageBase.typeR   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)   rP   _StorageBase.cudaW   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.
hpurQ   rR   rU   s       r)   rY   _StorageBase.hpuh   s2     28%,,uf-U\\%=PwwgwAAr,   c                    [         er#   r.   r0   s    r)   element_size_StorageBase.element_sizew   r3   r,   c                .    U R                   R                  $ r#   )r   indexr0   s    r)   
get_device_StorageBase.get_devicez   s    {{   r,   c                    [         er#   r.   r0   s    r)   data_ptr_StorageBase.data_ptr}   r3   r,   c                    [         er#   r.   r0   s    r)   	resizable_StorageBase.resizable   r3   r,   c                    [         er#   r.   r%   s      r)   _share_filename_cpu_!_StorageBase._share_filename_cpu_   r3   r,   c                    [         er#   r.   r%   s      r)   _share_fd_cpu__StorageBase._share_fd_cpu_   r3   r,   c                    [         er#   r.   clsrI   s     r)   _new_using_filename_cpu$_StorageBase._new_using_filename_cpu       !!r,   c                    [         er#   r.   ro   s     r)   _new_using_fd_cpu_StorageBase._new_using_fd_cpu   rs   r,   c                    [         er#   r.   rp   r'   r(   s      r)   from_buffer_StorageBase.from_buffer   rs   r,   )r   rL   c                   [         er#   r.   )rp   managerobjrI   r   rL   s         r)   _new_shared_filename_cpu%_StorageBase._new_shared_filename_cpu   s
     "!r,   c                    [         er#   r.   rx   s      r)   _release_ipc_counter_cuda&_StorageBase._release_ipc_counter_cuda   rs   r,   c                    [         er#   r.   rx   s      r)   _new_with_weak_ptr_StorageBase._new_with_weak_ptr   rs   r,   c                    [         er#   r.   r0   s    r)   _shared_decref_StorageBase._shared_decref   r3   r,   c                    [         er#   r.   r%   s      r)   _write_file_StorageBase._write_file   r3   r,   c                    [         er#   r.   r&   rI   s     r)   resize__StorageBase.resize_   r3   r,   c                    [         er#   r.   r%   s      r)   	_weak_ref_StorageBase._weak_ref   r3   r,   c                    [         er#   r.   r%   s      r)   _set_from_file_StorageBase._set_from_file   r3   r,   c                    [         er#   r.   r%   s      r)   
_set_cdata_StorageBase._set_cdata   r3   r,   c                    [         er#   r.   r%   s      r)   _share_cuda__StorageBase._share_cuda_   r3   r,   c                    [         er#   r.   r0   s    r)   	is_shared_StorageBase.is_shared   r3   r,   c                    [         er#   r.   rx   s      r)   _new_shared_cuda_StorageBase._new_shared_cuda   rs   r,   c                    [         er#   r.   r%   s      r)   _shared_incref_StorageBase._shared_incref   r3   r,   c                    [         er#   r.   rx   s      r)   _free_weak_ref_StorageBase._free_weak_ref   rs   r,   c                    [         er#   r.   r0   s    r)   is_cuda_StorageBase.is_cuda   rs   r,   c                    [         er#   r.   r0   s    r)   is_hpu_StorageBase.is_hpu   rs   r,   c                    [         er#   r.   )rp   filenamesharedrF   s       r)   	from_file_StorageBase.from_file   rs   r,   c                    [         er#   r.   rx   s      r)   _expired_StorageBase._expired   rs   r,   c                    [         er#   r.   r%   s      r)   	_byteswap_StorageBase._byteswap   r3   r,   c                    [         er#   r.   r%   s      r)   _get_filename_StorageBase._get_filename   r3   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   
)rS   typenamer   lenrM   joinrangerI   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   rI   r0   s   `r)   __iter___StorageBase.__iter__   s    8U499;%7888r,   c                "    U R                  5       $ r#   )cloner0   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$ )NrS   )
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BytesIOrS   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__rI   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   )rM   rF   r   r@   r0   s    r)   r   _StorageBase.clone   s(    Dz$++-<BB4HHr,   c                    [        U 5      $ z6Return a list containing the elements of this storage.)listr0   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   rM   rS   r   rI   r@   r0   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	  r0   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 rL   r   )
isinstancerS   rL   	TypeErrorrM   tensoruint8r   set_r   r   rT   _typed_storagerc   r   r&   rL   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  rS   r   r   )r&   r   r?   s      r)   rT   _StorageBase.to!  s.    &%,,//\\&)F4..r,   c                @    U R                  [        R                  5      $ z"Casts this storage to double type.)r   rS   doubler0   s    r)   r  _StorageBase.double&      xx%%r,   c                @    U R                  [        R                  5      $ z!Casts this storage to float type.)r   rS   floatr0   s    r)   r$  _StorageBase.float*      xx$$r,   c                @    U R                  [        R                  5      $ z Casts this storage to half type.)r   rS   halfr0   s    r)   r)  _StorageBase.half.      xx

##r,   c                @    U R                  [        R                  5      $ z Casts this storage to long type.)r   rS   longr0   s    r)   r.  _StorageBase.long2  r+  r,   c                @    U R                  [        R                  5      $ zCasts this storage to int type.)r   rS   intr0   s    r)   r2  _StorageBase.int6  s    xx		""r,   c                @    U R                  [        R                  5      $ z!Casts this storage to short type.)r   rS   shortr0   s    r)   r6  _StorageBase.short:  r&  r,   c                @    U R                  [        R                  5      $ z Casts this storage to char type.)r   rS   int8r0   s    r)   char_StorageBase.char>  r+  r,   c                @    U R                  [        R                  5      $ z Casts this storage to byte type.)r   rS   r  r0   s    r)   byte_StorageBase.byteB  r&  r,   c                @    U R                  [        R                  5      $ z Casts this storage to bool type.)r   rS   boolr0   s    r)   rC  _StorageBase.boolF  r+  r,   c                @    U R                  [        R                  5      $ z$Casts this storage to bfloat16 type.)r   rS   bfloat16r0   s    r)   rG  _StorageBase.bfloat16J  s    xx''r,   c                @    U R                  [        R                  5      $ z*Casts this storage to complex double type.)r   rS   cdoubler0   s    r)   complex_double_StorageBase.complex_doubleN  s    xx&&r,   c                @    U R                  [        R                  5      $ z)Casts this storage to complex float type.)r   rS   cfloatr0   s    r)   complex_float_StorageBase.complex_floatR  r!  r,   c                @    U R                  [        R                  5      $ z&Casts this storage to float8_e5m2 type)r   rS   float8_e5m2r0   s    r)   rU  _StorageBase.float8_e5m2V  s    xx))**r,   c                @    U R                  [        R                  5      $ z(Casts this storage to float8_e4m3fn type)r   rS   float8_e4m3fnr0   s    r)   rY  _StorageBase.float8_e4m3fnZ  s    xx++,,r,   c                @    U R                  [        R                  5      $ z*Casts this storage to float8_e5m2fnuz type)r   rS   float8_e5m2fnuzr0   s    r)   r]  _StorageBase.float8_e5m2fnuz^      xx--..r,   c                @    U R                  [        R                  5      $ z*Casts this storage to float8_e4m3fnuz type)r   rS   float8_e4m3fnuzr0   s    r)   rb  _StorageBase.float8_e4m3fnuzb  r_  r,   c                    [         R                  " / [         R                  U R                  S9R	                  [        [        U 5      5      R                  U5      $ )zDetermine whether the CPU storage is already pinned on device.

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

Returns:
    A boolean variable.
r  )rS   r  r  r   r  r   r   	is_pinnedr&   r   s     r)   re  _StorageBase.is_pinnedf  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       $ )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   rM   r  rS   r  r  r  r   r   
pin_memoryuntyped_storage)r&   r   pinned_tensors      r)   ri  _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_strategyrP   file_system)	torch.multiprocessingrp  r   rM   rS   _C_get_privateuse1_backend_nameri   rl   )r&   rp  s     r)   share_memory__StorageBase.share_memory_  sf    >;;(N(N(PQQ
 	 "#}4%%'  !r,   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   ro  rP   rY   r   rq  )	rr  rp  rS   r   rM   rs  rt  rq   ru   )rp   rI   r   rp  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$   r0   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)rS   _utils_element_size
is_complexmaxr2  r   )r&   rL   	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)rL   _Optional[str]r?   r   r  r   )r  r   )rp   Type[T]rI   r   r  r   )rp   r  r  r   )rI   r   r  r  )r   r   r?   r   rP   r   zUnion[str, torch.device])V__name__
__module____qualname____firstlineno____annotations__r   r   r!   r*   r1   r7   r:   r@   rC   rF   rI   rM   rP   rY   r\   r`   rc   rf   ri   rl   classmethodrq   ru   ry   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   rT   r  r$  r)  r.  r2  r6  r;  r?  rC  rG  rL  rQ  rU  rY  r]  rb  re  ri  ru  ry  r|  r  __static_attributes____classcell__r   s   @r)   r   r   2   s   KIu M5 ,0L)0"""""" CH0#0:?0	*0 ).B	*B"B"!"""" " " " " " "  	"	" 
	" 	" " " " """"""""" " "" " " " " " " " " " """*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   rM   r/   r   r7   r&   r'   r(   r   s      r)   r7   UntypedStorage.__getitem__  s6    ;;v%%&LMMw"D3F33r,   c                4    U R                   R                  S:H  $ NrP   r   rM   r0   s    r)   r   UntypedStorage.is_cuda  s    {{6))r,   c                4    U R                   R                  S:H  $ NrY   r  r0   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   r0   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   ru  r  s      r)   ru  UntypedStorage.share_memory_  s    B w$d5f55r,   c                $   > [         TU ]  " U0 UD6$ r#   )r   rl   r  s      r)   rl   UntypedStorage._share_fd_cpu_  s    w%t6v66r,   c                $   > [         TU ]  " U0 UD6$ r#   )r   ri   r  s      r)   ri   #UntypedStorage._share_filename_cpu_  s    w+T<V<<r,   r$   r  )r  r  r  r  r7   r  r   r   r   r  ru  rl   ri   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)rS   loadr   r   )r   s    r)   r   r     s    ::bjjm%88r,   )maxsizec                    [         R                  [         R                  [         R                  [         R                  [         R
                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  1$ r#   )rS   rU  rY  r]  rb  bits8bits16bits1x8bits2x4bits4x2	complex32uint16uint32uint64r$   r,   r)   _new_dtypesr    sq    
 	 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)rS   r  r$  r)  r.  r2  int16r:  r  rC  rG  rK  rP  qint8qint32quint8quint4x2quint2x4r$   r,   r)   _dtype_to_storage_type_mapr  -  s   o^ 	

M 	

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

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

M 	) 	- 	+ 	^ 	o 	o  	)!" 	)# r,   c                 j    [        5       R                  5        V Vs0 s H  u  pX_M	     nn nU$ s  snn f r#   )r  items)r  val	dtype_maps      r)   _storage_type_to_dtype_mapr  I  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  )rS   r  r  r  r  r  r  int32r:  r  r  _untyped_storage)sequencerL   r   interpret_dtypes
tmp_tensors        r)   _get_storage_from_sequencer  O  s      LL%++NNEKKNNEKKLL%++KK
 \\U3F


 \\(G
$$&777r,   c                x    [         (       a   [        U [        [        R                  45      $ [        U [        5      $ r#   )	HAS_NUMPYr  r2  npinteger)xs    r)   _isintr  h  s*    y!c2::.//!S!!r,   c                     [         $ r#   )"_always_warn_typed_storage_removalr$   r,   r)   &_get_always_warn_typed_storage_removalr  r  s    --r,   c                6    [        U [        5      (       d   eU qg r#   )r  rC  r  )always_warns    r)   &_set_always_warn_typed_storage_removalr  v  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  rP   rY   r  )rsplitrS   rs  rt  )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.dtyperL   c                    U R                   $ r#   )rL   r0   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   r0   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_storagerL   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)rL   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"  rL   r#  )r  rS   r  _LegacyStorageRuntimeErrorr   r   __new__r   r  r  collectionsabcSequencer  rM   r  r  r  r   r   rL   )	rp   r"  rL   r   r#  r'   arg_error_msg
cls_devicer   s	           r)   r,  TypedStorage.__new__  s'    ')%--...J  ,7?3'' % 6 6  !"!$UU   "!$TT  #t9q=&%(II 
 IN"47OO&tAw0H0HII#%<T$q']OLM 
 $**23>>B"	  t9>&%))  ",0D0DEE#%VW[\hWiVjkl 
 5S^^D
&&++z9&%?
|$\%8%8%=%=$>@@  $!-))"	 r,   )r   rL   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  rP   /Cannot create CUDA storage with quantized dtyper   r  r&  r%  )r  r   r+  r  rS   rL   r  rM   r   r  get_default_dtyper   r  r  r  r  r  r  r2  r  r-  r.  r/  r  )r&   r   rL   r"  r#  r'   r0  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   rM   r0   s    r)   r   TypedStorage.is_cudai  s%    #%$$++00F::r,   c                \    [        5         U R                  R                  R                  S:H  $ r  r8  r0   s    r)   r   TypedStorage.is_hpun  s%    #%$$++00E99r,   c                .    [        5         U R                  $ )z2Return the internal :class:`torch.UntypedStorage`.)r  r  r0   s    r)   r|  TypedStorage.untypeds  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"  )rM   rS   r   r   r   r   rL   )r&   rj  s     r)   _new_wrapped_storage!TypedStorage._new_wrapped_storagex  sY    O$(<(<<<<:%!0

d  :?;;r,   c                6    [        5         U R                  5       $ r#   r  r  r0   s    r)   r1   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  rM   r2  r  
IndexErrorrI   )r&   r6   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&   r6   r  s      r)   r:   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 )NrG  rH  z cannot set item with value type r  Tr)  )r  r2  r  r+  rM   rS   
is_storagerL   r  r  r  r  r  r  r  r:  r  r  r   r  r   )r&   r6   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  _getitemr5   s     r)   r7   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__rG  rH  Tr)  r   )unset_fake_temporarilyr  )r  r   rM   r/   r  r  r+  r2  rL   rS   r  r  r  r  r  r  r  r:  r   rT  rK  torch._subclasses.fake_tensorrW  r  r  item)r&   r6   r  idx_wrappedrW  r  s         r)   rT  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  _nbytesr0   s    r)   rF   TypedStorage.nbytes  s    #%||~r,   c                6    U R                   R                  5       $ r#   )r  rF   r0   s    r)   r_  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   rM   r  )r&   rL   r?   legacy_classs       r)   rM   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      $ )Nr4  )r  rL   rS   r  r  r  r  r  r+  r  rP   r@  )r&   r   r?   cuda_storages       r)   rP   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  rL   rS   r  r  r  r  r  r+  r  rY   r@  )r&   r   r?   hpu_storages       r)   rY   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 dtyperQ   )r  r  rS   r   rL   r  r  r  r  r  r+  rM   upperr  rT   r@  )r&   r   r?   
to_storages       r)   rT   TypedStorage.to5  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  r0   s    r)   r\   TypedStorage.element_sizeF  s    #%!!##r,   c                T    [         R                  R                  U R                  5      $ r#   )rS   r  r  rL   r0   s    r)   r  TypedStorage._element_sizeK  s    ||))$**55r,   c                J    [        5         U R                  R                  5       $ r#   )r  r  r`   r0   s    r)   r`   TypedStorage.get_deviceN  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  rS   r   rL   r   r   rM   r   r   rI   r   s   `  r)   __str__TypedStorage.__str__R  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   r0   s    r)   r   TypedStorage.__repr__^  s    #%4yr,   c                p   ^  [        5         [        U 4S j[        T R                  5       5       5       5      $ )Nc              3  .   >#    U  H
  nTU   v   M     g 7fr#   r$   r   s     r)   r   (TypedStorage.__iter__.<locals>.<genexpr>d  r   r   )r  r   r   rI   r0   s   `r)   r   TypedStorage.__iter__b  s%    #%8U499;%7888r,   c                t    [        5         U R                  [        R                  " U R                  5      5      $ r#   )r  r@  copyr  r0   s    r)   r   TypedStorage.__copy__f  s(    #%((43H3H)IJJr,   c                8    [        5         U R                  U5      $ r#   )r  	_deepcopyr&   r   s     r)   r   TypedStorage.__deepcopy__j  s    #%~~d##r,   c                b    U R                  [        R                  " U R                  U5      5      $ r#   )r@  r  deepcopyr  r  s     r)   r  TypedStorage._deepcopyo  s$    ((t7L7Ld)STTr,   c                V   > [        5         [        TU ]	  5       U R                  5       -   $ r#   )r  r   r   rF   r   s    r)   r   TypedStorage.__sizeof__r  s"    #%w!#dkkm33r,   c                h    [        5         U R                  U R                  R                  5       5      $ )r   )r  r@  r  r   r0   s    r)   r   TypedStorage.clonev  s(    #%(()>)>)D)D)FGGr,   c                ,    [        5         [        U 5      $ r  )r  r  r0   s    r)   r  TypedStorage.tolist{  s    #%Dzr,   c                h    [        5         U R                  U R                  R                  5       5      $ )r  )r  r@  r  r  r0   s    r)   r  TypedStorage.cpu  s(    #%(()>)>)B)B)DEEr,   c                L    [        5         U R                  R                  U5      $ )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  r  re  rf  s     r)   re  TypedStorage.is_pinned  s!     	$%$$..v66r,   c                f    [        5         U R                  U R                  R                  US95      $ )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@  r  ri  rf  s     r)   ri  TypedStorage.pin_memory  s4     	$%((!!,,F,;
 	
r,   c                6    [        5         U R                  5       $ )rn  )r  _share_memory_r0   s    r)   ru  TypedStorage.share_memory_  s    #%""$$r,   c                :    U R                   R                  5         U $ r#   )r  ru  r0   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$ )rx  r  r   Tr)  )rS   r   r   ry  r  r   rL   )r&   rI   r   rj  s       r)   ry  TypedStorage._new_shared  s^    >Ff%..::%%'' ; 
 (

d
 	
r,   c                .    U R                   R                  $ r#   )r  r   r0   s    r)   r   TypedStorage._cdata  s    $$+++r,   c                B    [        5         U R                  R                  $ r#   )r  r  r   r0   s    r)   r   TypedStorage.device  s    #%$$+++r,   c                6    [        5         U R                  5       $ r#   rC  r0   s    r)   rI   TypedStorage.size  rE  r,   c                X    U R                   R                  5       U R                  5       -  $ r#   )r  rF   r  r0   s    r)   r  TypedStorage._size  s'     $$++-1C1C1EEEr,   c                6    [        5         U R                  5       $ r#   )r  _pickle_storage_typer0   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  rL   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_ptrr0   s    r)   rc   TypedStorage.data_ptr  s    #%~~r,   c                6    U R                   R                  5       $ r#   )r  rc   r0   s    r)   r  TypedStorage._data_ptr  s    $$--//r,   c                J    [        5         U R                  R                  5       $ r#   )r  r  rf   r0   s    r)   rf   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   rx   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_bufferrx   s      r)   ry   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 rL      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   rS   r5  r   rM   r+  r   ry   r   r  )rp   rL   r   r'   r(   rj  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  rS   rL   r  rM   r  r   r  rT   r  rc   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   rS   r  r0   s    r)   r  TypedStorage.double%      #%xx%%r,   c                T    [        5         U R                  [        R                  5      $ r#  )r  r   rS   r$  r0   s    r)   r$  TypedStorage.float*      #%xx$$r,   c                T    [        5         U R                  [        R                  5      $ r(  )r  r   rS   r)  r0   s    r)   r)  TypedStorage.half/      #%xx

##r,   c                T    [        5         U R                  [        R                  5      $ r-  )r  r   rS   r.  r0   s    r)   r.  TypedStorage.long4  r  r,   c                T    [        5         U R                  [        R                  5      $ r1  )r  r   rS   r2  r0   s    r)   r2  TypedStorage.int9  s    #%xx		""r,   c                T    [        5         U R                  [        R                  5      $ r5  )r  r   rS   r6  r0   s    r)   r6  TypedStorage.short>  r  r,   c                T    [        5         U R                  [        R                  5      $ r9  )r  r   rS   r:  r0   s    r)   r;  TypedStorage.charC  r  r,   c                T    [        5         U R                  [        R                  5      $ r>  )r  r   rS   r  r0   s    r)   r?  TypedStorage.byteH  r  r,   c                T    [        5         U R                  [        R                  5      $ rB  )r  r   rS   rC  r0   s    r)   rC  TypedStorage.boolM  r  r,   c                T    [        5         U R                  [        R                  5      $ rF  )r  r   rS   rG  r0   s    r)   rG  TypedStorage.bfloat16R  s    #%xx''r,   c                T    [        5         U R                  [        R                  5      $ rJ  )r  r   rS   rK  r0   s    r)   rL  TypedStorage.complex_doubleW  s    #%xx&&r,   c                T    [        5         U R                  [        R                  5      $ rO  )r  r   rS   rP  r0   s    r)   rQ  TypedStorage.complex_float\  r  r,   c                T    [        5         U R                  [        R                  5      $ rT  )r  r   rS   rU  r0   s    r)   rU  TypedStorage.float8_e5m2a  s    #%xx))**r,   c                T    [        5         U R                  [        R                  5      $ rX  )r  r   rS   rY  r0   s    r)   rY  TypedStorage.float8_e4m3fnf  s    #%xx++,,r,   c                T    [        5         U R                  [        R                  5      $ r\  )r  r   rS   r]  r0   s    r)   r]  TypedStorage.float8_e5m2fnuzk      #%xx--..r,   c                T    [        5         U R                  [        R                  5      $ ra  )r  r   rS   rb  r0   s    r)   rb  TypedStorage.float8_e4m3fnuzp  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 classesr?  )	r  r   r+  r   r   rS   r  r  rL   )rp   r   r   rI   rj  r  s         r)   r   TypedStorage.from_fileu  s\    ( 	$%,PQQ(22dU\\%?%?		%JJ
 ?3r,   c                .    [         R                  " U0 UD6$ r#   )r   r   rx   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_sharedr0   s    r)   r   TypedStorage.is_shared  s    #%  r,   c                6    U R                   R                  5       $ r#   )r  r   r0   s    r)   r  TypedStorage._is_shared  s    $$..00r,   c                B    [         R                  R                  " U0 UD6$ r#   )rS   r   r   rx   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  ri   r  )r&   r'   r(   manager_handlestorage_handlerI   s         r)   ri   !TypedStorage._share_filename_cpu_  sB    
 !!66GG		
t7I7I7K/KKKr,   c                :    U R                   R                  5         U $ r#   )r  r   r0   s    r)   r   TypedStorage._shared_decref  s    ,,.r,   c               B    [         R                  R                  " U0 UD6$ r#   rS   r   r   )rp   r   r'   r(   s       r)   _release_ipc_counter!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  rl   r  )r&   r'   r(   fdrI   s        r)   rl   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  rP   rY   )	rL   r  r   rM   rS   rs  rt  getattrAttributeError)r&   storage_namer  s      r)   rd  &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  rL   r  )r  r   )Fr#   )r>   r   r?   z_Optional[bool]r  )rL   r  r?   rC  r  z&Union[_StorageBase, TypedStorage, str])r   r   r?   rC  r  r   r  r  r  )cr  r  r  r  r   r  r!   r  r  r   r   r,  r*   r   r   r|  r@  r1   rK  r:   r  r7   rT  r@   rF   r_  rM   rP   rY   rT   r\   r  r`   rz  r   r   r   r   r  r   r   r  r  re  ri  ru  r  ry  r   r   rI   r  r  r  r   rc   r  rf   r   r  r  r   r   ry   r  r   r  r$  r)  r.  r2  r6  r;  r?  rC  rG  rL  rQ  rU  rY  r]  rb  r   r   r   r   r   r   r   r  r   ri   r   r	  r   rl   rd  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  rL   c                    [        U5      [        :X  aM  [        U R                  5      nX!R                  R                   :H  =(       a    U R
                  UR
                  :H  $ gr  )rM   r   r  r  r   rL   )rp   instancer1  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$ )rx  r?  )rS   r   ry  r  )rp   rI   rj  s      r)   ry  _LegacyStorage._new_shared  s5      ..::4#%BUBUBW;WX00r,   c                B    [         R                  R                  " U0 UD6$ r#   r  rx   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$ )Nr?  )rS   r  r  rL   r   r~   )rp   r|   r}   rI   
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  ry  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   )D
__future__r   r-  r  r  r   r  r  typingr   r   r   _Dictr   	_Optionalr   r	   r
   r   typing_extensionsr   rS   torch._utilsr   r   torch.typesr   r   r   torch._prims_commonr   __all__numpyr  r  ModuleNotFoundErrorLockr  r   r  r   r   r  rs  StorageBaser   r   	lru_cacher  r  r  r  r  r  r  r  r  r  r  r   __doc__rM   rP   rY   rT   r  r*  r'  r$   r,   r)   <module>r7     s   #    	  	 	 	 #  # , , 2 +
,I ^^% 13 . 3C:;x" x"v!H@=UXX))< @=F9 T" #( T" #6 T" #
82" &+ ".5B(?~ ~B "MM   (--55   '++33   ++ 	 	
\-? 
*{.  I	Bs   "F9 9
GG