code: def test_values(
      distr: PiecewiseLinear,
      target: List[float],
      expected_target_cdf: List[float],
      expected_target_crps: List[float],
  ):
      target = torch.Tensor(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).numpy(), expected_target_cdf)
      )
      assert all(
          np.isclose(distr.crps(target).numpy(), expected_target_crps)
      )
  
      # compare with empirical cdf from samples
      num_samples = 100_000
      samples = distr.sample((num_samples,)).numpy()
      assert np.isfinite(samples).all()
  
      emp_cdf, edges = empirical_cdf(samples)
      calc_cdf = distr.cdf(torch.Tensor(edges)).numpy()
      assert np.allclose(calc_cdf[1:, :], emp_cdf, atol=1e-2)
  
file_path: gluonts/test/torch/distribution/test_torch_piecewise_linear.py
imports: from typing import Tuple, List
  import pytest
  import torch
  import numpy
  from gluonts.torch.distributions import PiecewiseLinear, PiecewiseLinearOutput
label_desc: Use image node_id 2 for calling a global function with example usage: test_values(distr, target, expected_target_cdf, expected_target_crps) without return types