code: def make_sparse_array(rng, shape, dtype, nnz=0.2):
      mat = rng(shape, dtype)
      size = math.prod(shape)
      if 0 < nnz < 1:
          nnz = nnz * size
      nnz = int(nnz)
      if nnz == 0:
          mat = np.zeros_like(mat)
      elif nnz < size:
          # TODO(jakevdp): do we care about duplicates?
          cutoff = np.sort(mat.ravel())[nnz]
          mat[mat >= cutoff] = 0
      nz = mat != 0
      data = jnp.array(mat[nz])
      indices = jnp.array(np.where(nz)).T
      aval = AbstractSparseArray(
          shape, data.dtype, indices.dtype, len(indices)
      )
      return SparseArray(aval, data, indices)
  
imports: from absl.testing import absltest
  import math
  import unittest
  import numpy
  import jax.numpy
  from jax import jit, lax, make_jaxpr
  from jax import config
  from jax.interpreters import mlir
  from jax.interpreters import xla
  from jax._src import core
  from jax._src import dtypes
  from jax._src import test_util
  from jax._src import xla_bridge
  from jax._src.lib.mlir import ir
  from jax._src.lib import xla_client
label_desc: Use image node_id 15 for calling a global function with example usage: make_sparse_array(rng, shape, dtype, nnz) and returns: SparseArray