code: def forward(
      self, encoded_layers: List[torch.Tensor], pad_mask: torch.Tensor
  ):
      assert self.num_layers <= len(
          encoded_layers
      ), "k should be less than the number of encoder layers"
      encoder_avg = torch.cat(encoded_layers[-self.num_layers :], 2)
  
      pad_mask = pad_mask.unsqueeze(2)
      encoder_avg = encoder_avg * pad_mask.float()
      pooled_output = torch.sum(encoder_avg, 1) / (
          torch.sum(pad_mask, 1).float() + self.tol
      )
      return pooled_output
  
imports: from typing import Any, List
  import torch
  import torch.nn
  from mmf.common.registry import registry
label_desc: Use image node_id 2 for calling the AverageConcatLastN obj's underlying member method code with example usage: obj.forward(encoded_layers, pad_mask) and returns: pooled_output