code: def crps_weights_pwl(quantile_levels: List[float]) -> List[float]:
      """
      Compute the quantile loss weights making mean quantile loss equal to CRPS
      under linear interpolation assumption.
  
      Quantile levels are assumed to be sorted in increasing order.
  
      Under the assumption of linear interpolation
  
      .. math:: CRPS = sum_{i=0}^{n-1} 0.5 * (q_{i+1}-q_{i}) * (z_{i+1}+z_{i})
  
      where :math:`z_i` is the i-th quantile prediction :math:`q_i`.
      The inner terms cancel due to the telescoping sum property and we obtain
  
      .. math:: CRPS = sum_{i=1}^n w_i z_i
  
      with the weights :math:`w_i = (q_{i+1}-q_{i-1})/2` for
      :math:`i = 1, ..., n-1`, :math:`w_0 = (q_1-q_0)/2` and
      :math:`w_n = (w_n - w_{n-1})/2`.
      """
      num_quantiles = len(quantile_levels)
  
      if num_quantiles < 2:
          return [1.0] * num_quantiles
  
      return (
          [0.5 * (quantile_levels[1] - quantile_levels[0])]
          + [
              0.5 * (quantile_levels[i + 1] - quantile_levels[i - 1])
              for i in range(1, num_quantiles - 1)
          ]
          + [0.5 * (quantile_levels[-1] - quantile_levels[-2])]
      )
  
imports: from typing import List, Optional
  from mxnet.gluon import nn
  from mxnet.gluon.loss import Loss
  from gluonts.core.component import validated
  from gluonts.mx import Tensor
label_desc: Use image node_id 2 for calling a global function with example usage: crps_weights_pwl(quantile_levels) and returns: unknown, unknown