class_docstr: Change the param by monitoring the change of a scalar statistics.
  The param will be changed when the scalar does not decrease/increase enough.
  
  Once triggered, this callback observes the latest **one** value of ``stat_name``, from the monitor backend.
  
  This callback will then change a hyperparameter ``param`` by ``new_value = value_func(old_value)``, if:
  ``min(history) >= history[0] - threshold``, where
  ``history = [the most recent k observations of stat_name]``
  
  Note:
      The statistics of interest must be created at a frequency higher than or equal to this callback.
      For example, using ``PeriodicTrigger(StatMonitorParamSetter(...), every_k_steps=100)``
      is meaningless if the statistics to be monitored is only updated every 500 steps.
  
      Callbacks are executed in order. Therefore, if the statistics to be monitored
      is created after this callback, the behavior of this callback may get delayed.
  
  Example:
  
      If validation error wasn't decreasing for 5 epochs, decay the learning rate by 0.2:
  
      .. code-block:: python
  
          StatMonitorParamSetter('learning_rate', 'val-error',
                                  lambda x: x * 0.2, threshold=0, last_k=5)
docstr: Args:
      param: same as in :class:`HyperParamSetter`.
      stat_name (str): name of the statistics.
      value_func (float -> float): a function which returns a new value
          taking the old value.
      threshold (float): change threshold.
      last_k (int): use last k observations of statistics.
      reverse (bool): monitor increasing instead of decreasing.
          If True, ``param`` will be changed when ``max(history) <= history[0] + threshold``.
docstr_tok: ["Args",":","param",":","same","as","in",":","class",":","`","HyperParamSetter","`",".","stat_name","(","str",")",":","name","of","the","statistics",".","value_func","(","float","-",">","float",")",":","a","function","which","returns","a","new","value","taking","the","old","value",".","threshold","(","float",")",":","change","threshold",".","last_k","(","int",")",":","use","last","k","observations","of","statistics",".","reverse","(","bool",")",":","monitor","increasing","instead","of","decreasing",".","If","True",",","``","param","``","will","be","changed","when","``","max","(","history",")","<","=","history","[","0","]","+","threshold","``","."]
code: def __init__(
      self,
      param,
      stat_name,
      value_func,
      threshold,
      last_k,
      reverse=False,
  ):
      """
      Args:
          param: same as in :class:`HyperParamSetter`.
          stat_name (str): name of the statistics.
          value_func (float -> float): a function which returns a new value
              taking the old value.
          threshold (float): change threshold.
          last_k (int): use last k observations of statistics.
          reverse (bool): monitor increasing instead of decreasing.
              If True, ``param`` will be changed when ``max(history) <= history[0] + threshold``.
      """
      super(StatMonitorParamSetter, self).__init__(param)
      self.stat_name = stat_name
      self.value_func = value_func
      self.history = deque(maxlen=last_k)
      self.threshold = threshold
      self.reverse = reverse
  
imports: import operator
  import os
  import numpy
  from abc import ABCMeta, abstractmethod
  from collections import deque
  import six
  from ..compat import tfv1
  from ..tfutils.common import get_op_tensor_name
  from ..utils import logger
  from .base import Callback
label_desc: Use image node_id 1 to create a new StatMonitorParamSetter object from inherited base classes: HyperParamSetter with example: obj = StatMonitorParamSetter(param, stat_name, value_func, threshold, last_k, reverse)