code: def get_covariances(
      Y: Union[torch.Tensor, ComplexTensor],
      inverse_power: torch.Tensor,
      bdelay: int,
      btaps: int,
      get_vector: bool = False,
  ) -> Union[torch.Tensor, ComplexTensor]:
      """Calculates the power normalized spatio-temporal covariance
          matrix of the framed signal.
  
      Args:
          Y : Complex STFT signal with shape (B, F, C, T)
          inverse_power : Weighting factor with shape (B, F, T)
  
      Returns:
          Correlation matrix: (B, F, (btaps+1) * C, (btaps+1) * C)
          Correlation vector: (B, F, btaps + 1, C, C)
      """  # noqa: H405, D205, D400, D401
      assert inverse_power.dim() == 3, inverse_power.dim()
      assert inverse_power.size(0) == Y.size(0), (
          inverse_power.size(0),
          Y.size(0),
      )
  
      Bs, Fdim, C, T = Y.shape
  
      # (B, F, C, T - bdelay - btaps + 1, btaps + 1)
      Psi = signal_framing(Y, btaps + 1, 1, bdelay, do_padding=False)[
          ..., : T - bdelay - btaps + 1, :
      ]
      # Reverse along btaps-axis:
      # [tau, tau-bdelay, tau-bdelay-1, ..., tau-bdelay-frame_length+1]
      Psi = reverse(Psi, dim=-1)
      Psi_norm = (
          Psi * inverse_power[..., None, bdelay + btaps - 1 :, None]
      )
  
      # let T' = T - bdelay - btaps + 1
      # (B, F, C, T', btaps + 1) x (B, F, C, T', btaps + 1)
      #  -> (B, F, btaps + 1, C, btaps + 1, C)
      covariance_matrix = einsum(
          "bfdtk,bfetl->bfkdle", Psi, Psi_norm.conj()
      )
  
      # (B, F, btaps + 1, C, btaps + 1, C)
      #   -> (B, F, (btaps + 1) * C, (btaps + 1) * C)
      covariance_matrix = covariance_matrix.view(
          Bs, Fdim, (btaps + 1) * C, (btaps + 1) * C
      )
  
      if get_vector:
          # (B, F, C, T', btaps + 1) x (B, F, C, T')
          #    --> (B, F, btaps +1, C, C)
          covariance_vector = einsum(
              "bfdtk,bfet->bfked",
              Psi_norm,
              Y[..., bdelay + btaps - 1 :].conj(),
          )
          return covariance_matrix, covariance_vector
      else:
          return covariance_matrix
  
imports: from typing import List, Union
  import torch
  from packaging.version import parse
  from torch_complex import functional
  from torch_complex.tensor import ComplexTensor
  from espnet2.enh.layers.complex_utils import cat, complex_norm, einsum, inverse, is_complex, is_torch_complex_tensor, matmul, reverse, solve, to_double
label_desc: Use image node_id 17 for calling a global function with example usage: get_covariances(Y, inverse_power, bdelay, btaps, get_vector) and returns: covariance_matrix,  covariance_vector, covariance_matrix