code: def get_anchors(source_dir, file_list, num_anchor):
      # List label width and height
      labels = []
      for file_name in tqdm.tqdm(file_list):
          src_label_file_name = os.path.join(
              source_dir, os.path.splitext(file_name)[0] + ".txt"
          )
          labels.extend(
              np.array(load_label(src_label_file_name))[:, 3:5]
          )
      labels = np.array(labels)
      logger.log(
          99,
          "{} labels are found in {} images ({:.2f} labels/image on average).".format(
              len(labels),
              len(file_list),
              len(labels) * 1.0 / len(file_list),
          ),
      )
  
      # k-means
      np.random.seed(0)
      classes = np.random.randint(num_anchor, size=len(labels))
      loop = 0
      while loop < 1000:
          means = []  # anchor * wh
          distance = []  # anchor * data
          for i in range(num_anchor):
              mean = labels[classes == i].mean(axis=0)
              means.append(mean)
              distance.append(np.sum((labels - mean) ** 2, axis=1))
  
          new_classes = np.array(distance).argmin(axis=0)
          # print(loop, means)
          loop += 1
          if np.sum(classes == new_classes) == len(classes):
              break
          classes = new_classes
  
      # sort anchors by area
      means = np.array(means)
      area = means[:, 0] * means[:, 1]
      return means[area.argsort()]
  
imports: import csv
  import multiprocessing
  import os
  import re
  import nnabla.logger
  import numpy
  import tqdm
  from nnabla.utils.image_utils import imsave, imread, imresize
label_desc: Use image node_id 3 for calling a global function with example usage: get_anchors(source_dir, file_list, num_anchor) and returns: means