a
    d{                     @   sP   d dl mZmZmZmZ d dlZd dlmZ d dlm	Z	m
Z
 G dd deZdS )    )Tensorfloat16float32float64N)_AugmentationBase)_transform_input3d_validate_input_dtypec                   @   s<   e Zd ZdZedddZeedddZedd	d
ZdS )AugmentationBase3Da  AugmentationBase3D base class for customized augmentation implementations.

    For any augmentation, the implementation of "generate_parameters" and "apply_transform" are required while the
    "compute_transformation" is only required when passing "return_transform" as True.

    Args:
        p: probability for applying an augmentation. This param controls the augmentation probabilities
          element-wise for a batch.
        p_batch: probability for applying an augmentation to a batch. This param controls the augmentation
          probabilities batch-wise.
        same_on_batch: apply the same transformation across the batch.
    )inputc                 C   s   t |tr|\}}t|jdkrlt|jdkr6td|jd |jd krtd|jd  d|jd  n:t|jdv rt|jdkrtd	ntd
t|j d S )N      z>Input tensor is in batch mode but transformation matrix is notr   zIn batch dimension, input has z but transformation matrix has )r         zBInput tensor is in non-batch mode but transformation matrix is notz3Unrecognized output shape. Expected 3, 4 or 5, got )
isinstancetuplelenshapeAssertionError
ValueError)selfr
   inpmat r   e/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/kornia/augmentation/_3d/base.py__check_batching__   s    

z%AugmentationBase3D.__check_batching__)r
   returnc                 C   s   t |tttgd t|S )zVConvert any incoming (D, H, W), (C, D, H, W) and (B, C, D, H, W) into (B, C, D, H, W).)Zaccepted_dtypes)r   r   r   r   r   r   r
   r   r   r   transform_tensor&   s    z#AugmentationBase3D.transform_tensor)r   c                 C   s   t d|S )zReturn 4x4 identity matrix.r   )korniaZeye_liker   r   r   r   identity_matrix+   s    z"AugmentationBase3D.identity_matrixN)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r	      s   r	   )Ztorchr   r   r   r   r   Zkornia.augmentation.baser   Zkornia.augmentation.utilsr   r   r	   r   r   r   r   <module>   s   