docstr: Make sure the math is correct.
docstr_tok: ["Make","sure","the","math","is","correct","."]
code: def test_schedules(self):
      """Make sure the math is correct."""
      for epochs, params, lr_checks, _ in self.cosine_schedule_cases:
          optimizer = self._get_optimizer()
          params["type"] = "cosine"
          scheduler = LearningRateScheduler.from_params(
              optimizer=optimizer, params=Params(params)
          )
          lrs = [optimizer.param_groups[0]["lr"]]
          for _ in range(epochs):
              scheduler.step()
              lrs.append(optimizer.param_groups[0]["lr"])
  
          for it, lr in lr_checks:
              assert lrs[it] == pytest.approx(
                  lr
              ), f"Iteration {it}: {lrs[it]} != {lr}"
  
file_path: allennlp/tests/training/learning_rate_schedulers/cosine_test.py
imports: from copy import deepcopy
  from typing import Dict, Any
  import torch
  import pytest
  from allennlp.common import Params
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.training.learning_rate_schedulers import LearningRateScheduler
  from allennlp.training.optimizers import Optimizer
label_desc: Use image node_id 4 for calling the CosineWithRestartsTest obj's underlying member method code with example usage: obj.test_schedules() without return types