code: def test_tensorboard_with_accummulated_gradients(
      mock_log_metrics, tmp_path
  ):
      """Tests to ensure that tensorboard log properly when accumulated_gradients > 1."""
  
      class TestModel(BoringModel):
          def __init__(self):
              super().__init__()
              self.indexes = []
  
          def training_step(self, *args):
              self.log("foo", 1, on_step=True, on_epoch=True)
              if (
                  not self.trainer.fit_loop._should_accumulate()
                  and self.trainer._logger_connector.should_update_logs
              ):
                  self.indexes.append(self.trainer.global_step)
              return super().training_step(*args)
  
      model = TestModel()
      logger_0 = TensorBoardLogger(tmp_path, default_hp_metric=False)
      trainer = Trainer(
          default_root_dir=tmp_path,
          limit_train_batches=12,
          limit_val_batches=0,
          max_epochs=3,
          accumulate_grad_batches=2,
          logger=[logger_0],
          log_every_n_steps=3,
      )
      trainer.fit(model)
  
      calls = [m[2] for m in mock_log_metrics.mock_calls]
      count_epochs = [
          c["step"] for c in calls if "foo_epoch" in c["metrics"]
      ]
      assert count_epochs == [5, 11, 17]
  
      count_steps = [
          c["step"] for c in calls if "foo_step" in c["metrics"]
      ]
      assert count_steps == model.indexes
  
imports: import logging
  import os
  from argparse import Namespace
  from unittest import mock
  from unittest.mock import Mock
  import numpy
  import pytest
  import torch
  import yaml
  from lightning.pytorch import Trainer
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.loggers import TensorBoardLogger
  from lightning.pytorch.loggers.tensorboard import _TENSORBOARD_AVAILABLE
  from lightning.pytorch.utilities.imports import _OMEGACONF_AVAILABLE
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 13 for calling a global function with example usage: test_tensorboard_with_accummulated_gradients(mock_log_metrics, tmp_path) and returns: super