a
    d                     @   s`   d dl mZmZ d dlmZ d
eee ee eeeef dddZdeee eddd	ZdS )    )OptionalTuple)TensorN)xyzero_diagonalreturnc                 C   s|   | j dkrtd| j |durZ|j dks@|jd | jd krHtd|du rTdn|}n|  }|du rndn|}| ||fS )a6  Check that input has the right dimensionality and sets the ``zero_diagonal`` argument if user has not set it.

    Args:
        x: tensor of shape ``[N,d]``
        y: if provided, a tensor of shape ``[M,d]``
        zero_diagonal: determines if the diagonal of the distance matrix should be set to zero

       zBExpected argument `x` to be a 2D tensor of shape `[N, d]` but got N   zoExpected argument `y` to be a 2D tensor of shape `[M, d]` where `d` should be same as the last dimension of `x`FT)ndim
ValueErrorshapeclone)r   r   r    r   q/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/torchmetrics/functional/pairwise/helpers.py_check_input   s    
r   )distmat	reductionr   c                 C   sN   |dkr| j ddS |dkr(| jddS |du s8|dkr<| S td| dS )zReduction of distance matrix.

    Args:
        distmat: a ``[N,M]`` matrix
        reduction: string determining how to reduce along last dimension

    mean)ZdimsumNnonez@Expected reduction to be one of `['mean', 'sum', None]` but got )r   r   r   )r   r   r   r   r   _reduce_distance_matrix.   s    r   )NN)N)	typingr   r   Ztorchr   boolr   strr   r   r   r   r   <module>   s    