class_docstr: The model saver callback saves the model during training at exponential
  frequency.
  
  Attributes:
      network: The network that was trained. Not available prior to training.
      saved_parameters: The parameters saved for the different milestones. Should only be
          accessed after training has finished and should not be modified.
      training_times: The training times in seconds for the different milestones.
      num_gradient_updates: The number of gradient updates for the different milestones.
class_docstr_tok: ["The","model","saver","callback","saves","the","model","during","training","at","exponential","frequency",".","Attributes",":","network",":","The","network","that","was","trained",".","Not","available","prior","to","training",".","saved_parameters",":","The","parameters","saved","for","the","different","milestones",".","Should","only","be","accessed","after","training","has","finished","and","should","not","be","modified",".","training_times",":","The","training","times","in","seconds","for","the","different","milestones",".","num_gradient_updates",":","The","number","of","gradient","updates","for","the","different","milestones","."]
docstr: Args:
      directory: The directory into which the model parameters ought to be saved. Models are
          stored as `model_<seq>.params` where `<seq>` starts with 0 and reaches
          `count - 1`. Note that the directory must exist.
      milestones: The number of seconds after which the model should be saved.
docstr_tok: ["Args",":","directory",":","The","directory","into","which","the","model","parameters","ought","to","be","saved",".","Models","are","stored","as","`","model_","<","seq",">",".params","`","where","`","<","seq",">","`","starts","with","0","and","reaches","`","count","-","1","`",".","Note","that","the","directory","must","exist",".","milestones",":","The","number","of","seconds","after","which","the","model","should","be","saved","."]
code: def __init__(
      self,
      directory: Path,
      milestones: List[float],
  ):
      """
      Args:
          directory: The directory into which the model parameters ought to be saved. Models are
              stored as `model_<seq>.params` where `<seq>` starts with 0 and reaches
              `count - 1`. Note that the directory must exist.
          milestones: The number of seconds after which the model should be saved.
      """
      assert all(
          x < y for x, y in zip(milestones, milestones[1:])
      ), "Time milestones must be increasing."
  
      super().__init__()
      self.directory = directory
      self.seq = 0
      self.batch_count = 0
      self.network: Optional[nn.HybridBlock] = None
      self.saved_parameters: List[Path] = []
      self.training_times: List[float] = []
      self.num_gradient_updates: List[int] = []
      self.milestones = milestones
  
file_path: gluonts/src/gluonts/nursery/tsbench/src/tsbench/gluonts/callbacks/save.py
imports: from pathlib import Path
  from typing import List, Optional
  from mxnet.gluon import nn
  from mxnet.gluon.trainer import Trainer
  from .base import Callback
label_desc: Use image node_id 1 to create a new ModelSaverCallback object from inherited base classes: Callback with example: obj = ModelSaverCallback(directory, milestones)