class_docstr: Contextual Block Conformer encoder module.
  
  Args:
      input_size: input dim
      output_size: dimension of attention
      attention_heads: the number of heads of multi head attention
      linear_units: the number of units of position-wise feed forward
      num_blocks: the number of decoder blocks
      dropout_rate: dropout rate
      attention_dropout_rate: dropout rate in attention
      positional_dropout_rate: dropout rate after adding positional encoding
      input_layer: input layer type
      pos_enc_class: PositionalEncoding or ScaledPositionalEncoding
      normalize_before: whether to use layer_norm before the first block
      concat_after: whether to concat attention layer's input and output
          if True, additional linear will be applied.
          i.e. x -> x + linear(concat(x, att(x)))
          if False, no additional linear will be applied.
          i.e. x -> x + att(x)
      positionwise_layer_type: linear of conv1d
      positionwise_conv_kernel_size: kernel size of positionwise conv1d layer
      padding_idx: padding_idx for input_layer=embed
      block_size: block size for contextual block processing
      hop_Size: hop size for block processing
      look_ahead: look-ahead size for block_processing
      init_average: whether to use average as initial context (otherwise max values)
      ctx_pos_enc: whether to use positional encoding to the context vectors
docstr: Embed positions in tensor.
  
  Args:
      xs_pad: input tensor (B, L, D)
      ilens: input length (B)
      prev_states: Not to be used now.
      infer_mode: whether to be used for inference. This is used to
          distinguish between forward_train (train and validate) and
          forward_infer (decode).
  Returns:
      position embedded tensor and mask
docstr_tok: ["Embed","positions","in","tensor",".","Args",":","xs_pad",":","input","tensor","(","B",",","L",",","D",")","ilens",":","input","length","(","B",")","prev_states",":","Not","to","be","used","now",".","infer_mode",":","whether","to","be","used","for","inference",".","This","is","used","to","distinguish","between","forward_train","(","train","and","validate",")","and","forward_infer","(","decode",")",".","Returns",":","position","embedded","tensor","and","mask"]
code: def forward(
      self,
      xs_pad: torch.Tensor,
      ilens: torch.Tensor,
      prev_states: torch.Tensor = None,
      is_final=True,
      infer_mode=False,
  ) -> Tuple[torch.Tensor, torch.Tensor, Optional[torch.Tensor]]:
      """Embed positions in tensor.
  
      Args:
          xs_pad: input tensor (B, L, D)
          ilens: input length (B)
          prev_states: Not to be used now.
          infer_mode: whether to be used for inference. This is used to
              distinguish between forward_train (train and validate) and
              forward_infer (decode).
      Returns:
          position embedded tensor and mask
      """
      if self.training or not infer_mode:
          return self.forward_train(xs_pad, ilens, prev_states)
      else:
          return self.forward_infer(
              xs_pad, ilens, prev_states, is_final
          )
  
imports: import math
  from typing import Optional, Tuple
  import torch
  from typeguard import check_argument_types
  from espnet2.asr.encoder.abs_encoder import AbsEncoder
  from espnet.nets.pytorch_backend.conformer.contextual_block_encoder_layer import ContextualBlockEncoderLayer
  from espnet.nets.pytorch_backend.conformer.convolution import ConvolutionModule
  from espnet.nets.pytorch_backend.nets_utils import get_activation, make_pad_mask
  from espnet.nets.pytorch_backend.transformer.attention import MultiHeadedAttention
  from espnet.nets.pytorch_backend.transformer.embedding import StreamPositionalEncoding
  from espnet.nets.pytorch_backend.transformer.layer_norm import LayerNorm
  from espnet.nets.pytorch_backend.transformer.multi_layer_conv import Conv1dLinear, MultiLayeredConv1d
  from espnet.nets.pytorch_backend.transformer.positionwise_feed_forward import PositionwiseFeedForward
  from espnet.nets.pytorch_backend.transformer.repeat import repeat
  from espnet.nets.pytorch_backend.transformer.subsampling_without_posenc import Conv2dSubsamplingWOPosEnc
label_desc: Use image node_id 3 for calling the ContextualBlockConformerEncoder obj's underlying member method code with example usage: obj.forward(xs_pad, ilens, prev_states, is_final, infer_mode) and returns: self, self