class_docstr: Hooks to be used in LightningModule.
class_docstr_tok: ["Hooks","to","be","used","in","LightningModule","."]
docstr: Called after ``training_step()`` and before ``optimizer.zero_grad()``.
  
  Called in the training loop after taking an optimizer step and before zeroing grads.
  Good place to inspect weight information with weights updated.
  
  This is where it is called::
  
      for optimizer in optimizers:
          out = training_step(...)
  
          model.on_before_zero_grad(optimizer) # < ---- called here
          optimizer.zero_grad()
  
          backward()
  
  Args:
      optimizer: The optimizer for which grads should be zeroed.
code: def on_before_zero_grad(self, optimizer: Optimizer) -> None:
      """Called after ``training_step()`` and before ``optimizer.zero_grad()``.
  
      Called in the training loop after taking an optimizer step and before zeroing grads.
      Good place to inspect weight information with weights updated.
  
      This is where it is called::
  
          for optimizer in optimizers:
              out = training_step(...)
  
              model.on_before_zero_grad(optimizer) # < ---- called here
              optimizer.zero_grad()
  
              backward()
  
      Args:
          optimizer: The optimizer for which grads should be zeroed.
  
      """
  
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 33 for calling the ModelHooks obj's underlying member method code with example usage: obj.on_before_zero_grad(optimizer) without return types