code: def image_folder_sample_show(
      root: str,
      rows: int = 4,
      cols: int = 4,
      img_size: int = 224,
      classes: Optional[List[str]] = None,
  ):
      """
      Show sample images for `torchvision.datasets.ImageFolder`,
      Put another way, the image root path structure just need to be like this:
      ```
      root-|
          #classname1#-|
              image-1.jpg
              image-2.jpg
          #classname2-|
              image-1.jpg
              image-2.jpg
          |
          |
          #classnameN-|
              image-1.jpg
              image-2.jpg
      ```
      it's useful to observe the images for different categories.
      You can randomly sample categories, or specify show classes.
      Args:
          root (`str`):
              Root of `ImageFolder` instance.
          rows (`int`):
              Count of show rows.
          cols (`int`):
              Count of show cols.
          img_size (`int` or `tuple`):
              Show image shape, if int, it's a square.
          classes (`Optional[list[str]]`):
              The specified classes you want to see. If not None, param `rows` will be invalid.
  
      """
      transform = transforms.Compose(
          [
              transforms.Resize(img_size),
              transforms.CenterCrop(img_size),
          ]
      )
      root_path = Path(root)
      rows = min(len(list(root_path.iterdir())), rows)
      if classes:
          sample_class_list = [root_path / cls for cls in classes]
      else:
          sample_class_list = random.sample(
              list(root_path.iterdir()), rows
          )
      row_grid_list = []
      cls_list = []
      for class_path in sample_class_list:
          cls = class_path.name
          class_sample_num = min(len(list(class_path.iterdir())), cols)
          class_sample_img_list = random.sample(
              list(class_path.iterdir()), class_sample_num
          )
          trans_img_list = []
          for img_path in class_sample_img_list:
              img = read_image(str(img_path))
              trans_img = transform(img)
              trans_img_list.append(trans_img)
          row_grid_list.append(trans_img_list)
          cls_list.append(cls)
      _show_grid(row_grid_list, cls_list)
  
imports: from typing import Optional, List, Any, Tuple
  from torchvision import transforms
  from torchvision.io import read_image
  from pathlib import Path
  from torch import nn
  from towhee.utils.pil_utils import PILImage
  from towhee.trainer.optimization.optimization import get_scheduler, get_warmup_steps
  from towhee.trainer.utils.trainer_utils import _construct_scheduler_from_config
  from towhee.trainer.training_config import TrainingConfig
  from towhee.trainer.utils.file_utils import is_captum_available, is_matplotlib_available
  from towhee.utils.log import trainer_log
  import torch
  import torch.nn.functional
  import numpy
  import random
  import os
  import copy
label_desc: Use image node_id 2 for calling a global function with example usage: image_folder_sample_show(root, rows, cols, img_size, classes) without return types