code: def __init__(self, path, batch_size):
      self.path = path
      self.batch_size = batch_size
  
      train_file = path + "/train.txt"
      test_file = path + "/test.txt"
  
      # get number of users and items
      self.n_users, self.n_items = 0, 0
      self.n_train, self.n_test = 0, 0
      self.exist_users = []
  
      user_item_src = []
      user_item_dst = []
  
      with open(train_file) as f:
          for l in f.readlines():
              if len(l) > 0:
                  l = l.strip("\n").split(" ")
                  items = [int(i) for i in l[1:]]
                  uid = int(l[0])
                  self.exist_users.append(uid)
                  self.n_items = max(self.n_items, max(items))
                  self.n_users = max(self.n_users, uid)
                  self.n_train += len(items)
                  for i in l[1:]:
                      user_item_src.append(uid)
                      user_item_dst.append(int(i))
  
      with open(test_file) as f:
          for l in f.readlines():
              if len(l) > 0:
                  l = l.strip("\n")
                  try:
                      items = [int(i) for i in l.split(" ")[1:]]
                  except Exception:
                      continue
                  self.n_items = max(self.n_items, max(items))
                  self.n_test += len(items)
      self.n_items += 1
      self.n_users += 1
  
      self.print_statistics()
  
      # training positive items corresponding to each user; testing positive items corresponding to each user
      self.train_items, self.test_set = {}, {}
      with open(train_file) as f_train:
          with open(test_file) as f_test:
              for l in f_train.readlines():
                  if len(l) == 0:
                      break
                  l = l.strip("\n")
                  items = [int(i) for i in l.split(" ")]
                  uid, train_items = items[0], items[1:]
                  self.train_items[uid] = train_items
  
              for l in f_test.readlines():
                  if len(l) == 0:
                      break
                  l = l.strip("\n")
                  try:
                      items = [int(i) for i in l.split(" ")]
                  except Exception:
                      continue
  
                  uid, test_items = items[0], items[1:]
                  self.test_set[uid] = test_items
  
      # construct graph from the train data and add self-loops
      user_selfs = [i for i in range(self.n_users)]
      item_selfs = [i for i in range(self.n_items)]
  
      data_dict = {
          ("user", "user_self", "user"): (user_selfs, user_selfs),
          ("item", "item_self", "item"): (item_selfs, item_selfs),
          ("user", "ui", "item"): (user_item_src, user_item_dst),
          ("item", "iu", "user"): (user_item_dst, user_item_src),
      }
      num_dict = {"user": self.n_users, "item": self.n_items}
  
      self.g = dgl.heterograph(data_dict, num_nodes_dict=num_dict)
  
file_path: dgl/examples/pytorch/NGCF/NGCF/utility/load_data.py
imports: import random
  import dgl
  import numpy
label_desc: Use image node_id 1 to create a new Data object from inherited base classes: object with example: obj = Data(path, batch_size)