class_docstr: Implementation of a Basic Iterative Pruner.
  Any iterative pruning technique can be extended from this by implementing the `prune_model` method.
  
  :param model: Model that needs to be pruned
  :type model: torch.nn.Module
  :param train_loader: Dataloader for training
  :type train_loader: torch.utils.data.DataLoader
  :param test_loader: Dataloader for validation/testing
  :type test_loader: torch.utils.data.DataLoader
  :param loss_fn: Loss function to be used for training
  :type loss_fn: torch.nn.Module
  :param device: Device used for implementation ("cpu" by default)
  :type device: torch.device
class_docstr_tok: ["Implementation","of","a","Basic","Iterative","Pruner",".","Any","iterative","pruning","technique","can","be","extended","from","this","by","implementing","the","`","prune_model","`","method",".",":","param","model",":","Model","that","needs","to","be","pruned",":","type","model",":","torch.nn.Module",":","param","train_loader",":","Dataloader","for","training",":","type","train_loader",":","torch.utils.data.DataLoader",":","param","test_loader",":","Dataloader","for","validation\/testing",":","type","test_loader",":","torch.utils.data.DataLoader",":","param","loss_fn",":","Loss","function","to","be","used","for","training",":","type","loss_fn",":","torch.nn.Module",":","param","device",":","Device","used","for","implementation","(","``","cpu","''","by","default",")",":","type","device",":","torch.device"]
docstr: Function used for facilitating the pruning pipeline
  
  :param num_iterations: Number of iterations for pruning
  :type num_iterations: int
  :param train_epochs: Number of iterations for training per pruning iteration
  :type train_epochs: int
  :param save_models: True if validated models (per pruning iteration) need to be saved
  :type save_models: bool
  :param prune_params: Any additional parameters needed by the "prune_model" method (specific to pruning technique used)
docstr_tok: ["Function","used","for","facilitating","the","pruning","pipeline",":","param","num_iterations",":","Number","of","iterations","for","pruning",":","type","num_iterations",":","int",":","param","train_epochs",":","Number","of","iterations","for","training","per","pruning","iteration",":","type","train_epochs",":","int",":","param","save_models",":","True","if","validated","models","(","per","pruning","iteration",")","need","to","be","saved",":","type","save_models",":","bool",":","param","prune_params",":","Any","additional","parameters","needed","by","the","``","prune_model","''","method","(","specific","to","pruning","technique","used",")"]
code: def prune(
      self,
      num_iterations=10,
      train_epochs=10,
      save_models=True,
      **prune_params,
  ):
      """
      Function used for facilitating the pruning pipeline
  
      :param num_iterations: Number of iterations for pruning
      :type num_iterations: int
      :param train_epochs: Number of iterations for training per pruning iteration
      :type train_epochs: int
      :param save_models: True if validated models (per pruning iteration) need to be saved
      :type save_models: bool
      :param prune_params: Any additional parameters needed by the "prune_model" method (specific to pruning technique used)
      """
  
      for it in range(num_iterations):
          print(
              "======== Pruning Iteration {:} / {:} ========".format(
                  it + 1, num_iterations
              )
          )
          if not it == 0:
              self.prune_model(**prune_params)
          self.optimizer = torch.optim.Adam(self.model.parameters())
          self.finetune_model(
              train_epochs,
              save_models,
              f"pruned_model_iteration_{it}.pt",
          )
  
file_path: KD_Lib/KD_Lib/Pruning/common/iterative_base_class.py
imports: import copy
  import numpy
  import torch
  import torch.nn
label_desc: Use image node_id 6 for calling the BaseIterativePruner obj's underlying member method code with example usage: obj.prune(num_iterations, train_epochs, save_models) without return types