class_docstr: A SessionRunHook handles ops related to SyncReplicasOptimizer.
class_docstr_tok: ["A","SessionRunHook","handles","ops","related","to","SyncReplicasOptimizer","."]
code: def begin(self):
      if (
          self._sync_optimizer._gradients_applied is False
      ):  # pylint: disable=protected-access
          raise ValueError(
              "SyncReplicasOptimizer.apply_gradient should be called before using "
              "the hook."
          )
      if self._is_chief:
          self._local_init_op = self._sync_optimizer.chief_init_op
          self._ready_for_local_init_op = (
              self._sync_optimizer.ready_for_local_init_op
          )
          self._q_runner = self._sync_optimizer.get_chief_queue_runner()
          self._init_tokens_op = (
              self._sync_optimizer.get_init_tokens_op(self._num_tokens)
          )
      else:
          self._local_init_op = self._sync_optimizer.local_step_init_op
          self._ready_for_local_init_op = (
              self._sync_optimizer.ready_for_local_init_op
          )
          self._q_runner = None
          self._init_tokens_op = None
  
imports: from tensorflow.python.distribute import distribute_lib
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import data_flow_ops
  from tensorflow.python.ops import state_ops
  from tensorflow.python.ops import variable_v1
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.training import optimizer
  from tensorflow.python.training import queue_runner
  from tensorflow.python.training import session_manager
  from tensorflow.python.training import session_run_hook
  from tensorflow.python.util import deprecation
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 2 for calling the _SyncReplicasOptimizerHook obj's underlying member method code with example usage: obj.begin() without return types