class_docstr: !
  @brief Visualizer of K-Means algorithm's results.
  @details K-Means visualizer provides visualization services that are specific for K-Means algorithm.
docstr: !
  @brief Animates clustering process that is performed by K-Means algorithm.
  
  @param[in] data (list): Dataset that is used for clustering.
  @param[in] observer (kmeans_observer): EM observer that was used for collection information about clustering process.
  @param[in] animation_velocity (uint): Interval between frames in milliseconds (for run-time animation only).
  @param[in] movie_fps (uint): Defines frames per second (for rendering movie only).
  @param[in] save_movie (string): If it is specified then animation will be stored to file that is specified in this parameter.
docstr_tok: ["!","@","brief","Animates","clustering","process","that","is","performed","by","K-Means","algorithm",".","@","param","[","in","]","data","(","list",")",":","Dataset","that","is","used","for","clustering",".","@","param","[","in","]","observer","(","kmeans_observer",")",":","EM","observer","that","was","used","for","collection","information","about","clustering","process",".","@","param","[","in","]","animation_velocity","(","uint",")",":","Interval","between","frames","in","milliseconds","(","for","run-time","animation","only",")",".","@","param","[","in","]","movie_fps","(","uint",")",":","Defines","frames","per","second","(","for","rendering","movie","only",")",".","@","param","[","in","]","save_movie","(","string",")",":","If","it","is","specified","then","animation","will","be","stored","to","file","that","is","specified","in","this","parameter","."]
code: def animate_cluster_allocation(
      data,
      observer,
      animation_velocity=500,
      movie_fps=1,
      save_movie=None,
  ):
      """!
      @brief Animates clustering process that is performed by K-Means algorithm.
  
      @param[in] data (list): Dataset that is used for clustering.
      @param[in] observer (kmeans_observer): EM observer that was used for collection information about clustering process.
      @param[in] animation_velocity (uint): Interval between frames in milliseconds (for run-time animation only).
      @param[in] movie_fps (uint): Defines frames per second (for rendering movie only).
      @param[in] save_movie (string): If it is specified then animation will be stored to file that is specified in this parameter.
  
      """
      figure = plt.figure()
  
      def init_frame():
          return frame_generation(0)
  
      def frame_generation(index_iteration):
          figure.clf()
  
          figure.suptitle(
              "K-Means algorithm (iteration: "
              + str(index_iteration)
              + ")",
              fontsize=18,
              fontweight="bold",
          )
  
          clusters = observer.get_clusters(index_iteration)
          centers = observer.get_centers(index_iteration)
          kmeans_visualizer.show_clusters(
              data,
              clusters,
              centers,
              None,
              figure=figure,
              display=False,
          )
  
          figure.subplots_adjust(top=0.85)
  
          return [figure.gca()]
  
      iterations = len(observer)
      cluster_animation = animation.FuncAnimation(
          figure,
          frame_generation,
          iterations,
          interval=animation_velocity,
          init_func=init_frame,
          repeat_delay=5000,
      )
  
      if save_movie is not None:
          cluster_animation.save(
              save_movie, writer="ffmpeg", fps=movie_fps, bitrate=3000
          )
      else:
          plt.show()
  
      plt.close(figure)
  
imports: import copy
  import numpy
  import matplotlib.pyplot
  import matplotlib.animation
  import pyclustering.core.kmeans_wrapper
  from pyclustering.core.wrapper import ccore_library
  from pyclustering.core.metric_wrapper import metric_wrapper
  from pyclustering.cluster.encoder import type_encoding
  from pyclustering.cluster import cluster_visualizer
  from pyclustering.utils.metric import distance_metric, type_metric
label_desc: Use image node_id 7 for calling the kmeans_visualizer obj's underlying member method code with example usage: obj.animate_cluster_allocation(data, observer, animation_velocity, movie_fps, save_movie) and returns: frame_generation, list