input: from typing import List, Tuple
  import tensorflow as tf
  
  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]`.
  
      Args:
          input: A `Tensor` of type `string`. Each string is a record in the LibSVM.
          num_features: An `int` that is `>= 1`. The number of features.
          dtype: An optional `tf.DType` from: `tf.float32, tf.float64, tf.int32, tf.int64`. Defaults to `tf.float32`.
          label_dtype: An optional `tf.DType` from: `tf.float32, tf.float64, tf.int32, tf.int64`. Defaults to `tf.int64`.
          name: A name for the operation (optional).
  
      Returns:
          A tuple of `Tensor` objects (label, feature_indices, feature_values, feature_shape).
          label: A `Tensor` of type `label_dtype`. A tensor of the same shape as input.
          feature_indices: A `Tensor` of type `int64`. A 2-D int64 tensor of dense_shape [N, ndims].
          feature_values: A `Tensor` of type `dtype`. A 1-D tensor of any type and dense_shape [N].
          feature_shape: A `Tensor` of type `int64`. A 1-D int64 tensor of dense_shape [ndims].
  
      >>> decode_libsvm(tf.constant(["1 2:3 4:5"]), 5, tf.int32, tf.int32)
      (<tf.Tensor: shape=(1,), dtype=int32, numpy=array([1], dtype=int32)>, <tf.Tensor: shape=(2, 2), dtype=int64, numpy=
      array([[0, 1],
             [0, 3]])>, <tf.Tensor: shape=(2,), dtype=int32, numpy=array([3, 5], dtype=int32)>, <tf.Tensor: shape=(2,), dtype=int64, numpy=array([1, 5])>)
      """
output:     with tf.name_scope(name, "decode_libsvm", [input]) as name:
          # Split the input string by spaces
          parts = tf.strings.split(input, sep=' ')
          
          # Extract the label (first element)
          label = tf.strings.to_number(parts.values[0], out_type=label_dtype)
          label = tf.expand_dims(label, axis=-1)
          
          # Extract the feature parts (excluding the first element)
          feature_parts = parts.values[1:]
          
          # Split the feature parts by colon to get indices and values
          feature_split = tf.strings.split(feature_parts, sep=':')
          
          # Extract feature indices and values
          feature_indices = tf.strings.to_number(feature_split.values[:, 0], out_type=tf.int64)
          feature_values = tf.strings.to_number(feature_split.values[:, 1], out_type=dtype)
          
          # Create the feature shape tensor
          feature_shape = tf.constant([tf.shape(input)[0], num_features], dtype=tf.int64)
          
          # Reshape feature indices to 2D tensor
          feature_indices = tf.stack([tf.range(tf.shape(feature_indices)[0], dtype=tf.int64), feature_indices], axis=1)
          
          return label, feature_indices, feature_values, feature_shape