class_docstr: This class handles iteration events to update the model with gradient op
  (by setting iteration message with a 'gradients' op at the beginning of
  each iteration).
class_docstr_tok: ["This","class","handles","iteration","events","to","update","the","model","with","gradient","op","(","by","setting","iteration","message","with","a","'gradients","'","op","at","the","beginning","of","each","iteration",")","."]
docstr: Making ``optimiser.apply_gradients`` ops.
  
  :param sender: a niftynet.application instance
  :param _unused:
  :return:
docstr_tok: ["Making","``","optimiser.apply_gradients","``","ops",".",":","param","sender",":","a","niftynet.application","instance",":","param","_unused",":",":","return",":"]
code: def make_gradients_op(self, sender, **_unused):
      """
      Making ``optimiser.apply_gradients`` ops.
  
      :param sender: a niftynet.application instance
      :param _unused:
      :return:
      """
      with tf.name_scope("ApplyGradients"):
          gradients = sender.gradients_collector.gradients
          bn_ops = tf.get_collection(BN_COLLECTION, PRIMARY_NAME_SCOPE)
          if not bn_ops:
              sender.gradient_op = _apply_multiopt_gradients(
                  sender.optimiser, gradients
              )
          else:
              with tf.get_default_graph().control_dependencies(bn_ops):
                  sender.gradient_op = _apply_multiopt_gradients(
                      sender.optimiser, gradients
                  )
  
file_path: NiftyNet/niftynet/engine/handler_gradient.py
imports: import tensorflow
  from niftynet.engine.signal import ITER_STARTED, GRAPH_CREATED
  from niftynet.layer.bn import BN_COLLECTION
  from niftynet.utilities import util_common
label_desc: Use image node_id 2 for calling the ApplyGradients obj's underlying member method code with example usage: obj.make_gradients_op(sender) without return types