code: def _values_and_jacobian(residuals, variables):
      """Computes the residual values and the Jacobian matrix.
  
      Args:
        residuals: A list of residuals.
        variables: A list of variables.
  
      Returns:
        The residual values and the Jacobian matrix.
      """
  
      def _compute_residual_values(residuals, variables):
          """Computes the residual values."""
          return tf.concat(
              [
                  tf.reshape(residual(*variables), shape=(-1,))
                  for residual in residuals
              ],
              axis=-1,
          )
  
      def _compute_jacobian(values, variables, tape):
          """Computes the Jacobian matrix."""
          jacobians = tape.jacobian(
              values,
              variables,
              unconnected_gradients=tf.UnconnectedGradients.ZERO,
          )
          return tf.concat(
              [
                  tf.reshape(
                      jacobian, shape=(tf.shape(input=jacobian)[0], -1)
                  )
                  for jacobian in jacobians
              ],
              axis=-1,
          )
  
      with tf.GradientTape(
          watch_accessed_variables=False, persistent=True
      ) as tape:
          for variable in variables:
              tape.watch(variable)
          values = _compute_residual_values(residuals, variables)
      jacobian = _compute_jacobian(values, variables, tape)
      del tape
      values = tf.expand_dims(values, axis=-1)
      return values, jacobian
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from six.moves import zip
  import tensorflow
  from tensorflow_graphics.util import export_api
label_desc: Use image node_id 1 for calling a global function with example usage: _values_and_jacobian(residuals, variables) and returns: values,  jacobian, tf, tf