class_docstr: Control the loops for training, evaluation, and prediction. This module is independent of
  the model definition. This class inherits from the Pytorch Lightning's LightningModule:
  https://lightning.ai/docs/pytorch/stable/common/lightning_module.html
class_docstr_tok: ["Control","the","loops","for","training",",","evaluation",",","and","prediction",".","This","module","is","independent","of","the","model","definition",".","This","class","inherits","from","the","Pytorch","Lightning","'s","LightningModule",":","https",":","\/\/lightning.ai\/docs\/pytorch\/stable\/common\/lightning_module.html"]
docstr: Configure optimizer. This function is registered by LightningModule.
  Refer to https://lightning.ai/docs/pytorch/stable/common/lightning_module.html#configure-optimizers
  Returns
  -------
  [optimizer]
      Optimizer.
  [sched]
      Learning rate scheduler.
docstr_tok: ["Configure","optimizer",".","This","function","is","registered","by","LightningModule",".","Refer","to","https",":","\/\/lightning.ai\/docs\/pytorch\/stable\/common\/lightning_module.html","#","configure-optimizers","Returns","--","--","--","-","[","optimizer","]","Optimizer",".","[","sched","]","Learning","rate","scheduler","."]
code: def configure_optimizers(self):
      """
      Configure optimizer. This function is registered by LightningModule.
      Refer to https://lightning.ai/docs/pytorch/stable/common/lightning_module.html#configure-optimizers
      Returns
      -------
      [optimizer]
          Optimizer.
      [sched]
          Learning rate scheduler.
      """
      # TODO: need to consider query_model and response_model in the optimizer
      # TODO: how to avoid pass one parameter multiple times in the optimizer?
      # TODO: in the late-fusion siamese setting, one shared parameter may have different layer ids in the query and response models.
      kwargs = dict(
          model=self.query_model,
          lr=self.hparams.lr,
          weight_decay=self.hparams.weight_decay,
      )
      if self.hparams.lr_choice == "two_stages":
          logger.debug("applying 2-stage learning rate...")
          grouped_parameters = apply_two_stages_lr(
              lr_mult=self.hparams.lr_mult,
              return_params=True,
              **kwargs,
          )
      elif self.hparams.lr_choice == "layerwise_decay":
          logger.debug("applying layerwise learning rate decay...")
          grouped_parameters = apply_layerwise_lr_decay(
              lr_decay=self.hparams.lr_decay,
              **kwargs,
          )
      else:
          logger.debug("applying single learning rate...")
          grouped_parameters = apply_single_lr(
              **kwargs,
          )
  
      optimizer = get_optimizer(
          optim_type=self.hparams.optim_type,
          optimizer_grouped_parameters=grouped_parameters,
          lr=self.hparams.lr,
          weight_decay=self.hparams.weight_decay,
      )
  
      logger.debug(f"trainer.max_steps: {self.trainer.max_steps}")
      if self.trainer.max_steps is None or -1:
          max_steps = (
              len(self.trainer.datamodule.train_dataloader())
              * self.trainer.max_epochs
              // self.trainer.accumulate_grad_batches
          )
          logger.debug(
              f"len(trainer.datamodule.train_dataloader()): "
              f"{len(self.trainer.datamodule.train_dataloader())}"
          )
          logger.debug(f"trainer.max_epochs: {self.trainer.max_epochs}")
          logger.debug(
              f"trainer.accumulate_grad_batches: {self.trainer.accumulate_grad_batches}"
          )
      else:
          max_steps = self.trainer.max_steps
  
      logger.debug(f"max steps: {max_steps}")
  
      warmup_steps = self.hparams.warmup_steps
      if isinstance(warmup_steps, float):
          warmup_steps = int(max_steps * warmup_steps)
  
      logger.debug(f"warmup steps: {warmup_steps}")
      logger.debug(f"lr_schedule: {self.hparams.lr_schedule}")
      scheduler = get_lr_scheduler(
          optimizer=optimizer,
          num_max_steps=max_steps,
          num_warmup_steps=warmup_steps,
          lr_schedule=self.hparams.lr_schedule,
          end_lr=self.hparams.end_lr,
      )
  
      sched = {"scheduler": scheduler, "interval": "step"}
      logger.debug("done configuring optimizer and scheduler")
      return [optimizer], [sched]
  
imports: import logging
  from typing import Callable, Dict, List, Optional, Union
  import lightning.pytorch
  import torch
  import torchmetrics
  from lightning.pytorch.utilities import grad_norm
  from omegaconf import DictConfig
  from torch import nn
  from torch.nn.modules.loss import _Loss
  from torchmetrics.aggregation import BaseAggregator
  from ..constants import FEATURES, LOGIT_SCALE, PROBABILITY, QUERY, RESPONSE
  from ..models.utils import run_model
  from ..utils.matcher import compute_matching_probability
  from .losses import MultiNegativesSoftmaxLoss
  from .utils import CustomHitRate, apply_layerwise_lr_decay, apply_single_lr, apply_two_stages_lr, generate_metric_learning_labels, get_lr_scheduler, get_optimizer
label_desc: Use image node_id 9 for calling the MatcherLitModule obj's underlying member method code with example usage: obj.configure_optimizers() and returns: list,  list