code: def quantize_pytorch(
      model: Module,
      quantization_type: QuantizationType,
      input_tfms: MultiStageTransformation,
      input_data_torch: List[Tuple[torch.Tensor, ...]],
      device: Device,
  ) -> Union[torch.nn.Module, ScriptModule, GraphModule]:
      model = copy.deepcopy(model).eval()
  
      try:
          model = symbolic_trace(model)
      except Exception:
          logger.warning("Unable to trace model with torch.fx")
  
      if quantization_type is QuantizationType.HALF:
          input_tfms.append(HalfPrecisionTransformation())
          quantized_model = _half_precision(model)
      elif quantization_type is QuantizationType.STATIC:
          quantized_model = _quantize_static(
              model, input_data_torch, device
          )
      elif quantization_type is QuantizationType.DYNAMIC:
          quantized_model = _quantize_dynamic(
              model, input_data_torch, device
          )
      else:
          raise NotImplementedError(
              f"No quantization implemented for quantization "
              f"type {quantization_type}"
          )
  
      return quantized_model
  
file_path: nebuly/optimization/nebullvm/nebullvm/operations/optimizations/compilers/quantizations/pytorch.py
imports: import copy
  from typing import List, Tuple, Union
  from loguru import logger
  from nebullvm.core.models import DeviceType, Device, QuantizationType
  from nebullvm.optional_modules.torch import torch, Module, symbolic_trace, QuantStub, DeQuantStub, GraphModule, default_dynamic_qconfig, prepare_fx, convert_fx, ScriptModule
  from nebullvm.tools.transformations import MultiStageTransformation, HalfPrecisionTransformation
  from nebullvm.tools.utils import check_module_version
label_desc: Use image node_id 8 for calling a global function with example usage: quantize_pytorch(model, quantization_type, input_tfms, input_data_torch, device) and returns: quantized_model