code: def quantize_tenary(self, inputs):
      input_flat = inputs.reshape(self.q_groups, -1)
      n = input_flat.shape[1]
      m = input_flat.norm(p=1, dim=1).div(n)
      thres = (0.7 * m).view(-1, 1)  # .expand_as(input_flat)
      pos = (input_flat > thres).type(inputs.type())
      neg = (input_flat < -thres).type(inputs.type())
      mask = (input_flat.abs() > thres).type(inputs.type())
      alpha = (
          (mask * input_flat).abs().sum(dim=1) / mask.sum(dim=1)
      ).view(-1, 1)
      output = alpha * pos - alpha * neg
      output = output.reshape(inputs.shape).contiguous()
      return output
  
file_path: H2O/h2o_flexgen/benchmark/third_party/DeepSpeed/deepspeed/runtime/quantize.py
imports: import torch
  import math
  from deepspeed.utils import logger
  from deepspeed.ops.quantizer import ds_quantizer
label_desc: Use image node_id 6 for calling the Quantizer obj's underlying member method code with example usage: obj.quantize_tenary(inputs) and returns: output