code: def predict_fcn(predict_type, clf, preproc=None):
      """
      Define a prediction function given a classifier Optionally a preprocessor
      with a .transform method can be passed.
      """
  
      if preproc:
          if not hasattr(preproc, "transform"):
              raise AttributeError(
                  "Passed preprocessor to predict_fn but the "
                  "preprocessor did not have a .transform method. "
                  "Are you sure you passed the correct object?"
              )
      if predict_type == "proba":
          if preproc:
              predict_fn = lambda x: clf.predict_proba(
                  preproc.transform(x)
              )  # noqa: E731
          else:
              predict_fn = lambda x: clf.predict_proba(x)  # noqa: E731
      elif predict_type == "class":
          if preproc:
              predict_fn = lambda x: clf.predict(
                  preproc.transform(x)
              )  # noqa: E731
          else:
              predict_fn = lambda x: clf.predict(x)  # noqa: E731
  
      return predict_fn
  
file_path: alibi/alibi/explainers/tests/utils.py
imports: import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: predict_fcn(predict_type, clf, preproc) and returns: predict_fn