code: def test_int_layernorm(self):
      output_bit = 8
  
      # some random matrix
      array = [
          [[i * j * j + j for j in range(5, 15)]]
          for i in range(-10, 10)
      ]
      x_int = torch.tensor(array)
      x_scaling_factor = torch.tensor(0.1)
      x = x_int * x_scaling_factor
  
      ln_q = IntLayerNorm(
          x.shape[1:], 1e-5, quant_mode=True, output_bit=output_bit
      )
      ln_dq = nn.LayerNorm(x.shape[1:], 1e-5)
  
      ln_q.weight = nn.Parameter(torch.ones(x.shape[1:]))
      ln_q.bias = nn.Parameter(torch.ones(x.shape[1:]))
      ln_dq.weight = nn.Parameter(torch.ones(x.shape[1:]))
      ln_dq.bias = nn.Parameter(torch.ones(x.shape[1:]))
  
      q, q_scaling_factor = ln_q(x, x_scaling_factor)
      q_int = q / q_scaling_factor
      dq = ln_dq(x)
  
      # output of the normal LN and the quantized LN should be similar
      self.assertTrue(torch.allclose(q, dq, atol=0.5))
  
      # output of the quantized GELU layer should be integer
      self.assertTrue(torch.allclose(q_int, q_int.round(), atol=1e-4))
  
imports: import copy
  import unittest
  from transformers import IBertConfig, is_torch_available
  from transformers.testing_utils import require_torch, slow, torch_device
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
  from ...test_pipeline_mixin import PipelineTesterMixin
label_desc: Use image node_id 8 for calling the IBertModelIntegrationTest obj's underlying member method code with example usage: obj.test_int_layernorm() without return types