class_docstr: Evaluator of Objective that requires train and test data for metric evaluation.
  Its role is to prepare graph on train-data and then evaluate metrics on test data.
  
  :param objective: Objective for evaluating metrics on pipelines.
  :param data_producer: Producer of data folds, each fold is a tuple of (train_data, test_data).
  If it returns a single fold, it's effectively a hold-out validation. For many folds it's k-folds.
  :param time_constraint: Optional time constraint for pipeline.fit.
  :param validation_blocks: Number of validation blocks, optional, used only for time series validation.
  :param pipelines_cache: Cache manager for fitted models, optional.
  :param preprocessing_cache: Cache manager for optional preprocessing encoders and imputers, optional.
  :param eval_n_jobs: number of jobs used to evaluate the objective.
  :params do_unfit: unfit graph after evaluation
class_docstr_tok: ["Evaluator","of","Objective","that","requires","train","and","test","data","for","metric","evaluation",".","Its","role","is","to","prepare","graph","on","train-data","and","then","evaluate","metrics","on","test","data",".",":","param","objective",":","Objective","for","evaluating","metrics","on","pipelines",".",":","param","data_producer",":","Producer","of","data","folds",",","each","fold","is","a","tuple","of","(","train_data",",","test_data",")",".","If","it","returns","a","single","fold",",","it","'s","effectively","a","hold-out","validation",".","For","many","folds","it","'s","k-folds",".",":","param","time_constraint",":","Optional","time","constraint","for","pipeline.fit",".",":","param","validation_blocks",":","Number","of","validation","blocks",",","optional",",","used","only","for","time","series","validation",".",":","param","pipelines_cache",":","Cache","manager","for","fitted","models",",","optional",".",":","param","preprocessing_cache",":","Cache","manager","for","optional","preprocessing","encoders","and","imputers",",","optional",".",":","param","eval_n_jobs",":","number","of","jobs","used","to","evaluate","the","objective",".",":","params","do_unfit",":","unfit","graph","after","evaluation"]
docstr: Evaluate intermediate metrics
docstr_tok: ["Evaluate","intermediate","metrics"]
code: def evaluate_intermediate_metrics(self, graph: Pipeline):
      """Evaluate intermediate metrics"""
      # Get the last fold
      last_fold = None
      fold_id = None
      for fold_id, last_fold in enumerate(self._data_producer()):
          pass
      # And so test only on the last fold
      train_data, test_data = last_fold
      graph.try_load_from_cache(
          self._pipelines_cache, self._preprocessing_cache, fold_id
      )
      for node in graph.nodes:
          if not isinstance(node.operation, Model):
              continue
          intermediate_graph = Pipeline(
              node,
              use_input_preprocessing=graph.use_input_preprocessing,
          )
          intermediate_graph.fit(
              train_data,
              time_constraint=self._time_constraint,
              n_jobs=self._eval_n_jobs,
          )
          intermediate_fitness = self._objective(
              intermediate_graph,
              reference_data=test_data,
              validation_blocks=self._validation_blocks,
          )
          # saving only the most important first metric
          node.metadata.metric = intermediate_fitness.values[0]
  
imports: import traceback
  from datetime import timedelta
  from typing import Callable, Iterable, Optional, Tuple
  import numpy
  from golem.core.log import default_log, is_test_session
  from golem.core.optimisers.fitness import Fitness
  from golem.core.optimisers.objective.objective import Objective, to_fitness
  from golem.core.optimisers.objective.objective_eval import ObjectiveEvaluate
  from fedot.core.caching.pipelines_cache import OperationsCache
  from fedot.core.caching.preprocessing_cache import PreprocessingCache
  from fedot.core.data.data import InputData
  from fedot.core.operations.model import Model
  from fedot.core.pipelines.pipeline import Pipeline
  from fedot.utilities.debug import is_recording_mode, save_debug_info_for_pipeline
label_desc: Use image node_id 4 for calling the PipelineObjectiveEvaluate obj's underlying member method code with example usage: obj.evaluate_intermediate_metrics(graph) without return types