code: def process_movielens(root_path):
      # User-Movie 943 1682 100000 UMUM
      # User-Age 943 8 943 UAUM
      # User-Occupation 943 21 943 UOUM
      # Movie-Genre 1682 18 2861 UMGM
  
      data_path = os.path.join(root_path, "Movielens")
      if not (os.path.exists(data_path)):
          print(
              "Can not find movielens in {}, please download the dataset first.".format(
                  data_path
              )
          )
  
      # Construct graph from raw data.
      # movie_genre
      movie_genre_src = []
      movie_genre_dst = []
      with open(os.path.join(data_path, "movie_genre.dat")) as fin:
          for line in fin.readlines():
              _line = line.strip().split("\t")
              movie, genre = int(_line[0]), int(_line[1])
              movie_genre_src.append(movie)
              movie_genre_dst.append(genre)
  
      # user_movie
      user_movie_src = []
      user_movie_dst = []
      with open(os.path.join(data_path, "user_movie.dat")) as fin:
          for line in fin.readlines():
              _line = line.strip().split("\t")
              user, item, rate = (
                  int(_line[0]),
                  int(_line[1]),
                  int(_line[2]),
              )
              if rate > 3:
                  user_movie_src.append(user)
                  user_movie_dst.append(item)
  
      # user_occupation
      user_occupation_src = []
      user_occupation_dst = []
      with open(os.path.join(data_path, "user_occupation.dat")) as fin:
          for line in fin.readlines():
              _line = line.strip().split("\t")
              user, occupation = int(_line[0]), int(_line[1])
              user_occupation_src.append(user)
              user_occupation_dst.append(occupation)
  
      # user_age
      user_age_src = []
      user_age_dst = []
      with open(os.path.join(data_path, "user_age.dat")) as fin:
          for line in fin.readlines():
              _line = line.strip().split("\t")
              user, age = int(_line[0]), int(_line[1])
              user_age_src.append(user)
              user_age_dst.append(age)
  
      # build graph
      hg = dgl.heterograph(
          {
              ("movie", "mg", "genre"): (
                  movie_genre_src,
                  movie_genre_dst,
              ),
              ("genre", "gm", "movie"): (
                  movie_genre_dst,
                  movie_genre_src,
              ),
              ("user", "um", "movie"): (user_movie_src, user_movie_dst),
              ("movie", "mu", "user"): (user_movie_dst, user_movie_src),
              ("user", "uo", "occupation"): (
                  user_occupation_src,
                  user_occupation_dst,
              ),
              ("occupation", "ou", "user"): (
                  user_occupation_dst,
                  user_occupation_src,
              ),
              ("user", "ua", "age"): (user_age_src, user_age_dst),
              ("age", "au", "user"): (user_age_dst, user_age_src),
          }
      )
  
      print("Graph constructed.")
  
      # Split data into train/eval/test
      train_data, eval_data, test_data = split_data(hg, "um")
  
      # delete the positive edges in eval/test data in the original graph
      train_pos = np.nonzero(train_data[:, 2])
      train_pos_idx = train_pos[0]
      user_movie_src_processed = train_data[train_pos_idx, 0]
      user_movie_dst_processed = train_data[train_pos_idx, 1]
      edges_dict = {
          ("movie", "mg", "genre"): (movie_genre_src, movie_genre_dst),
          ("genre", "gm", "movie"): (movie_genre_dst, movie_genre_src),
          ("user", "um", "movie"): (
              user_movie_src_processed,
              user_movie_dst_processed,
          ),
          ("movie", "mu", "user"): (
              user_movie_dst_processed,
              user_movie_src_processed,
          ),
          ("user", "uo", "occupation"): (
              user_occupation_src,
              user_occupation_dst,
          ),
          ("occupation", "ou", "user"): (
              user_occupation_dst,
              user_occupation_src,
          ),
          ("user", "ua", "age"): (user_age_src, user_age_dst),
          ("age", "au", "user"): (user_age_dst, user_age_src),
      }
      nodes_dict = {
          "user": hg.num_nodes("user"),
          "movie": hg.num_nodes("movie"),
          "genre": hg.num_nodes("genre"),
          "occupation": hg.num_nodes("occupation"),
          "age": hg.num_nodes("age"),
      }
      hg_processed = dgl.heterograph(
          data_dict=edges_dict, num_nodes_dict=nodes_dict
      )
      print("Graph processed.")
  
      # save the processed data
      with open(
          os.path.join(root_path, "movielens_hg.pkl"), "wb"
      ) as file:
          pkl.dump(hg_processed, file)
      with open(
          os.path.join(root_path, "movielens_train.pkl"), "wb"
      ) as file:
          pkl.dump(train_data, file)
      with open(
          os.path.join(root_path, "movielens_test.pkl"), "wb"
      ) as file:
          pkl.dump(test_data, file)
      with open(
          os.path.join(root_path, "movielens_eval.pkl"), "wb"
      ) as file:
          pkl.dump(eval_data, file)
  
      return hg_processed, train_data, eval_data, test_data
  
file_path: dgl/examples/pytorch/TAHIN/data_loader.py
imports: import os
  import pickle
  import random
  import dgl
  import numpy
  import torch
  from torch.utils.data import DataLoader, Dataset
label_desc: Use image node_id 3 for calling a global function with example usage: process_movielens(root_path) and returns: hg_processed,  train_data,  eval_data,  test_data