code: def _test_individuals_in_history(history: OptHistory):
      uids = set()
      ids = set()
      for ind in chain(*history.individuals):
          # All individuals in `history.individuals` must have a native generation.
          assert ind.has_native_generation
          assert ind.fitness
          if ind.native_generation == 0:
              continue
          # All individuals must have parents, except for the initial assumptions.
          assert ind.parents
          assert ind.parents_from_prev_generation
          # The first of `operators_from_prev_generation` must point to `parents_from_prev_generation`.
          assert ind.parents_from_prev_generation == list(
              ind.operators_from_prev_generation[0].parent_individuals
          )
          # All parents are from previous generations
          assert all(
              p.native_generation < ind.native_generation
              for p in ind.parents_from_prev_generation
          )
  
          uids.add(ind.uid)
          ids.add(id(ind))
          for parent_operator in ind.operators_from_prev_generation:
              uids.update(
                  {i.uid for i in parent_operator.parent_individuals}
              )
              ids.update(
                  {id(i) for i in parent_operator.parent_individuals}
              )
  
      assert len(uids) == len(ids)
  
imports: from itertools import chain
  from pathlib import Path
  import numpy
  import pytest
  from golem.core.dag.graph import Graph
  from golem.core.optimisers.fitness import SingleObjFitness
  from golem.core.optimisers.genetic.evaluation import MultiprocessingDispatcher
  from golem.core.optimisers.opt_history_objects.individual import Individual
  from golem.core.optimisers.opt_history_objects.opt_history import OptHistory
  from fedot import Fedot
  from fedot.core.data.data import InputData
  from fedot.core.operations.model import Model
  from fedot.core.optimisers.objective import PipelineObjectiveEvaluate
  from fedot.core.optimisers.objective.data_source_splitter import DataSourceSplitter
  from fedot.core.optimisers.objective.metrics_objective import MetricsObjective
  from fedot.core.pipelines.node import PipelineNode
  from fedot.core.pipelines.pipeline import Pipeline
  from fedot.core.pipelines.pipeline_graph_generation_params import get_pipeline_generation_params
  from fedot.core.repository.metrics_repository import ClassificationMetricsEnum, MetricIDType, RegressionMetricsEnum
  from fedot.core.repository.tasks import TaskTypesEnum
  from fedot.core.utils import fedot_project_root
  from test.unit.tasks.test_forecasting import get_ts_data
  from test.unit.validation.test_table_cv import get_classification_data
label_desc: Use image node_id 3 for calling a global function with example usage: _test_individuals_in_history(history) without return types