o
    yi                     @   sl   d dl mZmZ d dlmZ 	ddedee dee deeeef fdd	Zdd
edee defddZdS )    )OptionalTuple)TensorNxyzero_diagonalreturnc                 C   s|   | j dkrtd| j |dur-|j dks |jd | jd kr$td|du r*dn|}n|  }|du r7dn|}| ||fS )aI  Check that input has the right dimensionality and sets the ``zero_diagonal`` argument if user has not
    provided import module.

    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   \/home/ubuntu/.local/lib/python3.10/site-packages/torchmetrics/functional/pairwise/helpers.py_check_input   s   

r   distmat	reductionc                 C   sJ   |dkr
| j ddS |dkr| jddS |du s|dkr| S td| )zFinal reduction of distance matrix.

    Args:
        distmat: a ``[N,M]`` matrix
        reduction: string determining how to reduce along last dimension
    mean)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   torchr   boolr   strr   r   r   r   r   <module>   s   
 