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
docstr: quantize real value.
  
  Parameters
  ----------
  bits : int
      quantization bits length
  op : torch.nn.Module
      target module
  real_val : Tensor
      real value to be quantized
  
  Returns
  -------
  Tensor
docstr_tok: ["quantize","real","value",".","Parameters","--","--","--","--","--","bits",":","int","quantization","bits","length","op",":","torch.nn.Module","target","module","real_val",":","Tensor","real","value","to","be","quantized","Returns","--","--","--","-","Tensor"]
code: def _quantize(self, bits, op, real_val):
      """
      quantize real value.
  
      Parameters
      ----------
      bits : int
          quantization bits length
      op : torch.nn.Module
          target module
      real_val : Tensor
          real value to be quantized
  
      Returns
      -------
      Tensor
      """
      op.zero_point = op.zero_point.to(real_val.device)
      op.scale = op.scale.to(real_val.device)
      transformed_val = op.zero_point + real_val / op.scale
      qmin = 0
      qmax = (1 << bits) - 1
      clamped_val = torch.clamp(transformed_val, qmin, qmax)
      quantized_val = torch.round(clamped_val)
      return quantized_val
  
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 3 for calling the QAT_Quantizer obj's underlying member method code with example usage: obj._quantize(bits, op, real_val) and returns: quantized_val