code: def test_linear_superposition(input_shape, nb_instances):
      alphas = np.array([0.5, 0.5])
  
      vecs_list = []
      for i in range(nb_instances):
          v0 = np.zeros((1,) + input_shape)
          v1 = np.ones((1,) + input_shape)
          vec = np.stack((v0, v1), axis=1)
          vecs_list.append(vec)
      vecs = reduce(lambda x, y: np.vstack((x, y)), vecs_list)
  
      summ = _linear_superposition(alphas, vecs, input_shape)
  
      assert summ.shape[0] == nb_instances
      assert summ.shape[1:] == input_shape
      assert (summ == 0.5).all()
  
file_path: alibi/alibi/confidence/tests/test_model_linearity.py
imports: import pytest
  import numpy
  from sklearn.datasets import load_iris, load_diabetes
  from sklearn.linear_model import LogisticRegression, LinearRegression
  from sklearn.svm import SVR
  from alibi.confidence.model_linearity import linearity_measure, LinearityMeasure
  from alibi.confidence.model_linearity import _linear_superposition, _sample_grid, _sample_knn
  from functools import reduce
label_desc: Use image node_id 1 for calling a global function with example usage: test_linear_superposition(input_shape, nb_instances) without return types