code: def test_sparse_float_write_spmatrix_to_sparse_tensor():
      n = 4
      array_data = [
          [1.0, 2.0],
          [10.0, 30.0],
          [100.0, 200.0, 300.0, 400.0],
          [1000.0, 2000.0, 3000.0],
      ]
      keys_data = [[0, 1], [1, 2], [0, 1, 2, 3], [0, 2, 3]]
  
      flatten_data = list(itertools.chain.from_iterable(array_data))
      y_indices = list(itertools.chain.from_iterable(keys_data))
      x_indices = [
          [i] * len(keys_data[i]) for i in range(len(keys_data))
      ]
      x_indices = list(itertools.chain.from_iterable(x_indices))
  
      array = coo_matrix(
          (flatten_data, (x_indices, y_indices)), dtype="float64"
      )
      with tempfile.TemporaryFile() as f:
          write_spmatrix_to_sparse_tensor(f, array)
          f.seek(0)
          for record_data, expected_data, expected_keys in zip(
              read_recordio(f), array_data, keys_data
          ):
              record = Record()
              record.ParseFromString(record_data)
              assert (
                  record.features["values"].float64_tensor.values
                  == expected_data
              )
              assert (
                  record.features["values"].float64_tensor.keys
                  == expected_keys
              )
              assert record.features["values"].float64_tensor.shape == [
                  n
              ]
  
imports: from __future__ import absolute_import
  import numpy
  import tempfile
  import pytest
  import itertools
  from scipy.sparse import coo_matrix
  from sagemaker.amazon.common import RecordDeserializer, write_numpy_to_dense_tensor, read_recordio, RecordSerializer, write_spmatrix_to_sparse_tensor
  from sagemaker.amazon.record_pb2 import Record
label_desc: Use image node_id 19 for calling a global function with example usage: test_sparse_float_write_spmatrix_to_sparse_tensor() without return types