class_docstr: Run an Op. 
class_docstr_tok: ["Run","an","Op","."]
docstr: Args:
      op (tf.Operation or function): an Op, or a function that returns the Op in the graph.
          The function will be called after the main graph has been created (in the :meth:`setup_graph` callback).
      run_before (bool): run the Op before training
      run_as_trigger (bool): run the Op on every :meth:`trigger()` call.
      run_step (bool): run the Op every step (along with training)
      verbose (bool): print logs when the op is run.
  
  Example:
      The `DQN Example
      <https://github.com/tensorpack/tensorpack/blob/master/examples/DeepQNetwork/>`_
      uses this callback to update target network.
docstr_tok: ["Args",":","op","(","tf.Operation","or","function",")",":","an","Op",",","or","a","function","that","returns","the","Op","in","the","graph",".","The","function","will","be","called","after","the","main","graph","has","been","created","(","in","the",":","meth",":","`","setup_graph","`","callback",")",".","run_before","(","bool",")",":","run","the","Op","before","training","run_as_trigger","(","bool",")",":","run","the","Op","on","every",":","meth",":","`","trigger","(",")","`","call",".","run_step","(","bool",")",":","run","the","Op","every","step","(","along","with","training",")","verbose","(","bool",")",":","print","logs","when","the","op","is","run",".","Example",":","The","`","DQN","Example","<","https",":","\/\/github.com\/tensorpack\/tensorpack\/blob\/master\/examples\/DeepQNetwork\/",">","`","_","uses","this","callback","to","update","target","network","."]
code: def __init__(
      self,
      op,
      run_before=True,
      run_as_trigger=True,
      run_step=False,
      verbose=False,
  ):
      """
      Args:
          op (tf.Operation or function): an Op, or a function that returns the Op in the graph.
              The function will be called after the main graph has been created (in the :meth:`setup_graph` callback).
          run_before (bool): run the Op before training
          run_as_trigger (bool): run the Op on every :meth:`trigger()` call.
          run_step (bool): run the Op every step (along with training)
          verbose (bool): print logs when the op is run.
  
      Example:
          The `DQN Example
          <https://github.com/tensorpack/tensorpack/blob/master/examples/DeepQNetwork/>`_
          uses this callback to update target network.
      """
      if not callable(op):
          self.setup_func = lambda: op  # noqa
      else:
          self.setup_func = op
      self.run_before = run_before
      self.run_as_trigger = run_as_trigger
      self.run_step = run_step
      self.verbose = verbose
  
imports: import numpy
  import os
  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 RunOp object from inherited base classes: Callback with example: obj = RunOp(op, run_before, run_as_trigger, run_step, verbose)