code: def test_diag_conversions(shape):
      n_rows, n_cols = shape
      nnz = min(shape)
      ctx = F.ctx()
      val = torch.randn(nnz).to(ctx)
      D = diag(val, shape)
      row, col = D.coo()
      assert torch.allclose(row, torch.arange(nnz).to(ctx))
      assert torch.allclose(col, torch.arange(nnz).to(ctx))
  
      indptr, indices, _ = D.csr()
      exp_indptr = list(range(0, nnz + 1)) + [nnz] * (n_rows - nnz)
      assert torch.allclose(indptr, torch.tensor(exp_indptr).to(ctx))
      assert torch.allclose(indices, torch.arange(nnz).to(ctx))
  
      indptr, indices, _ = D.csc()
      exp_indptr = list(range(0, nnz + 1)) + [nnz] * (n_cols - nnz)
      assert torch.allclose(indptr, torch.tensor(exp_indptr).to(ctx))
      assert torch.allclose(indices, torch.arange(nnz).to(ctx))
  
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 13 for calling a global function with example usage: test_diag_conversions(shape) without return types