class_docstr: Maintain the moving average of summarized tensors in every step,
  by ops added to the collection.
  Note that it only **maintains** the moving averages by updating
  the relevant variables in the graph,
  the actual summary should be done in other callbacks.
  
  This callback is one of the :func:`DEFAULT_CALLBACKS()`.
class_docstr_tok: ["Maintain","the","moving","average","of","summarized","tensors","in","every","step",",","by","ops","added","to","the","collection",".","Note","that","it","only","*","*","maintains","*","*","the","moving","averages","by","updating","the","relevant","variables","in","the","graph",",","the","actual","summary","should","be","done","in","other","callbacks",".","This","callback","is","one","of","the",":","func",":","`","DEFAULT_CALLBACKS","(",")","`","."]
docstr: Args:
      collection(str): the collection of EMA-maintaining ops.
          The default value would work with
          the tensors you added by :func:`tfutils.summary.add_moving_summary()`,
          but you can use other collections as well.
      train_op (tf.Operation or str): the (name of) training op to associate the maintaing ops with.
          If not provided, the EMA-maintaining ops will be hooked to
          `trainer.hooked_session` and be executed in every iteration.
          Otherwise, the EMA-maintaining ops will be executed whenever
          the training op is executed.
docstr_tok: ["Args",":","collection","(","str",")",":","the","collection","of","EMA-maintaining","ops",".","The","default","value","would","work","with","the","tensors","you","added","by",":","func",":","`","tfutils.summary.add_moving_summary","(",")","`",",","but","you","can","use","other","collections","as","well",".","train_op","(","tf.Operation","or","str",")",":","the","(","name","of",")","training","op","to","associate","the","maintaing","ops","with",".","If","not","provided",",","the","EMA-maintaining","ops","will","be","hooked","to","`","trainer.hooked_session","`","and","be","executed","in","every","iteration",".","Otherwise",",","the","EMA-maintaining","ops","will","be","executed","whenever","the","training","op","is","executed","."]
code: def __init__(self, collection=MOVING_SUMMARY_OPS_KEY, train_op=None):
      """
      Args:
          collection(str): the collection of EMA-maintaining ops.
              The default value would work with
              the tensors you added by :func:`tfutils.summary.add_moving_summary()`,
              but you can use other collections as well.
          train_op (tf.Operation or str): the (name of) training op to associate the maintaing ops with.
              If not provided, the EMA-maintaining ops will be hooked to
              `trainer.hooked_session` and be executed in every iteration.
              Otherwise, the EMA-maintaining ops will be executed whenever
              the training op is executed.
      """
      self._collection = collection
      self._train_op = train_op
  
imports: import numpy
  from collections import deque
  from ..compat import tfv1
  from ..tfutils.common import get_op_tensor_name
  from ..utils import logger
  from ..utils.naming import MOVING_SUMMARY_OPS_KEY
  from .base import Callback
label_desc: Use image node_id 1 to create a new MovingAverageSummary object from inherited base classes: Callback with example: obj = MovingAverageSummary(collection, train_op)