class_docstr: Emformer layer attention module.
  
  Args:
      input_dim (int): input dimension.
      num_heads (int): number of attention heads in each Emformer layer.
      dropout (float, optional): dropout probability. (Default: 0.0)
      weight_init_gain (float or None, optional): scale factor to apply when initializing
          attention module parameters. (Default: ``None``)
      tanh_on_mem (bool, optional): if ``True``, applies tanh to memory elements. (Default: ``False``)
      negative_inf (float, optional): value to use for negative infinity in attention weights. (Default: -1e8)
class_docstr_tok: ["Emformer","layer","attention","module",".","Args",":","input_dim","(","int",")",":","input","dimension",".","num_heads","(","int",")",":","number","of","attention","heads","in","each","Emformer","layer",".","dropout","(","float",",","optional",")",":","dropout","probability",".","(","Default",":","0.0",")","weight_init_gain","(","float","or","None",",","optional",")",":","scale","factor","to","apply","when","initializing","attention","module","parameters",".","(","Default",":","``","None","``",")","tanh_on_mem","(","bool",",","optional",")",":","if","``","True","``",",","applies","tanh","to","memory","elements",".","(","Default",":","``","False","``",")","negative_inf","(","float",",","optional",")",":","value","to","use","for","negative","infinity","in","attention","weights",".","(","Default",":","-1e8",")"]
code: def _gen_key_value(
      self, input: torch.Tensor, mems: torch.Tensor
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      T, _, _ = input.shape
      summary_length = mems.size(0) + 1
      right_ctx_utterance_block = input[: T - summary_length]
      mems_right_ctx_utterance_block = torch.cat(
          [mems, right_ctx_utterance_block]
      )
      key, value = self.emb_to_key_value(
          mems_right_ctx_utterance_block
      ).chunk(chunks=2, dim=2)
      return key, value
  
imports: import math
  from typing import List, Optional, Tuple
  import torch
label_desc: Use image node_id 2 for calling the _EmformerAttention obj's underlying member method code with example usage: obj._gen_key_value(input, mems) and returns: key,  value