code: def segregate_self_loops(  # noqa: F811
      edge_index: Tensor,
      edge_attr: Optional[Tensor] = None,
  ) -> Tuple[Tensor, Optional[Tensor], Tensor, Optional[Tensor]]:
      r"""Segregates self-loops from the graph.
  
      Args:
          edge_index (LongTensor): The edge indices.
          edge_attr (Tensor, optional): Edge weights or multi-dimensional
              edge features. (default: :obj:`None`)
  
      :rtype: (:class:`LongTensor`, :class:`Tensor`, :class:`LongTensor`,
          :class:`Tensor`)
  
      Example:
          >>> edge_index = torch.tensor([[0, 0, 1],
          ...                            [0, 1, 0]])
          >>> (edge_index, edge_attr,
          ...  loop_edge_index,
          ...  loop_edge_attr) = segregate_self_loops(edge_index)
          >>>  loop_edge_index
          tensor([[0],
                  [0]])
      """
      mask = edge_index[0] != edge_index[1]
      inv_mask = ~mask
  
      is_undirected = False
      if not torch.jit.is_scripting() and isinstance(
          edge_index, EdgeIndex
      ):
          is_undirected = edge_index.is_undirected
  
      loop_edge_index = edge_index[:, inv_mask]
      loop_edge_attr = (
          None if edge_attr is None else edge_attr[inv_mask]
      )
      edge_index = edge_index[:, mask]
      edge_attr = None if edge_attr is None else edge_attr[mask]
  
      if not torch.jit.is_scripting() and isinstance(
          edge_index, EdgeIndex
      ):
          assert isinstance(loop_edge_index, EdgeIndex)
          edge_index._is_undirected = is_undirected
          loop_edge_index._is_undirected = is_undirected
  
      return edge_index, edge_attr, loop_edge_index, loop_edge_attr
  
imports: import typing
  from typing import Optional, Tuple, Union
  import torch
  from torch import Tensor
  from torch_geometric import EdgeIndex
  from torch_geometric.utils import scatter
  from torch_geometric.utils.num_nodes import maybe_num_nodes
  from torch_geometric.utils.sparse import is_torch_sparse_tensor, to_edge_index, to_torch_coo_tensor, to_torch_csr_tensor
label_desc: Use image node_id 9 for calling a global function with example usage: segregate_self_loops(edge_index, edge_attr) and returns: edge_index,  edge_attr,  loop_edge_index,  loop_edge_attr