code: def test_torch_defaults(tmpdir, device):
      from speechbrain.utils.checkpoints import Checkpointer
  
      module = torch.nn.Linear(10, 10).to(device)
      optimizer = torch.optim.Adam(module.parameters())
      lr_scheduler = torch.optim.lr_scheduler.CyclicLR(
          optimizer, 0.1, 1.0, cycle_momentum=False
      )
      # ReduceLROnPlateau is on an _LRScheduler for some reason, so have a separate test for it
      another_scheduler = torch.optim.lr_scheduler.ReduceLROnPlateau(
          optimizer
      )
      checkpointer = Checkpointer(
          tmpdir,
          recoverables={
              "module": module,
              "optimizer": optimizer,
              "scheduler": lr_scheduler,
              "scheduler2": another_scheduler,
          },
      )
      ckpt = checkpointer.save_checkpoint()
      # test the module:
      inp = torch.randn((3, 10), device=device)
      prev_output = module(inp)
  
      # Re-initialize everything
      module = torch.nn.Linear(10, 10, device=device)
      optimizer = torch.optim.Adam(module.parameters())
      lr_scheduler = torch.optim.lr_scheduler.CyclicLR(
          optimizer, 0.1, 1.0, cycle_momentum=False
      )
      another_scheduler = torch.optim.lr_scheduler.ReduceLROnPlateau(
          optimizer
      )
      checkpointer = Checkpointer(
          tmpdir,
          recoverables={
              "module": module,
              "optimizer": optimizer,
              "scheduler": lr_scheduler,
              "scheduler2": another_scheduler,
          },
      )
      checkpointer.load_checkpoint(ckpt)
      assert torch.allclose(module(inp), prev_output)
  
file_path: speechbrain/tests/unittests/test_checkpoints.py
imports: import torch
  import pytest
label_desc: Use image node_id 8 for calling a global function with example usage: test_torch_defaults(tmpdir, device) without return types