code: def test_backward_count_simple(torch_backward, num_steps):
      """Test that backward is called exactly once per step."""
      model = BoringModel()
      trainer = Trainer(max_steps=num_steps)
      trainer.fit(model)
      assert torch_backward.call_count == num_steps
  
      torch_backward.reset_mock()
  
      trainer.test(model)
      assert torch_backward.call_count == 0
  
file_path: pytorch-lightning/tests/tests_pytorch/trainer/optimization/test_backward_calls.py
imports: from unittest.mock import patch
  import pytest
  import torch
  from lightning.pytorch import Trainer
  from lightning.pytorch.demos.boring_classes import BoringModel
label_desc: Use image node_id 1 for calling a global function with example usage: test_backward_count_simple(torch_backward, num_steps) without return types