code: def parse_cora_content(in_file, train_percentage):
      """Converts the Cora content (in TSV) to `tf.train.Example` instances.
  
      This function parses Cora content (in TSV), converts string labels to integer
      label IDs, randomly splits the data into training and test sets, and returns
      the training and test sets as outputs.
  
      Args:
        in_file: A string indicating the input file path.
        train_percentage: A float indicating the percentage of training examples
          over the dataset.
  
      Returns:
        train_examples: A dict with keys being example IDs (string) and values being
        `tf.train.Example` instances.
        test_examples: A dict with keys being example IDs (string) and values being
        `tf.train.Example` instances.
      """
      # Provides a mapping from string labels to integer indices.
      label_index = {
          "Case_Based": 0,
          "Genetic_Algorithms": 1,
          "Neural_Networks": 2,
          "Probabilistic_Methods": 3,
          "Reinforcement_Learning": 4,
          "Rule_Learning": 5,
          "Theory": 6,
      }
      # Fixes the random seed so the train/test split can be reproduced.
      random.seed(1)
      train_examples = {}
      test_examples = {}
      with open(in_file, "r") as cora_content:
          for line in cora_content:
              entries = line.rstrip("\n").split("\t")
              # entries contains [ID, Word1, Word2, ..., Label]; 'Words' are 0/1 values.
              words = map(int, entries[1:-1])
              example_id = entries[0]
              features = {
                  "id": _bytes_feature(example_id),
                  "words": _int64_feature(*words),
                  "label": _int64_feature(label_index[entries[-1]]),
              }
              example_features = tf.train.Example(
                  features=tf.train.Features(feature=features)
              )
              if (
                  random.uniform(0, 1) <= train_percentage
              ):  # for train/test split.
                  train_examples[example_id] = example_features
              else:
                  test_examples[example_id] = example_features
  
      return train_examples, test_examples
  
file_path: neural-structured-learning/neural_structured_learning/examples/preprocess/cora/preprocess_cora_dataset.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import random
  import time
  from absl import app
  from absl import flags
  from absl import logging
  from neural_structured_learning.tools import graph_utils
  import six
  import tensorflow
label_desc: Use image node_id 3 for calling a global function with example usage: parse_cora_content(in_file, train_percentage) and returns: train_examples,  test_examples