code: def _ragged_feature_spec_from_batched_tensor(
      name: str, tensor: tf.RaggedTensor
  ) -> Union[tf.io.VarLenFeature, tf.io.RaggedFeature]:
      """Infer `tf.io.RaggedFeature` from a batched `tf.RaggedTensor`."""
      partitions = []
      row_lengths_partition_idx = 1
      # Ignore batch dimension.
      for dim in tensor.values.shape[1:]:
          if dim or dim == 0:
              partitions.append(
                  tf.io.RaggedFeature.UniformRowLength(  # pytype: disable=attribute-error
                      length=dim
                  )
              )
          else:
              partitions.append(
                  tf.io.RaggedFeature.RowLengths(  # pytype: disable=attribute-error
                      key="{}$row_lengths_{}".format(
                          name, row_lengths_partition_idx
                      )
                  )
              )
              row_lengths_partition_idx += 1
  
      return tf.io.RaggedFeature(
          dtype=tensor.dtype,
          value_key="{}$ragged_values".format(name),
          partitions=partitions,
          row_splits_dtype=tensor.row_splits.dtype,
      )
  
imports: import collections
  import itertools
  from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Tuple, Union
  from absl import logging
  import tensorflow
  from tensorflow_transform import common
  from tensorflow_transform import common_types
  from tensorflow_transform import graph_context
  from tensorflow_transform import tf2_utils
  from tensorflow_transform import tf_utils
  from tensorflow_transform.saved import saved_transform_io_v2
  from tensorflow_transform.tf_metadata import schema_utils
  from tfx_bsl.tfxio import tensor_representation_util
  from google.protobuf import any_pb2
  from tensorflow.python.eager import function
  from tensorflow.python.framework import ops
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 1 for calling a global function with example usage: _ragged_feature_spec_from_batched_tensor(name, tensor) and returns: tf