code: def create_temp_tfrecords(sources, targets):
      """
      Creates a temporary TFRecords file.
  
      Args:
        source: List of source sentences
        target: List of target sentences
  
      Returns:
        A tuple (sources_file, targets_file).
      """
  
      output_file = tempfile.NamedTemporaryFile()
      writer = tf.python_io.TFRecordWriter(output_file.name)
      for source, target in zip(sources, targets):
          ex = tf.train.Example()
          # pylint: disable=E1101
          ex.features.feature["source"].bytes_list.value.extend(
              [source.encode("utf-8")]
          )
          ex.features.feature["target"].bytes_list.value.extend(
              [target.encode("utf-8")]
          )
          writer.write(ex.SerializeToString())
      writer.close()
  
      return output_file
  
file_path: seq2seq/seq2seq/test/utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import tempfile
  import tensorflow
label_desc: Use image node_id 2 for calling a global function with example usage: create_temp_tfrecords(sources, targets) and returns: output_file