code: def get_initial_state_args(
      value_and_gradients_function,
      initial_position,
      grad_tolerance,
      control_inputs=None,
  ):
      """Returns a dictionary to populate the initial state of the search procedure.
  
      Performs an initial convergence check and the first evaluation of the
      objective function.
  
      Args:
        value_and_gradients_function: A Python callable that accepts a tensor and
          returns a tuple of two tensors: the objective function value and its
          derivative.
        initial_position: The starting point of the search procedure.
        grad_tolerance: The gradient tolerance for the procedure.
        control_inputs: Optional ops used to assert the validity of inputs, these
          are added as control dependencies to execute before the objective
          function is evaluated for the first time.
  
      Returns:
        An dictionary with values for the following keys:
          converged: True if the convergence check finds that the initial position
            is already an argmin of the objective function.
          failed: Initialized to False.
          num_objective_evaluations: Initialized to 1.
          position: Initialized to the initial position.
          objective_value: Initialized to the value of the objective function at
            the initial position.
          objective_gradient: Initialized to the gradient of the objective
            function at the initial position.
      """
      if control_inputs:
          with tf.control_dependencies(control_inputs):
              f0, df0 = value_and_gradients_function(initial_position)
      else:
          f0, df0 = value_and_gradients_function(initial_position)
      # This is a gradient-based convergence check.  We only do it for finite
      # objective values because we assume the gradient reported at a position with
      # a non-finite objective value is untrustworthy.  The main loop handles
      # non-finite objective values itself (see `terminate_if_not_finite`).
      init_converged = tf.math.is_finite(f0) & (
          norm(df0, dims=1) < grad_tolerance
      )
      return dict(
          converged=init_converged,
          failed=tf.zeros_like(init_converged),  # i.e. False.
          num_iterations=tf.convert_to_tensor(0),
          num_objective_evaluations=tf.convert_to_tensor(1),
          position=initial_position,
          objective_value=f0,
          objective_gradient=df0,
      )
  
file_path: probability/tensorflow_probability/python/optimizer/bfgs_utils.py
imports: import collections
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.optimizer.linesearch.hager_zhang import hager_zhang
label_desc: Use image node_id 3 for calling a global function with example usage: get_initial_state_args(value_and_gradients_function, initial_position, grad_tolerance, control_inputs) and returns: dict