class_docstr: Dataset for textual inversion, pairing prompts with normalized image tensors.
class_docstr_tok: ["Dataset","for","textual","inversion",",","pairing","prompts","with","normalized","image","tensors","."]
docstr: Returns a list of PIL Images loaded from all valid files contained in dir_path.
docstr_tok: ["Returns","a","list","of","PIL","Images","loaded","from","all","valid","files","contained","in","dir_path","."]
code: def _get_imgs_and_paths_from_dir_path(
      self, dir_path: str
  ) -> List[Tuple[Image.Image, Path]]:
      """Returns a list of PIL Images loaded from all valid files contained in dir_path."""
      imgs_and_paths = []
      for file_or_dir in os.listdir(dir_path):
          path = Path(dir_path).joinpath(file_or_dir)
          if path.is_file():
              try:
                  img = Image.open(path)
                  if not img.mode == "RGB":
                      img = img.convert("RGB")
                  imgs_and_paths.append((img, path))
              except PIL.UnidentifiedImageError:
                  self.logger.warning(
                      f"File at {path} raised UnidentifiedImageError and will be skipped."
                  )
      return imgs_and_paths
  
file_path: determined/examples/diffusion/textual_inversion_stable_diffusion/detsd/data.py
imports: import logging
  import os
  from pathlib import Path
  from typing import List, Sequence, Tuple
  import PIL
  import torch
  from detsd import defaults
  from PIL import Image
  from torch.utils.data import Dataset
  from torchvision import transforms
label_desc: Use image node_id 2 for calling the TextualInversionDataset obj's underlying member method code with example usage: obj._get_imgs_and_paths_from_dir_path(dir_path) and returns: imgs_and_paths