code: def create_trial(
      *,
      state: TrialState = TrialState.COMPLETE,
      value: Optional[float] = None,
      values: Optional[Sequence[float]] = None,
      params: Optional[Dict[str, Any]] = None,
      distributions: Optional[Dict[str, BaseDistribution]] = None,
      user_attrs: Optional[Dict[str, Any]] = None,
      system_attrs: Optional[Dict[str, Any]] = None,
      intermediate_values: Optional[Dict[int, float]] = None,
  ) -> FrozenTrial:
      """Create a new :class:`~optuna.trial.FrozenTrial`.
  
      Example:
  
          .. testcode::
  
              import optuna
              from optuna.distributions import CategoricalDistribution
              from optuna.distributions import FloatDistribution
  
              trial = optuna.trial.create_trial(
                  params={"x": 1.0, "y": 0},
                  distributions={
                      "x": FloatDistribution(0, 10),
                      "y": CategoricalDistribution([-1, 0, 1]),
                  },
                  value=5.0,
              )
  
              assert isinstance(trial, optuna.trial.FrozenTrial)
              assert trial.value == 5.0
              assert trial.params == {"x": 1.0, "y": 0}
  
      .. seealso::
  
          See :func:`~optuna.study.Study.add_trial` for how this function can be used to create a
          study from existing trials.
  
      .. note::
  
          Please note that this is a low-level API. In general, trials that are passed to objective
          functions are created inside :func:`~optuna.study.Study.optimize`.
  
      .. note::
          When ``state`` is :class:`TrialState.COMPLETE`, the following parameters are
          required:
  
          * ``params``
          * ``distributions``
          * ``value`` or ``values``
  
      Args:
          state:
              Trial state.
          value:
              Trial objective value. Must be specified if ``state`` is :class:`TrialState.COMPLETE`.
              ``value`` and ``values`` must not be specified at the same time.
          values:
              Sequence of the trial objective values. The length is greater than 1 if the problem is
              multi-objective optimization.
              Must be specified if ``state`` is :class:`TrialState.COMPLETE`.
              ``value`` and ``values`` must not be specified at the same time.
          params:
              Dictionary with suggested parameters of the trial.
          distributions:
              Dictionary with parameter distributions of the trial.
          user_attrs:
              Dictionary with user attributes.
          system_attrs:
              Dictionary with system attributes. Should not have to be used for most users.
          intermediate_values:
              Dictionary with intermediate objective values of the trial.
  
      Returns:
          Created trial.
      """
  
      params = params or {}
      distributions = distributions or {}
      distributions = {
          key: _convert_old_distribution_to_new_distribution(dist)
          for key, dist in distributions.items()
      }
      user_attrs = user_attrs or {}
      system_attrs = system_attrs or {}
      intermediate_values = intermediate_values or {}
  
      if state == TrialState.WAITING:
          datetime_start = None
      else:
          datetime_start = datetime.datetime.now()
  
      if state.is_finished():
          datetime_complete: Optional[
              datetime.datetime
          ] = datetime_start
      else:
          datetime_complete = None
  
      trial = FrozenTrial(
          number=-1,
          trial_id=-1,
          state=state,
          value=value,
          values=values,
          datetime_start=datetime_start,
          datetime_complete=datetime_complete,
          params=params,
          distributions=distributions,
          user_attrs=user_attrs,
          system_attrs=system_attrs,
          intermediate_values=intermediate_values,
      )
  
      trial._validate()
  
      return trial
  
imports: import datetime
  from typing import Any
  from typing import cast
  from typing import Dict
  from typing import List
  from typing import Mapping
  from typing import Optional
  from typing import overload
  from typing import Sequence
  import warnings
  from optuna import distributions
  from optuna import logging
  from optuna._convert_positional_args import convert_positional_args
  from optuna._deprecated import deprecated_func
  from optuna._typing import JSONSerializable
  from optuna.distributions import _convert_old_distribution_to_new_distribution
  from optuna.distributions import BaseDistribution
  from optuna.distributions import CategoricalChoiceType
  from optuna.distributions import CategoricalDistribution
  from optuna.distributions import FloatDistribution
  from optuna.distributions import IntDistribution
  from optuna.trial._base import _SUGGEST_INT_POSITIONAL_ARGS
  from optuna.trial._base import BaseTrial
  from optuna.trial._state import TrialState
label_desc: Use image node_id 1 for calling a global function with example usage: create_trial() and returns: trial