code: def get_rtf(
      psd_speech,
      psd_noise,
      mode="power",
      reference_vector: Union[int, torch.Tensor] = 0,
      iterations: int = 3,
  ):
      """Calculate the relative transfer function (RTF)
  
      Algorithm of power method:
          1) rtf = reference_vector
          2) for i in range(iterations):
               rtf = (psd_noise^-1 @ psd_speech) @ rtf
               rtf = rtf / ||rtf||_2  # this normalization can be skipped
          3) rtf = psd_noise @ rtf
          4) rtf = rtf / rtf[..., ref_channel, :]
      Note: 4) Normalization at the reference channel is not performed here.
  
      Args:
          psd_speech (torch.complex64/ComplexTensor):
              speech covariance matrix (..., F, C, C)
          psd_noise (torch.complex64/ComplexTensor):
              noise 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
      Returns:
          rtf (torch.complex64/ComplexTensor): (..., F, C, 1)
      """
      if mode == "power":
          phi = solve(psd_speech, psd_noise)
          rtf = (
              phi[..., reference_vector, None]
              if isinstance(reference_vector, int)
              else matmul(phi, reference_vector[..., None, :, None])
          )
          for _ in range(iterations - 2):
              rtf = matmul(phi, rtf)
              # rtf = rtf / complex_norm(rtf, dim=-1, keepdim=True)
          rtf = matmul(psd_speech, rtf)
      elif mode == "evd":
          assert (
              is_torch_1_9_plus
              and is_torch_complex_tensor(psd_speech)
              and is_torch_complex_tensor(psd_noise)
          )
          e_vec = generalized_eigenvalue_decomposition(
              psd_speech, psd_noise
          )[1]
          rtf = matmul(psd_noise, e_vec[..., -1, None])
      else:
          raise ValueError("Unknown mode: %s" % mode)
      return rtf
  
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 3 for calling a global function with example usage: get_rtf(psd_speech, psd_noise, mode, reference_vector, iterations) and returns: rtf