docstr: Max log-likelihood estimate for scale.
  
  Args:
    samples: Observed data points.
    scale_candidates: A simple grid of candiates for
      scale, with shape original_batch_shape + [num_candidates],
      where different candidates for a single scalar parameter are at the
      inner most dimension (axis -1).
  Returns:
    scale_mle: max log-likelihood estimate for scale.
docstr_tok: ["Max","log-likelihood","estimate","for","scale",".","Args",":","samples",":","Observed","data","points",".","scale_candidates",":","A","simple","grid","of","candiates","for","scale",",","with","shape","original_batch_shape","+","[","num_candidates","]",",","where","different","candidates","for","a","single","scalar","parameter","are","at","the","inner","most","dimension","(","axis","-1",")",".","Returns",":","scale_mle",":","max","log-likelihood","estimate","for","scale","."]
code: def _scale_mle(self, samples, scale_candidates):
      """Max log-likelihood estimate for scale.
  
      Args:
        samples: Observed data points.
        scale_candidates: A simple grid of candiates for
          scale, with shape original_batch_shape + [num_candidates],
          where different candidates for a single scalar parameter are at the
          inner most dimension (axis -1).
      Returns:
        scale_mle: max log-likelihood estimate for scale.
      """
      dist = horseshoe.Horseshoe(
          scale=scale_candidates, validate_args=True
      )
      dims = tf.shape(scale_candidates)
      num_candidates = dims[-1]
      original_batch_shape = dims[:-1]
      # log_likelihood has same shape as scale_candidates
      # i.e. original_batch_shape + [num_candidates]
      log_likelihood = tf.reduce_sum(
          # dist.log_prob here returns a tensor with shape
          # [num_samples] + original_batch_shape + [num_candidates]
          dist.log_prob(
              tf.reshape(
                  samples,
                  tf.concat([[-1], original_batch_shape, [1]], axis=0),
              )
          ),
          axis=0,
      )
      # max log-likelihood candidate location mask
      mask = tf.one_hot(
          tf.argmax(log_likelihood, axis=-1),
          depth=num_candidates,
          dtype=self.dtype,
      )
      return tf.reduce_sum(scale_candidates * mask, axis=-1)
  
imports: import numpy
  import scipy.stats
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import horseshoe
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
label_desc: Use image node_id 13 for calling the _HorseshoeTest obj's underlying member method code with example usage: obj._scale_mle(samples, scale_candidates) and returns: tf