
    i                     l    d dl mZ d dlmZ 	 ddedee   dee   deeeef   fdZdd	ed
ee   defdZy)    )Optional)TensorNxyzero_diagonalreturnc                 
   | j                   dk7  rt        d| j                         |@|j                   dk7  s|j                  d   | j                  d   k7  rt        d      |dn|}n| j                         }|d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    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   s      }/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/torchmetrics/functional/pairwise/helpers.py_check_inputr      s     	vv{]^_^e^e]fghh}66Q;!''!*
2C  "/!6MGGI - 5=a    distmat	reductionc                     |dk(  r| j                  d      S |dk(  r| j                  d      S ||dk(  r| S t        d|       )zReduction of distance matrix.

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

    mean)dimsumnonez@Expected reduction to be one of `['mean', 'sum', None]` but got )r   r   r   )r   r   s     r   _reduce_distance_matrixr   .   s]     F|||##E{{r{""I/
WXaWbc
ddr   )NN)N)	typingr   torchr   booltupler   strr    r   r   <module>r"      sq      LP6":B4.
664 6eV e eQW er   