code: def calc_cv_score(config, data=None, n_folds=5, is_loo=False):
      config = parse_config(config)
  
      if data is None:
          data = read_data_by_config(config)
  
      config, dirs_for_saved_models = change_savepath_for_model(config)
  
      cv_score = OrderedDict()
      for data_i in generate_train_valid(
          data, n_folds=n_folds, is_loo=is_loo
      ):
          iterator = get_iterator_from_config(config, data_i)
          create_dirs_to_save_models(dirs_for_saved_models)
          score = train_evaluate_model_from_config(
              config, iterator=iterator
          )
          delete_dir_for_saved_models(dirs_for_saved_models)
          for key, value in score["valid"].items():
              if key not in cv_score:
                  cv_score[key] = []
              cv_score[key].append(value)
  
      for key, value in cv_score.items():
          cv_score[key] = np.mean(value)
          log.info(
              'Cross-Validation "{}" is: {}'.format(key, cv_score[key])
          )
  
      return cv_score
  
file_path: DeepPavlov/deeppavlov/core/common/cross_validation.py
imports: import shutil
  from collections import OrderedDict
  from logging import getLogger
  from pathlib import Path
  import numpy
  from sklearn.model_selection import KFold
  from deeppavlov.core.commands.train import train_evaluate_model_from_config, get_iterator_from_config, read_data_by_config
  from deeppavlov.core.commands.utils import expand_path, parse_config
  from deeppavlov.core.common.params_search import ParamsSearch
label_desc: Use image node_id 5 for calling a global function with example usage: calc_cv_score(config, data, n_folds, is_loo) and returns: cv_score