code: def apply_fn(
      fn: Callable[[Any], Any],
      input_feature: str,
      output_feature: Optional[str] = None,
  ) -> ExampleTransformFn:
      """Returns a function that applies the given `fn` on the `input_feature`.
  
      Arguments:
        fn: the function to apply.
        input_feature: the name of the feature on which `fn` should be applied. If a
          nested feature needs to be transformed, then specify it using slashes. For
          example, to transform feature `b` inside `a`, use `a/b`.
        output_feature: the name of the feature where the result should be stored.
          If `None`, then `input_feature` will be overridden.
  
      Returns:
        a function that applies `fn` to `input_feature` field of examples and stores
        the result in `output_feature`.
      """
      input_parts = input_feature.split("/")
      if output_feature is not None:
          output_parts = output_feature.split("/")
      else:
          output_parts = input_parts
      if (
          len(input_parts) != len(output_parts)
          or input_parts[:-1] != output_parts[:-1]
      ):
          raise ValueError(
              "The out-feature must have the same ancestor as the "
              f"in-feature! Got in={input_parts}, out={output_parts}."
          )
  
      def transform(example: Example) -> Iterator[Example]:
          yield _transform_example(
              example=example,
              fn=fn,
              in_parts=input_parts,
              out_parts=output_parts,
          )
  
      return transform
  
file_path: datasets/tensorflow_datasets/core/transform/transform_lib.py
imports: from __future__ import annotations
  import functools
  from typing import Any, Callable, Iterator, List, Mapping, Optional, Union
  import numpy
  from tensorflow_datasets.core import split_builder
label_desc: Use image node_id 5 for calling a global function with example usage: apply_fn(fn, input_feature, output_feature) and returns: transform