code: def test_regression_task_input(linear_reg_model, random_reg_dataset):
      """
      Regression task explainer works when `Y_train` is a ``np.ndarray``. Doesn't work when `Y_train`
      is ``None``.
      """
  
      backend, model, loss_fn, target_fn = linear_reg_model
      (X_train, Y_train), (_, _) = random_reg_dataset
      regression_explainer = GradientSimilarity(
          predictor=model,
          loss_fn=loss_fn,
          sim_fn="grad_dot",
          task="regression",
          precompute_grads=False,
          backend=backend,
      )
  
      # classification similarity method y value cannot be none
      regression_explainer.fit(X_train=X_train, Y_train=Y_train)
      with pytest.raises(ValueError) as err:
          regression_explainer.explain(X_train[0])
      assert "Regression task requires a target value." in str(
          err.value
      )
  
      regression_explainer.explain(X_train[0], Y_train)
  
file_path: alibi/alibi/explainers/tests/test_simiarlity/test_grad_methods_unit.py
imports: import pytest
  from alibi.explainers.tests.test_simiarlity.conftest import get_flattened_model_parameters
  from alibi.explainers.similarity.grad import GradientSimilarity, Task
  from alibi.utils import _get_options_string
label_desc: Use image node_id 6 for calling a global function with example usage: test_regression_task_input(linear_reg_model, random_reg_dataset) without return types