code: def __init__(self, config_path, max_epoch, max_update):
      try:
          import yaml
      except ImportError:
          raise ImportError(
              "Please install yaml with: pip install yaml"
          )
  
      # parse config
      if config_path:
          with open(config_path) as config_file:
              config = quantization_options.parse_config_yaml(
                  yaml.safe_load(config_file)
              )
      else:
          config = quantization_options.parse_config_yaml({})
  
      self.n_centroids_config = config["n_centroids"]
      self.block_sizes_config = config["block_sizes"]
      self.layers_to_quantize = config["layers_to_quantize"]
  
      # We assume that training will run for a fixed number of epochs
      # (or updates) and that we should train for equal durations
      # between iterations of PQ.
      num_iterations = len(self.layers_to_quantize)
      if max_epoch > 0:
          assert max_epoch % num_iterations == 0, (
              "for iterative PQ, --max-epoch (={}) must be evenly divisible by "
              "len(layers_to_quantize) (={})".format(
                  max_epoch, num_iterations
              )
          )
          self.epoch_schedule = max_epoch // num_iterations
      else:
          self.epoch_schedule = None
      if max_update > 0:
          assert max_update % num_iterations == 0, (
              "for iterative PQ, --max-update (={}) must be evenly divisible by "
              "len(layers_to_quantize) (={})".format(
                  max_update, num_iterations
              )
          )
          self.update_schedule = max_update // num_iterations
      else:
          self.update_schedule = None
      assert (self.epoch_schedule is not None) ^ (
          self.update_schedule is not None
      ), "for iterative PQ, cannot specify both --max-update and --max-epoch"
  
      # 0 is a special value for quantization step, which will force
      # the first call to begin_epoch() to call step()
      self.quantization_step = 0
  
file_path: fairseq/fairseq/quantization_utils.py
imports: import logging
  from fairseq.modules.quantization import pq, quantization_options, scalar
  from omegaconf import DictConfig
label_desc: Use image node_id 1 to create a new Quantizer object from inherited base classes: object with example: obj = Quantizer(config_path, max_epoch, max_update)