code: def test_temporal_sample_neighbors_homo(
      indptr_dtype,
      indices_dtype,
      replace,
      use_node_timestamp,
      use_edge_timestamp,
  ):
      """Original graph in COO:
      1   0   1   0   1
      1   0   1   1   0
      0   1   0   1   0
      0   1   0   0   1
      1   0   0   0   1
      """
      # Initialize data.
      total_num_nodes = 5
      total_num_edges = 12
      indptr = torch.tensor([0, 3, 5, 7, 9, 12], dtype=indptr_dtype)
      indices = torch.tensor(
          [0, 1, 4, 2, 3, 0, 1, 1, 2, 0, 3, 4], dtype=indices_dtype
      )
      assert indptr[-1] == total_num_edges
      assert indptr[-1] == len(indices)
      assert len(indptr) == total_num_nodes + 1
  
      # Construct FusedCSCSamplingGraph.
      graph = gb.fused_csc_sampling_graph(indptr, indices)
  
      # Generate subgraph via sample neighbors.
      fanouts = torch.LongTensor([2])
      sampler = graph.temporal_sample_neighbors
  
      seed_list = [1, 3, 4]
      seed_timestamp = torch.randint(
          0, 100, (len(seed_list),), dtype=torch.int64
      )
      if use_node_timestamp:
          node_timestamp = torch.randint(
              0, 100, (total_num_nodes,), dtype=torch.int64
          )
          graph.node_attributes = {"timestamp": node_timestamp}
      if use_edge_timestamp:
          edge_timestamp = torch.randint(
              0, 100, (total_num_edges,), dtype=torch.int64
          )
          graph.edge_attributes = {"timestamp": edge_timestamp}
  
      # Sample with nodes in mismatched dtype with graph's indices.
      nodes = torch.tensor(
          seed_list,
          dtype=(
              torch.int64
              if indices_dtype == torch.int32
              else torch.int32
          ),
      )
      with pytest.raises(
          AssertionError,
          match=re.escape(
              "Data type of nodes must be consistent with indices.dtype"
          ),
      ):
          _ = sampler(
              nodes,
              seed_timestamp,
              fanouts,
              replace=replace,
              node_timestamp_attr_name="timestamp"
              if use_node_timestamp
              else None,
              edge_timestamp_attr_name="timestamp"
              if use_edge_timestamp
              else None,
          )
  
      def _get_available_neighbors():
          available_neighbors = []
          for i, seed in enumerate(seed_list):
              neighbors = []
              start = indptr[seed].item()
              end = indptr[seed + 1].item()
              for j in range(start, end):
                  neighbor = indices[j].item()
                  if (
                      use_node_timestamp
                      and (
                          node_timestamp[neighbor] >= seed_timestamp[i]
                      ).item()
                  ):
                      continue
                  if (
                      use_edge_timestamp
                      and (
                          edge_timestamp[j] >= seed_timestamp[i]
                      ).item()
                  ):
                      continue
                  neighbors.append(neighbor)
              available_neighbors.append(neighbors)
          return available_neighbors
  
      nodes = torch.tensor(seed_list, dtype=indices_dtype)
      subgraph = sampler(
          nodes,
          seed_timestamp,
          fanouts,
          replace=replace,
          node_timestamp_attr_name="timestamp"
          if use_node_timestamp
          else None,
          edge_timestamp_attr_name="timestamp"
          if use_edge_timestamp
          else None,
      )
      sampled_count = torch.diff(subgraph.sampled_csc.indptr).tolist()
      available_neighbors = _get_available_neighbors()
      for i, count in enumerate(sampled_count):
          if not replace:
              expect_count = min(
                  fanouts[0], len(available_neighbors[i])
              )
          else:
              expect_count = (
                  fanouts[0] if len(available_neighbors[i]) > 0 else 0
              )
          assert count == expect_count
      sampled_neighbors = torch.split(
          subgraph.sampled_csc.indices, sampled_count
      )
      for i, neighbors in enumerate(sampled_neighbors):
          assert set(neighbors.tolist()).issubset(
              set(available_neighbors[i])
          )
  
imports: import os
  import pickle
  import re
  import tempfile
  import unittest
  import backend
  import dgl
  import dgl.graphbolt
  import pytest
  import torch
  import torch.multiprocessing
  from dgl.graphbolt.base import etype_str_to_tuple
  from scipy import sparse
  from ..None import gb_test_utils
label_desc: Use image node_id 18 for calling a global function with example usage: test_temporal_sample_neighbors_homo(indptr_dtype, indices_dtype, replace, use_node_timestamp, use_edge_timestamp) and returns: available_neighbors