class_docstr: The BaseDataScheduler is the abstract scheduler class specifically for the
  BaseDataSparsifier class. This class controls a specific hyperparameter of
  the sparsifier class and varies it across the training process (or across time).
  
  Args:
      data_sparsifier (instance of BaseDataSparsifier)
          Implemented class data sparsifier class wherein the update_mask is implemented
      schedule_param (str)
          A specific hyperparameter of the passed sparsifier that needs to be scheduled/varied
      last_epoch (int, default=-1)
          This is specifically is passed when training needs to be resumed from a particular
          point.
      verbose (bool, default=False)
          Verbosity of the BaseDataScheduler
  
  The *get_hyperparam()* function needs to be implemented by the user.
class_docstr_tok: ["The","BaseDataScheduler","is","the","abstract","scheduler","class","specifically","for","the","BaseDataSparsifier","class",".","This","class","controls","a","specific","hyperparameter","of","the","sparsifier","class","and","varies","it","across","the","training","process","(","or","across","time",")",".","Args",":","data_sparsifier","(","instance","of","BaseDataSparsifier",")","Implemented","class","data","sparsifier","class","wherein","the","update_mask","is","implemented","schedule_param","(","str",")","A","specific","hyperparameter","of","the","passed","sparsifier","that","needs","to","be","scheduled\/varied","last_epoch","(","int",",","default=-1",")","This","is","specifically","is","passed","when","training","needs","to","be","resumed","from","a","particular","point",".","verbose","(","bool",",","default=False",")","Verbosity","of","the","BaseDataScheduler","The","*","get_hyperparam","(",")","*","function","needs","to","be","implemented","by","the","user","."]
code: def __init__(
      self,
      data_sparsifier,
      schedule_param: str,
      last_epoch=-1,
      verbose=False,
  ):
      # Attach sparsifier
      if not isinstance(data_sparsifier, BaseDataSparsifier):
          raise TypeError(
              "{} is not an instance of torch.ao.pruning.BaseDataSparsifier".format(
                  type(data_sparsifier).__name__
              )
          )
      self.data_sparsifier = data_sparsifier
      self.schedule_param = schedule_param
  
      # Initialize epoch and base hyper-params
      self.base_param = {
          name: config.get(schedule_param, None)
          for name, config in self.data_sparsifier.data_groups.items()
      }
  
      self.last_epoch = last_epoch
  
      # Following https://github.com/pytorch/pytorch/issues/20124
      # We would like to ensure that `scheduler.step()` is called after
      # `sparsifier.step()`
      def with_counter(method):
          if getattr(method, "_with_counter", False):
              # `sparsifier.step()` has already been replaced, return.
              return method
  
          # Keep a weak reference to the sparsifier instance to prevent
          # cyclic references.
          instance_ref = weakref.ref(method.__self__)
          # Get the unbound method for the same purpose.
          func = method.__func__
          cls = instance_ref().__class__
          del method
  
          @wraps(func)
          def wrapper(*args, **kwargs):
              instance = instance_ref()
              instance._step_count += 1  # type: ignore[union-attr]
              wrapped = func.__get__(instance, cls)
              return wrapped(*args, **kwargs)
  
          # Note that the returned function here is no longer a bound method,
          # so attributes like `__func__` and `__self__` no longer exist.
          wrapper._with_counter = True  # type: ignore[attr-defined]
          return wrapper
  
      self.data_sparsifier.step = with_counter(self.data_sparsifier.step)  # type: ignore[assignment]
      self.data_sparsifier._step_count = 0  # type: ignore[attr-defined]
      self._step_count: int = 0
      self.verbose = verbose
  
      # Housekeeping
      self._get_sp_called_within_step: bool = (
          False  # sp -> schedule parameter
      )
      self.step()
  
file_path: pytorch/torch/ao/pruning/_experimental/data_scheduler/base_data_scheduler.py
imports: from functools import wraps
  import weakref
  import abc
  import warnings
  from ..data_sparsifier import BaseDataSparsifier
label_desc: Use image node_id 1 to create a new BaseDataScheduler object  with example: obj = BaseDataScheduler(data_sparsifier, schedule_param, last_epoch, verbose)