code: def remove_self_loop(g, etype=None):
      r"""Remove self-loops for each node in the graph and return a new graph.
  
      Parameters
      ----------
      g : DGLGraph
          The graph.
      etype : str or (str, str, str), optional
          The type names of the edges. The allowed type name formats are:
  
          * ``(str, str, str)`` for source node type, edge type and destination node type.
          * or one ``str`` edge type name if the name can uniquely identify a
            triplet format in the graph.
  
          Can be omitted if the graph has only one type of edges.
  
      Notes
      -----
      If a node has multiple self-loops, remove them all. Do nothing for nodes without
      self-loops.
  
      This function preserves the batch information.
  
      Examples
      ---------
  
      >>> import dgl
      >>> import torch
  
      **Homogeneous Graphs**
  
      >>> g = dgl.graph((torch.tensor([0, 0, 0, 1]), torch.tensor([1, 0, 0, 2])))
      >>> g.edata['he'] = torch.arange(4).float().reshape(-1, 1)
      >>> g = dgl.remove_self_loop(g)
      >>> g
      Graph(num_nodes=3, num_edges=2,
          edata_schemes={'he': Scheme(shape=(2,), dtype=torch.float32)})
      >>> g.edata['he']
      tensor([[0.],[3.]])
  
      **Heterogeneous Graphs**
  
      >>> g = dgl.heterograph({
      ...     ('user', 'follows', 'user'): (torch.tensor([0, 1, 1, 1, 2]),
      ...                                   torch.tensor([0, 0, 1, 1, 1])),
      ...     ('user', 'plays', 'game'): (torch.tensor([0, 1]),
      ...                                 torch.tensor([0, 1]))
      ...     })
      >>> g = dgl.remove_self_loop(g, etype='follows')
      >>> g.num_nodes('user')
      3
      >>> g.num_nodes('game')
      2
      >>> g.num_edges('follows')
      2
      >>> g.num_edges('plays')
      2
  
      See Also
      --------
      add_self_loop
      """
      etype = g.to_canonical_etype(etype)
      if etype[0] != etype[2]:
          raise DGLError(
              "remove_self_loop does not support unidirectional bipartite graphs: {}."
              "Please make sure the types of head node and tail node are identical."
              "".format(etype)
          )
      u, v = g.edges(form="uv", order="eid", etype=etype)
      self_loop_eids = F.tensor(F.nonzero_1d(u == v), dtype=F.dtype(u))
      new_g = remove_edges(g, self_loop_eids, etype=etype)
      return new_g
  
imports: import copy
  from collections.abc import Iterable, Mapping
  import numpy
  import scipy.sparse
  import scipy.sparse.linalg
  from ..utils import version
  from ..None import backend, batch, convert, function, ndarray, subgraph, utils
  from .._ffi.function import _init_api
  from ..base import dgl_warning, DGLError, EID, NID
  from ..frame import Frame
  from ..heterograph import DGLGraph
  from ..heterograph_index import create_heterograph_from_relations, create_metagraph_index
  from ..partition import metis_partition, metis_partition_assignment, partition_graph_with_halo
  from ..sampling.neighbor import sample_neighbors
label_desc: Use image node_id 22 for calling a global function with example usage: remove_self_loop(g, etype) and returns: new_g