code: def write_spmatrix_to_sparse_tensor(file, array, labels=None):
      """Writes a scipy sparse matrix to a sparse tensor
  
      Args:
          file:
          array:
          labels:
      """
      try:
          import scipy
      except ImportError as e:
          logging.warning(
              "scipy failed to import. Sparse matrix functions will be impaired or broken."
          )
          # Any subsequent attempt to use scipy will raise the ImportError
          scipy = DeferredError(e)
  
      if not scipy.sparse.issparse(array):
          raise TypeError("Array must be sparse")
  
      # Validate shape of array and labels, resolve array and label types
      if not len(array.shape) == 2:
          raise ValueError("Array must be a Matrix")
      if labels is not None:
          if not len(labels.shape) == 1:
              raise ValueError("Labels must be a Vector")
          if labels.shape[0] not in array.shape:
              raise ValueError(
                  "Label shape {} not compatible with array shape {}".format(
                      labels.shape, array.shape
                  )
              )
          resolved_label_type = _resolve_type(labels.dtype)
      resolved_type = _resolve_type(array.dtype)
  
      csr_array = array.tocsr()
      n_rows, n_cols = csr_array.shape
  
      record = Record()
      for row_idx in range(n_rows):
          record.Clear()
          row = csr_array.getrow(row_idx)
          # Write values
          _write_feature_tensor(resolved_type, record, row.data)
          # Write keys
          _write_keys_tensor(
              resolved_type, record, row.indices.astype(np.uint64)
          )
  
          # Write labels
          if labels is not None:
              _write_label_tensor(
                  resolved_label_type, record, labels[row_idx]
              )
  
          # Write shape
          _write_shape(resolved_type, record, n_cols)
  
          _write_recordio(file, record.SerializeToString())
  
imports: from __future__ import absolute_import
  import io
  import logging
  import struct
  import sys
  import numpy
  from sagemaker.amazon.record_pb2 import Record
  from sagemaker.deprecations import deprecated_class
  from sagemaker.deserializers import SimpleBaseDeserializer
  from sagemaker.serializers import SimpleBaseSerializer
  from sagemaker.utils import DeferredError
label_desc: Use image node_id 6 for calling a global function with example usage: write_spmatrix_to_sparse_tensor(file, array, labels) without return types