code: def _validate_sample_weight(sample_weight, n_samples, n_clusters):
      if sample_weight is not None:
          if len(sample_weight) != n_samples:
              raise ValueError(
                  "sample_weight should be of equal size as samples."
              )
          if any(
              not isinstance(weight, int)
              and not isinstance(weight, float)
              for weight in sample_weight
          ):
              raise ValueError(
                  "sample_weight elements should either be int or floats."
              )
          if any(sample < 0 for sample in sample_weight):
              raise ValueError(
                  "sample_weight elements should be positive."
              )
          if sum([x > 0 for x in sample_weight]) < n_clusters:
              raise ValueError(
                  "Number of non-zero sample_weight elements should be "
                  "larger than the number of clusters."
              )
  
imports: from collections import defaultdict
  import numpy
  from joblib import Parallel, delayed
  from scipy import sparse
  from sklearn.base import BaseEstimator, ClusterMixin
  from sklearn.utils import check_random_state
  from sklearn.utils.validation import check_array
  from .util import get_max_value_key, encode_features, get_unique_rows, decode_centroids, pandas_to_numpy
  from .util.dissim import matching_dissim, ng_dissim
  from .util.init_methods import init_cao, init_huang
label_desc: Use image node_id 6 for calling a global function with example usage: _validate_sample_weight(sample_weight, n_samples, n_clusters) without return types