code: def _ragged_tensor_representation_from_feature_spec(
      spec: tf.io.RaggedFeature,
      name: str,
      domains: Dict[str, common_types.DomainType],
  ) -> Tuple[
      schema_pb2.Feature,
      List[schema_pb2.Feature],
      schema_pb2.TensorRepresentation,
  ]:
      """Returns representation of a RaggedTensor from a feature spec.
  
      Args:
        spec: A tf.io.RaggedFeature feature spec.
        name: Feature name.
        domains: A dict whose keys are feature names and values are one of
          schema_pb2.IntDomain, schema_pb2.StringDomain or schema_pb2.FloatDomain.
  
      Returns:
        A tuple (value_feature, partitions_features, ragged_tensor_rep),
          where value_feature represents RaggedTensor values, partitions_features
          represent row lengths partitions and ragged_tensor_rep - ragged
          TensorRepresentation.
  
      Raises:
        ValueError: If the feature spec contains partition types different from
          UniformRowLength and RowLengths.
      """
      value_feature = schema_pb2.Feature(name=spec.value_key or name)
      _set_type(name, value_feature, spec.dtype)
      _set_domain(name, value_feature, domains.get(name))
  
      ragged_tensor = schema_pb2.TensorRepresentation.RaggedTensor(
          feature_path=path_pb2.Path(step=[spec.value_key or name])
      )
  
      partitions_features = []
      for partition in spec.partitions:
          if isinstance(
              partition, tf.io.RaggedFeature.UniformRowLength
          ):  # pytype: disable=attribute-error
              ragged_tensor.partition.append(
                  schema_pb2.TensorRepresentation.RaggedTensor.Partition(
                      uniform_row_length=partition.length
                  )
              )
          elif isinstance(
              partition, tf.io.RaggedFeature.RowLengths
          ):  # pytype: disable=attribute-error
              ragged_tensor.partition.append(
                  schema_pb2.TensorRepresentation.RaggedTensor.Partition(
                      row_length=partition.key
                  )
              )
              partitions_features.append(
                  schema_pb2.Feature(
                      name=partition.key, type=schema_pb2.INT
                  )
              )
          else:
              raise ValueError(
                  "RaggedFeature can only be created with UniformRowLength and "
                  "RowLengths partitions."
              )
  
      return (
          value_feature,
          partitions_features,
          schema_pb2.TensorRepresentation(ragged_tensor=ragged_tensor),
      )
  
imports: import dataclasses
  import typing
  from typing import Dict, List, Mapping, Optional, Tuple, Union
  import tensorflow
  from tensorflow_transform import common_types
  from tensorflow_transform.tf_metadata import schema_utils_legacy
  from tfx_bsl.tfxio import tensor_representation_util
  from tensorflow_metadata.proto.v0 import path_pb2
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 2 for calling a global function with example usage: _ragged_tensor_representation_from_feature_spec(spec, name, domains) and returns: value_feature,  partitions_features,  schema_pb2