code: def test_api_tune_correct(task_type, metric_name, pred_model):
      tuning_timeout = 0.2
  
      if task_type == "ts_forecasting":
          forecast_length = 1
          train_data, test_data, _ = get_dataset(
              task_type,
              validation_blocks=1,
              forecast_length=forecast_length,
          )
          model = Fedot(
              problem=task_type,
              task_params=TsForecastingParams(
                  forecast_length=forecast_length
              ),
          )
      else:
          train_data, test_data, _ = get_dataset(
              task_type,
              n_samples=100,
              n_features=10,
              iris_dataset=False,
          )
          model = Fedot(problem=task_type)
  
      base_pipeline = deepcopy(
          model.fit(features=train_data, predefined_model=pred_model)
      )
      pred_before = model.predict(features=test_data)
  
      tuned_pipeline = deepcopy(model.tune(timeout=tuning_timeout))
      pred_after = model.predict(features=test_data)
  
      assert isinstance(tuned_pipeline, Pipeline)
      assert graph_structure(base_pipeline) != graph_structure(
          tuned_pipeline
      )
      assert model.api_composer.was_tuned
      assert not model.api_composer.was_optimised
      assert (
          len(test_data.target) == len(pred_before) == len(pred_after)
      )
  
imports: import os
  import shutil
  from copy import deepcopy
  import numpy
  import pandas
  import pytest
  from golem.core.dag.graph_utils import graph_structure
  from sklearn.datasets import load_iris
  from sklearn.preprocessing import LabelEncoder
  from examples.simple.time_series_forecasting.ts_pipelines import ts_complex_ridge_smoothing_pipeline
  from fedot import Fedot
  from fedot.core.pipelines.node import PipelineNode
  from fedot.core.pipelines.pipeline import Pipeline
  from fedot.core.repository.tasks import TsForecastingParams
  from test.data.datasets import get_dataset, get_multimodal_ts_data, load_categorical_unimodal, load_categorical_multidata
  from test.unit.common_tests import is_predict_ignores_target
  from test.unit.tasks.test_multi_ts_forecast import get_multi_ts_data
label_desc: Use image node_id 2 for calling a global function with example usage: test_api_tune_correct(task_type, metric_name, pred_model) without return types