class_docstr: Implement Non-monotonically Triggered AvSGD (NTA).
  This method is based on paper "Regularizing and Optimizing LSTM Language
  Models", (https://openreview.net/pdf?id=SyyGPP0TZ), and an implementation
  is available in Salesforce GitHub
  (https://github.com/salesforce/awd-lstm-lm/blob/master/main.py). Note that
  it mismatches the arxiv (and gluonnlp) version, which is referred to as
  NTA_V2 below.
docstr: Depending on the choice of metrics, the users may want to minimize or
  maximize the metrics. Thus, set maximize = True to maximize, otherwise
  minimize.
  
  Parameters
  ----------
  epochs
      The total number of epochs.
  n
      The non-monotone interval.
  maximize
      Whether to maximize or minimize the validation metric.
  eta
      Parameter of polynomial-decay averaging.
  last_n_trigger
      If True, use [-n:] in average trigger, otherwise use [:-n].
  fallback_alpha
      Fallback epoch proportion of averaging.
docstr_tok: ["Depending","on","the","choice","of","metrics",",","the","users","may","want","to","minimize","or","maximize","the","metrics",".","Thus",",","set","maximize","=","True","to","maximize",",","otherwise","minimize",".","Parameters","--","--","--","--","--","epochs","The","total","number","of","epochs",".","n","The","non-monotone","interval",".","maximize","Whether","to","maximize","or","minimize","the","validation","metric",".","eta","Parameter","of","polynomial-decay","averaging",".","last_n_trigger","If","True",",","use","[","-n",":","]","in","average","trigger",",","otherwise","use","[",":","-n","]",".","fallback_alpha","Fallback","epoch","proportion","of","averaging","."]
code: def __init__(
      self,
      epochs: int,
      n: int = 5,
      maximize: bool = False,
      last_n_trigger: bool = False,
      eta: float = 0,
      fallback_alpha: float = 0.05,
  ):
      r"""
      Depending on the choice of metrics, the users may want to minimize or
      maximize the metrics. Thus, set maximize = True to maximize, otherwise
      minimize.
  
      Parameters
      ----------
      epochs
          The total number of epochs.
      n
          The non-monotone interval.
      maximize
          Whether to maximize or minimize the validation metric.
      eta
          Parameter of polynomial-decay averaging.
      last_n_trigger
          If True, use [-n:] in average trigger, otherwise use [:-n].
      fallback_alpha
          Fallback epoch proportion of averaging.
      """
  
      super().__init__(eta=eta)
  
      assert 0 <= fallback_alpha <= 1
  
      self.n = n
      self.maximize = maximize
      self.last_n_trigger = last_n_trigger
      # Historical validation metrics.
      self.val_logs = []
  
      # The epoch where we fallback to alpha suffix. This solves the edge
      # case where the averaging is never triggered and without the fallback
      # the model of the last epoch would be returned.
      self.fallback_alpha_suffix = epochs * (1.0 - fallback_alpha)
  
imports: from typing import Any, Dict, List, Optional
  import logging
  import mxnet
  import mxnet.gluon.nn
  from mxnet import gluon
  from gluonts.core.component import validated
  from .callback import Callback
label_desc: Use image node_id 1 to create a new NTA object from inherited base classes: IterationAveragingStrategy with example: obj = NTA(epochs, n, maximize, last_n_trigger, eta, fallback_alpha)