code: def create_aspect_ratio_groups(dataset, k=0):
      # 计算所有数据集中的图片width/height比例
      aspect_ratios = compute_aspect_ratios(dataset)
      # 将[0.5, 2]区间划分成2*k等份(2k+1个点，2k个区间)
      bins = (
          (2 ** np.linspace(-1, 1, 2 * k + 1)).tolist()
          if k > 0
          else [1.0]
      )
  
      # 统计所有图像比例在bins区间中的位置索引
      groups = _quantize(aspect_ratios, bins)
      # count number of elements per group
      # 统计每个区间的频次
      counts = np.unique(groups, return_counts=True)[1]
      fbins = [0] + bins + [np.inf]
      print(
          "Using {} as bins for aspect ratio quantization".format(fbins)
      )
      print("Count of instances per bin: {}".format(counts))
      return groups
  
imports: import bisect
  from collections import defaultdict
  import copy
  from itertools import repeat, chain
  import math
  import numpy
  import torch
  import torch.utils.data
  from torch.utils.data.sampler import BatchSampler, Sampler
  from torch.utils.model_zoo import tqdm
  import torchvision
  from PIL import Image
label_desc: Use image node_id 9 for calling a global function with example usage: create_aspect_ratio_groups(dataset, k) and returns: groups