code: def _StatelessGammaGradAlpha(shape, alpha, sample, grad):
      """Returns gradients of a gamma sampler wrt alpha."""
      # Note that the shape handling is slightly different for stateless_gamma,
      # in particular num_sample_dimensions is different.
      num_sample_dimensions = array_ops.shape(shape)[
          0
      ] - array_ops.rank(alpha)
      # Make the parameters alpha broadcastable with samples by appending
      # unit dimensions.
      alpha_broadcastable = add_leading_unit_dimensions(
          alpha, num_sample_dimensions
      )
      partial_a = gen_random_ops.random_gamma_grad(
          alpha_broadcastable, sample
      )
  
      # The first two inputs are shape, seed, third input is alpha.
      return math_ops.reduce_sum(
          grad * partial_a, axis=math_ops.range(num_sample_dimensions)
      )
  
file_path: tensorflow-upstream/tensorflow/python/ops/random_grad.py
imports: import numpy
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import clip_ops
  from tensorflow.python.ops import gen_array_ops
  from tensorflow.python.ops import gen_random_ops
  from tensorflow.python.ops import math_ops
label_desc: Use image node_id 5 for calling a global function with example usage: _StatelessGammaGradAlpha(shape, alpha, sample, grad) and returns: math_ops