class_docstr: Custom Encoder with extended position embedding that is shift-invariant.
class_docstr_tok: ["Custom","Encoder","with","extended","position","embedding","that","is","shift-invariant","."]
docstr: Embed tokens prior to feeding into transformer.
  
  :param LongTensor[batch,seqlen] input:
      The input IDs
  :param LongTensor[batch,seqlen] positions:
      Positions for input IDs
  :param LongTensor[batch,seqlen]:
      If provided, additionally adds ``segments`` as extra embedding features.
  
  :return (tensor, mask):
      return embedded input and mask
docstr_tok: ["Embed","tokens","prior","to","feeding","into","transformer",".",":","param","LongTensor","[","batch",",","seqlen","]","input",":","The","input","IDs",":","param","LongTensor","[","batch",",","seqlen","]","positions",":","Positions","for","input","IDs",":","param","LongTensor","[","batch",",","seqlen","]",":","If","provided",",","additionally","adds","``","segments","``","as","extra","embedding","features",".",":","return","(","tensor",",","mask",")",":","return","embedded","input","and","mask"]
code: def forward_embedding(
      self,
      input: torch.LongTensor,
      positions: Optional[torch.LongTensor] = None,
      segments: Optional[torch.LongTensor] = None,
  ) -> Tuple[torch.Tensor, torch.BoolTensor]:
      """
      Embed tokens prior to feeding into transformer.
  
      :param LongTensor[batch,seqlen] input:
          The input IDs
      :param LongTensor[batch,seqlen] positions:
          Positions for input IDs
      :param LongTensor[batch,seqlen]:
          If provided, additionally adds ``segments`` as extra embedding features.
  
      :return (tensor, mask):
          return embedded input and mask
      """
      if self.n_positions_init is not None:
          mask = input != self.padding_idx
          if positions is None:
              positions = (
                  mask.cumsum(dim=1, dtype=torch.int64) - 1
              ).clamp_(min=0)
          positions = self.rearrange_positions(positions)  # type: ignore
      return super().forward_embedding(input, positions, segments)
  
file_path: ParlAI/projects/msc/agents/long_tga.py
imports: import torch
  from typing import Optional, Tuple
  from parlai.agents.transformer.modules import TransformerDecoder, TransformerEncoder, TransformerGeneratorModel
  from parlai.agents.transformer.transformer import TransformerGeneratorAgent
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser
label_desc: Use image node_id 2 for calling the ShiftInvariantForwardEmbeddingMixin obj's underlying member method code with example usage: obj.forward_embedding(input, positions, segments) and returns: super