code: def test_load_from_checkpoint_device_placement_with_extra_state(
      tmp_path,
  ):
      """Test that the device gets chosen based on the device of the saved tensors in the checkpoint."""
  
      class ExtraStateModel(BoringModel):
          def get_extra_state(self):
              return {"extra": "state"}  # state without tensors
  
          def set_extra_state(self, state):
              pass
  
      create_boring_checkpoint(
          tmp_path, ExtraStateModel(), accelerator="cuda"
      )
      model = ExtraStateModel.load_from_checkpoint(
          f"{tmp_path}/checkpoint.ckpt", map_location=None
      )
      assert model.device.type == "cuda"
  
file_path: pytorch-lightning/tests/tests_pytorch/core/test_saving.py
imports: import lightning.pytorch
  import pytest
  import torch
  from lightning.pytorch.callbacks import ModelCheckpoint
  from lightning.pytorch.demos.boring_classes import BoringDataModule, BoringModel
  from tests_pytorch.conftest import mock_cuda_count, mock_mps_count
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 7 for calling a global function with example usage: test_load_from_checkpoint_device_placement_with_extra_state(tmp_path) and returns: dict