code: def get_gain(base_score, score, perfect_score, max_gain):
      """Get gain between base score and score compared to the distance from the perfect score."""
      distance_from_perfect = perfect_score - base_score
      scores_diff = score - base_score
      if distance_from_perfect == 0:
          # If both base score and score are perfect, return 0 gain
          if scores_diff == 0:
              return 0
          # else base_score is better than score, return -max_gain
          return -max_gain
      ratio = scores_diff / distance_from_perfect
      if ratio < -max_gain:
          return -max_gain
      if ratio > max_gain:
          return max_gain
      return ratio
  
file_path: deepchecks/deepchecks/utils/metrics.py
imports: from typing import Union
  import numpy
  import pandas
  from sklearn.metrics._scorer import _BaseScorer
  from deepchecks.core.errors import DeepchecksValueError
label_desc: Use image node_id 1 for calling a global function with example usage: get_gain(base_score, score, perfect_score, max_gain) and returns: ratio, unknown, unknown, max_gain, int