code: def _left_doubling_increments(
      batch_shape, max_doublings, step_size, seed=None, name=None
  ):
      """Computes the doubling increments for the left end point.
  
      The doubling procedure expands an initial interval to find a superset of the
      true slice. At each doubling iteration, the interval width is doubled to
      either the left or the right hand side with equal probability.
      If, initially, the left end point is at `L(0)` and the width of the
      interval is `w(0)`, then the left end point and the width at the
      k-th iteration (denoted L(k) and w(k) respectively) are given by the following
      recursions:
  
      ```none
      w(k) = 2 * w(k-1)
      L(k) = L(k-1) - w(k-1) * X_k, X_k ~ Bernoulli(0.5)
      or, L(0) - L(k) = w(0) Sum(2^i * X(i+1), 0 <= i < k)
      ```
  
      This function computes the sequence of `L(0)-L(k)` and `w(k)` for k between 0
      and `max_doublings` independently for each chain.
  
      Args:
        batch_shape: Positive int32 `tf.Tensor`. The batch shape.
        max_doublings: Scalar positive int32 `tf.Tensor`. The maximum number of
          doublings to consider.
        step_size: A real `tf.Tensor` with shape compatible with [num_chains].
          The size of the initial interval.
        seed: PRNG seed; see `tfp.random.sanitize_seed` for details.
        name: Python `str` name prefixed to Ops created by this function.
          Default value: `None` (i.e., 'find_slice_bounds').
  
      Returns:
        left_increments: A tensor of shape (max_doublings+1, batch_shape). The
          relative position of the left end point after the doublings.
        widths: A tensor of shape (max_doublings+1, ones_like(batch_shape)). The
          widths of the intervals at each stage of the doubling.
      """
      with tf.name_scope(name or "left_doubling_increments"):
          step_size = tf.convert_to_tensor(value=step_size)
          dtype = dtype_util.base_dtype(step_size.dtype)
          # Output shape of the left increments tensor.
          output_shape = ps.concat(
              ([max_doublings + 1], batch_shape), axis=0
          )
          # A sample realization of X_k.
          expand_left = bernoulli_lib.Bernoulli(
              0.5, dtype=dtype
          ).sample(sample_shape=output_shape, seed=seed)
  
          # The widths of the successive intervals. Starts with 1.0 and ends with
          # 2^max_doublings.
          width_multipliers = tf.cast(
              2 ** tf.range(0, max_doublings + 1), dtype=dtype
          )
          # Output shape of the `widths` tensor.
          widths_shape = ps.concat(
              ([max_doublings + 1], ps.ones_like(batch_shape)), axis=0
          )
          width_multipliers = tf.reshape(
              width_multipliers, shape=widths_shape
          )
          # Widths shape is [max_doublings + 1, 1, 1, 1...].
          widths = width_multipliers * step_size
  
          # Take the cumulative sum of the left side increments in slice width to give
          # the resulting distance from the initial lower bound.
          left_increments = tf.cumsum(
              widths * expand_left, exclusive=True, axis=0
          )
          return left_increments, widths
  
file_path: probability/tensorflow_probability/python/mcmc/internal/slice_sampler_utils.py
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import bernoulli
  from tensorflow_probability.python.distributions import gamma
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
label_desc: Use image node_id 1 for calling a global function with example usage: _left_doubling_increments(batch_shape, max_doublings, step_size, seed, name) and returns: left_increments,  widths