code: def create_sparse_weight(weight, target_sparsity):
      shape = list(weight.shape)
      size = np.prod(shape)
      weight = 100 * np.random.rand(size)
      num_of_zeros = int(size * target_sparsity)
      weight[:num_of_zeros] = 0
      return np.reshape(weight, shape).astype(np.float32)
  
imports: import itertools
  import numpy
  import pytest
  import torch
  import coremltools
  import coremltools.optimize
  from coremltools._deps import _HAS_SKLEARN
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import types
  from coremltools.converters.mil.testing_utils import get_op_types_in_program
  from coremltools.optimize.coreml._post_training_quantization import CoreMLWeightMetaData
  from coremltools.test.ml_program.test_compression import get_test_model_and_data
label_desc: Use image node_id 7 for calling a global function with example usage: create_sparse_weight(weight, target_sparsity) and returns: np