code: def test_define_func(logistic_iris, target_class):
      X, y, model = logistic_iris
  
      x = X[0].reshape(1, -1)
      predict_fn = model.predict_proba
      probas = predict_fn(x)
      pred_class = probas.argmax(axis=1)[0]
      pred_prob = probas[:, pred_class][0]
  
      func, target = _define_func(predict_fn, pred_class, target_class)
  
      if target_class == "same":
          assert target == pred_class
          assert func(x) == pred_prob
      elif isinstance(target_class, int):
          assert target == target_class
          assert func(x) == probas[:, target]
      elif target_class == "other":
          assert target == "other"
          # highest probability different to the class of x
          ix2 = np.argsort(-probas)[:, 1]
          assert func(x) == probas[:, ix2]
  
file_path: alibi/alibi/explainers/tests/test_counterfactual.py
imports: import pytest
  import numpy
  from sklearn.datasets import load_iris
  from sklearn.linear_model import LogisticRegression
  import tensorflow
  from alibi.api.defaults import DEFAULT_META_CF, DEFAULT_DATA_CF
  from alibi.explainers.counterfactual import _define_func
  from alibi.explainers import Counterfactual
label_desc: Use image node_id 4 for calling a global function with example usage: test_define_func(logistic_iris, target_class) without return types