code: def write_tfrecord_from_tensorrec_dataset(tfrecord_path, dataset):
      """
      Writes the contents of a TensorRec Dataset to a TFRecord file.
      :param tfrecord_path: str
      :param dataset: tf.data.Dataset
      :return: str
      The tfrecord path
      """
      session = get_session()
      iterator = create_tensorrec_iterator("dataset_writing_iterator")
      initializer = iterator.make_initializer(dataset)
      (
          tf_row_index,
          tf_col_index,
          tf_values,
          tf_d0,
          tf_d1,
      ) = iterator.get_next()
      session.run(initializer)
      row_index, col_index, values, d0, d1 = session.run(
          [tf_row_index, tf_col_index, tf_values, tf_d0, tf_d1]
      )
  
      def _int64_feature(int_values):
          return tf.train.Feature(
              int64_list=tf.train.Int64List(value=int_values)
          )
  
      def _float_feature(float_values):
          return tf.train.Feature(
              float_list=tf.train.FloatList(value=float_values)
          )
  
      writer = tf.python_io.TFRecordWriter(tfrecord_path)
      feature = {
          "row_index": _int64_feature(row_index),
          "col_index": _int64_feature(col_index),
          "values": _float_feature(values),
          "d0": _int64_feature([d0]),
          "d1": _int64_feature([d1]),
      }
      example = tf.train.Example(
          features=tf.train.Features(feature=feature)
      )
      writer.write(example.SerializeToString())
      writer.close()
      return tfrecord_path
  
file_path: tensorrec/tensorrec/input_utils.py
imports: import numpy
  from scipy import sparse
  import tensorflow
  from .session_management import get_session
label_desc: Use image node_id 5 for calling a global function with example usage: write_tfrecord_from_tensorrec_dataset(tfrecord_path, dataset) and returns: tfrecord_path, tf, tf