code: def calc_anchors(self):
      self.whs = self.whs * np.array([self.size])
      # random select k centers
      whs, n, iters = self.whs, self.n, self.iters
      logger.info(
          "Running kmeans for %d anchors on %d points..."
          % (n, len(whs))
      )
      idx = np.random.choice(whs.shape[0], size=n, replace=False)
      centers = whs[idx]
      assignments = np.zeros(whs.shape[0:1]) * -1
      # kmeans
      if n == 1:
          return self.kmeans_maximizations(whs, centers, assignments)
  
      pbar = tqdm(
          range(iters), desc="Cluster anchors with k-means algorithm"
      )
      for _ in pbar:
          # E step
          converged, assignments = self.kmeans_expectation(
              whs, centers, assignments
          )
          if converged:
              logger.info("kmeans algorithm has converged")
              break
          # M step
          centers = self.kmeans_maximizations(whs, centers, assignments)
          ious = self.metric(whs, centers)
          pbar.desc = "avg_iou: %.4f" % (ious.max(1).mean())
  
      centers = sorted(centers, key=lambda x: x[0] * x[1])
      return centers
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import sys
  from ppdet.utils.logger import setup_logger
  from scipy.cluster.vq import kmeans
  import numpy
  from tqdm import tqdm
  from ppdet.utils.cli import ArgsParser
  from ppdet.utils.check import check_gpu, check_version, check_config
  from ppdet.core.workspace import load_config, merge_config
label_desc: Use image node_id 6 for calling the YOLOv2AnchorCluster obj's underlying member method code with example usage: obj.calc_anchors() and returns: centers, self