code: def templateLengthProcessData(
      data, start_centers, expected_cluster_length, ccore, **kwargs
  ):
      if isinstance(data, str):
          sample = read_sample(data)
      else:
          sample = data
  
      metric = kwargs.get(
          "metric", distance_metric(type_metric.EUCLIDEAN_SQUARE)
      )
      itermax = kwargs.get("itermax", 200)
  
      kmeans_instance = kmeans(
          sample,
          start_centers,
          0.001,
          ccore,
          metric=metric,
          itermax=itermax,
      )
      kmeans_instance.process()
  
      clusters = kmeans_instance.get_clusters()
      centers = kmeans_instance.get_centers()
      wce = kmeans_instance.get_total_wce()
  
      if itermax == 0:
          assertion.eq(start_centers, centers)
          assertion.eq([], clusters)
          assertion.eq(0.0, wce)
          return
  
      expected_wce = 0.0
      for index_cluster in range(len(clusters)):
          for index_point in clusters[index_cluster]:
              expected_wce += metric(
                  sample[index_point], centers[index_cluster]
              )
  
      assertion.eq(expected_wce, wce)
  
      obtained_cluster_sizes = [len(cluster) for cluster in clusters]
      assertion.eq(len(sample), sum(obtained_cluster_sizes))
  
      assertion.eq(len(clusters), len(centers))
      for center in centers:
          assertion.eq(len(sample[0]), len(center))
  
      if expected_cluster_length is not None:
          obtained_cluster_sizes.sort()
          expected_cluster_length.sort()
          assertion.eq(obtained_cluster_sizes, expected_cluster_length)
  
file_path: pyclustering/pyclustering/cluster/tests/kmeans_templates.py
imports: from pyclustering.tests.assertion import assertion
  from pyclustering.cluster.encoder import type_encoding, cluster_encoder
  from pyclustering.cluster.kmeans import kmeans, kmeans_observer, kmeans_visualizer
  from pyclustering.utils import read_sample
  from pyclustering.utils.metric import distance_metric, type_metric
  from random import random
  import numpy
label_desc: Use image node_id 1 for calling the KmeansTestTemplates obj's underlying member method code with example usage: obj.templateLengthProcessData(data, start_centers, expected_cluster_length, ccore) without return types