input: from typing import List, Tuple
  
  def decode_libsvm(input: Tuple[str], 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]`.
  
      >>> import tensorflow as tf
      >>> decode_libsvm(['1 1:0.1 2:0.2', '3 1:0.3 2:0.4'], 2, dtype=tf.float32, label_dtype=tf.int64)
      (<tf.Tensor: shape=(2,), dtype=int64, numpy=array([1, 3], dtype=int64)>, <tf.Tensor: shape=(4, 2), dtype=int64, numpy=array([[0, 1], [0, 2], [1, 1], [1, 2]], dtype=int64)>, <tf.Tensor: shape=(4,), dtype=float32, numpy=array([0.1, 0.2, 0.3, 0.4], dtype=float32)>, <tf.Tensor: shape=(2,), dtype=int64, numpy=array([2, 2], dtype=int64)>)
      >>> decode_libsvm(['1 1:0.5', '2 2:0.6'], 2, dtype=tf.float32, label_dtype=tf.int64)
      (<tf.Tensor: shape=(2,), dtype=int64, numpy=array([1, 2], dtype=int64)>, <tf.Tensor: shape=(2, 2), dtype=int64, numpy=array([[0, 1], [1, 2]], dtype=int64)>, <tf.Tensor: shape=(2,), dtype=float32, numpy=array([0.5, 0.6], dtype=float32)>, <tf.Tensor: shape=(2,), dtype=int64, numpy=array([1, 1], dtype=int64)>)
      """
  
output:     
      labels = []
      indices = []
      values = []
      dense_shape = [len(input), num_features]
      for i, line in enumerate(input):
          parts = line.split()
          labels.append(int(parts[0]))
          for part in parts[1:]:
              idx, val = part.split(':')
              indices.append([i, int(idx)-1])
              values.append(float(val))
      labels_tensor = tf.constant(labels, dtype=label_dtype)
      indices_tensor = tf.constant(indices, dtype=tf.int64)
      values_tensor = tf.constant(values, dtype=dtype)
      dense_shape_tensor = tf.constant(dense_shape, dtype=tf.int64)
      return labels_tensor, indices_tensor, values_tensor, dense_shape_tensor
  