code: def set_srn_sample_proto(
      shape_name: str,
      shape_id: int,
      view: int,
      image: np.ndarray,
      focal: np.ndarray,
      principal_point: np.ndarray,
      rotation_matrix: np.ndarray,
      translation_vector: np.ndarray,
      w2v_alpha: np.ndarray,
      w2v_beta: np.ndarray,
  ):
      """Set a proto message (tf.Example) containing rendering information from SRN-ShapeNet.
  
      Args:
          shape_name: Name of the 3D shape that the rendering came from.
          shape_id: Index of the 3D shape.
          view: Index of the camera view.
          image: A numpy array of size [height, witdth, 3].
          focal: A numpy array of size [2].
          principal_point: A numpy array of size [2].
          rotation_matrix: A numpy array of size [3, 3].
          translation_vector: A numpy array of size [3, 1].
          w2v_alpha: A numpy array of size [1, 3].
          w2v_beta: A numpy array of size [1, 3].
  
      Returns:
          A tf.Example proto message.
      """
      image_bytes = tf.io.encode_png((image * 255).astype(np.uint8))
  
      feature = {
          "name": _bytes_feature(shape_name.encode("utf_8")),
          "shape_index": _int64_feature(shape_id),
          "view": _int64_feature(view),
          "image_data": _bytes_feature(image_bytes),
          "image_size": _int64_feature(list(image.shape)),
          "focal": _float_feature(list(focal)),
          "principal_point": _float_feature(list(principal_point)),
          "rotation_matrix": _float_feature(
              list(rotation_matrix.flatten())
          ),
          "translation_vector": _float_feature(
              list(translation_vector.flatten())
          ),
          "w2v_alpha": _float_feature(list(w2v_alpha.flatten())),
          "w2v_beta": _float_feature(list(w2v_beta.flatten())),
      }
      proto_sample = tf.train.Example(
          features=tf.train.Features(feature=feature)
      )
      return proto_sample
  
file_path: graphics/tensorflow_graphics/projects/radiance_fields/data_loaders.py
imports: import json
  import os
  from typing import Optional
  import numpy
  from PIL import Image
  import tensorflow
label_desc: Use image node_id 6 for calling a global function with example usage: set_srn_sample_proto(shape_name, shape_id, view, image, focal, principal_point, rotation_matrix, translation_vector, w2v_alpha, w2v_beta) and returns: proto_sample