
    sg%                         d dl mZ d dlZd dlmZ dZdej                  dee   dee   dej                  fd	Zdej                  d
edej                  fdZ	y)    )SequenceN)ShardMetadataz@Please use DTensor instead and we are deprecating ShardedTensor.tensoroffsetssizesreturnc                     | }t        t        ||            D ]0  \  }\  }}|| j                  |      k  s|j                  |||      }2 |S )zC
    Narrow the tensor according to ``offsets`` and ``sizes``.
    )	enumeratezipsizenarrow)r   r   r   narrowed_tensoridxoffsetr   s          R/var/www/html/venv/lib/python3.12/site-packages/torch/distributed/_shard/_utils.pynarrow_tensor_by_indexr   
   s^     O(We)<= H^fd&++c"" .44S&$GOH     metadatac                 D    t        | |j                  |j                        S )z5
    Narrow the tensor according to the metadata
    )r   shard_offsetsshard_sizes)r   r   s     r   narrow_tensorr      s     "&(*@*@(BVBVWWr   )
typingr   torch!torch.distributed._shard.metadatar   DEPRECATE_MSGTensorintr   r    r   r   <module>r       su      ; SLLc] C= \\	$X%,, X- XELL Xr   