code: def test_suggest_categorical(trial_type: type) -> None:
      # Integer categories.
      trial = _create_trial(
          trial_type=trial_type,
          params={"x": 1},
          distributions={"x": CategoricalDistribution((0, 1, 2, 3))},
      )
      assert trial.suggest_categorical("x", (0, 1, 2, 3)) == 1
  
      with pytest.raises(ValueError):
          trial.suggest_categorical("y", [0, 1, 2, 3])
  
      # String categories.
      trial = _create_trial(
          trial_type=trial_type,
          params={"x": "baz"},
          distributions={
              "x": CategoricalDistribution(("foo", "bar", "baz"))
          },
      )
      assert (
          trial.suggest_categorical("x", ("foo", "bar", "baz")) == "baz"
      )
  
      # Unknown parameter.
      with pytest.raises(ValueError):
          trial.suggest_categorical("y", ["foo", "bar", "baz"])
  
      # Not in choices.
      with pytest.raises(ValueError):
          trial.suggest_categorical("x", ["foo", "bar"])
  
      # Unknown parameter and bad category type.
      with pytest.warns(UserWarning):
          with pytest.raises(
              ValueError
          ):  # Must come after `pytest.warns` to catch failures.
              trial.suggest_categorical("x", [{"foo": "bar"}])
  
imports: import datetime
  import time
  from typing import Any
  from typing import Dict
  from typing import Optional
  import pytest
  from optuna.distributions import BaseDistribution
  from optuna.distributions import CategoricalDistribution
  from optuna.distributions import FloatDistribution
  from optuna.distributions import IntDistribution
  from optuna.study.study import create_study
  from optuna.trial import BaseTrial
  from optuna.trial import create_trial
  from optuna.trial import FixedTrial
  from optuna.trial import FrozenTrial
  from optuna.trial import Trial
label_desc: Use image node_id 7 for calling a global function with example usage: test_suggest_categorical(trial_type) without return types