code: def predict_fn(request):
      """
      This fixture takes in a white-box model (Tensorflow or Pytorch) and returns an
      AnchorImage compatible prediction function.
      """
      if isinstance(request.param[0], tf.keras.Model):
          func = request.param[0].predict
      elif isinstance(request.param[0], torch.nn.Module):
  
          def func(image: np.ndarray) -> np.ndarray:
              # moveaxis is needed as torch uses 'bchw' layout instead of 'bhwc'
              # NB: torch models need dtype=torch.float32, we are not setting it here
              # to test that `dtype` argument to AnchorImage does the right thing when
              # a dummy call is made
              image = torch.as_tensor(np.moveaxis(image, -1, 1))  # type: ignore
              return request.param[0].forward(image).detach().numpy()
  
      else:
          raise ValueError(
              f"Unknown model {request.param[0]} of type {type(request.param[0])}"
          )
      return func
  
file_path: alibi/alibi/explainers/tests/test_anchor_image.py
imports: import pytest
  from pytest_lazyfixture import lazy_fixture
  import numpy
  import tensorflow
  import torch
  from alibi.api.defaults import DEFAULT_META_ANCHOR, DEFAULT_DATA_ANCHOR_IMG
  from alibi.exceptions import PredictorCallError, PredictorReturnTypeError
  from alibi.explainers.anchors.anchor_image import AnchorImage, AnchorImageSampler, scale_image
label_desc: Use image node_id 2 for calling a global function with example usage: predict_fn(request) and returns: func, request