code: def get_gev_vector(
      psd_noise: torch.Tensor,
      psd_speech: torch.Tensor,
      mode="power",
      reference_vector: Union[int, torch.Tensor] = 0,
      iterations: int = 3,
      diagonal_loading: bool = True,
      diag_eps: float = 1e-7,
      eps: float = 1e-8,
  ) -> torch.Tensor:
      """Return the generalized eigenvalue (GEV) beamformer vector:
  
          psd_speech @ h = lambda * psd_noise @ h
  
      Reference:
          Blind acoustic beamforming based on generalized eigenvalue decomposition;
          E. Warsitz and R. Haeb-Umbach, 2007.
  
      Args:
          psd_noise (torch.complex64):
              noise covariance matrix (..., F, C, C)
          psd_speech (torch.complex64):
              speech covariance matrix (..., F, C, C)
          mode (str): one of ("power", "evd")
              "power": power method
              "evd": eigenvalue decomposition
          reference_vector (torch.Tensor or int): (..., C) or scalar
          iterations (int): number of iterations in power method
          diagonal_loading (bool): Whether to add a tiny term to the diagonal of psd_n
          diag_eps (float):
          eps (float):
      Returns:
          beamform_vector (torch.complex64): (..., F, C)
      """  # noqa: H405, D205, D400
      if diagonal_loading:
          psd_noise = tik_reg(psd_noise, reg=diag_eps, eps=eps)
  
      if mode == "power":
          phi = torch.linalg.solve(psd_noise, psd_speech)
          e_vec = (
              phi[..., reference_vector, None]
              if isinstance(reference_vector, int)
              else torch.matmul(
                  phi, reference_vector[..., None, :, None]
              )
          )
          for _ in range(iterations - 1):
              e_vec = torch.matmul(phi, e_vec)
              # e_vec = e_vec / complex_norm(e_vec, dim=-1, keepdim=True)
          e_vec = e_vec.squeeze(-1)
      elif mode == "evd":
          # e_vec = generalized_eigenvalue_decomposition(psd_speech, psd_noise)[1][...,-1]
          e_vec = psd_noise.new_zeros(psd_noise.shape[:-1])
          for f in range(psd_noise.shape[-3]):
              try:
                  e_vec[
                      ..., f, :
                  ] = generalized_eigenvalue_decomposition(
                      psd_speech[..., f, :, :], psd_noise[..., f, :, :]
                  )[
                      1
                  ][
                      ..., -1
                  ]
              except RuntimeError:
                  # port from github.com/fgnt/nn-gev/blob/master/fgnt/beamforming.py#L106
                  print(
                      "GEV beamformer: LinAlg error for frequency {}".format(
                          f
                      ),
                      flush=True,
                  )
                  C = psd_noise.size(-1)
                  e_vec[..., f, :] = (
                      psd_noise.new_ones(e_vec[..., f, :].shape)
                      / FC.trace(psd_noise[..., f, :, :])
                      * C
                  )
      else:
          raise ValueError("Unknown mode: %s" % mode)
  
      beamforming_vector = e_vec / torch.norm(
          e_vec, dim=-1, keepdim=True
      )
      beamforming_vector = gev_phase_correction(beamforming_vector)
      return beamforming_vector
  
imports: from typing import List, Union
  import torch
  import torch_complex.functional
  import torchaudio
label_desc: Use image node_id 14 for calling a global function with example usage: get_gev_vector(psd_noise, psd_speech, mode, reference_vector, iterations, diagonal_loading, diag_eps, eps) and returns: beamforming_vector