class_docstr: If you wish to write a custom profiler, you should inherit from this class.
code: def __init__(
      self,
      dirpath: Optional[Union[str, Path]] = None,
      filename: Optional[str] = None,
  ) -> None:
      self.dirpath = dirpath
      self.filename = filename
  
      self._output_file: Optional[TextIO] = None
      self._write_stream: Optional[Callable] = None
      self._local_rank: Optional[int] = None
      self._stage: Optional[str] = None
  
imports: import logging
  import os
  from abc import ABC, abstractmethod
  from contextlib import contextmanager
  from pathlib import Path
  from typing import Any, Callable, Dict, Generator, Optional, TextIO, Union
  from lightning.fabric.utilities.cloud_io import get_filesystem
label_desc: Use image node_id 1 to create a new Profiler object from inherited base classes: ABC with example: obj = Profiler(dirpath, filename)