class_docstr: Generates a summary of all layers in a :class:`~lightning.pytorch.core.LightningModule`.
  
  Args:
      max_depth: The maximum depth of layer nesting that the summary will include. A value of 0 turns the
          layer summary off.
      **summarize_kwargs: Additional arguments to pass to the `summarize` method.
  
  Example::
  
      >>> from lightning.pytorch import Trainer
      >>> from lightning.pytorch.callbacks import ModelSummary
      >>> trainer = Trainer(callbacks=[ModelSummary(max_depth=1)])
code: def on_fit_start(
      self, trainer: "pl.Trainer", pl_module: "pl.LightningModule"
  ) -> None:
      if not self._max_depth:
          return
  
      model_summary = self._summary(trainer, pl_module)
      summary_data = model_summary._get_summary_data()
      total_parameters = model_summary.total_parameters
      trainable_parameters = model_summary.trainable_parameters
      model_size = model_summary.model_size
  
      if trainer.is_global_zero:
          self.summarize(
              summary_data,
              total_parameters,
              trainable_parameters,
              model_size,
              **self._summarize_kwargs,
          )
  
file_path: pytorch-lightning/src/lightning/pytorch/callbacks/model_summary.py
imports: import logging
  from typing import Any, Dict, List, Tuple, Union
  from typing_extensions import override
  import lightning.pytorch
  from lightning.pytorch.callbacks.callback import Callback
  from lightning.pytorch.utilities.model_summary import DeepSpeedSummary, summarize
  from lightning.pytorch.utilities.model_summary import ModelSummary
  from lightning.pytorch.utilities.model_summary.model_summary import _format_summary_table
label_desc: Use image node_id 2 for calling the ModelSummary obj's underlying member method code with example usage: obj.on_fit_start(trainer, pl_module) without return types