code: def image_folder_statistic(
      root: str,
      classes: Optional[List[str]] = None,
      show_bar: Optional[bool] = False,
  ):
      """
      Show count statistic infos 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
      ```
      Args:
          root (`str`):
              Root of `ImageFolder` instance.
          classes (`Optional[List[str]]`):
              The specified classes of statistic. If not None, all class statistic will be return.
          show_bar (`Optional[bool]`):
              Whether showing bar graph.
  
      Returns:
          (`dict`)
              Count statistic info, where key is category name, value is the count.
      """
      if not is_matplotlib_available():
          trainer_log.warning("Matplotlib is not available.")
      from towhee.utils.matplotlib_utils import matplotlib
      import matplotlib.pylab as plt  # pylint: disable=import-outside-toplevel
  
      root_path = Path(root)
      if classes:
          class_list = [root_path / cls for cls in classes]
      else:
          class_list = os.listdir(root)
      count_dict = {}
      for cls in class_list:
          cls_num = len(list((root_path / cls).iterdir()))
          count_dict[cls] = cls_num
      if show_bar:
          plt.figure(figsize=(30, 10))
          plt.bar(
              x=count_dict.keys(),
              height=count_dict.values(),
              color="red",
          )
          plt.xticks(rotation=90)
          plt.tight_layout()
          plt.grid(True)
          plt.title(root_path.name)
          plt.show()
      return count_dict
  
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 3 for calling a global function with example usage: image_folder_statistic(root, classes, show_bar) and returns: count_dict