code: def graph_random_splits(
      dataset: InMemoryDataset,
      train_ratio: float = 0.2,
      val_ratio: float = 0.4,
      seed: _typing.Optional[int] = ...,
  ):
      r"""Splitting graph dataset with specific ratio for train/val/test.
  
      Parameters
      ----------
      dataset: ``InMemoryStaticGraphSet``
  
      train_ratio : float
          the portion of data that used for training.
  
      val_ratio : float
          the portion of data that used for validation.
  
      seed : int
          random seed for splitting dataset.
      """
      _rng_state = torch.get_rng_state()
      if isinstance(seed, int):
          torch.manual_seed(seed)
      perm = torch.randperm(len(dataset))
      train_index = perm[: int(len(dataset) * train_ratio)]
      val_index = perm[
          int(len(dataset) * train_ratio) : int(
              len(dataset) * (train_ratio + val_ratio)
          )
      ]
      test_index = perm[int(len(dataset) * (train_ratio + val_ratio)) :]
      train_index = train_index.tolist()
      val_index = val_index.tolist()
      test_index = test_index.tolist()
      dataset.train_index = train_index
      dataset.val_index = val_index
      dataset.test_index = test_index
      if not isinstance(dataset, InMemoryDataset):
          dataset.train_split = [dataset[i] for i in train_index]
          dataset.val_split = [dataset[i] for i in val_index]
          dataset.test_split = [dataset[i] for i in test_index]
      torch.set_rng_state(_rng_state)
      return dataset
  
file_path: AutoGL/autogl/datasets/utils/_general.py
imports: import numpy
  import random
  import torch
  import torch.utils.data
  import typing
  from sklearn.model_selection import StratifiedKFold, KFold
  from autogl import backend
  from autogl.data import InMemoryDataset
label_desc: Use image node_id 6 for calling a global function with example usage: graph_random_splits(dataset, train_ratio, val_ratio, seed) and returns: dataset