code: def test_log_hyperparams_key_collision(_, tmpdir):
      class TestModel(BoringModel):
          def __init__(self, hparams: Dict[str, Any]) -> None:
              super().__init__()
              self.save_hyperparameters(hparams)
  
      class TestDataModule(BoringDataModule):
          def __init__(self, hparams: Dict[str, Any]) -> None:
              super().__init__()
              self.save_hyperparameters(hparams)
  
      class _Test:
          ...
  
      same_params = {
          1: 1,
          "2": 2,
          "three": 3.0,
          "test": _Test(),
          "4": torch.tensor(4),
      }
      model = TestModel(same_params)
  
      trainer = Trainer(
          default_root_dir=tmpdir,
          logger=TensorBoardLogger(tmpdir),
          max_epochs=1,
          limit_train_batches=0.1,
          limit_val_batches=0.1,
          num_sanity_val_steps=0,
          enable_checkpointing=False,
          enable_progress_bar=False,
          enable_model_summary=False,
      )
      # there should be no exceptions raised for the same key/value pair in the hparams of both
      # the lightning module and data module
      trainer.fit(model)
  
      obj_params = deepcopy(same_params)
      obj_params["test"] = _Test()
      model = TestModel(same_params)
      trainer.fit(model)
  
      diff_params = deepcopy(same_params)
      diff_params.update({1: 0, "test": _Test()})
      model = TestModel(same_params)
      dm = TestDataModule(diff_params)
      trainer = Trainer(
          default_root_dir=tmpdir,
          logger=TensorBoardLogger(tmpdir),
          max_epochs=1,
          limit_train_batches=0.1,
          limit_val_batches=0.1,
          num_sanity_val_steps=0,
          enable_checkpointing=False,
          enable_progress_bar=False,
          enable_model_summary=False,
      )
      with pytest.raises(
          RuntimeError, match="Error while merging hparams"
      ):
          trainer.fit(model, dm)
  
      tensor_params = deepcopy(same_params)
      tensor_params.update({"4": torch.tensor(3)})
      model = TestModel(same_params)
      dm = TestDataModule(tensor_params)
      trainer = Trainer(
          default_root_dir=tmpdir,
          logger=TensorBoardLogger(tmpdir),
          max_epochs=1,
          limit_train_batches=0.1,
          limit_val_batches=0.1,
          num_sanity_val_steps=0,
          enable_checkpointing=False,
          enable_progress_bar=False,
          enable_model_summary=False,
      )
      with pytest.raises(
          RuntimeError, match="Error while merging hparams"
      ):
          trainer.fit(model, dm)
  
imports: import pickle
  from argparse import Namespace
  from copy import deepcopy
  from typing import Any, Dict, Optional
  from unittest.mock import patch
  import numpy
  import pytest
  import torch
  from lightning.fabric.utilities.logger import _convert_params, _sanitize_params
  from lightning.pytorch import Trainer
  from lightning.pytorch.demos.boring_classes import BoringDataModule, BoringModel
  from lightning.pytorch.loggers import Logger, TensorBoardLogger
  from lightning.pytorch.loggers.logger import DummyExperiment, DummyLogger
  from lightning.pytorch.loggers.utilities import _scan_checkpoints
  from lightning.pytorch.utilities.rank_zero import rank_zero_only
label_desc: Use image node_id 10 for calling a global function with example usage: test_log_hyperparams_key_collision(_, tmpdir) without return types