code: def load_histories(history_dir, filename_filter=None):
      hs = []
      for obj in os.listdir(history_dir):
          fullpath = f"{history_dir}/{obj}"
          if not os.path.isfile(fullpath):
              continue
          if filename_filter and filename_filter not in str(obj):
              continue
          history = OptHistory.load(fullpath)
          hs.append(history)
      return hs
  
imports: import os
  from datetime import timedelta
  from typing import Sequence, Optional
  import numpy
  from matplotlib import pyplot
  from sklearn.metrics import roc_auc_score
  from fedot.core.composer.composer_builder import ComposerBuilder
  from fedot.core.data.data import InputData
  from golem.core.optimisers.genetic.gp_params import GPAlgorithmParameters
  from golem.core.optimisers.genetic.operators.crossover import CrossoverTypesEnum
  from golem.core.optimisers.genetic.operators.inheritance import GeneticSchemeTypesEnum
  from golem.core.optimisers.genetic.operators.mutation import MutationTypesEnum
  from golem.core.optimisers.opt_history_objects.opt_history import OptHistory
  from fedot.core.pipelines.pipeline_composer_requirements import PipelineComposerRequirements
  from fedot.core.repository.operation_types_repository import get_operations_for_task
  from fedot.core.repository.metrics_repository import ClassificationMetricsEnum
  from fedot.core.repository.tasks import Task, TaskTypesEnum
  from fedot.core.utils import fedot_project_root
label_desc: Use image node_id 2 for calling a global function with example usage: load_histories(history_dir, filename_filter) and returns: hs