code: def quant_weight_inplace(model):
      """Make quantization inplace
  
      Search for quantized modules including QuantConvNd and QuantLinear, make weight quantization in place using
      weight_quantizer.
  
      Most publications of quantization aware training uses STE by default, which is really an approximation of
      derivative of the nondifferentiable quantization function, which works to some extended but by no means the F=ma of
      the problem.
      Inplace quantization can be used to implement relax-and-round, which is a common method in Discrete Optimization's
      or Integer Programming.
      """
      for name, module in model.named_modules():
          if (
              hasattr(module, "_weight_quantizer")
              and module.weight_quantizer is not None
          ):
              if not module.weight_quantizer.fake_quant:
                  logger.warning(
                      (
                          "In-place real quantization is VERY dangerous and should be used for inference only. "
                          "Make sure that is the desired behavior."
                      )
                  )
              logger.warning("In-place quantize weight of %s", name)
              module.weight.data.copy_(
                  module.weight_quantizer(module.weight)
              )
  
imports: import re
  import logging
label_desc: Use image node_id 4 for calling a global function with example usage: quant_weight_inplace(model) without return types