code: def forward(self, xs):
      xs_emb = self.lt(xs)
      if self.freqs is not None:
          # tfidf embeddings
          l = xs.size(1)
          w = torch.Tensor(l)
          for i in range(l):
              w[i] = self.freqs[xs.data[0][i]]
          w = w.mul(1 / w.norm())
          xs_emb = xs_emb.squeeze(0).t().matmul(w.unsqueeze(1)).t()
      else:
          # basic embeddings (faster)
          xs_emb = xs_emb.mean(1)
      return xs_emb
  
file_path: ParlAI/parlai/agents/starspace/modules.py
imports: import math
  import torch
  import torch.nn
label_desc: Use image node_id 2 for calling the Encoder obj's underlying member method code with example usage: obj.forward(xs) and returns: xs_emb