code: def compare_metrics_with_diff(
      custom_metric, fit_eval, calc_eval, eps=1e-7
  ):
      csv_fit = csv.reader(open(fit_eval, "r"), dialect="excel-tab")
      csv_calc = csv.reader(open(calc_eval, "r"), dialect="excel-tab")
  
      head_fit = next(csv_fit)
      head_calc = next(csv_calc)
  
      if isinstance(custom_metric, str):
          custom_metric = [custom_metric]
  
      for metric_name in deepcopy(custom_metric):
          if metric_name in BY_CLASS_METRICS:
              custom_metric.remove(metric_name)
  
              for fit_metric_name in head_fit:
                  if fit_metric_name[: len(metric_name)] == metric_name:
                      custom_metric.append(fit_metric_name)
  
      col_idx_fit = {}
      col_idx_calc = {}
  
      for metric_name in custom_metric:
          col_idx_fit[metric_name] = head_fit.index(metric_name)
          col_idx_calc[metric_name] = head_calc.index(metric_name)
  
      while True:
          try:
              line_fit = next(csv_fit)
              line_calc = next(csv_calc)
              for metric_name in custom_metric:
                  fit_value = float(line_fit[col_idx_fit[metric_name]])
                  calc_value = float(
                      line_calc[col_idx_calc[metric_name]]
                  )
                  max_abs = max(abs(fit_value), abs(calc_value))
                  err = (
                      abs(fit_value - calc_value) / max_abs
                      if max_abs > 0
                      else 0
                  )
                  if err > eps:
                      raise Exception(
                          "{}, iter {}: fit vs calc = {} vs {}, err = {} > eps = {}".format(
                              metric_name,
                              line_fit[0],
                              fit_value,
                              calc_value,
                              err,
                              eps,
                          )
                      )
          except StopIteration:
              break
  
imports: import collections
  import csv
  import json
  import os
  import random
  import shutil
  import sys
  from pandas import read_csv, DataFrame
  from copy import deepcopy
  import numpy
  from catboost.utils import read_cd
label_desc: Use image node_id 8 for calling a global function with example usage: compare_metrics_with_diff(custom_metric, fit_eval, calc_eval, eps) without return types