class_docstr: Embed sequences for MemNN model.
  
  Applies Position Encoding if enabled and currently applies BOW sum.
class_docstr_tok: ["Embed","sequences","for","MemNN","model",".","Applies","Position","Encoding","if","enabled","and","currently","applies","BOW","sum","."]
docstr: Return BOW embedding with PE reweighting if enabled.
  
  :param input:
      (bsz x seqlen) LongTensor
  
  :returns:
      (bsz x esz) FloatTensor
docstr_tok: ["Return","BOW","embedding","with","PE","reweighting","if","enabled",".",":","param","input",":","(","bsz","x","seqlen",")","LongTensor",":","returns",":","(","bsz","x","esz",")","FloatTensor"]
code: def forward(self, input):
      """
      Return BOW embedding with PE reweighting if enabled.
  
      :param input:
          (bsz x seqlen) LongTensor
  
      :returns:
          (bsz x esz) FloatTensor
      """
      embs = super().forward(input)
      if self.position_encoding:
          if embs.dim() == 3:
              num_mems, seqlen, embdim = embs.size()
              pe = self.position_matrix(seqlen, embdim, embs.is_cuda)
              for i in range(num_mems):
                  embs[i] *= pe
          else:
              bsz, num_mems, seqlen, embdim = embs.size()
              pe = self.position_matrix(seqlen, embdim, embs.is_cuda)
              for i in range(num_mems):
                  embs[:, i] *= pe
      return self._reduce(embs, input)
  
file_path: ParlAI/parlai/agents/memnn/modules.py
imports: import torch
  import torch.nn
  from parlai.utils.torch import neginf
  from functools import lru_cache
label_desc: Use image node_id 3 for calling the Embed obj's underlying member method code with example usage: obj.forward(input) and returns: self