code: def test_warn_if_model_has_overridden_optimization_hooks():
      """Test that the callback warns if optimization hooks were overridden in the LightningModule."""
  
      class OverriddenOptimizerStepModel(BoringModel):
          def optimizer_step(self, *args, **kwargs):
              super().optimizer_step(*args, **kwargs)
  
      class OverriddenZeroGradModel(BoringModel):
          def optimizer_zero_grad(self, *args, **kwargs):
              super().optimizer_zero_grad(*args, **kwargs)
  
      scheduler = GradientAccumulationScheduler({1: 2})
      trainer = Trainer()
  
      model = OverriddenOptimizerStepModel()
      with pytest.warns(
          UserWarning,
          match="the hooks will not be called on every batch",
      ):
          scheduler.on_train_start(trainer, model)
  
      model = OverriddenZeroGradModel()
      with pytest.warns(
          UserWarning,
          match="the hooks will not be called on every batch",
      ):
          scheduler.on_train_start(trainer, model)
  
file_path: pytorch-lightning/tests/tests_pytorch/callbacks/test_gradient_accumulation_scheduler.py
imports: import math
  from unittest.mock import Mock, patch
  import pytest
  from lightning.pytorch import Trainer
  from lightning.pytorch.callbacks import GradientAccumulationScheduler
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.strategies import DeepSpeedStrategy
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.imports import _LIGHTNING_COLOSSALAI_AVAILABLE
label_desc: Use image node_id 7 for calling a global function with example usage: test_warn_if_model_has_overridden_optimization_hooks() without return types