docstr: Args:
      encoder_states: output of the encoder (B x L_enc x H)
      encoder_mask: encoder inputs mask (B x L_enc)
docstr_tok: ["Args",":","encoder_states",":","output","of","the","encoder","(","B","x","L_enc","x","H",")","encoder_mask",":","encoder","inputs","mask","(","B","x","L_enc",")"]
code: def forward(self, encoder_states, encoder_mask):
      """
      Args:
          encoder_states: output of the encoder (B x L_enc x H)
          encoder_mask: encoder inputs mask (B x L_enc)
      """
      # initialize hidden state
      hidden_mask = encoder_mask
      hidden_states = encoder_states
  
      # apply block (self-attention, max-pool) multiple times
      for self_att in self.self_att_layers:
          residual = hidden_states
  
          # self-attention over hidden
          hidden_states = self_att(
              encoder_states=hidden_states, encoder_mask=hidden_mask
          )
  
          hidden_states += residual
  
          # max pool reduction if possible
          if hidden_states.shape[1] >= self.hidden_steps:
              # max pool hidden states
              hidden_states = hidden_states.permute(0, 2, 1)
              hidden_states = self.pooling(hidden_states)
              hidden_states = hidden_states.permute(0, 2, 1)
  
              # max pool mask
              hidden_mask = (
                  self.pooling(
                      hidden_mask.unsqueeze(0).type_as(hidden_states)
                  )
                  .squeeze(0)
                  .type_as(hidden_mask)
              )
  
      return hidden_states, hidden_mask
  
file_path: NeMo/nemo/collections/nlp/modules/common/transformer/reduction_encoders.py
imports: import copy
  import torch
  from nemo.collections.nlp.modules.common.transformer.transformer_encoders import TransformerEncoder
label_desc: Use image node_id 8 for calling the PoolingEncoder obj's underlying member method code with example usage: obj.forward(encoder_states, encoder_mask) and returns: hidden_states,  hidden_mask