code: def test_launch_ln_i8O_bw():
      batch_size, seq_len = kt.bs_sl()
      bsz_seq = batch_size * seq_len
      hidden_dim = kt.hidden_dim
      with_mean = random.choice([True, False])
      fuse_add = random.choice([True, False])
      print(
          "(batch_token_num, hidden_dim, with_mean, fuse_add): "
          f"({bsz_seq}, {hidden_dim}, {with_mean}, {fuse_add})"
      )
  
      # shared weights
      inp = kt.rand((bsz_seq, hidden_dim))
      out_grad = kt.rand((bsz_seq, hidden_dim))
      residual_grad = kt.rand((bsz_seq, hidden_dim))
      gamma = kt.rand((hidden_dim))
      betta = kt.rand((hidden_dim))
      # forward
      ln_output = functional.layer_norm(
          inp, [hidden_dim], gamma, betta, kt.epsilon
      )
      vars = inp.var(dim=1).contiguous()
      means = inp.mean(dim=1).contiguous()
      cmax = kt.topk(inp)
      cmask = kt.get_cmask(ln_output, cmax)
      inp_or_out = inp if with_mean else ln_output
  
      # custom weights
      gamma_grad = kt.rand((hidden_dim))
      betta_grad = kt.rand((hidden_dim))
      inp_grad = kt.rand((bsz_seq, hidden_dim))
      cmax_grad = kt.zeros(1)
  
      if kt.dtype == torch.float:
          func = cuda_module.torch_launch_ln_bw_i8_fp32
      else:
          func = cuda_module.torch_launch_ln_bw_i8_fp16
  
      def custom():
          func(
              gamma_grad,
              betta_grad,
              inp_grad,
              cmax_grad,
              out_grad,
              residual_grad,
              inp_or_out,
              gamma,
              betta,
              vars,
              means,
              cmask,
              bsz_seq,
              hidden_dim,
              with_mean,
              fuse_add,
          )
          return [gamma_grad, betta_grad, inp_grad, cmax_grad]
  
      def baseline():
          if with_mean:
              (
                  f_out_grad,
                  f_input,
                  f_vars,
                  f_means,
                  f_betta,
                  f_gamma,
              ) = kt.cast_fp32_tensor(
                  [out_grad, inp, vars, means, betta, gamma]
              )
              xhat = (
                  f_input - f_means.unsqueeze(1)
              ) * f_vars.rsqrt().unsqueeze(1)
          else:
              (
                  f_out_grad,
                  f_out,
                  f_vars,
                  f_betta,
                  f_gamma,
              ) = kt.cast_fp32_tensor(
                  [out_grad, ln_output, vars, betta, gamma]
              )
              xhat = (f_out - f_betta) / f_gamma
          f_out_grad_inrange = kt.tensor_inrange(
              f_out_grad, ln_output, cmax
          )
          f_out_grad_outrange = kt.tensor_outrange(
              f_out_grad, ln_output, cmax
          )
          f_cmax_grad = f_out_grad_outrange.sum()
          dxhat = f_out_grad_inrange * f_gamma
          f_betta_grad = f_out_grad_inrange.sum(dim=0)
          f_gamma_grad = (f_out_grad_inrange * xhat).sum(dim=0)
          dinp = dxhat.sum(dim=1).unsqueeze(1) + xhat * (
              dxhat * xhat
          ).sum(dim=1).unsqueeze(1)
          dinp = dxhat - dinp / hidden_dim
          dinp = dinp * f_vars.rsqrt().unsqueeze(1)
          if fuse_add:
              dinp = dinp + residual_grad
          return kt.norm_res_list(
              f_gamma_grad, f_betta_grad, dinp, f_cmax_grad
          )
  
      return custom, baseline
  
imports: import random
  import torch
  from torch._C import ScriptModule, dtype
  from torch.nn import functional
  from lightseq.training.ops.pytorch.builder import KernelBuilder, AdamBuilder
  from tests.util import TestDecorator
  from torch_crf import CRF
label_desc: Use image node_id 13 for calling a global function with example usage: test_launch_ln_i8O_bw() and returns: custom,  baseline, list, kt