code: def test_tuner_lr_find(tmpdir, use_hparams):
      """Test that lr_find updates the learning rate attribute."""
      seed_everything(1)
  
      class CustomBoringModel(BoringModel):
          def __init__(self, lr):
              super().__init__()
              self.save_hyperparameters()
              self.lr = lr
  
          def configure_optimizers(self):
              return torch.optim.SGD(
                  self.parameters(),
                  lr=self.hparams.lr if use_hparams else self.lr,
              )
  
      before_lr = 1e-2
      model = CustomBoringModel(lr=before_lr)
      trainer = Trainer(default_root_dir=tmpdir, max_epochs=2)
      tuner = Tuner(trainer)
      tuner.lr_find(model, update_attr=True)
  
      after_lr = model.hparams.lr if use_hparams else model.lr
  
      assert after_lr is not None
      assert (
          before_lr != after_lr
      ), "Learning rate was not altered after running learning rate finder"
  
imports: import logging
  import math
  import os
  from copy import deepcopy
  from typing import Any
  from unittest import mock
  import pytest
  import torch
  from lightning.pytorch import Trainer, seed_everything
  from lightning.pytorch.callbacks.lr_finder import LearningRateFinder
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.tuner.lr_finder import _LRFinder
  from lightning.pytorch.tuner.tuning import Tuner
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.types import STEP_OUTPUT
  from lightning_utilities.test.warning import no_warning_call
  from tests_pytorch.helpers.datamodules import ClassifDataModule
  from tests_pytorch.helpers.runif import RunIf
  from tests_pytorch.helpers.simple_models import ClassificationModel
  from tests_pytorch.helpers.utils import getattr_recursive
label_desc: Use image node_id 4 for calling a global function with example usage: test_tuner_lr_find(tmpdir, use_hparams) and returns: torch