code: def test_loss_boundary(loss):
      """Test interval ranges of y_true and y_pred in losses."""
      # make sure low and high are always within the interval, used for linspace
      if loss.is_multiclass:
          y_true = np.linspace(0, 9, num=10)
      else:
          low, high = _inclusive_low_high(loss.interval_y_true)
          y_true = np.linspace(low, high, num=10)
  
      # add boundaries if they are included
      if loss.interval_y_true.low_inclusive:
          y_true = np.r_[y_true, loss.interval_y_true.low]
      if loss.interval_y_true.high_inclusive:
          y_true = np.r_[y_true, loss.interval_y_true.high]
  
      assert loss.in_y_true_range(y_true)
  
      n = y_true.shape[0]
      low, high = _inclusive_low_high(loss.interval_y_pred)
      if loss.is_multiclass:
          y_pred = np.empty((n, 3))
          y_pred[:, 0] = np.linspace(low, high, num=n)
          y_pred[:, 1] = 0.5 * (1 - y_pred[:, 0])
          y_pred[:, 2] = 0.5 * (1 - y_pred[:, 0])
      else:
          y_pred = np.linspace(low, high, num=n)
  
      assert loss.in_y_pred_range(y_pred)
  
      # calculating losses should not fail
      raw_prediction = loss.link.link(y_pred)
      loss.loss(y_true=y_true, raw_prediction=raw_prediction)
  
imports: import pickle
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal
  from pytest import approx
  from scipy.optimize import LinearConstraint, minimize, minimize_scalar, newton
  from scipy.special import logsumexp
  from sklearn._loss.link import IdentityLink, _inclusive_low_high
  from sklearn._loss.loss import _LOSSES, AbsoluteError, BaseLoss, HalfBinomialLoss, HalfGammaLoss, HalfMultinomialLoss, HalfPoissonLoss, HalfSquaredError, HalfTweedieLoss, HalfTweedieLossIdentity, HuberLoss, PinballLoss
  from sklearn.utils import _IS_WASM, assert_all_finite
  from sklearn.utils._testing import create_memmap_backed_data, skip_if_32bit
label_desc: Use image node_id 4 for calling a global function with example usage: test_loss_boundary(loss) without return types