code: def test_add(dtype, device, is_undirected):
      kwargs = dict(
          dtype=dtype, device=device, is_undirected=is_undirected
      )
      adj = EdgeIndex(
          [[0, 1, 1, 2], [1, 0, 2, 1]], sparse_size=(3, 3), **kwargs
      )
  
      out = torch.add(adj, 2, alpha=2)
      assert isinstance(out, EdgeIndex)
      assert out.equal(
          tensor([[4, 5, 5, 6], [5, 4, 6, 5]], device=device)
      )
      assert out.is_undirected == is_undirected
      assert out.sparse_size() == (7, 7)
  
      out = adj + torch.tensor([2], dtype=dtype, device=device)
      assert isinstance(out, EdgeIndex)
      assert out.equal(
          tensor([[2, 3, 3, 4], [3, 2, 4, 3]], device=device)
      )
      assert out.is_undirected == is_undirected
      assert out.sparse_size() == (5, 5)
  
      out = adj + torch.tensor([[2], [1]], dtype=dtype, device=device)
      assert isinstance(out, EdgeIndex)
      assert out.equal(
          tensor([[2, 3, 3, 4], [2, 1, 3, 2]], device=device)
      )
      assert not out.is_undirected
      assert out.sparse_size() == (5, 4)
  
      out = adj + torch.tensor([[2], [2]], dtype=dtype, device=device)
      assert isinstance(out, EdgeIndex)
      assert out.equal(
          tensor([[2, 3, 3, 4], [3, 2, 4, 3]], device=device)
      )
      assert out.is_undirected == is_undirected
      assert out.sparse_size() == (5, 5)
  
      out = adj.add(adj)
      assert isinstance(out, EdgeIndex)
      assert out.equal(
          tensor([[0, 2, 2, 4], [2, 0, 4, 2]], device=device)
      )
      assert not out.is_undirected
      assert out.sparse_size() == (6, 6)
  
      adj += 2
      assert isinstance(adj, EdgeIndex)
      assert adj.equal(
          tensor([[2, 3, 3, 4], [3, 2, 4, 3]], device=device)
      )
      assert adj.is_undirected == is_undirected
      assert adj.sparse_size() == (5, 5)
  
imports: import os.path
  import warnings
  from typing import List, Optional
  import pytest
  import torch
  from torch import Tensor, tensor
  import torch_geometric
  from torch_geometric import EdgeIndex
  from torch_geometric.edge_index import SUPPORTED_DTYPES, ReduceType, SortReturnType, _scatter_spmm, _torch_sparse_spmm, _TorchSPMM, set_tuple_item
  from torch_geometric.profile import benchmark
  from torch_geometric.testing import onlyCUDA, onlyLinux, withCUDA, withoutExtensions, withPackage
  from torch_geometric.typing import SparseTensor
  from torch_geometric.utils import scatter
label_desc: Use image node_id 24 for calling a global function with example usage: test_add(dtype, device, is_undirected) without return types