docstr: configures optimizers and learning rate schedulers for model optimization.
docstr_tok: ["configures","optimizers","and","learning","rate","schedulers","for","model","optimization","."]
code: def configure_optimizers(self):
      """configures optimizers and learning rate schedulers for model optimization."""
  
      # A utility function to create optimizer and lr scheduler from desired classes
      def _create_from_cls_and_kwargs(cls, kws):
          try:
              return cls(**kws)
          except (TypeError, ValueError) as e:
              raise_log(
                  ValueError(
                      "Error when building the optimizer or learning rate scheduler;"
                      "please check the provided class and arguments"
                      "\nclass: {}"
                      "\narguments (kwargs): {}"
                      "\nerror:\n{}".format(cls, kws, e)
                  ),
                  logger,
              )
  
      # Create the optimizer and (optionally) the learning rate scheduler
      # we have to create copies because we cannot save model.parameters into object state (not serializable)
      optimizer_kws = {k: v for k, v in self.optimizer_kwargs.items()}
      optimizer_kws["params"] = self.parameters()
  
      optimizer = _create_from_cls_and_kwargs(
          self.optimizer_cls, optimizer_kws
      )
  
      if self.lr_scheduler_cls is not None:
          lr_sched_kws = {
              k: v for k, v in self.lr_scheduler_kwargs.items()
          }
          lr_sched_kws["optimizer"] = optimizer
  
          # ReduceLROnPlateau requires a metric to "monitor" which must be set separately, most others do not
          lr_monitor = lr_sched_kws.pop("monitor", None)
  
          lr_scheduler = _create_from_cls_and_kwargs(
              self.lr_scheduler_cls, lr_sched_kws
          )
          return [optimizer], {
              "scheduler": lr_scheduler,
              "monitor": lr_monitor
              if lr_monitor is not None
              else "val_loss",
          }
      else:
          return optimizer
  
imports: from abc import ABC, abstractmethod
  from functools import wraps
  from typing import Any, Dict, Optional, Sequence, Tuple, Union
  import pytorch_lightning
  import torch
  import torch.nn
  import torchmetrics
  from joblib import Parallel, delayed
  from darts.logging import get_logger, raise_if, raise_log
  from darts.models.components.layer_norm_variants import RINorm
  from darts.timeseries import TimeSeries
  from darts.utils.likelihood_models import Likelihood
  from darts.utils.timeseries_generation import _build_forecast_series
  from darts.utils.torch import MonteCarloDropout
label_desc: Use image node_id 10 for calling the PLForecastingModule obj's underlying member method code with example usage: obj.configure_optimizers() and returns: list,  dict, optimizer, cls