code: def test_tf32_message(_, __, ___, caplog, monkeypatch):
      # for some reason, caplog doesn't work with our rank_zero_info utilities
      monkeypatch.setattr(
          lightning.fabric.accelerators.cuda,
          "rank_zero_info",
          logging.info,
      )
  
      device = Mock()
      expected = "Z100') that has Tensor Cores"
      assert (
          torch.get_float32_matmul_precision() == "highest"
      )  # default in torch
      with caplog.at_level(logging.INFO):
          _check_cuda_matmul_precision(device)
      assert expected in caplog.text
      _check_cuda_matmul_precision.cache_clear()
  
      caplog.clear()
      torch.backends.cuda.matmul.allow_tf32 = (
          True  # changing this changes the string
      )
      assert torch.get_float32_matmul_precision() == "high"
      with caplog.at_level(logging.INFO):
          _check_cuda_matmul_precision(device)
      assert not caplog.text
      _check_cuda_matmul_precision.cache_clear()
  
      caplog.clear()
      torch.backends.cuda.matmul.allow_tf32 = False
      torch.set_float32_matmul_precision(
          "medium"
      )  # also the other way around
      assert torch.backends.cuda.matmul.allow_tf32
      with caplog.at_level(logging.INFO):
          _check_cuda_matmul_precision(device)
      assert not caplog.text
      _check_cuda_matmul_precision.cache_clear()
  
      torch.set_float32_matmul_precision("highest")  # can be reverted
      with caplog.at_level(logging.INFO):
          _check_cuda_matmul_precision(device)
      assert expected in caplog.text
  
      # subsequent calls don't produce more messages
      caplog.clear()
      with caplog.at_level(logging.INFO):
          _check_cuda_matmul_precision(device)
      assert expected not in caplog.text
      _check_cuda_matmul_precision.cache_clear()
  
file_path: pytorch-lightning/tests/tests_fabric/accelerators/test_cuda.py
imports: import importlib
  import logging
  import os
  from re import escape
  from unittest import mock
  from unittest.mock import Mock
  import lightning.fabric
  import pytest
  import torch
  from lightning.fabric.accelerators.cuda import CUDAAccelerator, _check_cuda_matmul_precision, find_usable_cuda_devices, is_cuda_available, num_cuda_devices
  from tests_fabric.helpers.runif import RunIf
label_desc: Use image node_id 8 for calling a global function with example usage: test_tf32_message(_, __, ___, caplog, monkeypatch) without return types