code: def build_embedding(
      cls,
      args,
      dictionary,
      embed_dim,
      max_positions,
      emb_lookup=None,
      **kwargs,
  ):
      use_torch_layer = (
          args.use_torch_layer
          or args.no_scale_embedding
          or args.layernorm_embedding
      )
      config = TransformerEmbeddingLayerBase.get_config(
          vocab_size=len(dictionary),
          embedding_dim=embed_dim,
          max_batch_tokens=args.max_tokens,
          max_seq_len=max_positions,
          padding_idx=dictionary.pad(),
          dropout=args.dropout,
          fp16=args.fp16,
          local_rank=args.device_id,
          trainable_pos=(
              args.encoder_learned_pos or args.decoder_learned_pos
          ),
          no_scale_embedding=args.no_scale_embedding,
          layernorm_embedding=args.layernorm_embedding,
          need_offset=("bart" in args.arch),
      )
      if use_torch_layer:
          from lightseq.training.ops.pytorch.torch_transformer_layers import (
              TransformerEmbeddingLayer,
          )
  
          if emb_lookup is not None:
              emb_lookup = emb_lookup.emb_lookup
          emb = TransformerEmbeddingLayer(config, emb_lookup=emb_lookup)
      else:
          from lightseq.training.ops.pytorch.transformer_embedding_layer import (
              LSTransformerEmbeddingLayer as TransformerEmbeddingLayer,
          )
  
          if emb_lookup is not None:
              return emb_lookup
          emb = TransformerEmbeddingLayer(config)
  
      return emb
  
imports: import torch
  import torch.nn
  from fairseq import utils
  from fairseq.models import FairseqEncoder, FairseqEncoderDecoderModel, FairseqIncrementalDecoder, register_model, register_model_architecture
  from fairseq.models.fairseq_encoder import EncoderOut
  from fairseq.modules import LayerNorm
  from lightseq.training.ops.pytorch.layer_base import TransformerEmbeddingLayerBase
  from lightseq.training.ops.pytorch.quantization import QuantLinear, disable_quant, enable_quant, ptq_mode, qat_mode
label_desc: Use image node_id 4 for calling the LSTransformerModel obj's underlying member method code with example usage: obj.build_embedding(cls, args, dictionary, embed_dim, max_positions, emb_lookup) and returns: emb, emb_lookup