code: def get_WPD_filter(
      Phi: Union[torch.Tensor, ComplexTensor],
      Rf: Union[torch.Tensor, ComplexTensor],
      reference_vector: torch.Tensor,
      diagonal_loading: bool = True,
      diag_eps: float = 1e-7,
      eps: float = 1e-8,
  ) -> Union[torch.Tensor, ComplexTensor]:
      """Return the WPD vector.
  
          WPD is the Weighted Power minimization Distortionless response
          convolutional beamformer. As follows:
  
          h = (Rf^-1 @ Phi_{xx}) / tr[(Rf^-1) @ Phi_{xx}] @ u
  
      Reference:
          T. Nakatani and K. Kinoshita, "A Unified Convolutional Beamformer
          for Simultaneous Denoising and Dereverberation," in IEEE Signal
          Processing Letters, vol. 26, no. 6, pp. 903-907, June 2019, doi:
          10.1109/LSP.2019.2911179.
          https://ieeexplore.ieee.org/document/8691481
  
      Args:
          Phi (torch.complex64/ComplexTensor): (B, F, (btaps+1) * C, (btaps+1) * C)
              is the PSD of zero-padded speech [x^T(t,f) 0 ... 0]^T.
          Rf (torch.complex64/ComplexTensor): (B, F, (btaps+1) * C, (btaps+1) * C)
              is the power normalized spatio-temporal covariance matrix.
          reference_vector (torch.Tensor): (B, (btaps+1) * C)
              is the reference_vector.
          diagonal_loading (bool): Whether to add a tiny term to the diagonal of psd_n
          diag_eps (float):
          eps (float):
  
      Returns:
          filter_matrix (torch.complex64/ComplexTensor): (B, F, (btaps + 1) * C)
      """
      if diagonal_loading:
          Rf = tik_reg(Rf, reg=diag_eps, eps=eps)
  
      # numerator: (..., C_1, C_2) x (..., C_2, C_3) -> (..., C_1, C_3)
      numerator = solve(Phi, Rf)
      # NOTE (wangyou): until PyTorch 1.9.0, torch.trace does not
      # support bacth processing. Use FC.trace() as fallback.
      # ws: (..., C, C) / (...,) -> (..., C, C)
      ws = numerator / (FC.trace(numerator)[..., None, None] + eps)
      # h: (..., F, C_1, C_2) x (..., C_2) -> (..., F, C_1)
      beamform_vector = einsum(
          "...fec,...c->...fe", ws, reference_vector
      )
      # (B, F, (btaps + 1) * C)
      return beamform_vector
  
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 18 for calling a global function with example usage: get_WPD_filter(Phi, Rf, reference_vector, diagonal_loading, diag_eps, eps) and returns: beamform_vector