class_docstr: Base class to perform model training.
  
  Args:
      model (BaseAE): A instance of :class:`~pythae.models.BaseAE` to train
  
      train_dataset (BaseDataset): The training dataset of type
          :class:`~pythae.data.dataset.BaseDataset`
  
      eval_dataset (BaseDataset): The evaluation dataset of type
          :class:`~pythae.data.dataset.BaseDataset`
  
      training_config (BaseTrainerConfig): The training arguments summarizing the main
          parameters used for training. If None, a basic training instance of
          :class:`BaseTrainerConfig` is used. Default: None.
  
      callbacks (List[~pythae.trainers.training_callbacks.TrainingCallbacks]):
          A list of callbacks to use during training.
docstr: Perform an evaluation step
  
  Parameters:
      epoch (int): The current epoch number
  
  Returns:
      (torch.Tensor): The evaluation loss
docstr_tok: ["Perform","an","evaluation","step","Parameters",":","epoch","(","int",")",":","The","current","epoch","number","Returns",":","(","torch.Tensor",")",":","The","evaluation","loss"]
code: def eval_step(self, epoch: int):
      """Perform an evaluation step
  
      Parameters:
          epoch (int): The current epoch number
  
      Returns:
          (torch.Tensor): The evaluation loss
      """
  
      self.callback_handler.on_eval_step_begin(
          training_config=self.training_config,
          eval_loader=self.eval_loader,
          epoch=epoch,
          rank=self.rank,
      )
  
      self.model.eval()
  
      epoch_loss = 0
  
      with self.amp_context:
          for inputs in self.eval_loader:
              inputs = self._set_inputs_to_device(inputs)
  
              try:
                  with torch.no_grad():
                      model_output = self.model(
                          inputs,
                          epoch=epoch,
                          dataset_size=len(self.eval_loader.dataset),
                          uses_ddp=self.distributed,
                      )
  
              except RuntimeError:
                  model_output = self.model(
                      inputs,
                      epoch=epoch,
                      dataset_size=len(self.eval_loader.dataset),
                      uses_ddp=self.distributed,
                  )
  
              loss = model_output.loss
  
              epoch_loss += loss.item()
  
              if epoch_loss != epoch_loss:
                  raise ArithmeticError("NaN detected in eval loss")
  
              self.callback_handler.on_eval_step_end(
                  training_config=self.training_config
              )
  
      epoch_loss /= len(self.eval_loader)
  
      return epoch_loss
  
imports: import contextlib
  import datetime
  import logging
  import os
  from copy import deepcopy
  from typing import Any, Dict, List, Optional, Union
  import torch
  import torch.distributed
  import torch.optim
  import torch.optim.lr_scheduler
  from torch.nn.parallel import DistributedDataParallel
  from torch.utils.data import DataLoader, Dataset
  from torch.utils.data.distributed import DistributedSampler
  from ...customexception import ModelError
  from ...data.datasets import BaseDataset, collate_dataset_output
  from ...models import BaseAE
  from ..trainer_utils import set_seed
  from ..training_callbacks import CallbackHandler, MetricConsolePrinterCallback, ProgressBarCallback, TrainingCallback
  from .base_training_config import BaseTrainerConfig
label_desc: Use image node_id 18 for calling the BaseTrainer obj's underlying member method code with example usage: obj.eval_step(epoch) and returns: epoch_loss