code: def plot_boxes_3d(
      image,
      sample,
      predictions,
      figsize=5,
      groundtruth=True,
      class_id_to_name=CLASSES,
  ):
      """Plot."""
      batch_id = 0
  
      intrinsics = sample["k"][batch_id].numpy()
      pose_world2camera = sample["rt"][batch_id].numpy()
  
      figure = plt.figure(figsize=(figsize, figsize))
      plt.clf()
      plt.imshow(image)
  
      intrinsics = np.reshape(intrinsics, [3, 3])
      pose_world2camera = np.reshape(pose_world2camera, [3, 4])
  
      # Plot ground truth boxes
      if groundtruth:
          num_boxes = sample["groundtruth_boxes"][batch_id].shape[0]
          sample["detection_boxes"] = sample["groundtruth_boxes"][
              batch_id
          ].numpy()
          colors = ["c", "m", "y"]
          for i in range(num_boxes):
              predicted_pose_obj2world = np.eye(4)
              predicted_pose_obj2world[0:3, 0:3] = tf.reshape(
                  sample["rotations_3d"][batch_id][i], [3, 3]
              ).numpy()
              predicted_pose_obj2world[0:3, 3] = sample[
                  "translations_3d"
              ][batch_id][i].numpy()
              draw_bounding_box_3d(
                  sample["sizes_3d"][batch_id][i].numpy(),
                  predicted_pose_obj2world,
                  intrinsics,
                  pose_world2camera,
                  linestyle="dashed",
                  color=colors[i % 3],
              )
              y_min, x_min, y_max, x_max = sample["detection_boxes"][i]
              y_min *= sample["original_image_spatial_shape"][batch_id][
                  1
              ].numpy()
              y_max *= sample["original_image_spatial_shape"][batch_id][
                  1
              ].numpy()
              x_min *= sample["original_image_spatial_shape"][batch_id][
                  0
              ].numpy()
              x_max *= sample["original_image_spatial_shape"][batch_id][
                  0
              ].numpy()
              plt.text(
                  x_max,
                  y_min,
                  str(i)
                  + "_gt_"
                  + class_id_to_name[
                      int(
                          sample["groundtruth_valid_classes"][batch_id][
                              i
                          ]
                      )
                  ],
              )
  
      # Plot predicted boxes
      colors = [
          "r",
          "g",
          "b",
          "c",
          "m",
          "y",
          "c",
          "m",
          "y",
          "c",
          "m",
          "y",
      ]
      num_boxes = predictions["rotations_3d"].shape[0]
      for i in range(num_boxes):
          predicted_pose_obj2world = np.eye(4)
          predicted_pose_obj2world[0:3, 0:3] = predictions[
              "rotations_3d"
          ][i].numpy()
          predicted_pose_obj2world[0:3, 3] = predictions[
              "translations_3d"
          ][i].numpy()
          draw_bounding_box_3d(
              predictions["sizes_3d"].numpy()[i],
              predicted_pose_obj2world,
              intrinsics,
              pose_world2camera,
              linestyle="solid",
              color=colors[int(predictions["detection_classes"][i])],
          )
          x_min, y_min, x_max, y_max = predictions["detection_boxes"][i]
          plt.text(
              x_min,
              y_min,
              str(i)
              + "_"
              + class_id_to_name[
                  int(predictions["detection_classes"][i])
              ]
              + str(
                  int(predictions["detection_scores"][i] * 1000)
                  / 1000.0
              ),
          )
      plt.axis("off")
      plt.tight_layout()
      return figure
  
imports: import os
  import pickle
  import re
  import matplotlib.pyplot
  import numpy
  import tensorflow
  from tensorflow_graphics.projects.points_to_3Dobjects.utils import tf_utils
  from google3.pyglib import gfile
label_desc: Use image node_id 9 for calling a global function with example usage: plot_boxes_3d(image, sample, predictions, figsize, groundtruth, class_id_to_name) and returns: figure