code: def to_bigdl_metric(metric, loss):
      metric = metric.lower()
      loss_str = (
          loss
          if isinstance(loss, six.string_types)
          else loss.__class__.__name__
      ).lower()
      if metric == "accuracy" or metric == "acc":
          if (
              loss_str == "sparse_categorical_crossentropy"
              or loss_str == "sparsecategoricalcrossentropy"
          ):
              return metrics.SparseCategoricalAccuracy()
          elif (
              loss_str == "categorical_crossentropy"
              or loss_str == "categoricalcrossentropy"
          ):
              return metrics.CategoricalAccuracy()
          elif (
              loss_str == "binary_crossentropy"
              or loss_str == "binarycrossentropy"
          ):
              return metrics.BinaryAccuracy()
          else:
              invalidInputError(
                  False,
                  "Not supported combination: metric {} and"
                  " loss {}".format(metric, loss_str),
              )
      elif metric == "top5accuracy" or metric == "top5acc":
          return metrics.Top5Accuracy()
      elif metric == "mae":
          return metrics.MAE()
      elif metric == "mse":
          return metrics.MSE()
      elif metric == "auc":
          return metrics.AUC()
      elif metric == "loss":
          return Loss(to_bigdl_criterion(loss_str))
      elif metric == "treennaccuracy":
          return TreeNNAccuracy()
      else:
          invalidInputError(False, "Unsupported metric: %s" % metric)
  
imports: from bigdl.dllib.optim.optimizer import *
  from bigdl.dllib.keras.objectives import *
  from bigdl.dllib.keras import metrics
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 3 for calling a global function with example usage: to_bigdl_metric(metric, loss) and returns: metrics, metrics, metrics, metrics, metrics, metrics, metrics, Loss, TreeNNAccuracy