code: def templateSyncEnsembleAllocation(
      self,
      stimulus,
      steps,
      connection,
      amount_neighbors,
      analysed_iterations,
      expected_length_ensembles,
  ):
      testing_result = True
  
      for _ in range(3):
          network_instance = cnn_network(
              len(stimulus), connection, amount_neighbors
          )
          assert len(stimulus) == len(network_instance)
  
          output_dynamic = network_instance.simulate(steps, stimulus)
  
          ensembles = output_dynamic.allocate_sync_ensembles(
              analysed_iterations
          )
          obtained_ensemble_sizes = [
              len(ensemble) for ensemble in ensembles
          ]
  
          # critical checks - always determined
          assert len(stimulus) == len(network_instance)
          assert len(stimulus) == sum(obtained_ensemble_sizes)
  
          if expected_length_ensembles is not None:
              obtained_ensemble_sizes.sort()
              expected_length_ensembles.sort()
  
              if obtained_ensemble_sizes != expected_length_ensembles:
                  continue
  
      assert testing_result is True
  
file_path: pyclustering/pyclustering/nnet/tests/unit/ut_cnn.py
imports: import unittest
  import matplotlib
  from pyclustering.nnet.cnn import type_conn, cnn_network, cnn_visualizer
  from pyclustering.samples.definitions import SIMPLE_SAMPLES
  from pyclustering.utils import read_sample
label_desc: Use image node_id 1 for calling the CnnUnitTest obj's underlying member method code with example usage: obj.templateSyncEnsembleAllocation(stimulus, steps, connection, amount_neighbors, analysed_iterations, expected_length_ensembles) without return types