code: def test_sparse_coo_tensor_scipy_roundtrip(dtype_str, arrow_type):
      dtype = np.dtype(dtype_str)
      data = np.array([1, 2, 3, 4, 5, 6]).astype(dtype)
      row = np.array([0, 0, 2, 3, 1, 3])
      col = np.array([0, 2, 0, 4, 5, 5])
      shape = (4, 6)
      dim_names = ("x", "y")
  
      # non-canonical sparse coo matrix
      scipy_matrix = coo_matrix((data, (row, col)), shape=shape)
      sparse_tensor = pa.SparseCOOTensor.from_scipy(
          scipy_matrix, dim_names=dim_names
      )
      out_scipy_matrix = sparse_tensor.to_scipy()
  
      assert not scipy_matrix.has_canonical_format
      assert not sparse_tensor.has_canonical_format
      assert not out_scipy_matrix.has_canonical_format
      assert sparse_tensor.type == arrow_type
      assert sparse_tensor.dim_names == dim_names
      assert scipy_matrix.dtype == out_scipy_matrix.dtype
      assert np.array_equal(scipy_matrix.data, out_scipy_matrix.data)
      assert np.array_equal(scipy_matrix.row, out_scipy_matrix.row)
      assert np.array_equal(scipy_matrix.col, out_scipy_matrix.col)
  
      if dtype_str == "f2":
          dense_array = (
              scipy_matrix.astype(np.float32)
              .toarray()
              .astype(np.float16)
          )
      else:
          dense_array = scipy_matrix.toarray()
      assert np.array_equal(
          dense_array, sparse_tensor.to_tensor().to_numpy()
      )
  
      # canonical sparse coo matrix
      scipy_matrix.sum_duplicates()
      sparse_tensor = pa.SparseCOOTensor.from_scipy(
          scipy_matrix, dim_names=dim_names
      )
      out_scipy_matrix = sparse_tensor.to_scipy()
  
      assert scipy_matrix.has_canonical_format
      assert sparse_tensor.has_canonical_format
      assert out_scipy_matrix.has_canonical_format
  
imports: import pytest
  import sys
  import weakref
  import numpy
  import pyarrow
label_desc: Use image node_id 14 for calling a global function with example usage: test_sparse_coo_tensor_scipy_roundtrip(dtype_str, arrow_type) without return types