code: def _str2metric(metric):
      # map metric str to function
      if isinstance(metric, str):
          metric_name = metric
          from bigdl.chronos.metric.forecast_metrics import (
              REGRESSION_MAP,
          )
  
          metric_func = REGRESSION_MAP[metric_name]
  
          def metric(y_label, y_predict):
              y_label = y_label.numpy()
              y_predict = y_predict.numpy()
              return metric_func(y_label, y_predict)
  
          metric.__name__ = metric_name
      return metric
  
imports: import warnings
  import keras
  import tensorflow
  import numpy
  from bigdl.chronos.forecaster.abstract import Forecaster
  from bigdl.chronos.data import TSDataset
  from bigdl.chronos.metric.forecast_metrics import Evaluator
  from bigdl.nano.utils.common import invalidInputError
  from bigdl.chronos.forecaster.tf.utils import np_to_data_creator, tsdata_to_data_creator, np_to_xshards, xshard_to_np, np_to_tfdataset
label_desc: Use image node_id 1 for calling a global function with example usage: _str2metric(metric) and returns: metric, metric_func