code: def test_to_sparse_csr(dtype, device):
      kwargs = dict(dtype=dtype, device=device)
      with pytest.raises(ValueError, match="not sorted"):
          EdgeIndex(
              [[0, 1, 1, 2], [1, 0, 2, 1]], **kwargs
          ).to_sparse_csr()
  
      adj = EdgeIndex(
          [[0, 1, 1, 2], [1, 0, 2, 1]], sort_order="row", **kwargs
      )
      if torch_geometric.typing.WITH_PT20:
          out = adj.to_sparse(layout=torch.sparse_csr)
      else:
          out = adj.to_sparse_csr()
      assert isinstance(out, Tensor)
      assert out.dtype == torch.float
      assert out.device == device
      assert out.layout == torch.sparse_csr
      assert out.size() == (3, 3)
      assert adj._indptr.equal(out.crow_indices())
      assert adj[1].equal(out.col_indices())
  
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 21 for calling a global function with example usage: test_to_sparse_csr(dtype, device) without return types