code: def test_sample_neighbors_etype_sorted_homogeneous(
      format_, direction
  ):
      rare_cnt = 4
      g = create_etype_test_graph(100, 30, rare_cnt)
      h_g = dgl.to_homogeneous(g)
      seed_ntype = g.get_ntype_id("u")
      seeds = F.nonzero_1d(h_g.ndata[dgl.NTYPE] == seed_ntype)
      fanouts = F.tensor([6, 5, -1, 3, 2], dtype=F.int64)
      h_g = h_g.formats(format_)
      if (direction, format_) in [("in", "csr"), ("out", "csc")]:
          h_g = h_g.formats(["csc", "csr", "coo"])
  
      if direction == "in":
          h_g = dgl.sort_csc_by_tag(
              h_g, h_g.edata[dgl.ETYPE], tag_type="edge"
          )
      else:
          h_g = dgl.sort_csr_by_tag(
              h_g, h_g.edata[dgl.ETYPE], tag_type="edge"
          )
      # shuffle
      h_g_etype = F.asnumpy(h_g.edata[dgl.ETYPE])
      h_g_offset = np.cumsum(
          np.insert(np.bincount(h_g_etype), 0, 0)
      ).tolist()
      sg = dgl.sampling.sample_etype_neighbors(
          h_g,
          seeds,
          h_g_offset,
          fanouts,
          edge_dir=direction,
          etype_sorted=True,
      )
  
imports: import unittest
  import warnings
  import backend
  import dgl
  import numpy
  import pytest
label_desc: Use image node_id 28 for calling a global function with example usage: test_sample_neighbors_etype_sorted_homogeneous(format_, direction) without return types