code: def _petitjean_cost(X, barycenter, assign, weights):
      cost = 0.0
      barycenter_size = barycenter.shape[0]
      for t_barycenter in range(barycenter_size):
          for i_ts, t_ts in zip(
              assign[0][t_barycenter], assign[1][t_barycenter]
          ):
              sq_norm = (
                  numpy.linalg.norm(
                      X[i_ts, t_ts] - barycenter[t_barycenter]
                  )
                  ** 2
              )
              cost += weights[i_ts] * sq_norm
      return cost / weights.sum()
  
imports: import numpy
  import warnings
  from scipy.interpolate import interp1d
  from sklearn.exceptions import ConvergenceWarning
  from sklearn.utils import check_random_state
  from ..metrics import dtw_path
  from ..utils import to_time_series_dataset, ts_size
  from .utils import _set_weights
label_desc: Use image node_id 4 for calling a global function with example usage: _petitjean_cost(X, barycenter, assign, weights) and returns: unknown