a
    d                     @   s   U d Z ddlmZmZmZ ddlZddlmZ ddlmZm	Z	 dgZ
ee ed< i Zeeejef ef ed	< ejeed
ddZdS )z<Provides phony for arbitrary dependency in a autograd graph.    )DictListTupleN)Tensor   )default_stream
use_stream	get_phony__all___phonies)devicerequires_gradreturnc                C   sp   | |f}zt | }W nV tyj   tt|   tjd| |d}W d   n1 sT0    Y  |t |< Y n0 |S )a  Gets a phony. Phony is tensor without space. It is useful to make
    arbitrary dependency in a autograd graph because it doesn't require any
    gradient accumulation.

    .. note::

        Phonies for each device are cached. If an autograd function gets a phony
        internally, the phony must be detached to be returned. Otherwise, the
        autograd engine will mutate the cached phony in-place::

            class Phonify(torch.autograd.Function):
                @staticmethod
                def forward(ctx, input):
                    phony = get_phony(input.device, requires_grad=False)
                    return phony.detach()  # detach() is necessary.

    r   )r   r   N)r   KeyErrorr   r   torchempty)r   r   keyZphony r   n/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/torch/distributed/pipeline/sync/phony.pyr	      s    .)__doc__typingr   r   r   r   r   streamr   r   r
   str__annotations__r   r   boolr	   r   r   r   r   <module>   s   