
    [Th                     V    S SK Jr  S SKJr  S SKJrJr  S SKJr  \ " S S5      5       r	g)    )	dataclass)reduce)OptionalUnion)_remote_devicec            
           \ rS rSr% Sr/ SQr\\   \S'   \\   \S'   \	\
   \S'    SS\\   S\\   S\	\\\
4      4S jjrS	 rS
rg)ShardMetadata	   a  
Represents a shard of the overall Tensor including its
offsets, lengths and device placement.

Args:
    shard_offsets(List[int]): Offsets in the original tensor indicating
        the start offsets for this shard. Should have the same rank as
        the original tensor.
    shard_sizes(List[int]): Integers indicating the size of each
        dimension for this shard. Should have the same rank as the
        original tensor.
    placement(:class:`torch.distributed._remote_device`):
        Specifies the placement of this shard.
)shard_offsetsshard_sizes	placementr   r   r   Nc                    Xl         X l        [        U[        5      (       a  [	        U5      U l        OX0l        [        U R                   5      [        U R                  5      :w  a/  [        S[        U R                   5       SU R                   S35      e[        [        U R                   5      5       H?  nU R                   U   S:  a  [        S5      eU R                  U   S:  d  M6  [        S5      e   g )NzMshard_offsets and shard_sizes should have the same number of elements, found z and z respectivelyr   zshard_offsets should be >=0zshard_sizes should be >= 0)	r   r   
isinstancestrr   r   len
ValueErrorrange)selfr   r   r   is        Y/var/www/auris/envauris/lib/python3.13/site-packages/torch/distributed/_shard/metadata.py__init__ShardMetadata.__init__    s     +&i%%+I6DN&Nt!!"c$*:*:&;;669$:L:L6M5N O''(7  s4--./A!!!$q( !>??"Q& !=>>	 0    c                     S n[        XR                  S5      n[        XR                  U5      nU" X R                  5      nU$ )Nc                 $    U S-  [        U5      -   $ )N   )hash)abs     r   _hash_reduce,ShardMetadata.__hash__.<locals>._hash_reduce:   s    Fd1g%%r   %   )r   r   r   r   )r   r    ress      r   __hash__ShardMetadata.__hash__9   s@    	& \#5#5r:\#3#3S93/
r   )r   r   r   )N)__name__
__module____qualname____firstlineno____doc__	__slots__listint__annotations__r   r   r   r   r   r$   __static_attributes__ r   r   r	   r	   	   so     >I9c'' ;?	?Cy? #Y? E#~"567	?2r   r	   N)
dataclassesr   	functoolsr   typingr   r   torch.distributed.remote_devicer   r	   r0   r   r   <module>r5      s*    !  " : 6 6 6r   