class_docstr: YOLO anchor optimizer using k-means. Code refer to `AlexeyAB/darknet.
  <https://github.com/AlexeyAB/darknet/blob/master/src/detector.c>`_.
  
  Args:
      num_anchors (int) : Number of anchors.
      iters (int): Maximum iterations for k-means.
class_docstr_tok: ["YOLO","anchor","optimizer","using","k-means",".","Code","refer","to","`","AlexeyAB\/darknet",".","<","https",":","\/\/github.com\/AlexeyAB\/darknet\/blob\/master\/src\/detector.c",">","`","_",".","Args",":","num_anchors","(","int",")",":","Number","of","anchors",".","iters","(","int",")",":","Maximum","iterations","for","k-means","."]
docstr: Expectation part of EM algorithm(Expectation-Maximization)
docstr_tok: ["Expectation","part","of","EM","algorithm","(","Expectation-Maximization",")"]
code: def kmeans_expectation(self, bboxes, assignments, centers):
      """Expectation part of EM algorithm(Expectation-Maximization)"""
      ious = bbox_overlaps(bboxes, centers)
      closest = ious.argmax(1)
      converged = (closest == assignments).all()
      return converged, closest
  
imports: import argparse
  import os.path
  import numpy
  import torch
  from mmengine.config import Config
  from mmengine.fileio import dump
  from mmengine.logging import MMLogger
  from mmengine.registry import init_default_scope
  from mmengine.utils import ProgressBar
  from scipy.optimize import differential_evolution
  from mmdet.registry import DATASETS
  from mmdet.structures.bbox import bbox_cxcywh_to_xyxy, bbox_overlaps, bbox_xyxy_to_cxcywh
  from mmdet.utils import replace_cfg_vals, update_data_root
label_desc: Use image node_id 5 for calling the YOLOKMeansAnchorOptimizer obj's underlying member method code with example usage: obj.kmeans_expectation(bboxes, assignments, centers) and returns: converged,  closest