class_docstr: A custom trainer whose training duration is based on wall clock time
  instead of epochs.
class_docstr_tok: ["A","custom","trainer","whose","training","duration","is","based","on","wall","clock","time","instead","of","epochs","."]
code: def __init__(
      self,
      training_time: float,
      validation_milestones: Optional[List[float]] = None,
      learning_rate: float = 1e-3,
      callbacks: Optional[List[Callback]] = None,
  ) -> None:
      super().__init__(learning_rate=learning_rate)
  
      validation_milestones = validation_milestones or []
      assert all(
          x < y
          for x, y in zip(
              validation_milestones, validation_milestones[1:]
          )
      ), "Validation milestones must be increasing."
  
      self.training_time = training_time
      self.validation_milestones = validation_milestones or []
      self.callbacks = CallbackList(callbacks or [])
  
imports: import itertools
  import logging
  import time
  from typing import List, Optional
  import mxnet
  import numpy
  from gluonts.core.component import validated
  from gluonts.dataset.loader import DataLoader
  from gluonts.gluonts_tqdm import tqdm
  from gluonts.mx.trainer import Trainer
  from gluonts.mx.util import HybridContext
  from mxnet import autograd
  from mxnet.gluon import nn
  from mxnet.metric import ndarray
  from .callbacks import Callback, CallbackList
label_desc: Use image node_id 1 to create a new TimedTrainer object from inherited base classes: Trainer with example: obj = TimedTrainer(training_time, validation_milestones, learning_rate, callbacks)