code: def test__validation_step__log(tmpdir):
      """Tests that validation_step can log."""
  
      class TestModel(BoringModel):
          def training_step(self, batch, batch_idx):
              out = super().training_step(batch, batch_idx)
              self.log("a", out["loss"], on_step=True, on_epoch=True)
              self.log("a2", 2)
              return out
  
          def validation_step(self, batch, batch_idx):
              out = super().validation_step(batch, batch_idx)
              self.log("b", out["x"], on_step=True, on_epoch=True)
              return out
  
      model = TestModel()
      trainer = Trainer(
          default_root_dir=tmpdir,
          limit_train_batches=2,
          limit_val_batches=2,
          max_epochs=2,
          log_every_n_steps=1,
          enable_model_summary=False,
      )
      trainer.fit(model)
  
      assert set(trainer.logged_metrics) == {
          "a2",
          "a_step",
          "a_epoch",
          "b_step",
          "b_epoch",
      }
  
      # we don't want to enable val metrics during steps because it is not something that users should do
      # on purpose DO NOT allow b_step... it's silly to monitor val step metrics
      assert set(trainer.callback_metrics) == {
          "a",
          "a2",
          "b",
          "a_epoch",
          "b_epoch",
          "a_step",
      }
      assert all(
          isinstance(v, Tensor)
          for v in trainer.callback_metrics.values()
      )
      assert all(
          isinstance(v, Tensor) for v in trainer.logged_metrics.values()
      )
      assert all(
          isinstance(v, float)
          for v in trainer.progress_bar_metrics.values()
      )
  
imports: import collections
  import itertools
  import os
  from contextlib import redirect_stdout
  from io import StringIO
  from unittest import mock
  from unittest.mock import ANY, call
  import numpy
  import pytest
  import torch
  from lightning.fabric.utilities.imports import _PYTHON_GREATER_EQUAL_3_8_0
  from lightning.pytorch import Trainer, callbacks
  from lightning.pytorch.callbacks.progress.rich_progress import _RICH_AVAILABLE
  from lightning.pytorch.demos.boring_classes import BoringModel, RandomDataset
  from lightning.pytorch.loggers import TensorBoardLogger
  from lightning.pytorch.loops import _EvaluationLoop
  from lightning.pytorch.trainer.states import RunningStage
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from torch import Tensor
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 1 for calling a global function with example usage: test__validation_step__log(tmpdir) and returns: out, out