code: def find_classes(directory: str):
      # 1. Get the class names by scanning the target directory
      classes = sorted(
          entry.name
          for entry in os.scandir(directory)
          if entry.is_dir()
      )
      # 2. Raise an error if class names not found
      if not classes:
          raise FileNotFoundError(
              f"Couldn't find any classes in {directory}."
          )
      # 3. Crearte a dictionary of index labels (computers prefer numerical rather than string labels)
      class_to_idx = {cls_name: i for i, cls_name in enumerate(classes)}
      return classes, class_to_idx
  
file_path: gradio/demo/musical_instrument_identification/data_setups.py
imports: import os
  import librosa
  import torch
  import numpy
  from torchaudio.transforms import Resample
label_desc: Use image node_id 1 for calling a global function with example usage: find_classes(directory) and returns: classes,  class_to_idx