o
    Zh                     @   s:   d dl Z d dlZd dlmZ dejdeej fddZdS )    N)is_traceable_wrapper_subclasstreturnc                    s   | g}t  }t|dkrG|  t r'  \}}| fdd|D  nt ds:tjdt	  t
dd n|   t|dks|S )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   c                    s   g | ]}t  |qS  )getattr).0attrobjr   T/var/www/auris/lib/python3.10/site-packages/torch/distributed/_tools/common_utils.py
<listcomp>   s    z(get_untyped_storages.<locals>.<listcomp>untyped_storagezEExpected a tensor or a traceable wrapper-subclass of tensor, but got    )category
stacklevel)setlenpopr   Z__tensor_flatten__extendhasattrwarningswarntypeUserWarningaddr   )r   Zunflattened_tensorsZflattened_tensor_storagesattrs_r   r	   r   get_untyped_storages   s    

r   )r   ZtorchZtorch.utils._python_dispatchr   ZTensorr   ZUntypedStorager   r   r   r   r   <module>   s    