code: def _get_split_label_images(
      root_dir: str,
  ) -> Tuple[SplitExampleDict, List[str]]:
      """Extract all label names and associated images.
  
      This function guarantee that examples are deterministically shuffled
      and labels are sorted.
  
      Args:
        root_dir: The folder where the `split/label/image.png` are located
  
      Returns:
        split_examples: Mapping split_names -> List[_Example]
        labels: The list off labels
      """
      split_examples = collections.defaultdict(list)
      labels = set()
      for split_name in sorted(_list_folders(root_dir)):
          split_dir = os.path.join(root_dir, split_name)
          for label_name in sorted(_list_folders(split_dir)):
              labels.add(label_name)
              split_examples[split_name].extend(
                  [
                      _Example(image_path=image_path, label=label_name)
                      for image_path in sorted(
                          _list_img_paths(
                              os.path.join(split_dir, label_name)
                          )
                      )
                  ]
              )
  
      # Shuffle the images deterministically
      for split_name, examples in split_examples.items():
          rgn = random.Random(
              split_name
          )  # Uses different seed for each split
          rgn.shuffle(examples)
      return split_examples, sorted(labels)
  
imports: from __future__ import annotations
  import collections
  import os
  import random
  from typing import Dict, List, NoReturn, Optional, Tuple
  from tensorflow_datasets.core import dataset_builder
  from tensorflow_datasets.core import dataset_info
  from tensorflow_datasets.core import decode
  from tensorflow_datasets.core import features
  from tensorflow_datasets.core import splits
  from tensorflow_datasets.core.utils import type_utils
  from tensorflow_datasets.core.utils import version
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
label_desc: Use image node_id 2 for calling a global function with example usage: _get_split_label_images(root_dir) and returns: split_examples,  sorted