class_docstr: Encoder Embedding + Positional Embedding
class_docstr_tok: ["Encoder","Embedding","+","Positional","Embedding"]
code: def __init__(self, args, embed_tokens):
      super().__init__()
      self.dropout = args.dropout
      self.max_source_positions = args.max_source_positions
      self.embed_tokens = embed_tokens
      if isinstance(embed_tokens, nn.ModuleList):
          self.padding_idx = embed_tokens[0].padding_idx
          embed_dim = sum(e.embedding_dim for e in embed_tokens)
      else:
          self.padding_idx = embed_tokens.padding_idx
          embed_dim = embed_tokens.embedding_dim
      self.embed_scale = math.sqrt(embed_dim)
      self.embed_positions = (
          PositionalEmbedding(
              args.max_source_positions,
              embed_dim,
              self.padding_idx,
              learned=args.encoder_learned_pos,
          )
          if not args.no_token_positional_embeddings
          else None
      )
      if getattr(args, "layernorm_embedding", False):
          self.layernorm_embedding = LayerNorm(embed_dim)
      else:
          self.layernorm_embedding = None
  
imports: import math
  from collections import namedtuple
  import torch
  import torch.nn
  import torch.nn.functional
  from fairseq import options, utils
  from fairseq.modules import AdaptiveSoftmax, LayerNorm, MultiheadAttention, PositionalEmbedding
label_desc: Use image node_id 1 to create a new TransformerEncoderEmbedding object from inherited base classes: nn with example: obj = TransformerEncoderEmbedding(args, embed_tokens)