docstr: Attention-based reference forward function.
  
  Args:
      psd_in (torch.complex64/ComplexTensor): (B, F, C, C)
      ilens (torch.Tensor): (B,)
      scaling (float):
  Returns:
      u (torch.Tensor): (B, C)
      ilens (torch.Tensor): (B,)
docstr_tok: ["Attention-based","reference","forward","function",".","Args",":","psd_in","(","torch.complex64\/ComplexTensor",")",":","(","B",",","F",",","C",",","C",")","ilens","(","torch.Tensor",")",":","(","B",",",")","scaling","(","float",")",":","Returns",":","u","(","torch.Tensor",")",":","(","B",",","C",")","ilens","(","torch.Tensor",")",":","(","B",",",")"]
code: def forward(
      self,
      psd_in: Union[torch.Tensor, ComplexTensor],
      ilens: torch.LongTensor,
      scaling: float = 2.0,
  ) -> Tuple[torch.Tensor, torch.LongTensor]:
      """Attention-based reference forward function.
  
      Args:
          psd_in (torch.complex64/ComplexTensor): (B, F, C, C)
          ilens (torch.Tensor): (B,)
          scaling (float):
      Returns:
          u (torch.Tensor): (B, C)
          ilens (torch.Tensor): (B,)
      """
      B, _, C = psd_in.size()[:3]
      assert psd_in.size(2) == psd_in.size(3), psd_in.size()
      # psd_in: (B, F, C, C)
      psd = psd_in.masked_fill(
          torch.eye(C, dtype=torch.bool, device=psd_in.device).type(
              torch.bool
          ),
          0,
      )
      # psd: (B, F, C, C) -> (B, C, F)
      psd = (psd.sum(dim=-1) / (C - 1)).transpose(-1, -2)
  
      # Calculate amplitude
      psd_feat = (psd.real**2 + psd.imag**2 + self.eps) ** 0.5
  
      # (B, C, F) -> (B, C, F2)
      mlp_psd = self.mlp_psd(psd_feat)
      # (B, C, F2) -> (B, C, 1) -> (B, C)
      e = self.gvec(torch.tanh(mlp_psd)).squeeze(-1)
      u = F.softmax(scaling * e, dim=-1)
      return u, ilens
  
file_path: espnet/espnet2/enh/layers/dnn_beamformer.py
imports: import logging
  from typing import List, Optional, Tuple, Union
  import torch
  from packaging.version import parse
  from torch.nn import functional
  from torch_complex.tensor import ComplexTensor
  import espnet2.enh.layers.beamformer
  import espnet2.enh.layers.beamformer_th
  from espnet2.enh.layers.complex_utils import stack, to_double, to_float
  from espnet2.enh.layers.mask_estimator import MaskEstimator
label_desc: Use image node_id 2 for calling the AttentionReference obj's underlying member method code with example usage: obj.forward(psd_in, ilens, scaling) and returns: u,  ilens