class_docstr: Example:
      >>> auto_est = AutoEstimator.from_torch(model_creator=model_creator,
                                              optimizer=get_optimizer,
                                              loss=nn.BCELoss(),
                                              logs_dir="/tmp/zoo_automl_logs",
                                              resources_per_trial={"cpu": 2},
                                              name="test_fit")
      >>> auto_est.fit(data=data,
                       validation_data=validation_data,
                       search_space=create_linear_search_space(),
                       n_sampling=4,
                       epochs=1,
                       metric="accuracy")
      >>> best_model = auto_est.get_best_model()
class_docstr_tok: ["Example",":",">",">",">","auto_est","=","AutoEstimator.from_torch","(","model_creator=model_creator",",","optimizer=get_optimizer",",","loss=nn.BCELoss","(",")",",","logs_dir=","''","\/tmp\/zoo_automl_logs","''",",","resources_per_trial=","{","``","cpu","''",":","2","}",",","name=","''","test_fit","''",")",">",">",">","auto_est.fit","(","data=data",",","validation_data=validation_data",",","search_space=create_linear_search_space","(",")",",","n_sampling=4",",","epochs=1",",","metric=","''","accuracy","''",")",">",">",">","best_model","=","auto_est.get_best_model","(",")"]
code: def _validate_metric_mode(
      metric: Optional[Union[Callable, str]], mode: Optional[str]
  ) -> Optional[str]:
      if not mode:
          if callable(metric):
              invalidInputError(
                  False,
                  "You must specify `metric_mode` for your metric function",
              )
          try:
              from bigdl.orca.automl.metrics import Evaluator
  
              mode = Evaluator.get_metric_mode(metric)
          except ValueError:
              pass
          if not mode:
              invalidInputError(
                  False,
                  f"We cannot infer metric mode with metric name of {metric}."
                  f" Please specify the `metric_mode` parameter in"
                  f" AutoEstimator.fit().",
              )
      if mode not in ["min", "max"]:
          invalidInputError(
              False, "`mode` has to be one of ['min', 'max']"
          )
      return mode
  
file_path: BigDL/python/orca/src/bigdl/orca/automl/auto_estimator.py
imports: from bigdl.orca.automl.search import SearchEngineFactory
  from bigdl.dllib.utils.log4Error import *
  from bigdl.dllib.utils.log4Error import invalidInputError
  from numpy import ndarray
  from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Tuple, Union, Any
label_desc: Use image node_id 8 for calling the AutoEstimator obj's underlying member method code with example usage: obj._validate_metric_mode(metric, mode) and returns: mode