code: def _mean_pooling(enc_feats, src_masks):
      # enc_feats: T x B x C
      # src_masks: B x T or None
      if src_masks is None:
          enc_feats = enc_feats.mean(0)
      else:
          src_masks = (~src_masks).transpose(0, 1).type_as(enc_feats)
          enc_feats = (
              (enc_feats / src_masks.sum(0)[None, :, None])
              * src_masks[:, :, None]
          ).sum(0)
      return enc_feats
  
imports: import torch
  import torch.nn.functional
  from fairseq import utils
  from fairseq.iterative_refinement_generator import DecoderOut
  from fairseq.models import register_model, register_model_architecture
  from fairseq.models.nat import FairseqNATDecoder, FairseqNATModel, ensemble_decoder
  from fairseq.models.transformer import Embedding
  from fairseq.modules.transformer_sentence_encoder import init_bert_params
label_desc: Use image node_id 1 for calling a global function with example usage: _mean_pooling(enc_feats, src_masks) and returns: enc_feats