code: def test_wrong_configure_optimizers(tmpdir):
      """Test that an error is thrown when no `configure_optimizers()` is defined."""
      trainer = Trainer(default_root_dir=tmpdir, max_epochs=1)
  
      with pytest.raises(
          MisconfigurationException,
          match=r"No `configure_optimizers\(\)` method defined.",
      ):
          model = BoringModel()
          model.configure_optimizers = None
          trainer.fit(model)
  
file_path: pytorch-lightning/tests/tests_pytorch/trainer/test_config_validator.py
imports: from unittest.mock import Mock
  import pytest
  import torch
  from lightning.fabric.utilities.warnings import PossibleUserWarning
  from lightning.pytorch import LightningDataModule, LightningModule, Trainer
  from lightning.pytorch.demos.boring_classes import BoringModel, RandomDataset
  from lightning.pytorch.trainer.configuration_validator import __verify_eval_loop_configuration, __verify_train_val_loop_configuration
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
label_desc: Use image node_id 2 for calling a global function with example usage: test_wrong_configure_optimizers(tmpdir) without return types