code: def interval_location(f, minstep=1e-5, maxstep=50.0, maxiter=1024):
      """
      Identify interval where, potentially, optimal step could be.
  
      Parameters
      ----------
      f : func
  
      minstep : float
          Defaults to ``1e-5``.
  
      maxstep : float
          Defaults to ``50``.
  
      maxiter : int
          Defaults to ``1024``.
  
      tol : float
          Defaults to ``1e-5``.
  
      Returns
      -------
      float
          Right bound of interval where could be optimal step in
          specified direction. In case if there is no such direction
          function return ``maxstep`` instead.
      """
      with tf.name_scope("interval-location"):
  
          def find_right_bound(_, prev_func_output, step):
              func_output = f(step)
              step = tf.where(
                  tf.greater(prev_func_output, func_output),
                  tf.minimum(2.0 * step, maxstep),
                  step,
              )
              continue_searching = tf.logical_and(
                  tf.greater_equal(prev_func_output, func_output),
                  step < maxstep,
              )
              return [continue_searching, func_output, step]
  
          _, _, step = tf.while_loop(
              cond=lambda continue_searching, *args: continue_searching,
              body=find_right_bound,
              loop_vars=[
                  True,
                  tf.constant(asfloat(np.inf)),
                  tf.constant(asfloat(minstep)),
              ],
              back_prop=False,
              maximum_iterations=maxiter,
          )
          return step
  
imports: import math
  import numpy
  import tensorflow
  from neupy.utils import asfloat
label_desc: Use image node_id 1 for calling a global function with example usage: interval_location(f, minstep, maxstep, maxiter) and returns: step, list