code: def mean(rep: Tensor, padding_mask: Optional[Tensor]):
      rep_sum = rep.sum(dim=1)  # B x T x C => B x C
      if padding_mask is not None:
          lengths = (~padding_mask).sum(dim=1).reshape(-1, 1)
      else:
          bsz, max_token_len, _embed_dim = rep.size()
          lengths = torch.full(
              (bsz, 1),
              max_token_len,
              dtype=torch.long,
              device=rep.device,
          )
  
      return rep_sum / lengths
  
imports: from typing import List, Optional, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from pytext.config.module_config import Activation, ModuleConfig
  from pytext.models.module import create_module, Module
  from pytext.optimizer import get_activation
  from torch import Tensor
  from .light_conv import LightweightConv
label_desc: Use image node_id 1 for calling a global function with example usage: mean(rep, padding_mask) and returns: unknown