code: def test_values(
      distr: PiecewiseLinear,
      target: List[float],
      expected_target_cdf: List[float],
      expected_target_crps: List[float],
      serialize_fn,
  ):
      distr = serialize_fn(distr)
      target = mx.nd.array(target).reshape(shape=(len(target),))
      expected_target_cdf = np.array(expected_target_cdf).reshape(
          (len(expected_target_cdf),)
      )
      expected_target_crps = np.array(expected_target_crps).reshape(
          (len(expected_target_crps),)
      )
  
      assert all(
          np.isclose(distr.cdf(target).asnumpy(), expected_target_cdf)
      )
      assert all(
          np.isclose(distr.crps(target).asnumpy(), expected_target_crps)
      )
  
      # compare with empirical cdf from samples
      num_samples = 100_000
      samples = distr.sample(num_samples).asnumpy()
      assert np.isfinite(samples).all()
  
      emp_cdf, edges = empirical_cdf(samples)
      calc_cdf = distr.cdf(mx.nd.array(edges)).asnumpy()
      assert np.allclose(calc_cdf[1:, :], emp_cdf, atol=1e-2)
  
file_path: gluonts/test/mx/distribution/test_piecewise_linear.py
imports: from typing import List, Tuple
  import mxnet
  import numpy
  import pytest
  from gluonts.core.serde import dump_json, load_json
  from gluonts.mx.distribution import FixedKnotsPiecewiseLinearOutput, PiecewiseLinear, PiecewiseLinearOutput
  from gluonts.testutil import empirical_cdf
label_desc: Use image node_id 1 for calling a global function with example usage: test_values(distr, target, expected_target_cdf, expected_target_crps, serialize_fn) without return types