class_docstr: Hooks to be used in LightningModule.
class_docstr_tok: ["Hooks","to","be","used","in","LightningModule","."]
docstr: Called in the training loop at the very end of the epoch.
  
  To access all batch outputs at the end of the epoch, you can cache step outputs as an attribute of the
  :class:`~lightning.pytorch.LightningModule` and access them in this hook:
  
  .. code-block:: python
  
      class MyLightningModule(L.LightningModule):
          def __init__(self):
              super().__init__()
              self.training_step_outputs = []
  
          def training_step(self):
              loss = ...
              self.training_step_outputs.append(loss)
              return loss
  
          def on_train_epoch_end(self):
              # do something with all training_step outputs, for example:
              epoch_mean = torch.stack(self.training_step_outputs).mean()
              self.log("training_epoch_mean", epoch_mean)
              # free up the memory
              self.training_step_outputs.clear()
code: def on_train_epoch_end(self) -> None:
      """Called in the training loop at the very end of the epoch.
  
      To access all batch outputs at the end of the epoch, you can cache step outputs as an attribute of the
      :class:`~lightning.pytorch.LightningModule` and access them in this hook:
  
      .. code-block:: python
  
          class MyLightningModule(L.LightningModule):
              def __init__(self):
                  super().__init__()
                  self.training_step_outputs = []
  
              def training_step(self):
                  loss = ...
                  self.training_step_outputs.append(loss)
                  return loss
  
              def on_train_epoch_end(self):
                  # do something with all training_step outputs, for example:
                  epoch_mean = torch.stack(self.training_step_outputs).mean()
                  self.log("training_epoch_mean", epoch_mean)
                  # free up the memory
                  self.training_step_outputs.clear()
  
      """
  
imports: from typing import Any, Dict, Optional
  import torch
  from torch import Tensor
  from torch.optim.optimizer import Optimizer
  from lightning.fabric.utilities.imports import _TORCH_GREATER_EQUAL_2_0
  from lightning.pytorch.utilities import move_data_to_device
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.types import EVAL_DATALOADERS, STEP_OUTPUT, TRAIN_DATALOADERS
label_desc: Use image node_id 26 for calling the ModelHooks obj's underlying member method code with example usage: obj.on_train_epoch_end() without return types