code: def test_trainer_manual_optimization_config():
      """Test error message when requesting Trainer features unsupported with manual optimization."""
      model = BoringModel()
      model.automatic_optimization = False
  
      trainer = Trainer(gradient_clip_val=1.0)
      with pytest.raises(
          MisconfigurationException,
          match="Automatic gradient clipping is not supported",
      ):
          trainer.fit(model)
  
      trainer = Trainer(accumulate_grad_batches=2)
      with pytest.raises(
          MisconfigurationException,
          match="Automatic gradient accumulation is not supported",
      ):
          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 6 for calling a global function with example usage: test_trainer_manual_optimization_config() without return types