input: 
  from typing import List, Tuple
  
  
  def decode_libsvm(input: tf.Tensor, num_features: int, dtype: tf.DType = tf.float32, label_dtype: tf.DType = tf.int64, name: str = None) -> Tuple[tf.Tensor, tf.Tensor, tf.Tensor, tf.Tensor]:
      """Convert LibSVM input to tensors. The output consists of a label and a feature tensor.
      The shape of the label tensor is the same as input and the shape of the feature tensor is [input_shape, num_features].
  
      >>> decode_libsvm(tf.constant(["1 1:1.0 2:2.0", "2 1:1.0 3:3.0"]), 3)
      (<tf.Tensor: shape=(2,), dtype=int64, numpy=array([1, 2])>, 
       <tf.Tensor: shape=(4, 2), dtype=int64, numpy=
          array([[0, 1],
                 [0, 2],
                 [1, 1],
                 [1, 3]])>, 
       <tf.Tensor: shape=(4,), dtype=float32, numpy=array([1., 2., 1., 3.], dtype=float32)>, 
       <tf.Tensor: shape=(2,), dtype=int64, numpy=array([2, 2])>)
      """
  
output:     
      def parse_line(line):
          parts = tf.strings.split(line, " ")
          label = tf.strings.to_number(parts[0], out_type=label_dtype)
          indices = []
          values = []
          for part in parts[1:]:
              idx, val = tf.strings.split(part, ":")
              indices.append(tf.strings.to_number(idx, out_type=tf.int64))
              values.append(tf.strings.to_number(val, out_type=dtype))
          return label, indices, values
  
      labels, indices_list, values_list = tf.map_fn(
          parse_line, input, dtype=(label_dtype, tf.int64, dtype),
          infer_shape=False
      )
  
      indices = tf.concat(indices_list, axis=0)
      values = tf.concat(values_list, axis=0)
      row_lengths = tf.map_fn(lambda x: tf.size(x[1]), (labels, indices_list), dtype=tf.int64)
  
      dense_shape = tf.stack([tf.shape(input)[0], num_features])
      sparse_indices = tf.RaggedTensor.from_row_lengths(indices, row_lengths).flat_values
      sparse_values = tf.RaggedTensor.from_row_lengths(values, row_lengths).flat_values
  
      return labels, sparse_indices, sparse_values, row_lengths
  