def METHOD_NAME(study: "optuna.Study", trial: Union[trial_module.Trial, int]) -> FrozenTrial:
    if isinstance(trial, trial_module.Trial):
        trial_id = trial._trial_id
    elif isinstance(trial, int):
        trial_number = trial
        try:
            trial_id = study._storage.get_trial_id_from_study_id_trial_number(
                study._study_id, trial_number
            )
        except KeyError as e:
            raise ValueError(
                f"Cannot tell for trial with number {trial_number} since it has not been "
                "created."
            ) from e
    else:
        raise TypeError("Trial must be a trial object or trial number.")
    return study._storage.get_trial(trial_id)