question: Using Multiple Optimisers gives Index Error?
context: Hello,
  I am trying to build a model which uses multiple optimisers. When I try to train the model I get the error validation_step() missing 1 required positional argument: 'optimizer_idx'. I have reproduced this error on the BoringModel used for bug reports:
  #!/usr/bin/env python3
  # -*- coding: utf-8 -*-
  
  import os
  
  import torch
  from torch.utils.data import DataLoader, Dataset
  
  from pytorch_lightning import LightningModule, Trainer
  
  
  class RandomDataset(Dataset):
      def __init__(self, size, length):
          self.len = length
          self.data = torch.randn(length, size)
  
      def __getitem__(self, index):
          return self.data[index]
  
      def __len__(self):
          return self.len
  
  
  class BoringModel(LightningModule):
      def __init__(self):
          super().__init__()
          self.layer = torch.nn.Linear(32, 2)
  
      def forward(self, x):
          return self.layer(x)
  
      def training_step(self, batch, batch_idx, optimizer_idx):
          if optimizer_idx == 0:
              loss = self(batch).sum()
              self.log("train_loss", loss)
          if optimizer_idx == 1:
              loss = self(batch).sum()
              self.log("train_loss", loss)
          return {"loss": loss}
  
      def validation_step(self, batch, batch_idx, optimizer_idx):
          if optimizer_idx == 0:
              loss = self(batch).sum()
              self.log("valid_loss", loss)
          if optimizer_idx == 1:
              loss = self(batch).sum()
              self.log("valid_loss", loss)
          return {"loss": loss}
  
      def test_step(self, batch, batch_idx, optimizer_idx):
          if optimizer_idx == 0:
              loss = self(batch).sum()
              self.log("test_loss", loss)
          if optimizer_idx == 1:
              loss = self(batch).sum()
              self.log("test_loss", loss)
          return {"loss": loss}
  
      def configure_optimizers(self):
          opt_a = torch.optim.SGD(self.layer.parameters(), lr=0.1)
          opt_b = torch.optim.SGD(self.layer.parameters(), lr=0.1)
          return [opt_a, opt_b], []
  
  
  def run():
      train_data = DataLoader(RandomDataset(32, 64), batch_size=2)
      val_data = DataLoader(RandomDataset(32, 64), batch_size=2)
      test_data = DataLoader(RandomDataset(32, 64), batch_size=2)
  
      model = BoringModel()
      trainer = Trainer(
          default_root_dir=os.getcwd(),
          limit_train_batches=1,
          limit_val_batches=1,
          limit_test_batches=1,
          num_sanity_val_steps=0,
          max_epochs=1,
          enable_model_summary=False,
      )
      trainer.fit(model, train_dataloaders=train_data, val_dataloaders=val_data)
      trainer.test(model, dataloaders=test_data)
  
  
  if __name__ == "__main__":
      run()
  
  What am I missing?
  Thanks for the help!
answer: Validation doesn't require optimizers. Try removing the
  optimizer_idx argument from your validation_step method definition