code: def test_int_softmax(self):
      output_bit = 8
      softmax_q = IntSoftmax(output_bit, quant_mode=True)
      softmax_dq = nn.Softmax()
  
      def _test(array):
          x_int = torch.tensor(array)
          x_scaling_factor = torch.tensor(0.1)
          x = x_int * x_scaling_factor
  
          q, q_scaling_factor = softmax_q(x, x_scaling_factor)
          q_int = q / q_scaling_factor
          dq = softmax_dq(x)
  
          # output of the normal Softmax and the quantized Softmax 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)
          )
  
          # Output of the quantize Softmax should not exceed the output_bit
          self.assertTrue(q.abs().max() < 2**output_bit)
  
      array = [[i + j for j in range(10)] for i in range(-10, 10)]
      _test(array)
      array = [[i + j for j in range(50)] for i in range(-10, 10)]
      _test(array)
      array = [[i + 100 * j for j in range(2)] for i in range(-10, 10)]
      _test(array)
  
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 6 for calling the IBertModelIntegrationTest obj's underlying member method code with example usage: obj.test_int_softmax() without return types