docstr: :meth:`advance_optimization` for Lightning 1.x.
code: def _legacy_advance_optimization(
      self,
      loss: Any,
      batch_idx: int,
      optimizers: list[Optimizer],
      gradient_clip_val: int | float | None = None,
      gradient_clip_algorithm: str | None = None,
  ):
      """:meth:`advance_optimization` for Lightning 1.x."""
  
      if self.trainer.optimizer_frequencies:  # type: ignore
          warnings.warn(
              "optimizer_frequencies is not supported in NAS. It will be ignored.",
              UserWarning,
          )
  
      opt_idx = self._optimizer_progress % len(optimizers)
      optimizer = cast(
          Optimizer, optimizers[opt_idx]
      )  # LightningOptimizer has the same interface as Optimizer.
  
      # There should be many before/after hooks called here, but they are omitted in this implementation.
      # 1. zero gradient
      self.training_module.optimizer_zero_grad(self.trainer.current_epoch, batch_idx, optimizer, opt_idx)  # type: ignore
      # 2. backward
      self.manual_backward(loss)
      # 3. grad clip
      self.training_module.configure_gradient_clipping(optimizer, opt_idx, gradient_clip_val, gradient_clip_algorithm)  # type: ignore
      # 4. optimizer step
      self.training_module.optimizer_step(
          self.trainer.current_epoch, batch_idx, optimizer, opt_idx
      )
  
imports: from __future__ import annotations
  import warnings
  from typing import Any, Iterable, List, cast, TYPE_CHECKING
  import torch.optim
  import torch.nn
  from torch.optim import Optimizer
  import nni.nas.nn.pytorch
  from nni.nas.evaluator.pytorch import LightningModule, Trainer
  from nni.mutable import Sample
  from .supermodule.base import BaseSuperNetModule
label_desc: Use image node_id 17 for calling the BaseOneShotLightningModule obj's underlying member method code with example usage: obj._legacy_advance_optimization(loss, batch_idx, optimizers, gradient_clip_val, gradient_clip_algorithm) without return types