code: def get_lcmv_vector_with_rtf(
      psd_n: torch.Tensor,
      rtf_mat: torch.Tensor,
      reference_vector: Union[int, torch.Tensor, None] = None,
      diagonal_loading: bool = True,
      diag_eps: float = 1e-7,
      eps: float = 1e-8,
  ) -> torch.Tensor:
      """Return the LCMV (Linearly Constrained Minimum Variance) vector
          calculated with RTF:
  
          h = (Npsd^-1 @ rtf_mat) @ (rtf_mat^H @ Npsd^-1 @ rtf_mat)^-1 @ p
  
      Reference:
          H. L. Van Trees, “Optimum array processing: Part IV of detection, estimation,
          and modulation theory,” John Wiley & Sons, 2004. (Chapter 6.7)
  
      Args:
          psd_n (torch.complex64):
              observation/noise covariance matrix (..., F, C, C)
          rtf_mat (torch.complex64):
              RTF matrix (..., F, C, num_spk)
          reference_vector (torch.Tensor or int): (..., num_spk) or scalar
          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_n = tik_reg(psd_n, reg=diag_eps, eps=eps)
  
      # numerator: (..., C_1, C_2) x (..., C_2, num_spk) -> (..., C_1, num_spk)
      numerator = torch.linalg.solve(psd_n, rtf_mat)
      denominator = torch.matmul(
          rtf_mat.conj().transpose(-1, -2), numerator
      )
      if isinstance(reference_vector, int):
          ws = denominator.inverse()[..., reference_vector, None]
      else:
          ws = torch.linalg.solve(denominator, reference_vector)
      beamforming_vector = torch.matmul(numerator, ws).squeeze(-1)
      return beamforming_vector
  
imports: from typing import List, Union
  import torch
  import torch_complex.functional
  import torchaudio
label_desc: Use image node_id 10 for calling a global function with example usage: get_lcmv_vector_with_rtf(psd_n, rtf_mat, reference_vector, diagonal_loading, diag_eps, eps) and returns: beamforming_vector