parameters: (X, sample_weight, x_squared_norms,
                                       centers, distances)
return_statement: return labels, inertia
docstring: Compute labels and inertia using a full distance matrix.
  
      This will overwrite the 'distances' array in-place.
  
      Parameters
      ----------
      X : numpy array, shape (n_sample, n_features)
          Input data.
  
      sample_weight : array-like, shape (n_samples,)
          The weights for each observation in X.
  
      x_squared_norms : numpy array, shape (n_samples,)
          Precomputed squared norms of X.
  
      centers : numpy array, shape (n_clusters, n_features)
          Cluster centers which data is assigned to.
  
      distances : numpy array, shape (n_samples,)
          Pre-allocated array in which distances are stored.
  
      Returns
      -------
      labels : numpy array, dtype=np.int, shape (n_samples,)
          Indices of clusters that samples are assigned to.
  
      inertia : float
          Sum of squared distances of samples to their closest cluster center.
docstring_summary: Compute labels and inertia using a full distance matrix.
docstring_tokens: Compute labels and inertia using a full distance matrix .
function: def _labels_inertia_precompute_dense(X, sample_weight, x_squared_norms,
                                       centers, distances):
      """Compute labels and inertia using a full distance matrix.
  
      This will overwrite the 'distances' array in-place.
  
      Parameters
      ----------
      X : numpy array, shape (n_sample, n_features)
          Input data.
  
      sample_weight : array-like, shape (n_samples,)
          The weights for each observation in X.
  
      x_squared_norms : numpy array, shape (n_samples,)
          Precomputed squared norms of X.
  
      centers : numpy array, shape (n_clusters, n_features)
          Cluster centers which data is assigned to.
  
      distances : numpy array, shape (n_samples,)
          Pre-allocated array in which distances are stored.
  
      Returns
      -------
      labels : numpy array, dtype=np.int, shape (n_samples,)
          Indices of clusters that samples are assigned to.
  
      inertia : float
          Sum of squared distances of samples to their closest cluster center.
  
      """
      n_samples = X.shape[0]
  
      # Breakup nearest neighbor distance computation into batches to prevent
      # memory blowup in the case of a large number of samples and clusters.
      # TODO: Once PR #7383 is merged use check_inputs=False in metric_kwargs.
      labels, mindist = pairwise_distances_argmin_min(
          X=X, Y=centers, metric='euclidean', metric_kwargs={'squared': True})
      # cython k-means code assumes int32 inputs
      labels = labels.astype(np.int32, copy=False)
      if n_samples == distances.shape[0]:
          # distances will be changed in-place
          distances[:] = mindist
      inertia = (mindist * sample_weight).sum()
      return labels, inertia
function_tokens: def _labels_inertia_precompute_dense ( X , sample_weight , x_squared_norms , centers , distances ) : n_samples = X . shape [ 0 ] # Breakup nearest neighbor distance computation into batches to prevent # memory blowup in the case of a large number of samples and clusters. # TODO: Once PR #7383 is merged use check_inputs=False in metric_kwargs. labels , mindist = pairwise_distances_argmin_min ( X = X , Y = centers , metric = 'euclidean' , metric_kwargs = { 'squared' : True } ) # cython k-means code assumes int32 inputs labels = labels . astype ( np . int32 , copy = False ) if n_samples == distances . shape [ 0 ] : # distances will be changed in-place distances [ : ] = mindist inertia = ( mindist * sample_weight ) . sum ( ) return labels , inertia