class_docstr: Implementation of Static Quantization for PyTorch models.
  
  :param model: Model that needs to be pruned
  :type model: torch.nn.Module
  :param qconfig: Configuration used for quantization
  :type qconfig: Qconfig
  :param train_loader: DataLoader used for training (calibration)
  :type train_loader: torch.utils.data.DataLoader
  :param test_loader: DataLoader used for testing
  :type test_loader: torch.utils.data.DataLoader
  :param criterion: Loss function used for calibration
  :type criterion: Loss_fn
  :param device: Device used for training ("cpu" or "cuda")
  :type device: torch.device
docstr: Function used for calibrating the model for quantization
  
  :param num_batches: Number of batches used for calibration
  :type num_batches: int
docstr_tok: ["Function","used","for","calibrating","the","model","for","quantization",":","param","num_batches",":","Number","of","batches","used","for","calibration",":","type","num_batches",":","int"]
code: def _calibrate_model(self, num_batches):
      """
      Function used for calibrating the model for quantization
  
      :param num_batches: Number of batches used for calibration
      :type num_batches: int
      """
  
      self.quantized_model.eval()
      correct = 0
      cnt = 0
      len_dataset = min(
          num_batches * self.train_loader.batch_size,
          len(self.train_loader.dataset),
      )
  
      with torch.no_grad():
          for image, target in self.train_loader:
              output = self.quantized_model(image)
  
              if isinstance(output, tuple):
                  output = output[0]
  
              loss = self.criterion(output, target)
              cnt += 1
              pred = output.argmax(dim=1, keepdim=True)
              correct += pred.eq(target.view_as(pred)).sum().item()
              if cnt >= num_batches:
                  return correct / len_dataset
  
      return correct / len_dataset
  
file_path: KD_Lib/KD_Lib/Quantization/static/static_quantization.py
imports: from copy import deepcopy
  import torch
  from KD_Lib.Quantization.common import Quantizer
label_desc: Use image node_id 3 for calling the Static_Quantizer obj's underlying member method code with example usage: obj._calibrate_model(num_batches) and returns: unknown, unknown