class_docstr: Quantizer defined in:
  Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference
  http://openaccess.thecvf.com/content_cvpr_2018/papers/Jacob_Quantization_and_Training_CVPR_2018_paper.pdf
code: def quantize_weight(self, wrapper, **kwargs):
      config = wrapper.config
      module = wrapper.module
      weight = copy.deepcopy(wrapper.module.old_weight.data)
      weight_bits = get_bits_length(config, "weight")
      quant_start_step = config.get("quant_start_step", 0)
      assert weight_bits >= 1, "quant bits length should be at least 1"
  
      # we dont update weight in evaluation stage
      if (
          quant_start_step > self.bound_model.steps
          or not wrapper.training
      ):
          return weight
  
      # if bias exists, quantize bias to uint32
      if (
          hasattr(wrapper.module, "bias")
          and wrapper.module.bias is not None
      ):
          bias = wrapper.module.bias.data
          bias_bits = 32
          rmin, rmax = torch.min(bias), torch.max(bias)
          module.scale, module.zero_point = update_quantization_param(
              bias_bits, rmin, rmax
          )
          bias = self._quantize(bias_bits, module, bias)
          bias = self._dequantize(module, bias)
          wrapper.module.bias.data = bias
  
      # quantize weight
      rmin, rmax = torch.min(weight), torch.max(weight)
      module.scale, module.zero_point = update_quantization_param(
          weight_bits, rmin, rmax
      )
      weight = self._quantize(weight_bits, module, weight)
      weight = self._dequantize(module, weight)
      wrapper.module.weight = weight
      return weight
  
imports: import logging
  import copy
  import torch
  from schema import Schema, And, Or, Optional
  from ..utils.config_validation import CompressorSchema
  from ..compressor import Quantizer, QuantGrad, QuantType
label_desc: Use image node_id 5 for calling the QAT_Quantizer obj's underlying member method code with example usage: obj.quantize_weight(wrapper) and returns: weight, weight