class_docstr: The ``{before,after}_epoch``, ``{before,after}_run``, ``trigger_{epoch,step}``
  methods of the given callback will be enabled only when ``global_step % every_k_steps == 0`
  or ``epoch_num % every_k_epochs == 0``. The other methods are unaffected.
  
  Note that this can only makes a callback **less** frequent than itself.
  If you have a callback that by default runs every epoch by its :meth:`trigger()` method,
  use :class:`PeriodicTrigger` to schedule it more frequent than itself.
docstr: Args:
      callback (Callback): a Callback instance.
      every_k_steps (int): enable the callback when ``global_step % k == 0``. Set to
          None to ignore.
      every_k_epochs (int): enable the callback when ``epoch_num % k == 0``.
          Also enable when the last step finishes (``epoch_num == max_epoch``
          and ``local_step == steps_per_epoch - 1``). Set to None to ignore.
  
  every_k_steps and every_k_epochs can be both set, but cannot be both None.
docstr_tok: ["Args",":","callback","(","Callback",")",":","a","Callback","instance",".","every_k_steps","(","int",")",":","enable","the","callback","when","``","global_step","%","k","==","0","``",".","Set","to","None","to","ignore",".","every_k_epochs","(","int",")",":","enable","the","callback","when","``","epoch_num","%","k","==","0","``",".","Also","enable","when","the","last","step","finishes","(","``","epoch_num","==","max_epoch","``","and","``","local_step","==","steps_per_epoch","-","1","``",")",".","Set","to","None","to","ignore",".","every_k_steps","and","every_k_epochs","can","be","both","set",",","but","can","not","be","both","None","."]
code: def __init__(self, callback, every_k_steps=None, every_k_epochs=None):
      """
      Args:
          callback (Callback): a Callback instance.
          every_k_steps (int): enable the callback when ``global_step % k == 0``. Set to
              None to ignore.
          every_k_epochs (int): enable the callback when ``epoch_num % k == 0``.
              Also enable when the last step finishes (``epoch_num == max_epoch``
              and ``local_step == steps_per_epoch - 1``). Set to None to ignore.
  
      every_k_steps and every_k_epochs can be both set, but cannot be both None.
      """
      assert isinstance(callback, Callback), type(callback)
      assert (every_k_epochs is not None) or (
          every_k_steps is not None
      ), "every_k_steps and every_k_epochs cannot be both None!"
      self._step_k = every_k_steps
      self._epoch_k = every_k_epochs
      super(PeriodicCallback, self).__init__(
          callback, PeriodicCallback.predicate
      )
  
imports: from .base import Callback, ProxyCallback
label_desc: Use image node_id 1 to create a new PeriodicCallback object from inherited base classes: EnableCallbackIf with example: obj = PeriodicCallback(callback, every_k_steps, every_k_epochs)