code: def test_neighbor_loader_with_imbalanced_sampler():
      zeros = torch.zeros(10, dtype=torch.long)
      ones = torch.ones(90, dtype=torch.long)
  
      y = torch.cat([zeros, ones], dim=0)
      edge_index = torch.empty((2, 0), dtype=torch.long)
      data = Data(edge_index=edge_index, y=y, num_nodes=y.size(0))
  
      torch.manual_seed(12345)
      sampler = ImbalancedSampler(data)
      loader = NeighborLoader(
          data, batch_size=10, sampler=sampler, num_neighbors=[-1]
      )
  
      y = torch.cat([batch.y for batch in loader])
  
      histogram = y.bincount()
      prob = histogram / histogram.sum()
  
      assert histogram.sum() == data.num_nodes
      assert prob.min() > 0.4 and prob.max() < 0.6
  
      # Test with label tensor as input:
      torch.manual_seed(12345)
      sampler = ImbalancedSampler(data.y)
      loader = NeighborLoader(
          data, batch_size=10, sampler=sampler, num_neighbors=[-1]
      )
  
      assert torch.allclose(y, torch.cat([batch.y for batch in loader]))
  
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 3 for calling a global function with example usage: test_neighbor_loader_with_imbalanced_sampler() without return types