code: def _random_inverse_gaussian_bwd(shape, aux, g):
      """The gradient of the inverse gaussian samples."""
      samples, loc, concentration = aux
      partial_concentration, partial_loc = _compute_partials(
          samples, loc, concentration
      )
      dsamples = g
  
      # These will need to be shifted by the extra dimensions added from
      # `sample_shape`.
      reduce_dims = tf.range(
          tf.size(shape)
          - tf.maximum(tf.rank(concentration), tf.rank(loc))
      )
      grad_concentration = tf.math.reduce_sum(
          dsamples * partial_concentration, axis=reduce_dims
      )
      grad_loc = tf.math.reduce_sum(
          dsamples * partial_loc, axis=reduce_dims
      )
  
      if (
          tensorshape_util.is_fully_defined(concentration.shape)
          and tensorshape_util.is_fully_defined(loc.shape)
          and concentration.shape == loc.shape
      ):
          return grad_concentration, grad_loc, None  # seed=None
  
      (
          grad_loc,
          grad_concentration,
      ) = generic.fix_gradient_for_broadcasting(
          [loc, concentration], [grad_loc, grad_concentration]
      )
  
      return grad_loc, grad_concentration, None
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import chain
  from tensorflow_probability.python.bijectors import exp
  from tensorflow_probability.python.bijectors import scale
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import custom_gradient
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import reparameterization
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import special_math
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.math import generic
label_desc: Use image node_id 4 for calling a global function with example usage: _random_inverse_gaussian_bwd(shape, aux, g) and returns: grad_loc,  grad_concentration,  None, grad_concentration,  grad_loc,  None