code: def test_get_stale_trial_ids() -> None:
      storage_mode = "sqlite"
      heartbeat_interval = 1
      grace_period = 2
  
      with StorageSupplier(storage_mode) as storage:
          assert isinstance(storage, RDBStorage)
          storage.heartbeat_interval = heartbeat_interval
          storage.grace_period = grace_period
          study = optuna.create_study(storage=storage)
  
          with pytest.warns(UserWarning):
              trial = study.ask()
          storage.record_heartbeat(trial._trial_id)
          time.sleep(grace_period + 1)
          assert len(storage._get_stale_trial_ids(study._study_id)) == 1
          assert (
              storage._get_stale_trial_ids(study._study_id)[0]
              == trial._trial_id
          )
  
imports: import itertools
  import multiprocessing
  import time
  from typing import Any
  from typing import Optional
  from unittest.mock import Mock
  from unittest.mock import patch
  import warnings
  import pytest
  import optuna
  from optuna import Study
  from optuna._callbacks import RetryFailedTrialCallback
  from optuna.storages import RDBStorage
  from optuna.storages._heartbeat import BaseHeartbeat
  from optuna.storages._heartbeat import is_heartbeat_enabled
  from optuna.testing.storages import STORAGE_MODES_HEARTBEAT
  from optuna.testing.storages import StorageSupplier
  from optuna.testing.threading import _TestableThread
  from optuna.trial import FrozenTrial
  from optuna.trial import TrialState
label_desc: Use image node_id 9 for calling a global function with example usage: test_get_stale_trial_ids() without return types