class_docstr: _EfficientKMeans is primarily used by palettization to perform a k-means operation. This class also has an in-house
  implementation of k-means, called ``kmeans_pp`` which runs entirely on GPU and is ~10x faster than sklearn's API.
code: def get_cluster_avg(n_clusters: int, indices, vals):
      v_sum = (
          _torch.zeros(
              [n_clusters] + list(vals[0].size()), dtype=vals.dtype
          )
          .to(vals.device)
          .index_add_(0, indices, vals)
      )
      v_numel = (
          _torch.zeros(n_clusters, dtype=_torch.int)
          .to(vals.device)
          .index_add_(
              0,
              indices,
              _torch.ones(len(vals), dtype=_torch.int).to(vals.device),
          )
      )
      v_avg = v_sum / v_numel.reshape(-1, 1)
  
      return v_avg
  
file_path: coremltools/coremltools/optimize/torch/palettization/_efficient_kmeans.py
imports: import numpy
  import torch
  import torch.distributed
label_desc: Use image node_id 1 for calling the _EfficientKMeans obj's underlying member method code with example usage: obj.get_cluster_avg(n_clusters, indices, vals) and returns: v_avg