code: def get_condition_class_performance_imbalance_ratio_less_than(
      threshold: float, score: str
  ) -> t.Callable[[pd.DataFrame], ConditionResult]:
      """Add condition - relative ratio difference between highest-class and lowest-class is less than threshold.
  
      Parameters
      ----------
      threshold : float
          ratio difference threshold
      score : str
          limit score for condition
  
      Returns
      -------
      Callable
          the condition function
      """
  
      def condition(check_result: pd.DataFrame) -> ConditionResult:
          if score not in set(check_result["Metric"]):
              raise DeepchecksValueError(
                  f"Data was not calculated using the scoring function: {score}"
              )
  
          condition_passed = True
          datasets_details = []
          for dataset in ["Test", "Train"]:
              data = check_result.loc[
                  (check_result["Dataset"] == dataset)
                  & (check_result["Metric"] == score)
              ]
  
              min_value_index = data["Value"].idxmin()
              min_row = data.loc[min_value_index]
              min_class_name = min_row.get(
                  "Class Name", min_row["Class"]
              )
              min_value = min_row["Value"]
  
              max_value_index = data["Value"].idxmax()
              max_row = data.loc[max_value_index]
              max_class_name = max_row.get(
                  "Class Name", max_row["Class"]
              )
              max_value = max_row["Value"]
  
              relative_difference = abs(
                  (min_value - max_value) / max_value
              )
              condition_passed &= relative_difference < threshold
  
              details = (
                  f"Relative ratio difference between highest and lowest in {dataset} dataset "
                  f"classes is {format_percent(relative_difference)}, using {score} metric. "
                  f"Lowest class - {min_class_name}: {format_number(min_value)}; "
                  f"Highest class - {max_class_name}: {format_number(max_value)}"
              )
              datasets_details.append(details)
  
          category = (
              ConditionCategory.PASS
              if condition_passed
              else ConditionCategory.FAIL
          )
          return ConditionResult(
              category, details="\n".join(datasets_details)
          )
  
      return condition
  
file_path: deepchecks/deepchecks/core/check_utils/class_performance_utils.py
imports: import typing
  import numpy
  import pandas
  from deepchecks.core import ConditionResult
  from deepchecks.core.condition import ConditionCategory
  from deepchecks.core.errors import DeepchecksValueError
  from deepchecks.utils.dict_funcs import get_dict_entry_by_value
  from deepchecks.utils.strings import format_number, format_percent
label_desc: Use image node_id 3 for calling a global function with example usage: get_condition_class_performance_imbalance_ratio_less_than(threshold, score) and returns: condition, ConditionResult