code: def sparse_config_generator():
      np.random.seed(1999)
  
      for nonzero_data_dtype in [np.float32]:  # [np.uint8, np.int8]:
          # float16 already covered under backends parameterization
          # Not possible to write 8-bit tests since no other op consumes uint8/int8 tensors
          for output_rank in range(1, 6):
              output_shape = np.random.randint(
                  low=2, high=5, size=output_rank
              )
              output_size = np.prod(output_shape)
              nBytes = np.ceil(output_size / 8).astype(np.int32)
  
              mask = np.random.randint(
                  low=255, size=nBytes, dtype=np.uint8
              )
              bitarray = np.unpackbits(mask, bitorder="little")
              while any(
                  bitarray[i] != 0
                  for i in range(output_size, len(bitarray))
              ):
                  mask = np.random.randint(
                      low=255, size=nBytes, dtype=np.uint8
                  )
                  bitarray = np.unpackbits(mask, bitorder="little")
  
              nonzero_size = np.sum(
                  np.where(
                      np.unpackbits(mask, bitorder="little") != 0, 1, 0
                  )
              )
  
              if nonzero_data_dtype == np.uint8:
                  nonzero_data = np.random.randint(
                      low=255, size=nonzero_size, dtype=np.uint8
                  )
              elif nonzero_data_dtype == np.int8:
                  nonzero_data = np.random.randint(
                      low=-128,
                      high=127,
                      size=nonzero_size,
                      dtype=np.int8,
                  )
              else:
                  nonzero_data = np.random.rand(nonzero_size).astype(
                      nonzero_data_dtype
                  )
  
              params = {
                  "nonzero_data": nonzero_data,
                  "shape": output_shape,
                  "mask": mask,
              }
              yield params
  
imports: import itertools
  import numpy
  import pytest
  from coremltools.converters.mil import testing_reqs
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import types
  from coremltools.converters.mil.mil.ops.defs.iOS16 import constexpr_ops
  from coremltools.converters.mil.mil.ops.tests.iOS16 import backends
  from coremltools.converters.mil.mil.ops.tests.testing_utils import run_compare_builder
  from coremltools.converters.mil.testing_utils import get_op_types_in_program, ssa_fn
label_desc: Use image node_id 3 for calling the TestConstexprSparseToDense obj's underlying member method code with example usage: obj.sparse_config_generator() without return types