code: def get_labels(metadata_dir, version="v4"):
      if version == "v4" or version == "challenge2018":
          csv_file = (
              "class-descriptions-boxable.csv"
              if version == "v4"
              else "challenge-2018-class-descriptions-500.csv"
          )
  
          boxable_classes_descriptions = os.path.join(
              metadata_dir, csv_file
          )
          id_to_labels = {}
          cls_index = {}
  
          i = 0
          with open(boxable_classes_descriptions) as f:
              for row in csv.reader(f):
                  # make sure the csv row is not empty (usually the last one)
                  if len(row):
                      label = row[0]
                      description = (
                          row[1]
                          .replace('"', "")
                          .replace("'", "")
                          .replace("`", "")
                      )
  
                      id_to_labels[i] = description
                      cls_index[label] = i
  
                      i += 1
      else:
          trainable_classes_path = os.path.join(
              metadata_dir, "classes-bbox-trainable.txt"
          )
          description_path = os.path.join(
              metadata_dir, "class-descriptions.csv"
          )
  
          description_table = {}
          with open(description_path) as f:
              for row in csv.reader(f):
                  # make sure the csv row is not empty (usually the last one)
                  if len(row):
                      description_table[row[0]] = (
                          row[1]
                          .replace('"', "")
                          .replace("'", "")
                          .replace("`", "")
                      )
  
          with open(trainable_classes_path, "rb") as f:
              trainable_classes = f.read().split("\n")
  
          id_to_labels = dict(
              [
                  (i, description_table[c])
                  for i, c in enumerate(trainable_classes)
              ]
          )
          cls_index = dict(
              [(c, i) for i, c in enumerate(trainable_classes)]
          )
  
      return id_to_labels, cls_index
  
imports: import csv
  import json
  import os
  import warnings
  import numpy
  from PIL import Image
  from .generator import Generator
  from ..utils.image import read_image_bgr
label_desc: Use image node_id 4 for calling a global function with example usage: get_labels(metadata_dir, version) and returns: id_to_labels,  cls_index