code: def test_triton_layer_norm(
      M, N, dtype, residual, input_bias, eps=1e-5, device="cuda"
  ):
      if not deepspeed.HAS_TRITON:
          pytest.skip("triton has to be installed for the test")
      torch.manual_seed(0)
      # create data
      x_shape = (M, N)
      w_shape = (x_shape[-1],)
      weight = torch.rand(
          w_shape, dtype=dtype, device="cuda", requires_grad=False
      )
      bias = torch.rand(
          w_shape, dtype=dtype, device="cuda", requires_grad=False
      )
      x_bias = torch.rand(
          w_shape, dtype=dtype, device="cuda", requires_grad=False
      )
      x = -2.3 + 0.5 * torch.randn(x_shape, dtype=dtype, device="cuda")
      dy = 0.1 * torch.randn_like(x)
      if residual:
          res = torch.rand(
              x_shape, dtype=dtype, device="cuda", requires_grad=False
          )
      else:
          res = torch.zeros(
              x_shape, dtype=dtype, device="cuda", requires_grad=False
          )
      x.requires_grad_(True)
      # forward pass
      if residual or input_bias:
          y_tri = layer_norm_residual(
              x, x_bias if input_bias else None, res, weight, bias, eps
          )
      else:
          y_tri = layer_norm(x, weight, bias, eps)
      y_ref = torch.nn.functional.layer_norm(
          x + res + (x_bias if input_bias else 0),
          w_shape,
          weight,
          bias,
          eps,
      ).to(dtype)
      # compare
      assert_almost_equal(y_tri, y_ref)
  
file_path: DeepSpeed/tests/unit/ops/transformer/inference/test_layer_norm.py
imports: import deepspeed
  import torch
  import pytest
  from deepspeed.accelerator import get_accelerator
  from deepspeed.ops.op_builder import InferenceBuilder
  from .inference_test_utils import allclose, get_dtypes, assert_almost_equal
label_desc: Use image node_id 12 for calling a global function with example usage: test_triton_layer_norm(M, N, dtype, residual, input_bias, eps, device) without return types