docstr: split the dataset into training set, validation set and testing set
docstr_tok: ["split","the","dataset","into","training","set",",","validation","set","and","testing","set"]
code: def _random_split(
      self, graph, seed=717, train_size=0.7, val_size=0.1
  ):
      """split the dataset into training set, validation set and testing set"""
  
      assert 0 <= train_size + val_size <= 1, (
          "The sum of valid training set size and validation set size "
          "must between 0 and 1 (inclusive)."
      )
  
      num_edges = graph.num_edges(etype="forward")
      index = np.arange(num_edges)
  
      index = np.random.RandomState(seed).permutation(index)
      train_idx = index[: int(train_size * num_edges)]
      val_idx = index[num_edges - int(val_size * num_edges) :]
      test_idx = index[
          int(train_size * num_edges) : num_edges
          - int(val_size * num_edges)
      ]
      train_mask = np.zeros(num_edges, dtype=np.bool_)
      val_mask = np.zeros(num_edges, dtype=np.bool_)
      test_mask = np.zeros(num_edges, dtype=np.bool_)
      train_mask[train_idx] = True
      val_mask[val_idx] = True
      test_mask[test_idx] = True
      graph.edges["forward"].data["train_mask"] = th.tensor(train_mask)
      graph.edges["forward"].data["val_mask"] = th.tensor(val_mask)
      graph.edges["forward"].data["test_mask"] = th.tensor(test_mask)
      graph.edges["backward"].data["train_mask"] = th.tensor(train_mask)
      graph.edges["backward"].data["val_mask"] = th.tensor(val_mask)
      graph.edges["backward"].data["test_mask"] = th.tensor(test_mask)
  
file_path: dgl/examples/pytorch/gas/dataloader.py
imports: import os
  import dgl
  import numpy
  import scipy.io
  import torch
  from dgl.data import DGLBuiltinDataset
  from dgl.data.utils import _get_dgl_url, load_graphs, save_graphs
label_desc: Use image node_id 10 for calling the GASDataset obj's underlying member method code with example usage: obj._random_split(graph, seed, train_size, val_size) without return types