class_docstr: A ``pl.LightningModule`` class that can be used to train a
  ``TemporalFusionTransformerModel`` with PyTorch Lightning.
  
  This is a thin layer around a (wrapped) ``TemporalFusionTransformerModel``
  object, that exposes the methods to evaluate training and validation loss.
  
  Parameters
  ----------
  model_kwargs
      Keyword arguments to construct the ``TemporalFusionTransformerModel`` to be trained.
  lr
      Learning rate.
  weight_decay
      Weight decay regularization parameter.
  patience
      Patience parameter for learning rate scheduler.
class_docstr_tok: ["A","``","pl.LightningModule","``","class","that","can","be","used","to","train","a","``","TemporalFusionTransformerModel","``","with","PyTorch","Lightning",".","This","is","a","thin","layer","around","a","(","wrapped",")","``","TemporalFusionTransformerModel","``","object",",","that","exposes","the","methods","to","evaluate","training","and","validation","loss",".","Parameters","--","--","--","--","--","model_kwargs","Keyword","arguments","to","construct","the","``","TemporalFusionTransformerModel","``","to","be","trained",".","lr","Learning","rate",".","weight_decay","Weight","decay","regularization","parameter",".","patience","Patience","parameter","for","learning","rate","scheduler","."]
docstr: Returns the optimizer to use.
docstr_tok: ["Returns","the","optimizer","to","use","."]
code: def configure_optimizers(self):
      """
      Returns the optimizer to use.
      """
      optimizer = torch.optim.Adam(
          self.model.parameters(),
          lr=self.lr,
          weight_decay=self.weight_decay,
      )
      monitor = (
          "val_loss"
          if has_validation_loop(self.trainer)
          else "train_loss"
      )
  
      return {
          "optimizer": optimizer,
          "lr_scheduler": {
              "scheduler": ReduceLROnPlateau(
                  optimizer=optimizer,
                  mode="min",
                  factor=0.5,
                  patience=self.patience,
              ),
              "monitor": monitor,
          },
      }
  
file_path: gluonts/src/gluonts/torch/model/tft/lightning_module.py
imports: import lightning.pytorch
  import torch
  from torch.optim.lr_scheduler import ReduceLROnPlateau
  from gluonts.core.component import validated
  from gluonts.itertools import select
  from gluonts.torch.model.lightning_util import has_validation_loop
  from .module import TemporalFusionTransformerModel
label_desc: Use image node_id 5 for calling the TemporalFusionTransformerLightningModule obj's underlying member method code with example usage: obj.configure_optimizers() and returns: dict