
    kh                    V    d dl mZ d dlmZmZmZ d dlZd dlZddl	m
Z
  G d de
      Zy)    )annotations)AnyOptionalUnionN   )TVTensorc                  4    e Zd ZdZdddd	 	 	 	 	 	 	 	 	 ddZy)Maska  :class:`torch.Tensor` subclass for segmentation and detection masks with shape ``[..., H, W]``.

    Args:
        data (tensor-like, PIL.Image.Image): Any data that can be turned into a tensor with :func:`torch.as_tensor` as
            well as PIL images.
        dtype (torch.dtype, optional): Desired data type. If omitted, will be inferred from
            ``data``.
        device (torch.device, optional): Desired device. If omitted and ``data`` is a
            :class:`torch.Tensor`, the device is taken from it. Otherwise, the mask is constructed on the CPU.
        requires_grad (bool, optional): Whether autograd should record operations. If omitted and
            ``data`` is a :class:`torch.Tensor`, the value is taken from it. Otherwise, defaults to ``False``.
    Ndtypedevicerequires_gradc                   t        |t        j                  j                        rddlm} |j                  |      }| j                  ||||      }|j                  |       S )Nr   )
functionalr   )
isinstancePILImagetorchvision.transforms.v2r   pil_to_tensor
_to_tensoras_subclass)clsdatar   r   r   Ftensors          X/var/www/teggl/fontify/venv/lib/python3.12/site-packages/torchvision/tv_tensors/_mask.py__new__zMask.__new__   sO     dCIIOO,A??4(DE&P]^!!#&&    )
r   r   r   zOptional[torch.dtype]r   z'Optional[Union[torch.device, str, int]]r   zOptional[bool]returnr
   )__name__
__module____qualname____doc__r    r   r   r
   r
      sG    " (,:>(,'' %	'
 8' &' 
'r   r
   )
__future__r   typingr   r   r   	PIL.Imager   torch
_tv_tensorr   r
   r$   r   r   <module>r*      s#    " ' '    '8 'r   