class_docstr: Whole utterance augmented memory transformer encoder layer. This is a master layer
  where we can define multiple augmented memory transformers. There are two reasons
  to setup the master layer.
  1. We only need to define once about the attention mask. All the layers in the master
     layer share the same mask.
  2. pyspeech nn layer has special input and output format. Defining one master layer is
     easier to passing memory between different layes inside the master layer
  
  args:
      input_dim: input embedding dimension
      num_heads: number of heads in multihead self-attention
      ffn_dim: ffn dimension in FFN layer
      num_layers: number of augmented memory transformer layers
      dropout_in_attn: dropout used in multi-head self-attention
      dropout_on_attn: dropout used for output from te multihead self-attention
      dropout_on_fc1: dropout used in FFN layer for the first linear layer
      dropout_on_fc2: dropout used in FFN layer for the second linear layer
      segment_size: segment size for each segment
      context_config: (left_context_size, right_context_size) defines the surround context size
          for each segment
      max_memory_size: maximum memory size used for each segment
      scaled_init: whether use scaled init for weight initialization in attention layer
      std_scale: if std_scale is not None. The weak attention suppression is
          turned on. For std_scale = 0.5, all the attention smaller than
          mean + 0.5 * std will be suppressed.
      activation_fn: activation function used in FFN layer. [ReLU, GELU] supported
      tanh_on_mem: whether use tanh on memory
      mini_batches: use mini-btach training
      negative_inf: the negative infinity value used in attention masking. default is "-inf".
          For some situation, e.g. LM. it is better to use "-1e8" to avoid nan issue.
      summarization_method: method to generate segment summrization embedding
      max_relative_position: max relatie position for relative position embedding
      rpe_old_option: To be compatible with previous model. The previous model
          was trained with attention += attention + rpe. The correct equation
          should be attention = attention + rpe
      [TODO]: remove the rpe_old_option by the end of 2021 Q1.
class_docstr_tok: ["Whole","utterance","augmented","memory","transformer","encoder","layer",".","This","is","a","master","layer","where","we","can","define","multiple","augmented","memory","transformers",".","There","are","two","reasons","to","setup","the","master","layer",".","1",".","We","only","need","to","define","once","about","the","attention","mask",".","All","the","layers","in","the","master","layer","share","the","same","mask",".","2.","pyspeech","nn","layer","has","special","input","and","output","format",".","Defining","one","master","layer","is","easier","to","passing","memory","between","different","layes","inside","the","master","layer","args",":","input_dim",":","input","embedding","dimension","num_heads",":","number","of","heads","in","multihead","self-attention","ffn_dim",":","ffn","dimension","in","FFN","layer","num_layers",":","number","of","augmented","memory","transformer","layers","dropout_in_attn",":","dropout","used","in","multi-head","self-attention","dropout_on_attn",":","dropout","used","for","output","from","te","multihead","self-attention","dropout_on_fc1",":","dropout","used","in","FFN","layer","for","the","first","linear","layer","dropout_on_fc2",":","dropout","used","in","FFN","layer","for","the","second","linear","layer","segment_size",":","segment","size","for","each","segment","context_config",":","(","left_context_size",",","right_context_size",")","defines","the","surround","context","size","for","each","segment","max_memory_size",":","maximum","memory","size","used","for","each","segment","scaled_init",":","whether","use","scaled","init","for","weight","initialization","in","attention","layer","std_scale",":","if","std_scale","is","not","None",".","The","weak","attention","suppression","is","turned","on",".","For","std_scale","=","0.5",",","all","the","attention","smaller","than","mean","+","0.5","*","std","will","be","suppressed",".","activation_fn",":","activation","function","used","in","FFN","layer",".","[","ReLU",",","GELU","]","supported","tanh_on_mem",":","whether","use","tanh","on","memory","mini_batches",":","use","mini-btach","training","negative_inf",":","the","negative","infinity","value","used","in","attention","masking",".","default","is","``","-inf","''",".","For","some","situation",",","e.g",".","LM",".","it","is","better","to","use","``","-1e8","''","to","avoid","nan","issue",".","summarization_method",":","method","to","generate","segment","summrization","embedding","max_relative_position",":","max","relatie","position","for","relative","position","embedding","rpe_old_option",":","To","be","compatible","with","previous","model",".","The","previous","model","was","trained","with","attention","+=","attention","+","rpe",".","The","correct","equation","should","be","attention","=","attention","+","rpe","[","TODO","]",":","remove","the","rpe_old_option","by","the","end","of","2021","Q1","."]
code: def gen_summary_queries(self, input):
      sum_input = self.memory_op(input)
      return sum_input
  
imports: import math
  import re
  from functools import partial
  from typing import List, Optional, Tuple
  import torch
  import torch.nn
  from torch import Tensor
  from torch import device
  from fairseq.models import FairseqEncoder
  from fairseq.models.speech_to_text.utils import NoOp, attention_suppression, layer_norm_backward_hook, lengths_to_padding_mask, segments_to_sequence
label_desc: Use image node_id 11 for calling the NoSegAugmentedMemoryTransformerEncoderLayer obj's underlying member method code with example usage: obj.gen_summary_queries(input) and returns: sum_input