import tensorflow as tf

      'bounding_box_samples': _float_feature(d['bounding_box_samples']),
      'depth_renders': _float_feature(d['depth_renders']),
      'mesh_name': _bytes_feature(d['mesh_name']),
      'near_surface_samples': _float_feature(d['near_surface_samples']),
      'grid': _float_feature(d['grid']),
      'world2grid': _float_feature(d['world2grid']),
      'surface_point_samples': _float_feature(d['surface_point_samples'])
  }
  example_proto = tf.train.Example(features=tf.train.Features(feature=feature))
  return example_proto.SerializeToString()


def full_featurespec():
  return {
      'bounding_box_samples': tf.io.FixedLenFeature([100000, 4], tf.float32),
      'depth_renders': tf.io.FixedLenFeature([20, 224, 224, 1], tf.float32),
      'mesh_name': tf.io.FixedLenFeature([], tf.string),
      'near_surface_samples': tf.io.FixedLenFeature([100000, 4], tf.float32),
      'grid': tf.io.FixedLenFeature([32, 32, 32], tf.float32),
      'world2grid': tf.io.FixedLenFeature([4, 4], tf.float32),
      'surface_point_samples': tf.io.FixedLenFeature([10000, 6], tf.float32)
  }


def parse_tf_example(example_proto):
  d = tf.io.parse_single_example(example_proto, full_featurespec())
  return (d['bounding_box_samples'], d['depth_renders'], d['mesh_name'],
          d['near_surface_samples'], d['grid'], d['world2grid'],
          d['surface_point_samples'])

