class_docstr: E2E module.
  
  :param int idim: dimension of inputs
  :param int odim: dimension of outputs
  :param Namespace args: argument Namespace containing options
class_docstr_tok: ["E2E","module",".",":","param","int","idim",":","dimension","of","inputs",":","param","int","odim",":","dimension","of","outputs",":","param","Namespace","args",":","argument","Namespace","containing","options"]
docstr: E2E attention calculation.
  
  :param torch.Tensor xs_pad: batch of padded input sequences (B, Tmax, idim)
  :param torch.Tensor ilens: batch of lengths of input sequences (B)
  :param torch.Tensor ys_pad:
      batch of padded character id sequence tensor (B, num_spkrs, Lmax)
  :return: attention weights with the following shape,
      1) multi-head case => attention weights (B, H, Lmax, Tmax),
      2) other case => attention weights (B, Lmax, Tmax).
  :rtype: float ndarray
docstr_tok: ["E2E","attention","calculation",".",":","param","torch.Tensor","xs_pad",":","batch","of","padded","input","sequences","(","B",",","Tmax",",","idim",")",":","param","torch.Tensor","ilens",":","batch","of","lengths","of","input","sequences","(","B",")",":","param","torch.Tensor","ys_pad",":","batch","of","padded","character","id","sequence","tensor","(","B",",","num_spkrs",",","Lmax",")",":","return",":","attention","weights","with","the","following","shape",",","1",")","multi-head","case","=",">","attention","weights","(","B",",","H",",","Lmax",",","Tmax",")",",","2",")","other","case","=",">","attention","weights","(","B",",","Lmax",",","Tmax",")",".",":","rtype",":","float","ndarray"]
code: def calculate_all_attentions(self, xs_pad, ilens, ys_pad):
      """E2E attention calculation.
  
      :param torch.Tensor xs_pad: batch of padded input sequences (B, Tmax, idim)
      :param torch.Tensor ilens: batch of lengths of input sequences (B)
      :param torch.Tensor ys_pad:
          batch of padded character id sequence tensor (B, num_spkrs, Lmax)
      :return: attention weights with the following shape,
          1) multi-head case => attention weights (B, H, Lmax, Tmax),
          2) other case => attention weights (B, Lmax, Tmax).
      :rtype: float ndarray
      """
      with torch.no_grad():
          # 0. Frontend
          if self.frontend is not None:
              hs_pad, hlens, mask = self.frontend(
                  to_torch_tensor(xs_pad), ilens
              )
              hlens_n = [None] * self.num_spkrs
              for i in range(self.num_spkrs):
                  hs_pad[i], hlens_n[i] = self.feature_transform(
                      hs_pad[i], hlens
                  )
              hlens = hlens_n
          else:
              hs_pad, hlens = xs_pad, ilens
  
          # 1. Encoder
          if not isinstance(
              hs_pad, list
          ):  # single-channel multi-speaker input x
              hs_pad, hlens, _ = self.enc(hs_pad, hlens)
          else:  # multi-channel multi-speaker input x
              for i in range(self.num_spkrs):
                  hs_pad[i], hlens[i], _ = self.enc(hs_pad[i], hlens[i])
  
          # Permutation
          ys_pad = ys_pad.transpose(0, 1)  # (num_spkrs, B, Lmax)
          if self.num_spkrs <= 3:
              loss_ctc = torch.stack(
                  [
                      self.ctc(
                          hs_pad[i // self.num_spkrs],
                          hlens[i // self.num_spkrs],
                          ys_pad[i % self.num_spkrs],
                      )
                      for i in range(self.num_spkrs**2)
                  ],
                  1,
              )  # (B, num_spkrs^2)
              loss_ctc, min_perm = self.pit.pit_process(loss_ctc)
          for i in range(ys_pad.size(1)):  # B
              ys_pad[:, i] = ys_pad[min_perm[i], i]
  
          # 2. Decoder
          att_ws = [
              self.dec.calculate_all_attentions(
                  hs_pad[i], hlens[i], ys_pad[i], strm_idx=i
              )
              for i in range(self.num_spkrs)
          ]
  
      return att_ws
  
imports: import argparse
  import logging
  import math
  import os
  import sys
  from itertools import groupby
  import numpy
  import torch
  from espnet.nets.asr_interface import ASRInterface
  from espnet.nets.e2e_asr_common import get_vgg2l_odim, label_smoothing_dist
  from espnet.nets.pytorch_backend.ctc import ctc_for
  from espnet.nets.pytorch_backend.e2e_asr import E2E
  from espnet.nets.pytorch_backend.e2e_asr import Reporter
  from espnet.nets.pytorch_backend.frontends.feature_transform import feature_transform_for
  from espnet.nets.pytorch_backend.frontends.frontend import frontend_for
  from espnet.nets.pytorch_backend.initialization import lecun_normal_init_parameters, set_forget_bias_to_one
  from espnet.nets.pytorch_backend.nets_utils import get_subsample, make_pad_mask, pad_list, to_device, to_torch_tensor
  from espnet.nets.pytorch_backend.rnn.attentions import att_for
  from espnet.nets.pytorch_backend.rnn.decoders import decoder_for
  from espnet.nets.pytorch_backend.rnn.encoders import RNNP, VGG2L
  from espnet.nets.pytorch_backend.rnn.encoders import encoder_for
label_desc: Use image node_id 10 for calling the E2E obj's underlying member method code with example usage: obj.calculate_all_attentions(xs_pad, ilens, ys_pad) and returns: att_ws