code: def test_input_invariance(
      model,
      data: np.ndarray,
      params: dict,
      expected: Union[float, dict, bool],
  ):
      x_batch, y_batch = (
          data["x_batch"],
          data["y_batch"],
      )
  
      init_params = params.get("init", {})
      call_params = params.get("call", {})
  
      if params.get("a_batch_generate", True):
          explain = call_params["explain_func"]
          explain_func_kwargs = call_params.get(
              "explain_func_kwargs", {}
          )
          a_batch = explain(
              model=model,
              inputs=x_batch,
              targets=y_batch,
              **explain_func_kwargs,
          )
      elif "a_batch" in data:
          a_batch = data["a_batch"]
      else:
          a_batch = None
  
      scores = InputInvariance(**init_params)(
          model=model,
          x_batch=x_batch,
          y_batch=y_batch,
          a_batch=a_batch,
          **call_params,
      )
  
      assert np.all(
          [s in expected["dtypes"] for s in scores]
      ), "Test failed."
  
file_path: Quantus/tests/metrics/test_axiomatic_metrics.py
imports: from typing import Union
  import pytest
  from pytest_lazyfixture import lazy_fixture
  import numpy
  from quantus.functions.explanation_func import explain
  from quantus.metrics.axiomatic import Completeness, InputInvariance, NonSensitivity
label_desc: Use image node_id 3 for calling a global function with example usage: test_input_invariance(model, data, params, expected) without return types