code: def _subgradient_valence_warping(list_p_k, barycenter_size, weights):
      """Compute Valence and Warping matrices from paths.
  
      Valence matrices are denoted :math:`V^{(k)}` and Warping matrices are
      :math:`W^{(k)}` in [1]_.
  
      This function returns a list of :math:`V^{(k)}` diagonals (as a vector)
      and a list of :math:`W^{(k)}` matrices.
  
      Parameters
      ----------
      list_p_k : list of index pairs
          Warping paths
  
      barycenter_size : int
          Size of the barycenter to generate.
  
      weights: array
          Weights of each X[i]. Must be the same size as len(X).
  
      Returns
      -------
      list of numpy.array of shape (barycenter_size, )
          list of weighted :math:`V^{(k)}` diagonals (as a vector)
  
      list of numpy.array of shape (barycenter_size, sz_k)
          list of weighted :math:`W^{(k)}` matrices
  
      References
      ----------
  
      .. [1] D. Schultz and B. Jain. Nonsmooth Analysis and Subgradient Methods
         for Averaging in Dynamic Time Warping Spaces.
         Pattern Recognition, 74, 340-358.
      """
      list_v_k = []
      list_w_k = []
      for k, p_k in enumerate(list_p_k):
          sz_k = p_k[-1][1] + 1
          w_k = numpy.zeros((barycenter_size, sz_k))
          for i, j in p_k:
              w_k[i, j] = 1.0
          list_w_k.append(w_k * weights[k])
          list_v_k.append(w_k.sum(axis=1) * weights[k])
      return list_v_k, list_w_k
  
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 7 for calling a global function with example usage: _subgradient_valence_warping(list_p_k, barycenter_size, weights) and returns: list_v_k,  list_w_k