code: def crps(
      forecast,
      actuals,
      levels: np.ndarray = (np.arange(10) / 10.0)[1:],
      weighted: bool = True,
  ):
      quantiles = np.array(
          [forecast.quantile(level) for level in levels]
      )
  
      levels = np.expand_dims(levels, axis=-1)
  
      crps = np.where(
          actuals >= quantiles,
          levels * (actuals - quantiles),
          (1 - levels) * (quantiles - actuals),
      )
  
      if weighted:
          return crps.sum() / actuals.sum()
      else:
          return crps.sum()
  
file_path: gluonts/src/gluonts/nursery/temporal_hierarchical_forecasting/utils/gluonts_helper.py
imports: from typing import Dict
  import numpy
  import pandas
  from gluonts.dataset.common import DataEntry, Dataset
  from gluonts.dataset.field_names import FieldName
label_desc: Use image node_id 4 for calling a global function with example usage: crps(forecast, actuals, levels, weighted) and returns: unknown, crps