code: def test_csr_to_csc(dense_dim, indptr, indices, shape):
      val_shape = (len(indices),)
      if dense_dim is not None:
          val_shape += (dense_dim,)
      ctx = F.ctx()
      val = torch.randn(val_shape).to(ctx)
      indptr = torch.tensor(indptr).to(ctx)
      indices = torch.tensor(indices).to(ctx)
      mat = from_csr(indptr, indices, val, shape)
      mat_indptr, mat_indices, value_indices = mat.csc()
      mat_val = (
          mat.val if value_indices is None else mat.val[value_indices]
      )
  
      if shape is None:
          shape = (indptr.numel() - 1, torch.max(indices).item() + 1)
  
      row = (
          torch.arange(0, indptr.shape[0] - 1)
          .to(ctx)
          .repeat_interleave(torch.diff(indptr))
      )
  
      col = indices
      col, sort_index = col.sort(stable=True)
      row = row[sort_index]
      val = val[sort_index]
      indptr = torch.zeros(shape[1] + 1).to(ctx)
      indptr = _scatter_add(indptr, col + 1)
      indptr = torch.cumsum(indptr, 0).long()
      indices = row
  
      assert mat.shape == shape
      assert mat.nnz == row.numel()
      assert mat.device == row.device
      assert mat.dtype == val.dtype
      assert torch.allclose(mat_val, val)
      assert torch.allclose(mat_indptr, indptr)
      assert torch.allclose(mat_indices, indices)
  
imports: import unittest
  import warnings
  import backend
  import pytest
  import torch
  from dgl.sparse import diag, from_coo, from_csc, from_csr, from_torch_sparse, identity, to_torch_sparse_coo, to_torch_sparse_csc, to_torch_sparse_csr, val_like
  from .utils import rand_coo, rand_csc, rand_csr, rand_diag, sparse_matrix_to_dense
label_desc: Use image node_id 12 for calling a global function with example usage: test_csr_to_csc(dense_dim, indptr, indices, shape) without return types