code: def _validate_num_clusters(num_clusters, initial_centers, num_rows):
      
  
      ## Basic validation
      if num_clusters is not None and not isinstance(num_clusters, int):
          raise _ToolkitError("Parameter 'num_clusters' must be an integer.")
  
      ## Determine the correct number of clusters.
      if initial_centers is None:
          if num_clusters is None:
              raise ValueError("Number of clusters cannot be determined from " +
                               "'num_clusters' or 'initial_centers'. You must " +
                               "specify one of these arguments.")
          else:
              _num_clusters = num_clusters
  
      else:
          num_centers = initial_centers.num_rows()
  
          if num_clusters is None:
              _num_clusters = num_centers
          else:
              if num_clusters != num_centers:
                  raise ValueError("The value of 'num_clusters' does not match " +
                                   "the number of provided initial centers. " +
                                   "Please provide only one of these arguments " +
                                   "or ensure the values match.")
              else:
                  _num_clusters = num_clusters
  
      if _num_clusters > num_rows:
          raise ValueError("The desired number of clusters exceeds the number " +
                           "of data points. Please set 'num_clusters' to be " +
                           "smaller than the number of data points.")
  
      return _num_clusters
docs: Validate the combination of the `num_clusters` and `initial_centers`
      parameters in the Kmeans model create function. If the combination is
      valid, determine and return the correct number of clusters.
  
      Parameters
      ----------
      num_clusters : int
          Specified number of clusters.
  
      initial_centers : SFrame
          Specified initial cluster center locations, in SFrame form. If the
          number of rows in this SFrame does not match `num_clusters`, there is a
          problem.
  
      num_rows : int
          Number of rows in the input dataset.
  
      Returns
      -------
      _num_clusters : int
          The correct number of clusters to use going forward