code: def test_spline_transformer_unity_decomposition(
      degree, n_knots, knots, extrapolation
  ):
      """Test that B-splines are indeed a decomposition of unity.
  
      Splines basis functions must sum up to 1 per row, if we stay in between boundaries.
      """
      X = np.linspace(0, 1, 100)[:, None]
      # make the boundaries 0 and 1 part of X_train, for sure.
      X_train = np.r_[[[0]], X[::2, :], [[1]]]
      X_test = X[1::2, :]
  
      if extrapolation == "periodic":
          n_knots = (
              n_knots + degree
          )  # periodic splines require degree < n_knots
  
      splt = SplineTransformer(
          n_knots=n_knots,
          degree=degree,
          knots=knots,
          include_bias=True,
          extrapolation=extrapolation,
      )
      splt.fit(X_train)
      for X in [X_train, X_test]:
          assert_allclose(np.sum(splt.transform(X), axis=1), 1)
  
imports: import sys
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal
  from scipy import sparse
  from scipy.interpolate import BSpline
  from scipy.sparse import random
  from sklearn.linear_model import LinearRegression
  from sklearn.pipeline import Pipeline
  from sklearn.preprocessing import KBinsDiscretizer, PolynomialFeatures, SplineTransformer
  from sklearn.preprocessing._csr_polynomial_expansion import _calc_expanded_nnz, _calc_total_nnz, _get_sizeof_LARGEST_INT_t
  from sklearn.utils._testing import assert_array_almost_equal
  from sklearn.utils.fixes import CSC_CONTAINERS, CSR_CONTAINERS, parse_version, sp_version
label_desc: Use image node_id 6 for calling a global function with example usage: test_spline_transformer_unity_decomposition(degree, n_knots, knots, extrapolation) without return types