code: def test_snapshot_given(
      storage_mode: str, capsys: _pytest.capture.CaptureFixture
  ) -> None:
      with StorageSupplier(storage_mode) as storage:
          assert isinstance(storage, JournalStorage)
          replay_result = JournalStorageReplayResult("")
          # Bytes object which is a valid pickled object.
          storage.restore_replay_result(pickle.dumps(replay_result))
          assert (
              replay_result.log_number_read
              == storage._replay_result.log_number_read
          )
  
          # We need to reconstruct our default handler to properly capture stderr.
          optuna.logging._reset_library_root_logger()
          optuna.logging.enable_default_handler()
          optuna.logging.set_verbosity(optuna.logging.WARNING)
  
          # Bytes object which cannot be unpickled is passed.
          storage.restore_replay_result(b"hoge")
          _, err = capsys.readouterr()
          assert err
  
          # Bytes object which can be pickled but is not `JournalStorageReplayResult`.
          storage.restore_replay_result(pickle.dumps("hoge"))
          _, err = capsys.readouterr()
          assert err
  
imports: from concurrent.futures import as_completed
  from concurrent.futures import ProcessPoolExecutor
  from concurrent.futures import ThreadPoolExecutor
  import pickle
  from types import TracebackType
  from typing import Any
  from typing import IO
  from typing import Optional
  from typing import Type
  from unittest import mock
  import _pytest.capture
  from fakeredis import FakeStrictRedis
  import pytest
  import optuna
  from optuna import create_study
  from optuna.storages import JournalStorage
  from optuna.storages._journal.base import BaseJournalLogSnapshot
  from optuna.storages._journal.file import JournalFileBaseLock
  from optuna.storages._journal.storage import JournalStorageReplayResult
  from optuna.testing.storages import StorageSupplier
  from optuna.testing.tempfile_pool import NamedTemporaryFilePool
label_desc: Use image node_id 8 for calling a global function with example usage: test_snapshot_given(storage_mode, capsys) without return types