class_docstr: The Timer callback tracks the time spent in the training, validation, and test loops and interrupts the Trainer
  if the given time limit for the training loop is reached.
  
  Args:
      duration: A string in the format DD:HH:MM:SS (days, hours, minutes seconds), or a :class:`datetime.timedelta`,
          or a dict containing key-value compatible with :class:`~datetime.timedelta`.
      interval: Determines if the interruption happens on epoch level or mid-epoch.
          Can be either ``"epoch"`` or ``"step"``.
      verbose: Set this to ``False`` to suppress logging messages.
  
  Raises:
      MisconfigurationException:
          If ``interval`` is not one of the supported choices.
  
  Example::
  
      from lightning.pytorch import Trainer
      from lightning.pytorch.callbacks import Timer
  
      # stop training after 12 hours
      timer = Timer(duration="00:12:00:00")
  
      # or provide a datetime.timedelta
      from datetime import timedelta
      timer = Timer(duration=timedelta(weeks=1))
  
      # or provide a dictionary
      timer = Timer(duration=dict(weeks=4, days=2))
  
      # force training to stop after given time limit
      trainer = Trainer(callbacks=[timer])
  
      # query training/validation/test time (in seconds)
      timer.time_elapsed("train")
      timer.start_time("validate")
      timer.end_time("test")
class_docstr_tok: ["The","Timer","callback","tracks","the","time","spent","in","the","training",",","validation",",","and","test","loops","and","interrupts","the","Trainer","if","the","given","time","limit","for","the","training","loop","is","reached",".","Args",":","duration",":","A","string","in","the","format","DD",":","HH",":","MM",":","SS","(","days",",","hours",",","minutes","seconds",")",",","or","a",":","class",":","`","datetime.timedelta","`",",","or","a","dict","containing","key-value","compatible","with",":","class",":","`","~datetime.timedelta","`",".","interval",":","Determines","if","the","interruption","happens","on","epoch","level","or","mid-epoch",".","Can","be","either","``","``","epoch","''","``","or","``","``","step","''","``",".","verbose",":","Set","this","to","``","False","``","to","suppress","logging","messages",".","Raises",":","MisconfigurationException",":","If","``","interval","``","is","not","one","of","the","supported","choices",".","Example",":",":","from","lightning.pytorch","import","Trainer","from","lightning.pytorch.callbacks","import","Timer","#","stop","training","after","12","hours","timer","=","Timer","(","duration=","''","00:12:00:00","''",")","#","or","provide","a","datetime.timedelta","from","datetime","import","timedelta","timer","=","Timer","(","duration=timedelta","(","weeks=1",")",")","#","or","provide","a","dictionary","timer","=","Timer","(","duration=dict","(","weeks=4",",","days=2",")",")","#","force","training","to","stop","after","given","time","limit","trainer","=","Trainer","(","callbacks=","[","timer","]",")","#","query","training\/validation\/test","time","(","in","seconds",")","timer.time_elapsed","(","``","train","''",")","timer.start_time","(","``","validate","''",")","timer.end_time","(","``","test","''",")"]
code: def on_train_epoch_end(
      self, trainer: "pl.Trainer", *args: Any, **kwargs: Any
  ) -> None:
      if self._interval != Interval.epoch or self._duration is None:
          return
      self._check_time_remaining(trainer)
  
imports: import logging
  import time
  from datetime import timedelta
  from typing import Any, Dict, Optional, Union
  from typing_extensions import override
  import lightning.pytorch
  from lightning.pytorch.callbacks.callback import Callback
  from lightning.pytorch.trainer.states import RunningStage
  from lightning.pytorch.utilities import LightningEnum
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.rank_zero import rank_zero_info
label_desc: Use image node_id 14 for calling the Timer obj's underlying member method code with example usage: obj.on_train_epoch_end(trainer) without return types