code: def get_conllu_example(
      sentence, example_id, features
  ) -> Mapping[str, Union[str, Sequence[str]]]:
      """Processes a conllu-annotated sentence into an example to be serialized.
  
      Args:
        sentence: the annotated sentence parsed with the conllu library.
        example_id: the example_id of the example, which will be used if the `idx`
          feature is present but not defined in the annotated sentence.
        features: the features defined in the output example.
  
      Returns:
        An example to be serialized.
      """
      example = {}
  
      for feature in features:
          # Use the idx parsed from the data, example_id if not available.
          if feature == "idx":
              idx = sentence.metadata.get("sent_id", example_id)
              example["idx"] = idx
  
          # CoNNL-U format stores tokens using the `form` tag.
          elif feature == "tokens":
              example["tokens"] = [token["form"] for token in sentence]
  
          # CoNNL-U format stores lemmas using the `lemma` tag.
          elif feature == "lemmas":
              example["lemmas"] = [token["lemma"] for token in sentence]
  
          elif feature == "text":
              if "text" in sentence.metadata:
                  text = sentence.metadata["text"]
              else:
                  text = " ".join(example["tokens"])
              example["text"] = text
  
          # All other features are Sequences whose feature name corresponds to
          # the respective tag name in the annotations generated with the
          # conllu library.
          else:
              # UPOS are stored as ClassLabels and are therefore not converted
              # into strings.
              # Future features might follow the same principle, therefore we
              # check for list membership.
              if feature in ["upos"]:
                  example[feature] = [
                      token[feature] for token in sentence
                  ]
              else:
                  example[feature] = [
                      str(token[feature]) for token in sentence
                  ]
  
      return example
  
file_path: datasets/tensorflow_datasets/core/dataset_builders/conll/conllu_dataset_builder.py
imports: from typing import Callable, List, Mapping, Optional, OrderedDict, Sequence, Union
  from etils import epath
  from tensorflow_datasets.core import dataset_builder
  from tensorflow_datasets.core import dataset_info
  from tensorflow_datasets.core import lazy_imports_lib
  from tensorflow_datasets.core import split_builder
  from tensorflow_datasets.core.features import feature
  from tensorflow_datasets.core.features.features_dict import FeaturesDict
label_desc: Use image node_id 1 for calling a global function with example usage: get_conllu_example(sentence, example_id, features) and returns: example