code: def read_graph_data(
      kg_file,
      add_reverse_graph,
      add_inverse_edge,
      mode,
      num_epochs,
      batchsize,
      max_neighbors,
      max_negatives,
      train_graph=None,
      text_kg_file=None,
      val_graph=None,
  ):
      """Read graph, create dataset and build model."""
      # Read graphs and create datasets
      entity_vocab = relation_vocab = None
      if train_graph:
          entity_vocab = train_graph.entity_vocab
          relation_vocab = train_graph.relation_vocab
      if FLAGS.clueweb_data and mode == "train":
          graph_type = clueweb_text_graph.CWTextGraph
          text_kg_file = FLAGS.clueweb_data
      elif text_kg_file and mode == "train":
          graph_type = text_graph.TextGraph
          text_kg_file = FLAGS.text_kg_file
      else:
          graph_type = graph.Graph
          text_kg_file = None
      k_graph = graph_type(
          text_kg_file=text_kg_file,
          skip_new=True,
          max_text_len=FLAGS.max_text_len,
          max_vocab_size=FLAGS.max_vocab_size,
          min_word_freq=FLAGS.min_word_freq,
          kg_file=kg_file,
          add_reverse_graph=add_reverse_graph,
          add_inverse_edge=add_inverse_edge,
          mode=mode,
          entity_vocab=entity_vocab,
          relation_vocab=relation_vocab,
          max_path_length=FLAGS.max_path_length
          if mode == "train"
          else None,
          embeddings_file=FLAGS.clueweb_embeddings,
          sentence_vocab_file=FLAGS.clueweb_sentences,
          subsample=FLAGS.subsample_text_rels,
      )
      if FLAGS.text_kg_file:
          max_text_len = FLAGS.max_text_len
          if mode == "train":
              max_text_len = max_text_len or k_graph.max_text_len
          elif train_graph:
              max_text_len = max_text_len or train_graph.max_text_len
      else:
          max_text_len = None
      k_data = dataset.Dataset(
          data_graph=k_graph,
          train_graph=train_graph,
          mode=mode,
          num_epochs=num_epochs,
          batchsize=batchsize,
          max_neighbors=max_neighbors,
          max_negatives=max_negatives,
          model_type=FLAGS.model,
          max_text_len=max_text_len,
          max_text_neighbors=FLAGS.max_text_neighbors,
          val_graph=val_graph,
      )
      # Create the training data iterator and return the input tensors
      # with tf.device("/job:worker"):
      k_data.create_dataset_iterator(
          num_parallel=FLAGS.num_parallel_preprocess,
          prefetch=FLAGS.prefetch_examples,
          shuffle_buffer=FLAGS.shuffle_buffer
          # , device="worker" if FLAGS.master != "local" else "cpu"
      )
  
      return k_graph, k_data
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import gc
  import math
  import os
  from absl import app
  from absl import flags
  from absl import logging
  import clueweb_text_graph
  import dataset
  import graph
  import losses
  import metrics
  import models
  import numpy
  import slim
  from tensorboard.plugins import projector
  import tensorflow
  from tensorflow.python.training.summary_io import SummaryWriterCache
  import text_graph
  import utils
label_desc: Use image node_id 3 for calling a global function with example usage: read_graph_data(kg_file, add_reverse_graph, add_inverse_edge, mode, num_epochs, batchsize, max_neighbors, max_negatives, train_graph, text_kg_file, val_graph) and returns: k_graph,  k_data