code: def decode_bytes(serialized):
      """Extracts the contents from a VoxelSample proto to tensors."""
      message_type = "giotto_occluded_primitives.CenterNetSample"
      field_names = [
          "name",
          "image_data",
          "image_size",
          "center2d",
          "center3d",
          "box_dims2d",
          "box_dims3d",
          "rotation",
          "translation",
          "rt",
          "k",
      ]
      output_types = [
          tf.string,
          tf.string,
          tf.int32,
          tf.float32,
          tf.float32,
          tf.float32,
          tf.float32,
          tf.float32,
          tf.float32,
          tf.float32,
          tf.float32,
      ]
      _, tensors = decode_proto(
          serialized, message_type, field_names, output_types
      )
      tensors = [tf.squeeze(t) for t in tensors]
      tensor_dict = dict(zip(field_names, tensors))
      tensor_dict["image"] = tf.cast(
          tf.io.decode_image(tensor_dict["image_data"], channels=3),
          tf.float32,
      )
      tensor_dict["image"].set_shape([None, None, 3])
      tensor_dict["original_image_spatial_shape"] = tf.shape(
          tensor_dict["image"]
      )[:2]
  
      # Compute ground truth boxes. From (center2d,size2d) --> (ymin,xmin,ymax,xmax)
      box_min = (
          tensor_dict["center2d"] - tensor_dict["box_dims2d"] / 2.0
      )
      box_max = (
          tensor_dict["center2d"] + tensor_dict["box_dims2d"] / 2.0
      )
      box_min = tf.divide(
          box_min,
          tf.cast(
              tensor_dict["original_image_spatial_shape"], tf.float32
          ),
      )
      box_max = tf.divide(
          box_max,
          tf.cast(
              tensor_dict["original_image_spatial_shape"], tf.float32
          ),
      )
      tensor_dict["groundtruth_boxes"] = tf.reshape(
          tf.concat(
              [box_min[1], box_min[0], box_max[1], box_max[0]], axis=0
          ),
          [1, 4],
      )
  
      tensor_dict["groundtruth_valid_classes"] = [1]
      tensor_dict["num_boxes"] = 1  # needs to be a scalar, no tensor
      tensor_dict["per_class_weight"] = [1]
  
      tensor_dict["box_dims3d"] = tf.reshape(
          tensor_dict["box_dims3d"], [1, 3]
      )
      tensor_dict["size_offset3d"] = tensor_dict["box_dims3d"] - 0.5
  
      # Compute the dot on the ground plane used as prior for 3d pose (batched)
      image_size = tensor_dict["image_size"]
      ray_2d = tf.cast(image_size, tf.float32) * [
          0.5,
          3.0 / 4.0,
          1 / image_size[-1],
      ]
      ray_2d = tf.reshape(ray_2d, [3, 1])
      k = tf.reshape(tensor_dict["k"], [3, 3])
      k_inv = tf.linalg.inv(k)
      rt = tf.reshape(tensor_dict["rt"], [3, 4])
      r = tf.gather(rt, [0, 1, 2], axis=1)
      t = tf.gather(rt, [3], axis=1)
      r_inv = tf.transpose(r, [1, 0])
      t_inv = tf.matmul(r_inv, t) * -1
      ray = tf.matmul(r_inv, tf.matmul(k_inv, ray_2d))
      l = -t_inv[-1] / ray[-1]  # determine lambda
      dot = tf.expand_dims(l, -1) * ray + t_inv
      tensor_dict["dot"] = tf.transpose(dot)
      tensor_dict["center3d"] = tf.reshape(
          tensor_dict["center3d"], [1, 3]
      )
      tensor_dict["dot_offset3d"] = (
          tensor_dict["center3d"] - tensor_dict["dot"]
      )
  
      # Rotation
      rad = tensor_dict["rotation"] * -1 * math.pi / 180
      cos = tf.reshape(tf.cos(rad), [1, 1])
      sin = tf.reshape(tf.sin(rad), [1, 1])
      tensor_dict["rotation"] = tf.concat(
          [cos - 1, sin - 0, -sin - 0, cos - 1], axis=1
      )
      return tensor_dict
  
file_path: graphics/tensorflow_graphics/projects/points_to_3Dobjects/data_preparation/extract_protos.py
imports: import math
  import tensorflow
  from tensorflow_graphics.geometry.transformation import rotation_matrix_3d
  from tensorflow_graphics.projects.points_to_3Dobjects.utils import tf_utils
label_desc: Use image node_id 2 for calling a global function with example usage: decode_bytes(serialized) and returns: tensor_dict