code: def test_remove_edges(idtype):
      # homogeneous Graphs
      g = dgl.graph(([0, 1], [1, 2]), idtype=idtype, device=F.ctx())
      e = 0
      g = dgl.remove_edges(g, e)
      assert g.num_edges() == 1
      u, v = g.edges(form="uv", order="eid")
      assert F.array_equal(u, F.tensor([1], dtype=idtype))
      assert F.array_equal(v, F.tensor([2], dtype=idtype))
      g = dgl.graph(([0, 1], [1, 2]), idtype=idtype, device=F.ctx())
      e = [0]
      g = dgl.remove_edges(g, e)
      assert g.num_edges() == 1
      u, v = g.edges(form="uv", order="eid")
      assert F.array_equal(u, F.tensor([1], dtype=idtype))
      assert F.array_equal(v, F.tensor([2], dtype=idtype))
      e = F.tensor([0], dtype=idtype)
      g = dgl.remove_edges(g, e)
      assert g.num_edges() == 0
  
      # has node data
      g = dgl.graph(([0, 1], [1, 2]), idtype=idtype, device=F.ctx())
      g.ndata["h"] = F.copy_to(
          F.tensor([1, 2, 3], dtype=idtype), ctx=F.ctx()
      )
      g = dgl.remove_edges(g, 1)
      assert g.num_edges() == 1
      assert F.array_equal(
          g.ndata["h"], F.tensor([1, 2, 3], dtype=idtype)
      )
  
      # has edge data
      g = dgl.graph(([0, 1], [1, 2]), idtype=idtype, device=F.ctx())
      g.edata["h"] = F.copy_to(
          F.tensor([1, 2], dtype=idtype), ctx=F.ctx()
      )
      g = dgl.remove_edges(g, 0)
      assert g.num_edges() == 1
      assert F.array_equal(g.edata["h"], F.tensor([2], dtype=idtype))
  
      # invalid eid
      assert_fail = False
      try:
          g = dgl.remove_edges(g, 1)
      except:
          assert_fail = True
      assert assert_fail
  
      # bipartite graph
      g = dgl.heterograph(
          {("user", "plays", "game"): ([0, 1], [1, 2])},
          idtype=idtype,
          device=F.ctx(),
      )
      e = 0
      g = dgl.remove_edges(g, e)
      assert g.num_edges() == 1
      u, v = g.edges(form="uv", order="eid")
      assert F.array_equal(u, F.tensor([1], dtype=idtype))
      assert F.array_equal(v, F.tensor([2], dtype=idtype))
      g = dgl.heterograph(
          {("user", "plays", "game"): ([0, 1], [1, 2])},
          idtype=idtype,
          device=F.ctx(),
      )
      e = [0]
      g = dgl.remove_edges(g, e)
      assert g.num_edges() == 1
      u, v = g.edges(form="uv", order="eid")
      assert F.array_equal(u, F.tensor([1], dtype=idtype))
      assert F.array_equal(v, F.tensor([2], dtype=idtype))
      e = F.tensor([0], dtype=idtype)
      g = dgl.remove_edges(g, e)
      assert g.num_edges() == 0
  
      # has data
      g = dgl.heterograph(
          {("user", "plays", "game"): ([0, 1], [1, 2])},
          idtype=idtype,
          device=F.ctx(),
      )
      g.nodes["user"].data["h"] = F.copy_to(
          F.tensor([1, 1], dtype=idtype), ctx=F.ctx()
      )
      g.nodes["game"].data["h"] = F.copy_to(
          F.tensor([2, 2, 2], dtype=idtype), ctx=F.ctx()
      )
      g.edata["h"] = F.copy_to(
          F.tensor([1, 2], dtype=idtype), ctx=F.ctx()
      )
      g = dgl.remove_edges(g, 1)
      assert g.num_edges() == 1
      assert F.array_equal(
          g.nodes["user"].data["h"], F.tensor([1, 1], dtype=idtype)
      )
      assert F.array_equal(
          g.nodes["game"].data["h"], F.tensor([2, 2, 2], dtype=idtype)
      )
      assert F.array_equal(g.edata["h"], F.tensor([1], dtype=idtype))
  
      # heterogeneous graph
      g = create_test_heterograph3(idtype)
      g.edges["plays"].data["h"] = F.copy_to(
          F.tensor([1, 2, 3, 4], dtype=idtype), ctx=F.ctx()
      )
      g = dgl.remove_edges(g, 1, etype="plays")
      assert g.num_edges("plays") == 3
      u, v = g.edges(form="uv", order="eid", etype="plays")
      assert F.array_equal(u, F.tensor([0, 1, 2], dtype=idtype))
      assert F.array_equal(v, F.tensor([0, 1, 1], dtype=idtype))
      assert F.array_equal(
          g.edges["plays"].data["h"], F.tensor([1, 3, 4], dtype=idtype)
      )
      # remove all edges of 'develops'
      g = dgl.remove_edges(g, [0, 1], etype="develops")
      assert g.num_edges("develops") == 0
      assert F.array_equal(
          g.nodes["user"].data["h"], F.tensor([1, 1, 1], dtype=idtype)
      )
      assert F.array_equal(
          g.nodes["game"].data["h"], F.tensor([2, 2], dtype=idtype)
      )
      assert F.array_equal(
          g.nodes["developer"].data["h"], F.tensor([3, 3], dtype=idtype)
      )
  
      # batched graph
      ctx = F.ctx()
      g1 = dgl.graph(
          ([0, 1], [1, 2]), num_nodes=5, idtype=idtype, device=ctx
      )
      g2 = dgl.graph(([], []), idtype=idtype, device=ctx)
      g3 = dgl.graph(([2, 3, 4], [3, 2, 1]), idtype=idtype, device=ctx)
      bg = dgl.batch([g1, g2, g3])
      bg_r = dgl.remove_edges(bg, 2)
      assert bg.batch_size == bg_r.batch_size
      assert F.array_equal(bg.batch_num_nodes(), bg_r.batch_num_nodes())
      assert F.array_equal(
          bg_r.batch_num_edges(), F.tensor([2, 0, 2], dtype=idtype)
      )
  
      bg_r = dgl.remove_edges(bg, [0, 2])
      assert bg.batch_size == bg_r.batch_size
      assert F.array_equal(bg.batch_num_nodes(), bg_r.batch_num_nodes())
      assert F.array_equal(
          bg_r.batch_num_edges(), F.tensor([1, 0, 2], dtype=idtype)
      )
  
      bg_r = dgl.remove_edges(bg, F.tensor([0, 2], dtype=idtype))
      assert bg.batch_size == bg_r.batch_size
      assert F.array_equal(bg.batch_num_nodes(), bg_r.batch_num_nodes())
      assert F.array_equal(
          bg_r.batch_num_edges(), F.tensor([1, 0, 2], dtype=idtype)
      )
  
      # batched heterogeneous graph
      g1 = dgl.heterograph(
          {
              ("user", "follows", "user"): ([0, 1], [1, 2]),
              ("user", "plays", "game"): ([1, 3], [0, 1]),
          },
          num_nodes_dict={"user": 4, "game": 3},
          idtype=idtype,
          device=ctx,
      )
      g2 = dgl.heterograph(
          {
              ("user", "follows", "user"): ([0, 2], [3, 4]),
              ("user", "plays", "game"): ([], []),
          },
          num_nodes_dict={"user": 6, "game": 2},
          idtype=idtype,
          device=ctx,
      )
      g3 = dgl.heterograph(
          {
              ("user", "follows", "user"): ([], []),
              ("user", "plays", "game"): ([1, 2], [1, 2]),
          },
          idtype=idtype,
          device=ctx,
      )
      bg = dgl.batch([g1, g2, g3])
      bg_r = dgl.remove_edges(bg, 1, etype="follows")
      assert bg.batch_size == bg_r.batch_size
      ntypes = bg.ntypes
      for nty in ntypes:
          assert F.array_equal(
              bg.batch_num_nodes(nty), bg_r.batch_num_nodes(nty)
          )
      assert F.array_equal(
          bg_r.batch_num_edges("follows"),
          F.tensor([1, 2, 0], dtype=idtype),
      )
      assert F.array_equal(
          bg_r.batch_num_edges("plays"), bg.batch_num_edges("plays")
      )
  
      bg_r = dgl.remove_edges(bg, 2, etype="plays")
      assert bg.batch_size == bg_r.batch_size
      for nty in ntypes:
          assert F.array_equal(
              bg.batch_num_nodes(nty), bg_r.batch_num_nodes(nty)
          )
      assert F.array_equal(
          bg.batch_num_edges("follows"), bg_r.batch_num_edges("follows")
      )
      assert F.array_equal(
          bg_r.batch_num_edges("plays"),
          F.tensor([2, 0, 1], dtype=idtype),
      )
  
      bg_r = dgl.remove_edges(bg, [0, 1, 3], etype="follows")
      assert bg.batch_size == bg_r.batch_size
      for nty in ntypes:
          assert F.array_equal(
              bg.batch_num_nodes(nty), bg_r.batch_num_nodes(nty)
          )
      assert F.array_equal(
          bg_r.batch_num_edges("follows"),
          F.tensor([0, 1, 0], dtype=idtype),
      )
      assert F.array_equal(
          bg.batch_num_edges("plays"), bg_r.batch_num_edges("plays")
      )
  
      bg_r = dgl.remove_edges(bg, [1, 2], etype="plays")
      assert bg.batch_size == bg_r.batch_size
      for nty in ntypes:
          assert F.array_equal(
              bg.batch_num_nodes(nty), bg_r.batch_num_nodes(nty)
          )
      assert F.array_equal(
          bg.batch_num_edges("follows"), bg_r.batch_num_edges("follows")
      )
      assert F.array_equal(
          bg_r.batch_num_edges("plays"),
          F.tensor([1, 0, 1], dtype=idtype),
      )
  
      bg_r = dgl.remove_edges(
          bg, F.tensor([0, 1, 3], dtype=idtype), etype="follows"
      )
      assert bg.batch_size == bg_r.batch_size
      for nty in ntypes:
          assert F.array_equal(
              bg.batch_num_nodes(nty), bg_r.batch_num_nodes(nty)
          )
      assert F.array_equal(
          bg_r.batch_num_edges("follows"),
          F.tensor([0, 1, 0], dtype=idtype),
      )
      assert F.array_equal(
          bg.batch_num_edges("plays"), bg_r.batch_num_edges("plays")
      )
  
      bg_r = dgl.remove_edges(
          bg, F.tensor([1, 2], dtype=idtype), etype="plays"
      )
      assert bg.batch_size == bg_r.batch_size
      for nty in ntypes:
          assert F.array_equal(
              bg.batch_num_nodes(nty), bg_r.batch_num_nodes(nty)
          )
      assert F.array_equal(
          bg.batch_num_edges("follows"), bg_r.batch_num_edges("follows")
      )
      assert F.array_equal(
          bg_r.batch_num_edges("plays"),
          F.tensor([1, 0, 1], dtype=idtype),
      )
  
imports: import math
  import os
  import unittest
  import backend
  import dgl
  import dgl.function
  import dgl.partition
  import networkx
  import numpy
  import pytest
  from scipy import sparse
  from utils import parametrize_idtype
  from utils.graph_cases import get_cases
label_desc: Use image node_id 27 for calling a global function with example usage: test_remove_edges(idtype) without return types