code: def test_embedding_layer_backward():
      batch_size, seq_len = kt.bs_sl()
      print(f"(batch_size, seq_len): ({batch_size}, {seq_len})")
  
      padding_mask = kt.attn_mask(batch_size, seq_len, dtype=torch.int)
      config = ls_emb_config_fp16
      input = kt.randint(
          config.padding_idx + 1,
          config.vocab_size,
          (batch_size, seq_len),
      )
      pad_left = random.choice([True, False])
      if pad_left:
          input = input * padding_mask + config.padding_idx * (
              1 - padding_mask
          )
      else:
          input = (
              input * (1 - padding_mask)
              + config.padding_idx * padding_mask
          )
  
      if kt.dtype == torch.float:
          custom_layer = custom_emb_layer_fp32
          fs_layer = fs_emb_layer_fp32
      else:
          custom_layer = custom_emb_layer_fp16
          fs_layer = fs_emb_layer_fp16
  
      loss_data = torch.randn(1, dtype=kt.dtype).sum()
  
      def custom():
          custom_layer.zero_grad()
          custom_input = input.clone()
          res = custom_layer(custom_input)
          custom_loss = (res / 1000).sum()
          custom_loss.data.copy_(loss_data)
          custom_loss.backward()
          return [
              custom_layer.embeddings.grad.contiguous().detach()[
                  : custom_layer.embeddings.grad.numel() - 1
              ],
          ]
  
      def baseline():
          fs_layer.zero_grad()
          fs_input = input.clone()
          res = fs_layer(fs_input)
          fs_loss = (res / 1000).sum()
          fs_loss.data.copy_(loss_data)
          fs_loss.backward()
          return [
              fs_layer.embeddings.grad.contiguous().detach(),
          ]
  
      return custom, baseline
  
imports: import random
  import math
  from copy import deepcopy
  from dataclasses import dataclass
  import torch
  import torch.nn
  from tests.util import TestDecorator, get_fairseq_enc_params, get_fairseq_dec_params, max_batch_tokens, max_seq_len, split_custom_layer_grad, copy_grad_from_paras, copy_cmax_grad_from_paras
  from tests import fairseq_layers
  from lightseq.training.ops.pytorch.transformer_encoder_layer import LSTransformerEncoderLayer
  from lightseq.training.ops.pytorch.transformer_embedding_layer import LSTransformerEmbeddingLayer
  from lightseq.training.ops.pytorch.cross_entropy_layer import LSCrossEntropyLayer
  from lightseq.training.ops.pytorch.quant_linear_layer import LSQuantLinearLayer
  from lightseq.training.cli.fs_modules.ls_fs_transformer_decoder_layer import LSFSTransformerDecoderLayer
  from lightseq.training.ops.pytorch.quantization import enable_quant, disable_quant, qat_mode, ptq_mode
label_desc: Use image node_id 24 for calling a global function with example usage: test_embedding_layer_backward() and returns: custom,  baseline, list, list