code: def infer_problem_type_by_eval_metric(
      eval_metric_name: str, problem_type: str
  ):
      if eval_metric_name is not None and eval_metric_name.lower() in [
          "rmse",
          "r2",
          "pearsonr",
          "spearmanr",
      ]:
          if problem_type is None:
              logger.debug(
                  f"Infer problem type to be a regression problem "
                  f"since the evaluation metric is set as {eval_metric_name}."
              )
              problem_type = REGRESSION
          else:
              problem_prop = PROBLEM_TYPES_REG.get(problem_type)
              if NUMERICAL not in problem_prop.supported_label_type:
                  raise ValueError(
                      f"The provided evaluation metric will require the problem "
                      f"to support label type = {NUMERICAL}. However, "
                      f"the provided problem type = {problem_type} only "
                      f"supports label type = {problem_prop.supported_label_type}."
                  )
  
      return problem_type
  
imports: import logging
  import math
  import operator
  import warnings
  from typing import Dict, List, Optional, Tuple, Union
  import evaluate
  import numpy
  from sklearn.metrics import f1_score
  from autogluon.core.metrics import Scorer, get_metric
  from ..constants import ACCURACY, AVERAGE_PRECISION, BINARY, DIRECT_LOSS, F1, FEW_SHOT_CLASSIFICATION, IOU, MAP, MATCHING_METRICS, MATCHING_METRICS_WITHOUT_PROBLEM_TYPE, MAX, METRIC_MODE_MAP, MIN, MULTICLASS, NDCG, NER, NER_TOKEN_F1, NUMERICAL, OBJECT_DETECTION, OPEN_VOCABULARY_OBJECT_DETECTION, OVERALL_ACCURACY, OVERALL_F1, PRECISION, RECALL, REGRESSION, RETRIEVAL_METRICS, RMSE, ROC_AUC, SEMANTIC_SEGMENTATION, SPEARMANR, Y_PRED, Y_PRED_PROB, Y_TRUE
  from ..problem_types import PROBLEM_TYPES_REG
label_desc: Use image node_id 6 for calling a global function with example usage: infer_problem_type_by_eval_metric(eval_metric_name, problem_type) and returns: problem_type