def pop_ragged_source_columns(
    name: str, tensor_representation: schema_pb2.TensorRepresentation,
    feature_by_name: Dict[str, schema_pb2.Feature]) -> schema_pb2.Feature:
  """Removes source columns of a ragged tensor from the given features dict.

  Args:
    name: Name of the ragged tensor.
    tensor_representation: Ragged TensorRepresentation.
    feature_by_name: Dict of features that contains source columns of the ragged
      TensorRepresentation.

  Returns:
    Value feature of the ragged tensor.

  Raises:
    ValueError: If any of the source columns are missing in the features dict.
  """
  source_columns = (
      tensor_representation_util.GetSourceColumnsFromTensorRepresentation(
          tensor_representation))
  missing_column_error_format = (
      'Ragged feature "{}" referred to value feature "{}" which did not exist '
      'in the schema or was referred to as an index or value multiple times.')

  assert source_columns
  assert len(source_columns[0].steps()) == 1, (name, source_columns[0].steps())
  try:
    value_feature = feature_by_name.pop(source_columns[0].steps()[0])
  except KeyError:
    raise ValueError(
        missing_column_error_format.format(name, source_columns[0].steps()[0]))
  for column_path in source_columns[1:]:
    assert len(column_path.steps()) == 1, (name, column_path.steps())
    try:
      row_length_feature = feature_by_name.pop(column_path.steps()[0])
    except KeyError:
      raise ValueError(
          missing_column_error_format.format(name,
                                             column_path.steps()[0]))
    if row_length_feature.type != schema_pb2.FeatureType.INT:
      raise ValueError(
          'Row length feature "{}" is not an integer feature.'.format(
              row_length_feature.name))
  return value_feature
Removes source columns of a ragged tensor from the given features dict.

  Args:
    name: Name of the ragged tensor.
    tensor_representation: Ragged TensorRepresentation.
    feature_by_name: Dict of features that contains source columns of the ragged
      TensorRepresentation.

  Returns:
    Value feature of the ragged tensor.

  Raises:
    ValueError: If any of the source columns are missing in the features dict.
  
tensorflow_transform/tf_metadata/schema_utils.py