code: def _gradient_stub(
      data_vectors,
      barycentric,
      blur_neighbours1,
      blur_neighbours2,
      indices,
      name,
  ):
      """
      This is a stub operator whose purpose is
      to allow us to overwrite the gradient.
      The forward pass gives zeros and
      the backward pass gives the correct gradients
      for the permutohedral_compute function
  
      :param data_vectors:
      :param barycentric:
      :param blur_neighbours1:
      :param blur_neighbours2:
      :param indices:
      :param name:
      :return:
      """
  
      def _dummy_wrapper(*_unused):
          return np.float32(0)
  
      def _permutohedral_grad_wrapper(op, grad):
          # Differentiation can be done using permutohedral lattice
          # with Gaussian filter order reversed
          filtering_grad = permutohedral_compute(
              grad,
              op.inputs[1],
              op.inputs[2],
              op.inputs[3],
              op.inputs[4],
              name,
              reverse=True,
          )
          return [filtering_grad] + [None for i in op.inputs[1:]]
  
      _inputs = [
          data_vectors,
          barycentric,
          blur_neighbours1,
          blur_neighbours2,
          indices,
      ]
  
      partial_grads_func = _py_func_with_grads(
          _dummy_wrapper,
          _inputs,
          [tf.float32],
          name=name,
          grad=_permutohedral_grad_wrapper,
      )
      partial_grads_func.set_shape(data_vectors.shape.as_list())
      return partial_grads_func
  
file_path: NiftyNet/niftynet/layer/crf.py
imports: from __future__ import absolute_import, print_function
  import numpy
  import tensorflow
  from niftynet.layer.base_layer import TrainableLayer
  from niftynet.layer.layer_util import infer_spatial_rank, expand_spatial_params
label_desc: Use image node_id 5 for calling a global function with example usage: _gradient_stub(data_vectors, barycentric, blur_neighbours1, blur_neighbours2, indices, name) and returns: partial_grads_func, np, unknown