code: def fetch_kmeans_model(
      n_clusters,
      init,
      max_iter,
      batch_size,
      tol,
      max_no_improvement,
      n_init,
      reassignment_ratio,
      random_state,
      checkpoint_path,
  ):
      """Return a k-means clustering model with specified parameters.
  
      Arguments
      ---------
          n_clusters : MiniBatchKMeans
              The number of clusters to form as well as the number of centroids to generate.
          init : int
              Method for initialization: {'k-means++'', ''random''}
          max_iter : int
              Maximum number of iterations over the complete dataset before stopping independently of any early stopping criterion heuristics.
          batch_size : int
              Size of the mini batches.
          tol : float
              Control early stopping based on the relative center changes as measured by a smoothed, variance-normalized of the mean center squared position changes.
          max_no_improvement :int
              Control early stopping based on the consecutive number of mini batches that does not yield an improvement on the smoothed inertia.
          n_init : int
              Number of random initializations that are tried
          reassignment_ratio : float
              Control the fraction of the maximum number of counts for a center to be reassigned.
          random_state :int
              Determines random number generation for centroid initialization and random reassignment.
          compute_labels : bool
              Compute label assignment and inertia for the complete dataset once the minibatch optimization has converged in fit.
          init_size : int
              Number of samples to randomly sample for speeding up the initialization.
          checkpoint_path : str
              Path to saved model.
  
      Returns
      ---------
          MiniBatchKMeans
              a k-means clustering model with specified parameters.
      """
      if os.path.exists(checkpoint_path):
          logger.info(
              f"The checkpoint is loaded from {checkpoint_path}."
          )
          return joblib.load(checkpoint_path)
  
      logger.info(
          f"No checkpoint is found at {checkpoint_path}. New model is initialized for training."
      )
      return MiniBatchKMeans(
          n_clusters=n_clusters,
          init=init,
          max_iter=max_iter,
          batch_size=batch_size,
          tol=tol,
          max_no_improvement=max_no_improvement,
          n_init=n_init,
          reassignment_ratio=reassignment_ratio,
          random_state=random_state,
          verbose=1,
          compute_labels=True,
          init_size=None,
      )
  
imports: import os
  import logging
  from tqdm.contrib import tqdm
  import joblib
label_desc: Use image node_id 2 for calling a global function with example usage: fetch_kmeans_model(n_clusters, init, max_iter, batch_size, tol, max_no_improvement, n_init, reassignment_ratio, random_state, checkpoint_path) and returns: MiniBatchKMeans, joblib