code: def _dense_solutions_to_final_time(
      final_time,
      solver_state,
      diagnostics,
      step_fn,
      ode_fn,
      times_array,
      solutions_arrays,
      validate_args=False,
  ):
      """Integrates `solver_state` to `final_time`.
  
      Performs integration of the `solver_state` to `final_time` while saving
      solutions at all intermediate time steps. This corresponds to the expected
      behavior of `ChosenBySolver` option. The solution at `final_time` is obtained
      by interpolation and is set as a final state of the solver.
  
      Args:
        final_time: Floating `Tensor` representing the final time of integration.
        solver_state: `_DopriSolverInternalState` - initial solver state.
        diagnostics: `_DopriDiagnostics` - info on the current `_solve` call.
        step_fn: Partial `Dopri._step` method that performs a single step updating
          the `solver_state`, `diagnostics` and `solver_state`.
        ode_fn: Callable(t, y) -> dy_dt.
        times_array: `TensorArray` where time values are recorded.
        solutions_arrays: `TensorArray`s where solutions are recorded.
        validate_args: Python `bool` indicating whether to validate inputs.
          Default value: False.
  
      Returns:
        solver_state: `_RungeKuttaSolverInternalState` holding final solver state.
        diagnostics: `_DopriDiagnostics` holding diagnostic values.
        times_array: `TensorArray` with recorded solution times.
        solutions_arrays: `TensorArray`s with solution values at time corresponding
          to times_array.
      """
  
      def step_and_record(
          solver_state, diagnostics, solutions_arrays, times_array
      ):
          y = solver_state.current_state
          time_id = times_array.size()
          solutions_arrays = _write_solution_components(
              y, solutions_arrays, time_id
          )
          times_array = times_array.write(
              time_id, solver_state.current_time
          )
          solver_state, diagnostics = step_fn(solver_state, diagnostics)
          return (
              solver_state,
              diagnostics,
              solutions_arrays,
              times_array,
          )
  
      def step_cond(solver_internal_state, *_):
          return solver_internal_state.current_time <= final_time
  
      [
          solver_state,
          diagnostics,
          solutions_arrays,
          times_array,
      ] = tf.while_loop(
          step_cond,
          step_and_record,
          [solver_state, diagnostics, solutions_arrays, times_array],
      )
      # Interpolating the last time point, updating the state and write results.
      y, coefficients = _interpolate_solution_at(
          final_time, solver_state, validate_args
      )
      dy_dt = ode_fn(final_time, y)
      dy_dt = tf.nest.map_structure(tf.convert_to_tensor, dy_dt)
  
      time_id = times_array.size()
      times_array = times_array.write(time_id, final_time)
      solutions_arrays = _write_solution_components(
          y, solutions_arrays, time_id
      )
      solver_state = _RungeKuttaSolverInternalState(
          current_state=y,
          current_derivative=dy_dt,
          last_step_start=solver_state.last_step_start,
          current_time=final_time,
          step_size=solver_state.step_size,
          interpolating_coefficients=coefficients,
      )
      return solver_state, diagnostics, times_array, solutions_arrays
  
imports: import collections
  import functools
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.math.ode import base
  from tensorflow_probability.python.math.ode import runge_kutta_util
  from tensorflow_probability.python.math.ode import util
  from tensorflow.python.util import nest
label_desc: Use image node_id 1 for calling a global function with example usage: _dense_solutions_to_final_time(final_time, solver_state, diagnostics, step_fn, ode_fn, times_array, solutions_arrays, validate_args) and returns: solver_state,  diagnostics,  times_array,  solutions_arrays, solver_state,  diagnostics,  solutions_arrays,  times_array, unknown