class_docstr: This collector has a list of all gradients, collected when
  constructing the tf graph. The gradient from multiple GPUs
  will be averaged, and the averaged op is added to graph
  by application driver
docstr: Add gradient generated by optimiser.compute_gradients to a
  dictionary. This will be retrieved during training.
  The gradient can be a list of model updates,
  application can choose to implement `set_iteration_update()` interface
  to specify how the gradients are used at each iteration
  
  :param gradients: generated by optimiser.compute_gradients(loss)
  :return:
docstr_tok: ["Add","gradient","generated","by","optimiser.compute_gradients","to","a","dictionary",".","This","will","be","retrieved","during","training",".","The","gradient","can","be","a","list","of","model","updates",",","application","can","choose","to","implement","`","set_iteration_update","(",")","`","interface","to","specify","how","the","gradients","are","used","at","each","iteration",":","param","gradients",":","generated","by","optimiser.compute_gradients","(","loss",")",":","return",":"]
code: def add_to_collection(self, gradients):
      """
      Add gradient generated by optimiser.compute_gradients to a
      dictionary. This will be retrieved during training.
      The gradient can be a list of model updates,
      application can choose to implement `set_iteration_update()` interface
      to specify how the gradients are used at each iteration
  
      :param gradients: generated by optimiser.compute_gradients(loss)
      :return:
      """
      assert (
          len(self._gradients) < self.n_devices
      ), "call add_to_collection once per device"
      self._gradients.append(gradients)
  
imports: from __future__ import absolute_import, print_function
  import tensorflow
  from tensorflow.contrib.framework import list_variables
  from niftynet.io.misc_io import image3_axial, image3_coronal, image3_sagittal, resolve_checkpoint
  from niftynet.utilities import util_common
  from niftynet.utilities.restore_initializer import restore_initializer
label_desc: Use image node_id 2 for calling the GradientsCollector obj's underlying member method code with example usage: obj.add_to_collection(gradients) without return types