code: def test_infer_quantile_forecast(
      quantile_predictions,
      inference_quantiles,
      inferred_quantile_predictions,
  ):
      tol = 1e-5
      forecast_keys = []
      output = []
      for key, value in quantile_predictions.items():
          forecast_keys.append(key)
          output.append(value)
      output = np.array(output)
      quantile_forecast = QuantileForecast(
          output,
          start_date=Period("01-01-2019 04:00:00", freq="h"),
          forecast_keys=forecast_keys,
      )
      if len(forecast_keys) == 1:
          for q in inference_quantiles:
              if forecast_keys[0] == str(q):
                  assert (
                      sum(
                          inferred_quantile_predictions[str(q)]
                          - quantile_forecast.quantile(q)
                      )
                      < tol
                  ), "infer_quantile_forecast failed for singleton quantile."
  
      else:
          assert (
              sum(
                  sum(
                      inferred_quantile_predictions[str(q)]
                      - quantile_forecast.quantile(q)
                  )
                  for q in inference_quantiles
              )
              < tol
          ), "infer_quantile_forecast failed."
  
file_path: gluonts/test/mx/model/seq2seq/test_quantile_loss.py
imports: from mxnet import nd
  import pytest
  import numpy
  from pandas import Period
  from gluonts.mx.block.quantile_output import QuantileLoss, crps_weights_pwl
  from gluonts.model.forecast import QuantileForecast
label_desc: Use image node_id 3 for calling a global function with example usage: test_infer_quantile_forecast(quantile_predictions, inference_quantiles, inferred_quantile_predictions) without return types