code: def save_to_tfrecord(
      image, label, process_no, idx, output_path, output_file_prefix
  ):
      """Save to TFRecord."""
      d_feature = {}
      d_feature["image/ct_image"] = tf.train.Feature(
          bytes_list=tf.train.BytesList(
              value=[image.reshape([-1]).tobytes()]
          )
      )
      d_feature["image/label"] = tf.train.Feature(
          bytes_list=tf.train.BytesList(
              value=[label.reshape([-1]).tobytes()]
          )
      )
  
      example = tf.train.Example(
          features=tf.train.Features(feature=d_feature)
      )
      serialized = example.SerializeToString()
  
      result_file = os.path.join(
          output_path,
          "{}-{}-{}.tfrecords".format(
              output_file_prefix, process_no, idx
          ),
      )
      options = tf.python_io.TFRecordOptions(
          tf.python_io.TFRecordCompressionType.GZIP
      )
      with tf.python_io.TFRecordWriter(
          result_file, options=options
      ) as w:
          w.write(serialized)
  
file_path: mesh/mesh_tensorflow/experimental/offline_data_aug.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import os
  from absl import app
  from absl import flags
  from six.moves import range
  import tensorflow.compat.v1
  from mesh_tensorflow.experimental import data_aug_lib
label_desc: Use image node_id 2 for calling a global function with example usage: save_to_tfrecord(image, label, process_no, idx, output_path, output_file_prefix) without return types