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_input_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 )AugmentationBase2Da  AugmentationBase2D 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.
        keepdim: whether to keep the output shape the same as input ``True`` or broadcast it to the batch
          form ``False``.
    )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   r   zBInput tensor is in non-batch mode but transformation matrix is notz4Unrecognized output shape. Expected 2, 3, or 4, 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/_2d/base.py__check_batching__   s    

z%AugmentationBase2D.__check_batching__)r
   returnc                 C   s   t |tttgd t|S )zJConvert any incoming (H, W), (C, H, W) and (B, C, H, W) into (B, C, H, W).)Zaccepted_dtypes)r   r   r   r   r   r   r
   r   r   r   transform_tensor(   s    z#AugmentationBase2D.transform_tensor)r   c                 C   s   t d|S )zReturn 3x3 identity matrix.r   )korniaZeye_liker   r   r   r   identity_matrix-   s    z"AugmentationBase2D.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   