code: def quantize(args: argparse.Namespace):
      setup_main_logger(
          file_logging=False,
          console=not args.quiet,
          level=args.loglevel,
      )
      utils.log_basic_info(args)
  
      params_fname = os.path.join(args.model, C.PARAMS_BEST_NAME)
      config_fname = os.path.join(args.model, C.CONFIG_NAME)
  
      model, _, _ = load_model(args.model, device=pt.device("cpu"))
      original_dtype = model.config.dtype
  
      if original_dtype == args.dtype:
          logger.info(
              f"Model already has dtype {args.dtype}. Skipping quantization."
          )
          return
  
      backup_params_fname = f"{params_fname}.{original_dtype}"
      backup_config_fname = f"{config_fname}.{original_dtype}"
  
      for fname in (backup_params_fname, backup_config_fname):
          if os.path.exists(fname):
              raise FileExistsError(
                  f"File {fname} exists. To quantize this model, make sure that {params_fname} and "
                  f"{config_fname} match the original dtype and that {backup_params_fname} and "
                  f"{backup_config_fname} do not exist."
              )
  
      logger.info(f"Moving {params_fname} -> {backup_params_fname}")
      os.rename(params_fname, backup_params_fname)
      logger.info(f"Moving {config_fname} -> {backup_config_fname}")
      os.rename(config_fname, backup_config_fname)
  
      model.cast(args.dtype)
  
      model.save_parameters(params_fname)
      model.save_config(args.model)
  
file_path: sockeye/sockeye/quantize.py
imports: import argparse
  import logging
  import os
  import torch
  from .None import arguments
  from .None import constants
  from .None import utils
  from .log import setup_main_logger
  from .model import load_model
label_desc: Use image node_id 2 for calling a global function with example usage: quantize(args) without return types