class_docstr: Callback to track Optuna trials with MLflow.
  
  This callback adds relevant information that is
  tracked by Optuna to MLflow.
  
  Example:
  
      Add MLflow callback to Optuna optimization.
  
      .. testsetup::
  
          import pathlib
          import tempfile
  
          tempdir = tempfile.mkdtemp()
          YOUR_TRACKING_URI = pathlib.Path(tempdir).as_uri()
  
      .. testcode::
  
          import optuna
          from optuna.integration.mlflow import MLflowCallback
  
  
          def objective(trial):
              x = trial.suggest_float("x", -10, 10)
              return (x - 2) ** 2
  
  
          mlflc = MLflowCallback(
              tracking_uri=YOUR_TRACKING_URI,
              metric_name="my metric score",
          )
  
          study = optuna.create_study(study_name="my_study")
          study.optimize(objective, n_trials=10, callbacks=[mlflc])
  
      .. testcleanup::
  
          import shutil
  
          shutil.rmtree(tempdir)
  
  Args:
      tracking_uri:
          The URI of the MLflow tracking server.
  
          Please refer to `mlflow.set_tracking_uri
          <https://www.mlflow.org/docs/latest/python_api/mlflow.html#mlflow.set_tracking_uri>`_
          for more details.
      metric_name:
          Name assigned to optimized metric. In case of multi-objective optimization,
          list of names can be passed. Those names will be assigned
          to metrics in the order returned by objective function.
          If single name is provided, or this argument is left to default value,
          it will be broadcasted to each objective with a number suffix in order
          returned by objective function e.g. two objectives and default metric name
          will be logged as ``value_0`` and ``value_1``. The number of metrics must be
          the same as the number of values an objective function returns.
      create_experiment:
          When :obj:`True`, new MLflow experiment will be created for each optimization run,
          named after the Optuna study. Setting this argument to :obj:`False` lets user run
          optimization under existing experiment, set via `mlflow.set_experiment
          <https://www.mlflow.org/docs/latest/python_api/mlflow.html#mlflow.get_tracking_uri>`_,
          by passing ``experiment_id`` as one of ``mlflow_kwargs`` or under default MLflow
          experiment, when no additional arguments are passed. Note that this argument
          must be set to :obj:`False` when using Optuna with this callback within
          Databricks Notebook.
      mlflow_kwargs:
          Set of arguments passed when initializing MLflow run.
          Please refer to `MLflow API documentation
          <https://www.mlflow.org/docs/latest/python_api/mlflow.html#mlflow.start_run>`_
          for more details.
  
              .. note::
                  ``nest_trials`` argument added in v2.3.0 is a part of ``mlflow_kwargs``
                  since v3.0.0. Anyone using ``nest_trials=True`` should migrate to
                  ``mlflow_kwargs={"nested": True}`` to avoid raising :exc:`TypeError`.
  
      tag_study_user_attrs:
          Flag indicating whether or not to add the study's user attrs
          to the mlflow trial as tags. Please note that when this flag is
          set, key value pairs in :attr:`~optuna.study.Study.user_attrs`
          will supersede existing tags.
      tag_trial_user_attrs:
          Flag indicating whether or not to add the trial's user attrs
          to the mlflow trial as tags. Please note that when both trial and
          study user attributes are logged, the latter will supersede the former
          in case of a collision.
code: def __call__(
      self, study: optuna.study.Study, trial: optuna.trial.FrozenTrial
  ) -> None:
      with self._lock:
          self._initialize_experiment(study)
  
          with mlflow.start_run(
              run_id=trial.system_attrs.get(RUN_ID_ATTRIBUTE_KEY),
              experiment_id=self._mlflow_kwargs.get("experiment_id"),
              run_name=self._mlflow_kwargs.get("run_name")
              or str(trial.number),
              nested=self._mlflow_kwargs.get("nested") or False,
              tags=self._mlflow_kwargs.get("tags"),
          ):
              # This sets the metrics for MLflow.
              self._log_metrics(trial.values)
  
              # This sets the params for MLflow.
              self._log_params(trial.params)
  
              # This sets the tags for MLflow.
              self._set_tags(trial, study)
  
imports: import functools
  import threading
  from typing import Any
  from typing import Callable
  from typing import Dict
  from typing import List
  from typing import Optional
  from typing import Sequence
  from typing import Union
  import optuna
  from optuna._experimental import experimental_class
  from optuna._experimental import experimental_func
  from optuna._imports import try_import
  from optuna.study.study import ObjectiveFuncType
label_desc: Use image node_id 2 for calling the MLflowCallback obj's underlying member method code with example usage: obj.__call__(study, trial) without return types