class_docstr: A Minin object to add hpo related methods to models.
  
  It is used to add hpo related search methods onto
  tf.keras.Sequential, tf.keras.Model, as well as custom
      model subclassing from tf.keras.Model.
class_docstr_tok: ["A","Minin","object","to","add","hpo","related","methods","to","models",".","It","is","used","to","add","hpo","related","search","methods","onto","tf.keras.Sequential",",","tf.keras.Model",",","as","well","as","custom","model","subclassing","from","tf.keras.Model","."]
code: def _fix_target_metric(self, target_metric, fit_kwargs):
      compile_metrics = self.compile_kwargs.get("metrics", None)
      if target_metric is None:
          if fit_kwargs.get("validation_data", None) or fit_kwargs.get(
              "validation_split", None
          ):
              # if validation data or split is provided
              # use validation metrics
              prefix = "val_"
          else:
              prefix = ""
  
          if compile_metrics is None:
              target_metric = prefix + "loss"
          elif isinstance(compile_metrics, list):
              target_metric = prefix + str(compile_metrics[0])
          else:
              target_metric = prefix + str(compile_metrics)
      elif isinstance(target_metric, list):
          invalidInputError(
              False, "multiple objective metric is not supported."
          )
      else:
          stripped_target_metric = _strip_val_prefix(target_metric)
          if compile_metrics is None:
              if stripped_target_metric not in ["loss", "val_loss"]:
                  invalidInputError(
                      False,
                      "target metric is should be loss or val_loss"
                      " if metrics is not provided in compile",
                  )
          elif isinstance(compile_metrics, list):
              target_not_in = stripped_target_metric not in [
                  "loss",
                  "val_loss",
              ]
              if (
                  stripped_target_metric not in compile_metrics
                  and target_not_in
              ):
                  invalidInputError(False, "invalid target metric")
          else:
              target_not_in = stripped_target_metric not in [
                  "loss",
                  "val_loss",
              ]
              if (
                  stripped_target_metric != compile_metrics
                  and target_not_in
              ):
                  invalidInputError(False, "invalid target metric")
      return target_metric
  
imports: import copy
  import warnings
  from .objective import Objective
  from bigdl.nano.automl.hpo.backend import create_hpo_backend
  from bigdl.nano.automl.hpo.search import _search_summary, _end_search, _create_study, _validate_args, _strip_val_prefix, _prepare_args
  from bigdl.nano.automl.hpo.space import AutoObject
  from bigdl.nano.utils.common import invalidInputError
  from bigdl.nano.automl.utils.parallel import run_parallel
  import math
label_desc: Use image node_id 2 for calling the HPOMixin obj's underlying member method code with example usage: obj._fix_target_metric(target_metric, fit_kwargs) and returns: target_metric