code: def test_get_batch_num_gradients_logistic_iris(
      logistic_iris, batch_size
  ):
      X, y, lr = logistic_iris
      predict_fn = lr.predict_proba
      x = X[0:batch_size]
      probas = predict_fn(x)
  
      # true gradient of the logistic regression wrt x
      grad_true = np.zeros((batch_size, 3, 4))
      for i, p in enumerate(probas):
          p = p.reshape(1, 3)
          grad = p.T * (np.eye(3, 3) - p) @ lr.coef_
          grad_true[i, :, :] = grad
      assert grad_true.shape == (batch_size, 3, 4)
  
      grad_approx = num_grad_batch(predict_fn, x)
  
      assert grad_approx.shape == grad_true.shape
      assert np.allclose(grad_true, grad_approx)
  
file_path: alibi/alibi/utils/tests/test_gradients.py
imports: import numpy
  import pytest
  from sklearn.datasets import load_iris
  from sklearn.linear_model import LogisticRegression
  from alibi.utils.distance import cityblock_batch
  from alibi.utils.gradients import num_grad_batch
label_desc: Use image node_id 3 for calling a global function with example usage: test_get_batch_num_gradients_logistic_iris(logistic_iris, batch_size) without return types