class_docstr: Basic DQN Model.
  
  >>> DQNLightning(env="CartPole-v1")  # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
  DQNLightning(
    (net): DQN(
      (net): Sequential(...)
    )
    (target_net): DQN(
      (net): Sequential(...)
    )
  )
docstr: Calculates the mse loss using a mini batch from the replay buffer.
  
  Args:
      batch: current mini batch of replay data
  
  Returns:
      loss
docstr_tok: ["Calculates","the","mse","loss","using","a","mini","batch","from","the","replay","buffer",".","Args",":","batch",":","current","mini","batch","of","replay","data","Returns",":","loss"]
code: def dqn_mse_loss(
      self, batch: Tuple[torch.Tensor, torch.Tensor]
  ) -> torch.Tensor:
      """Calculates the mse loss using a mini batch from the replay buffer.
  
      Args:
          batch: current mini batch of replay data
  
      Returns:
          loss
  
      """
      states, actions, rewards, dones, next_states = batch
  
      state_action_values = (
          self.net(states).gather(1, actions.unsqueeze(-1)).squeeze(-1)
      )
  
      with torch.no_grad():
          next_state_values = self.target_net(next_states).max(1)[0]
          next_state_values[dones] = 0.0
          next_state_values = next_state_values.detach()
  
      expected_state_action_values = (
          next_state_values * self.gamma + rewards
      )
  
      return nn.MSELoss()(
          state_action_values, expected_state_action_values
      )
  
imports: import argparse
  from collections import OrderedDict, deque, namedtuple
  from typing import Iterator, List, Tuple
  import gym
  import numpy
  import torch
  import torch.nn
  import torch.optim
  from lightning.pytorch import LightningModule, Trainer, cli_lightning_logo, seed_everything
  from torch.optim.optimizer import Optimizer
  from torch.utils.data import DataLoader
  from torch.utils.data.dataset import IterableDataset
label_desc: Use image node_id 4 for calling the DQNLightning obj's underlying member method code with example usage: obj.dqn_mse_loss(batch) and returns: nn