docstr: Ensure provided `direction` is valid and inferred if necessary
  
  Parameters
  ----------
  direction: {"infer", "max", "min"}
      See `direction` documentation of :meth:`Metric.__init__`
  
  Returns
  -------
  String
      One of "min", or "max" depending on explicit `direction`/inference
docstr_tok: ["Ensure","provided","`","direction","`","is","valid","and","inferred","if","necessary","Parameters","--","--","--","--","--","direction",":","{","``","infer","''",",","``","max","''",",","``","min","''","}","See","`","direction","`","documentation","of",":","meth",":","`","Metric.__init__","`","Returns","--","--","--","-","String","One","of","``","min","''",",","or","``","max","''","depending","on","explicit","`","direction","`","\/inference"]
code: def _set_direction(self, direction):
      """Ensure provided `direction` is valid and inferred if necessary
  
      Parameters
      ----------
      direction: {"infer", "max", "min"}
          See `direction` documentation of :meth:`Metric.__init__`
  
      Returns
      -------
      String
          One of "min", or "max" depending on explicit `direction`/inference
      """
      if direction == "infer":
          # Check if `name` or `metric_function`'s name includes "error"/"loss"
          if any(_ in self.name for _ in ["error", "loss"]):
              return "min"
          if any(
              _ in self.metric_function.__name__
              for _ in ["error", "loss"]
          ):
              return "min"
          return "max"
      elif direction not in ["max", "min"]:
          raise ValueError(
              f"`direction` must be 'infer', 'max', or 'min', not {direction}"
          )
      return direction
  
imports: from collections import OrderedDict
  from contextlib import suppress
  import numpy
  import pandas
  from typing import Dict, Iterable, List, Tuple, Union
  from sklearn import metrics
  from sklearn.utils.multiclass import type_of_target, unique_labels
label_desc: Use image node_id 6 for calling the Metric obj's underlying member method code with example usage: obj._set_direction(direction) and returns: direction, str, str, str