code: def test_in_memory_dataset_imbalanced_sampler():
      torch.manual_seed(12345)
      dataset = FakeDataset(
          num_graphs=100,
          avg_num_nodes=10,
          avg_degree=0,
          num_channels=0,
          num_classes=2,
      )
      sampler = ImbalancedSampler(dataset)
      loader = DataLoader(dataset, batch_size=10, sampler=sampler)
  
      y = torch.cat([batch.y for batch in loader])
      histogram = y.bincount()
      prob = histogram / histogram.sum()
  
      assert histogram.sum() == len(dataset)
      assert prob.min() > 0.4 and prob.max() < 0.6
  
file_path: pytorch_geometric/test/loader/test_imbalanced_sampler.py
imports: from typing import List
  import torch
  from torch_geometric.data import Data
  from torch_geometric.datasets import FakeDataset, FakeHeteroDataset
  from torch_geometric.loader import DataLoader, ImbalancedSampler, NeighborLoader
  from torch_geometric.testing import onlyNeighborSampler
label_desc: Use image node_id 2 for calling a global function with example usage: test_in_memory_dataset_imbalanced_sampler() without return types