code: def fit_naive_surrogate_model(
      black_box_model: "Pipeline",
      surrogate_model: "Pipeline",
      data: "InputData",
      metric: "Metric" = None,
  ) -> Optional[float]:
      output_mode = "default"
  
      if data.task.task_type == TaskTypesEnum.classification:
          output_mode = "labels"
          if metric is None:
              metric = F1
      elif (
          data.task.task_type == TaskTypesEnum.regression
          and metric is None
      ):
          metric = R2
  
      prediction = black_box_model.predict(
          data, output_mode=output_mode
      )
      data.target = prediction.predict
      surrogate_model.fit(data)
  
      data_c = deepcopy(data)
      data_c.target = surrogate_model.predict(
          data, output_mode=output_mode
      ).predict
      score = round(abs(metric.metric(data_c, prediction)), 2)
  
      return score
  
imports: import os
  from copy import deepcopy
  from inspect import signature
  from typing import Optional
  from matplotlib import pyplot
  from sklearn import tree
  from sklearn.tree._tree import TREE_LEAF
  from fedot.core.composer.metrics import Metric
  from fedot.core.composer.metrics import R2, F1
  from fedot.core.data.data import InputData
  from fedot.core.pipelines.node import PipelineNode
  from fedot.core.pipelines.pipeline import Pipeline
  from fedot.core.repository.tasks import TaskTypesEnum
  from fedot.explainability.explainer_template import Explainer
label_desc: Use image node_id 2 for calling a global function with example usage: fit_naive_surrogate_model(black_box_model, surrogate_model, data, metric) and returns: score