code: def test_from_params_in_trainer(self):
      # This is more of an integration test, making sure that a bunch of pieces fit together
      # correctly, but it matters most for this learning rate scheduler, so we're testing it here.
      params = Params(
          {
              "num_epochs": 5,
              "learning_rate_scheduler": {
                  "type": "slanted_triangular",
                  "gradual_unfreezing": True,
                  "discriminative_fine_tuning": True,
                  "decay_factor": 0.5,
              },
          }
      )
      # The method called in the logic below only checks the length of this list, not its
      # contents, so this should be safe.
      instances = [1] * 40
      optim = self._get_optimizer()
      trainer = Trainer.from_params(
          model=self.model,
          optimizer=Lazy(lambda **kwargs: optim),
          serialization_dir=self.TEST_DIR,
          params=params,
          data_loader=SimpleDataLoader(instances, batch_size=10),
      )
      assert isinstance(
          trainer._learning_rate_scheduler, SlantedTriangular
      )
  
      # This is what we wrote this test for: to be sure that num_epochs is passed correctly, and
      # that num_steps_per_epoch is computed and passed correctly.  This logic happens inside of
      # `Trainer.from_partial_objects`.
      assert trainer._learning_rate_scheduler.num_epochs == 5
      assert trainer._learning_rate_scheduler.num_steps_per_epoch == 4
  
      # And we'll do one more to make sure that we can override num_epochs in the scheduler if we
      # really want to.  Not sure why you would ever want to in this case; this is just testing
      # the functionality.
      params = Params(
          {
              "num_epochs": 5,
              "learning_rate_scheduler": {
                  "type": "slanted_triangular",
                  "num_epochs": 3,
                  "gradual_unfreezing": True,
                  "discriminative_fine_tuning": True,
                  "decay_factor": 0.5,
              },
          }
      )
      trainer = Trainer.from_params(
          model=self.model,
          optimizer=Lazy(lambda **kwargs: optim),
          serialization_dir=self.TEST_DIR,
          params=params,
          data_loader=SimpleDataLoader(instances, batch_size=10),
      )
      assert trainer._learning_rate_scheduler.num_epochs == 3
  
imports: from collections import OrderedDict
  from copy import deepcopy
  from typing import Any, Dict, List, Tuple
  import torch
  import pytest
  from allennlp.common import Lazy, Params
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.data.data_loaders import SimpleDataLoader
  from allennlp.training import Trainer
  from allennlp.training.learning_rate_schedulers import LearningRateScheduler, SlantedTriangular
  from allennlp.training.optimizers import Optimizer
label_desc: Use image node_id 5 for calling the SlantedTriangularTest obj's underlying member method code with example usage: obj.test_from_params_in_trainer() without return types