code: def get_image_paths(directory: str) -> List[str]:
      """Returns a list of paths to all image files in the input directory and its subdirectories."""
      image_paths = []
      for root, _, fnames in sorted(os.walk(directory, topdown=False)):
          for fname in sorted(fnames):
              path = os.path.join(root, fname)
              if file_has_valid_image_extension(path):
                  image_paths.append(path)
  
      return image_paths
  
file_path: ml-cvnets/data/datasets/utils/common.py
imports: import collections
  import os
  import random
  from typing import Any, List, Optional, Tuple, Union
label_desc: Use image node_id 3 for calling a global function with example usage: get_image_paths(directory) and returns: image_paths