code: def _custom_format_warning(
      message: Union[Warning, str],
      category: Type[Warning],
      filename: str,
      lineno: int,
      line: Optional[str] = None,
  ) -> str:
      """Custom formatting that avoids an extra line in case warnings are emitted from the `rank_zero`-functions."""
      if _is_path_in_lightning(Path(filename)):
          # The warning originates from the Lightning package
          return f"{filename}:{lineno}: {message}\n"
      return _default_format_warning(
          message, category, filename, lineno, line
      )
  
file_path: pytorch-lightning/src/lightning/fabric/utilities/warnings.py
imports: import warnings
  from pathlib import Path
  from typing import Optional, Type, Union
  from lightning.fabric.utilities.rank_zero import LightningDeprecationWarning
label_desc: Use image node_id 2 for calling a global function with example usage: _custom_format_warning(message, category, filename, lineno, line) and returns: _default_format_warning, filename, str, lineno, str, message, str