code: def should_selective_backprop(
      current_duration: float,
      batch_idx: int,
      start: float = 0.5,
      end: float = 0.9,
      interrupt: int = 2,
  ) -> bool:
      """
      Decides if selective backprop should be run based on time in training.
  
      Returns true if the ``current_duration`` is between ``start`` and
      ``end``. It is recommended that SB be applied during the later stages of
      a training run, once the model has already "learned" easy examples.
  
      To preserve convergence, SB can be interrupted with vanilla minibatch
      gradient steps every ``interrupt`` steps. When ``interrupt=0``, SB will be
      used at every step during the SB interval. When ``interrupt=2``, SB will
      alternate with vanilla minibatch steps.
  
      Args:
          current_duration (float): The elapsed training duration. Must be
              within ``[0.0, 1.0)``.
          batch_idx (int): The current batch within the epoch.
          start (float, optional): The duration at which selective backprop
              should be enabled, as a percentage. Default: ``0.5``.
          end (float, optional): The duration at which selective backprop
              should be disabled. Default: ``0.9``.
          interrupt (int, optional): The number of batches between vanilla
              minibatch gradient updates. Default: ``2``.
  
      Returns
      -------
          bool: If selective backprop should be performed on this batch.
  
      """
      is_interval = (current_duration >= start) and (
          current_duration < end
      )
      is_step = (interrupt == 0) or ((batch_idx + 1) % interrupt != 0)
  
      return is_interval and is_step
  
file_path: BigDL/python/nano/src/bigdl/nano/pytorch/algorithms/selective_backprop/selective_backprop.py
imports: from typing import Any, Callable, Tuple, Union
  import warnings
  import numpy
  from bigdl.nano.utils.common import invalidInputError
  import torch
  from torch.nn import functional
  import pytorch_lightning
  from pytorch_lightning.callbacks import Callback
label_desc: Use image node_id 1 for calling a global function with example usage: should_selective_backprop(current_duration, batch_idx, start, end, interrupt) and returns: unknown