def bisect(value_and_gradients_function,<EOL>initial_left,<EOL>initial_right,<EOL>f_lim):
failed = ~is_finite(initial_left, initial_right)<EOL>needs_bisect = (initial_right.df < <NUM_LIT:0>) & (initial_right.f > f_lim)<EOL>bisect_args = _IntermediateResult(<EOL>iteration=tf.convert_to_tensor(value=<NUM_LIT:0>),<EOL>stopped=failed | ~needs_bisect,<EOL>failed=failed,<EOL>num_evals=tf.convert_to_tensor(value=<NUM_LIT:0>),<EOL>left=initial_left,<EOL>right=initial_right)<EOL>return _bisect(value_and_gradients_function, bisect_args, f_lim)<EOL>
Bisects an interval and updates to satisfy opposite slope conditions.

    Corresponds to the step U3 in [Hager and Zhang (2006)][2].

    Args:
      value_and_gradients_function: A Python callable that accepts a real scalar
        tensor and returns a namedtuple containing the value filed `f` of the
        function and its derivative value field `df` at that point.
        Alternatively, the function may representthe batching of `n` such line
        functions (e.g. projecting a single multivariate objective function along
        `n` distinct directions at once) accepting n points as input, i.e. a
        tensor of shape [n], and return a tuple of two tensors of shape [n], the
        function values and the corresponding derivatives at the input points.
      initial_left: Return value of value_and_gradients_function at the left end
        point of the current bracketing interval.
      initial_right: Return value of value_and_gradients_function at the right end
        point of the current bracketing interval.
      f_lim: real `Tensor` of shape [n]. The function value threshold for
        the approximate Wolfe conditions to be checked for each batch member.

    Returns:
      A namedtuple containing the following fields:
        iteration: An int32 scalar `Tensor`. The number of iterations performed.
          Bounded above by `max_iterations` parameter.
        stopped: A boolean scalar `Tensor`. True if the bisect algorithm
          terminated.
        failed: A scalar boolean tensor. Indicates whether the objective function
          failed to produce a finite value.
        num_evals: A scalar int32 tensor. The number of value and gradients
          function evaluations.
        left: Return value of value_and_gradients_function at the left end
          point of the bracketing interval found.
        right: Return value of value_and_gradients_function at the right end
          point of the bracketing interval found.