docstr: Make sure `from_params` initializes an instance properly.
docstr_tok: ["Make","sure","`","from_params","`","initializes","an","instance","properly","."]
code: def test_from_params(self):
      """Make sure `from_params` initializes an instance properly."""
      optim = self._get_optimizer()
      sched = LearningRateScheduler.from_params(
          optimizer=optim,
          params=Params({"type": "cosine", "t_initial": 5}),
      )
  
      assert sched.t_initial == 5
      assert sched.last_epoch == -1
  
      # Learning should be unchanged after initializing scheduler.
      assert optim.param_groups[0]["lr"] == 1.0
  
      with pytest.raises(ConfigurationError):
          # t_initial is required.
          LearningRateScheduler.from_params(
              optimizer=optim, params=Params({"type": "cosine"})
          )
  
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 3 for calling the CosineWithRestartsTest obj's underlying member method code with example usage: obj.test_from_params() without return types