code: def labels_cost(
      Xnum,
      Xcat,
      centroids,
      num_dissim,
      cat_dissim,
      gamma,
      membship=None,
      sample_weight=None,
  ):
      """Calculate labels and cost function given a matrix of points and
      a list of centroids for the k-prototypes algorithm.
      """
  
      n_points = Xnum.shape[0]
      Xnum = check_array(Xnum)
  
      cost = 0.0
      labels = np.empty(n_points, dtype=np.uint16)
      for ipoint in range(n_points):
          # Numerical cost = sum of Euclidean distances
          num_costs = num_dissim(centroids[0], Xnum[ipoint])
          cat_costs = cat_dissim(
              centroids[1], Xcat[ipoint], X=Xcat, membship=membship
          )
          # Gamma relates the categorical cost to the numerical cost.
          tot_costs = num_costs + gamma * cat_costs
          clust = np.argmin(tot_costs)
          labels[ipoint] = clust
          if sample_weight is not None:
              cost += tot_costs[clust] * sample_weight[ipoint]
          else:
              cost += tot_costs[clust]
  
      return labels, cost
  
imports: from collections import defaultdict
  import numpy
  from joblib import Parallel, delayed
  from scipy import sparse
  from sklearn.utils import check_random_state
  from sklearn.utils.validation import check_array
  from .None import kmodes
  from .util import get_max_value_key, encode_features, get_unique_rows, decode_centroids, pandas_to_numpy
  from .util.dissim import matching_dissim, euclidean_dissim
  from .util.init_methods import init_cao, init_huang
label_desc: Use image node_id 1 for calling a global function with example usage: labels_cost(Xnum, Xcat, centroids, num_dissim, cat_dissim, gamma, membship, sample_weight) and returns: labels,  cost