
    %`i                     j    d dl Z d dlZ e j        d           d Zd Zd ZddZd Zd	 ZddZ	d Z
dS )    NzThe 'torchvision.transforms._functional_video' module is deprecated since 0.12 and will be removed in the future. Please use the 'torchvision.transforms.functional' module instead.c                     t          j        |           st          dt          |           z            |                                 dk    s$t          d|                                 z            dS )Nzclip should be Tensor. Got %s   zclip should be 4D. Got %dDT)torch	is_tensor	TypeErrortype
ndimension
ValueErrordimclips    |/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/torchvision/transforms/_functional_video.py_is_tensor_video_clipr      se    ?4   F7$t**DEEE??!!5

BCCC4    c                     t          |                                           dk    rt          d          | d|||z   |||z   f         S )z[
    Args:
        clip (torch.tensor): Video clip to be cropped. Size is (C, T, H, W)
    r   zclip should be a 4D tensor.)lensizer
   )r   ijhws        r   cropr      sP    
 499;;15666QQYAE	)**r   c                     t          |          dk    rt          d|           t          j        j                            | ||d          S )N   z9target size should be tuple (height, width), instead got F)r   modealign_corners)r   r
   r   nn
functionalinterpolate)r   target_sizeinterpolation_modes      r   resizer"       sQ    
;1bU`bbccc8**4kHZjo*pppr   bilinearc                     t          |           st          d          t          | ||||          } t          | ||          } | S )a  
    Do spatial cropping and resizing to the video clip
    Args:
        clip (torch.tensor): Video clip to be cropped. Size is (C, T, H, W)
        i (int): i in (i,j) i.e coordinates of the upper left corner.
        j (int): j in (i,j) i.e coordinates of the upper left corner.
        h (int): Height of the cropped region.
        w (int): Width of the cropped region.
        size (tuple(int, int)): height and width of resized clip
    Returns:
        clip (torch.tensor): Resized and cropped clip. Size is (C, T, H, W)
     clip should be a 4D torch.tensor)r   r
   r   r"   )r   r   r   r   r   r   r!   s          r   resized_cropr&   &   sO     !&& =;<<<aAq!!D$011DKr   c                    t          |           st          d          |                     d          |                     d          }}|\  }}||k     s||k     rt          d          t          t	          ||z
  dz                      }t          t	          ||z
  dz                      }t          | ||||          S )Nr%   z2height and width must be no smaller than crop_sizeg       @)r   r
   r   introundr   )r   	crop_sizer   r   thtwr   r   s           r   center_cropr/   :   s     && =;<<<99R==$))B--qAFB2vvRMNNNE1r6S.!!""AE1r6S.!!""AaB###r   c                     t          |            | j        t          j        k    s$t	          dt          | j                  z            |                                                     dddd          dz  S )a  
    Convert tensor data type from uint8 to float, divide value by 255.0 and
    permute the dimensions of clip tensor
    Args:
        clip (torch.tensor, dtype=torch.uint8): Size is (T, H, W, C)
    Return:
        clip (torch.tensor, dtype=torch.float): Size is (C, T, H, W)
    z/clip tensor should have data type uint8. Got %s   r      r   g     o@)r   dtyper   uint8r   strfloatpermuter   s    r   	to_tensorr8   G   sf     $:$$ICPTPZOO[\\\::<<1a++e33r   Fc                 r   t          |           st          d          |s|                                 } t          j        || j        | j                  }t          j        || j        | j                  }|                     |dddddf                                       |dddddf                    | S )a  
    Args:
        clip (torch.tensor): Video clip to be normalized. Size is (C, T, H, W)
        mean (tuple): pixel RGB mean. Size is (3)
        std (tuple): pixel standard deviation. Size is (3)
    Returns:
        normalized clip (torch.tensor): Size is (C, T, H, W)
    r%   )r3   deviceN)	r   r
   cloner   	as_tensorr3   r:   sub_div_)r   meanstdinplaces       r   	normalizerB   V   s     !&& =;<<< zz||?4tz$+FFFD
/#TZ
D
D
DCIId111dD$&'((--c!!!T42E.FGGGKr   c                 h    t          |           st          d          |                     d          S )z
    Args:
        clip (torch.tensor): Video clip to be normalized. Size is (C, T, H, W)
    Returns:
        flipped clip (torch.tensor): Size is (C, T, H, W)
    r%   r)   )r   r
   flipr   s    r   hfliprE   i   s3     !&& =;<<<99R==r   )r#   )F)warningsr   warnr   r   r"   r&   r/   r8   rB   rE    r   r   <module>rI      s      I    + + +q q q   (
$ 
$ 
$4 4 4   &	 	 	 	 	r   