class_docstr: Mixin class for adding basic quantization logic to quantized modules
class_docstr_tok: ["Mixin","class","for","adding","basic","quantization","logic","to","quantized","modules"]
docstr: Helper function for __init__ of simple quantized module
  
  Create input quantizer based on quant_desc passed by kwargs, or default of the class.
  
  Args:
      quant_desc_input: An instance of :class:`QuantDescriptor <csrc.pytorch.pytorch_quantization.tensor_quant.QuantDescriptor>`
docstr_tok: ["Helper","function","for","__init__","of","simple","quantized","module","Create","input","quantizer","based","on","quant_desc","passed","by","kwargs",",","or","default","of","the","class",".","Args",":","quant_desc_input",":","An","instance","of",":","class",":","`","QuantDescriptor","<","csrc.pytorch.pytorch_quantization.tensor_quant.QuantDescriptor",">","`"]
code: def init_quantizer(self, quant_desc_input):
      """Helper function for __init__ of simple quantized module
  
      Create input quantizer based on quant_desc passed by kwargs, or default of the class.
  
      Args:
          quant_desc_input: An instance of :class:`QuantDescriptor <csrc.pytorch.pytorch_quantization.tensor_quant.QuantDescriptor>`
      """
      if not inspect.stack()[1].function == "__init__":
          raise TypeError(
              "{} should be only called by __init__ of quantized module.".format(
                  __name__
              )
          )
      self._fake_quant = True
      if not quant_desc_input.fake_quant:
          raise ValueError("Only fake quantization is supported!")
  
      logger.info(
          "Input is %squantized to %d bits in %s with axis %s!",
          "" if not quant_desc_input.fake_quant else "fake ",
          quant_desc_input.num_bits,
          self.__class__.__name__,
          quant_desc_input.axis,
      )
  
      self._input_quantizer = TensorQuantizer(quant_desc_input)
  
file_path: lightseq/lightseq/csrc/pytorch/pytorch_quantization/nn/modules/_utils.py
imports: import copy
  import inspect
  import logging
  from torch import nn
  from csrc.pytorch.pytorch_quantization.nn import TensorQuantizer
  from csrc.pytorch.pytorch_quantization.tensor_quant import QuantDescriptor, QUANT_DESC_8BIT_PER_TENSOR
label_desc: Use image node_id 2 for calling the QuantInputMixin obj's underlying member method code with example usage: obj.init_quantizer(quant_desc_input) without return types