class_docstr: Abstract base class used to build new callbacks.
  
  Subclass this class and override any of the relevant hooks
class_docstr_tok: ["Abstract","base","class","used","to","build","new","callbacks",".","Subclass","this","class","and","override","any","of","the","relevant","hooks"]
docstr: Called when the train epoch ends.
  
  To access all batch outputs at the end of the epoch, you can cache step outputs as an attribute of the
  :class:`lightning.pytorch.core.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
  
  
      class MyCallback(L.Callback):
          def on_train_epoch_end(self, trainer, pl_module):
              # do something with all training_step outputs, for example:
              epoch_mean = torch.stack(pl_module.training_step_outputs).mean()
              pl_module.log("training_epoch_mean", epoch_mean)
              # free up the memory
              pl_module.training_step_outputs.clear()
docstr_tok: ["Called","when","the","train","epoch","ends",".","To","access","all","batch","outputs","at","the","end","of","the","epoch",",","you","can","cache","step","outputs","as","an","attribute","of","the",":","class",":","`","lightning.pytorch.core.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","class","MyCallback","(","L.Callback",")",":","def","on_train_epoch_end","(","self",",","trainer",",","pl_module",")",":","#","do","something","with","all","training_step","outputs",",","for","example",":","epoch_mean","=","torch.stack","(","pl_module.training_step_outputs",")",".mean","(",")","pl_module.log","(","``","training_epoch_mean","''",",","epoch_mean",")","#","free","up","the","memory","pl_module.training_step_outputs.clear","(",")"]
code: def on_train_epoch_end(
      self, trainer: "pl.Trainer", pl_module: "pl.LightningModule"
  ) -> None:
      """Called when the train epoch ends.
  
      To access all batch outputs at the end of the epoch, you can cache step outputs as an attribute of the
      :class:`lightning.pytorch.core.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
  
  
          class MyCallback(L.Callback):
              def on_train_epoch_end(self, trainer, pl_module):
                  # do something with all training_step outputs, for example:
                  epoch_mean = torch.stack(pl_module.training_step_outputs).mean()
                  pl_module.log("training_epoch_mean", epoch_mean)
                  # free up the memory
                  pl_module.training_step_outputs.clear()
  
      """
  
imports: from typing import Any, Dict, Type
  from torch import Tensor
  from torch.optim import Optimizer
  import lightning.pytorch
  from lightning.pytorch.utilities.types import STEP_OUTPUT
label_desc: Use image node_id 13 for calling the Callback obj's underlying member method code with example usage: obj.on_train_epoch_end(trainer, pl_module) without return types