code: def psd(
      specgram: Tensor,
      mask: Optional[Tensor] = None,
      normalize: bool = True,
      eps: float = 1e-10,
  ) -> Tensor:
      """Compute cross-channel power spectral density (PSD) matrix.
  
      .. devices:: CPU CUDA
  
      .. properties:: Autograd TorchScript
  
      Args:
          specgram (torch.Tensor): Multi-channel complex-valued spectrum.
              Tensor with dimensions `(..., channel, freq, time)`.
          mask (torch.Tensor or None, optional): Time-Frequency mask for normalization.
              Tensor with dimensions `(..., freq, time)`. (Default: ``None``)
          normalize (bool, optional): If ``True``, normalize the mask along the time dimension. (Default: ``True``)
          eps (float, optional): Value to add to the denominator in mask normalization. (Default: ``1e-15``)
  
      Returns:
          torch.Tensor: The complex-valued PSD matrix of the input spectrum.
          Tensor with dimensions `(..., freq, channel, channel)`
      """
      specgram = specgram.transpose(
          -3, -2
      )  # shape (freq, channel, time)
      # outer product:
      # (..., ch_1, time) x (..., ch_2, time) -> (..., time, ch_1, ch_2)
      psd = torch.einsum(
          "...ct,...et->...tce", [specgram, specgram.conj()]
      )
  
      if mask is not None:
          if (
              mask.shape[:-1] != specgram.shape[:-2]
              or mask.shape[-1] != specgram.shape[-1]
          ):
              raise ValueError(
                  "The dimensions of mask except the channel dimension should be the same as specgram."
                  f"Found {mask.shape} for mask and {specgram.shape} for specgram."
              )
          # Normalized mask along time dimension:
          if normalize:
              mask = mask / (mask.sum(dim=-1, keepdim=True) + eps)
  
          psd = psd * mask[..., None, None]
  
      psd = psd.sum(dim=-3)
      return psd
  
imports: import math
  import tempfile
  import warnings
  from collections.abc import Sequence
  from typing import List, Optional, Tuple, Union
  import torch
  import torchaudio
  from torch import Tensor
  from torchaudio._internal.module_utils import deprecated
  from .filtering import highpass_biquad, treble_biquad
label_desc: Use image node_id 38 for calling a global function with example usage: psd(specgram, mask, normalize, eps) and returns: psd