
    Vh                     ^    d dl Z d dlZd dlmZ dej                  deej                     fdZy)    N)is_traceable_wrapper_subclasstreturnc           	         | g}t               }t        |      dkD  r|j                         }t        |      r=|j	                         \  }}|j                  |D cg c]  }t        ||       c}       nTt        |d      s)t        j                  dt        |       t        d       n|j                  |j                                t        |      dkD  r|S c c}w )z
    Recursively extracts untyped storages from a tensor or its subclasses.

    Args:
        t (torch.Tensor): The tensor to extract storages from.

    Returns:
        Set[torch.UntypedStorage]: A set of untyped storages.
    r   untyped_storagezEExpected a tensor or a traceable wrapper-subclass of tensor, but got    )category
stacklevel)setlenpopr   __tensor_flatten__extendgetattrhasattrwarningswarntypeUserWarningaddr   )r   unflattened_tensorsflattened_tensor_storagesobjattrs_attrs          U/home/dcms/DCMS/lib/python3.12/site-packages/torch/distributed/_tools/common_utils.pyget_untyped_storagesr      s     # #
!
"Q
&!%%'(---/HE1&&u'MtT(:'MN3 12[\`ad\e[fg(  *--c.A.A.CD !
"Q
& %$ (Ns   C)r   torchtorch.utils._python_dispatchr   Tensorr   UntypedStorager        r   <module>r%      s0      F%ELL %S1E1E-F %r$   