code: def run_integer_quantize(q_bits, activations_ref, num_groups):
      activations_ref = activations_ref.reshape(num_groups, -1).to(
          dtype=torch.float32
      )
  
      max_abs_activations_ref = torch.amax(
          torch.abs(activations_ref), dim=-1
      ).view(num_groups, -1)
  
      _, q_max, q_min = get_q_props(q_bits)
      print(max_abs_activations_ref)
      max_abs_activations_ref = (
          (max_abs_activations_ref + 1).to(torch.int8).to(torch.float32)
      )
      print(max_abs_activations_ref)
      numerator = activations_ref * q_max
      print(numerator.dtype)
      denominator = max_abs_activations_ref
  
      data_f = numerator / denominator
  
      data_i32 = torch.round(data_f).to(dtype=torch.int32)
      data_i32 = torch.minimum(
          torch.maximum(data_i32, q_min.expand_as(data_i32)),
          q_max.expand_as(data_i32),
      )
      data_i8 = data_i32.to(dtype=torch.int8)
  
      return data_i8, max_abs_activations_ref.to(torch.int32)
  
file_path: H2O/h2o_flexgen/benchmark/third_party/DeepSpeed/tests/unit/ops/quantizer/test_quantize.py
imports: import pytest
  import torch
  from deepspeed.ops import op_builder
label_desc: Use image node_id 8 for calling a global function with example usage: run_integer_quantize(q_bits, activations_ref, num_groups) and returns: data_i8,  max_abs_activations_ref