def extend_example_with_2d_3d_keypoints(example, input_list, headers):
  """Extends an existing tf.example with 2D and 3D keypoint information.

  Args:
    example: A tf.example to add keypoint information.
    input_list: A list of values with 2D keypoints, 3D keypoints and metadata
      (subject name, action, name, camera, timestamp and image size).
    headers: A list of string headers with 2D keypoint names, 3D keypoint names,
      and metadata to write to the tf.example.

  Returns:
    example: A tf.example with appended information from input_list.
  """
  # Write subject name.
  example.features.feature[headers[0]].bytes_list.value.extend(
      [input_list[0].encode()])
  # Write action name.
  example.features.feature[headers[1]].bytes_list.value.extend(
      [input_list[1].encode()])
  # Write camera name.
  example.features.feature[headers[2]].int64_list.value.extend(
      [int(input_list[2])])
  # Write timestamp.
  example.features.feature[headers[3]].int64_list.value.extend(
      [int(input_list[3])])
  # Write image width and height.
  example.features.feature[headers[4]].int64_list.value.extend(
      [int(input_list[4])])
  example.features.feature[headers[5]].int64_list.value.extend(
      [int(input_list[5])])

  # Write the 2D and 3D keypoints as floats.
  for i in range(6, len(headers)):
    example.features.feature[headers[i]].float_list.value.extend(
        [float(input_list[i])])
  return example