code: def test_decoder_layer_forward_inference():
      batch_size, enc_seq_len = kt.bs_sl()
      beam_size = random.randint(2, 5)
      print(
          f"(batch_size, enc_seq_len, beam_size): ({batch_size}, {enc_seq_len},"
          f" {beam_size})"
      )
  
      ls_encoder_out = kt.rand((enc_seq_len, batch_size, 1024))
      fs_encoder_out = (
          ls_encoder_out.unsqueeze(2)
          .repeat(1, 1, beam_size, 1)
          .reshape(enc_seq_len, -1, 1024)
      )
      ls_enc_mask = kt.attn_mask(
          batch_size, enc_seq_len, dtype=torch.bool
      )
      fs_enc_mask = (
          ls_enc_mask.unsqueeze(1)
          .repeat(1, beam_size, 1)
          .reshape(-1, enc_seq_len)
      )
  
      hidden_states_list = []
      max_step = 10
      for _ in range(max_step):
          hidden_states = kt.rand((batch_size * beam_size, 1, 1024))
          hidden_states_list.append(hidden_states)
  
      def custom():
          incremental_state = {}
          res_list = []
          for i in range(max_step):
              res = hidden_states_list[i].clone()
              for i in range(NUM_LAYERS):
                  res, _, _ = custom_dec_layer_list[i](
                      res,
                      encoder_out=ls_encoder_out,
                      encoder_padding_mask=ls_enc_mask,
                      incremental_state=incremental_state,
                  )
              res_list.append(res)
          return [x.contiguous().detach() for x in res_list]
  
      def baseline():
          incremental_state = {}
          res_list = []
          for i in range(max_step):
              res = hidden_states_list[i].clone()
              for i in range(NUM_LAYERS):
                  res, _, _ = fairseq_dec_layer_list[i](
                      res,
                      encoder_out=fs_encoder_out,
                      encoder_padding_mask=fs_enc_mask,
                      incremental_state=incremental_state,
                  )
              res_list.append(res)
          return [x.contiguous().detach() for x in res_list]
  
      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 21 for calling a global function with example usage: test_decoder_layer_forward_inference() and returns: custom,  baseline, unknown, unknown