class_docstr: Track your parameters, metrics, source code and more using `Comet
  <https://www.comet.com/?utm_source=lightning.pytorch&utm_medium=referral>`_.
  
  Install it with pip:
  
  .. code-block:: bash
  
      pip install comet-ml
  
  Comet requires either an API Key (online mode) or a local directory path (offline mode).
  
  **ONLINE MODE**
  
  .. code-block:: python
  
      import os
      from lightning.pytorch import Trainer
      from lightning.pytorch.loggers import CometLogger
  
      # arguments made to CometLogger are passed on to the comet_ml.Experiment class
      comet_logger = CometLogger(
          api_key=os.environ.get("COMET_API_KEY"),
          workspace=os.environ.get("COMET_WORKSPACE"),  # Optional
          save_dir=".",  # Optional
          project_name="default_project",  # Optional
          rest_api_key=os.environ.get("COMET_REST_API_KEY"),  # Optional
          experiment_key=os.environ.get("COMET_EXPERIMENT_KEY"),  # Optional
          experiment_name="lightning_logs",  # Optional
      )
      trainer = Trainer(logger=comet_logger)
  
  **OFFLINE MODE**
  
  .. code-block:: python
  
      from lightning.pytorch.loggers import CometLogger
  
      # arguments made to CometLogger are passed on to the comet_ml.Experiment class
      comet_logger = CometLogger(
          save_dir=".",
          workspace=os.environ.get("COMET_WORKSPACE"),  # Optional
          project_name="default_project",  # Optional
          rest_api_key=os.environ.get("COMET_REST_API_KEY"),  # Optional
          experiment_name="lightning_logs",  # Optional
      )
      trainer = Trainer(logger=comet_logger)
  
  **Log Hyperparameters:**
  
  Log parameters used to initialize a :class:`~lightning.pytorch.core.LightningModule`:
  
  .. code-block:: python
  
      class LitModule(LightningModule):
          def __init__(self, *args, **kwarg):
              self.save_hyperparameters()
  
  Log other Experiment Parameters
  
  .. code-block:: python
  
      # log a single parameter
      logger.log_hyperparams({"batch_size": 16})
  
      # log multiple parameters
      logger.log_hyperparams({"batch_size": 16, "learning_rate": 0.001})
  
  **Log Metrics:**
  
  .. code-block:: python
  
      # log a single metric
      logger.log_metrics({"train/loss": 0.001})
  
      # add multiple metrics
      logger.log_metrics({"train/loss": 0.001, "val/loss": 0.002})
  
  **Access the Comet Experiment object:**
  
  You can gain access to the underlying Comet
  `Experiment <https://www.comet.com/docs/v2/api-and-sdk/python-sdk/reference/Experiment/>`__ object
  and its methods through the :obj:`logger.experiment` property. This will let you use
  the additional logging features provided by the Comet SDK.
  
  Some examples of data you can log through the Experiment object:
  
  Log Image data:
  
  .. code-block:: python
  
      img = PIL.Image.open("<path to image>")
      logger.experiment.log_image(img, file_name="my_image.png")
  
  Log Text data:
  
  .. code-block:: python
  
      text = "Lightning is awesome!"
      logger.experiment.log_text(text)
  
  Log Audio data:
  
  .. code-block:: python
  
      audio = "<path to audio data>"
      logger.experiment.log_audio(audio, file_name="my_audio.wav")
  
  Log arbitrary data assets:
  
  You can log any type of data to Comet as an asset. These can be model
  checkpoints, datasets, debug logs, etc.
  
  .. code-block:: python
  
      logger.experiment.log_asset("<path to your asset>", file_name="my_data.pkl")
  
  Log Models to Comet's Model Registry:
  
  .. code-block:: python
  
      logger.experiment.log_model(name="my-model", "<path to your model>")
  
  See Also:
      - `Demo in Google Colab <https://tinyurl.com/22phzw5s>`__
      - `Comet Documentation <https://www.comet.com/docs/v2/integrations/ml-frameworks/pytorch-lightning/>`__
  
  Args:
      api_key: Required in online mode. API key, found on Comet.ml. If not given, this
          will be loaded from the environment variable COMET_API_KEY or ~/.comet.config
          if either exists.
      save_dir: Required in offline mode. The path for the directory to save local
          comet logs. If given, this also sets the directory for saving checkpoints.
      project_name: Optional. Send your experiment to a specific project.
          Otherwise will be sent to Uncategorized Experiments.
          If the project name does not already exist, Comet.ml will create a new project.
      rest_api_key: Optional. Rest API key found in Comet.ml settings.
          This is used to determine version number
      experiment_name: Optional. String representing the name for this particular experiment on Comet.ml.
      experiment_key: Optional. If set, restores from existing experiment.
      offline: If api_key and save_dir are both given, this determines whether
          the experiment will be in online or offline mode. This is useful if you use
          save_dir to control the checkpoints directory and have a ~/.comet.config
          file but still want to run offline experiments.
      prefix: A string to put at the beginning of metric keys.
      \**kwargs: Additional arguments like `workspace`, `log_code`, etc. used by
          :class:`CometExperiment` can be passed as keyword arguments in this logger.
  
  Raises:
      ModuleNotFoundError:
          If required Comet package is not installed on the device.
      MisconfigurationException:
          If neither ``api_key`` nor ``save_dir`` are passed as arguments.
docstr: When calling ``self.experiment.end()``, that experiment won't log any more data to Comet. That's why, if you
  need to log any more data, you need to create an ExistingCometExperiment. For example, to log data when testing
  your model after training, because when training is finalized :meth:`CometLogger.finalize` is called.
  
  This happens automatically in the :meth:`~CometLogger.experiment` property, when
  ``self._experiment`` is set to ``None``, i.e. ``self.reset_experiment()``.
docstr_tok: ["When","calling","``","self.experiment.end","(",")","``",",","that","experiment","wo","n't","log","any","more","data","to","Comet",".","That","'s","why",",","if","you","need","to","log","any","more","data",",","you","need","to","create","an","ExistingCometExperiment",".","For","example",",","to","log","data","when","testing","your","model","after","training",",","because","when","training","is","finalized",":","meth",":","`","CometLogger.finalize","`","is","called",".","This","happens","automatically","in","the",":","meth",":","`","~CometLogger.experiment","`","property",",","when","``","self._experiment","``","is","set","to","``","None","``",",","i.e",".","``","self.reset_experiment","(",")","``","."]
code: def finalize(self, status: str) -> None:
      r"""When calling ``self.experiment.end()``, that experiment won't log any more data to Comet. That's why, if you
      need to log any more data, you need to create an ExistingCometExperiment. For example, to log data when testing
      your model after training, because when training is finalized :meth:`CometLogger.finalize` is called.
  
      This happens automatically in the :meth:`~CometLogger.experiment` property, when
      ``self._experiment`` is set to ``None``, i.e. ``self.reset_experiment()``.
  
      """
      if self._experiment is None:
          # When using multiprocessing, finalize() should be a no-op on the main process, as no experiment has been
          # initialized there
          return
      self.experiment.end()
      self.reset_experiment()
  
imports: import logging
  import os
  from argparse import Namespace
  from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union
  from lightning_utilities.core.imports import RequirementCache
  from torch import Tensor
  from torch.nn import Module
  from typing_extensions import override
  from lightning.fabric.utilities.logger import _add_prefix, _convert_params, _flatten_dict
  from lightning.pytorch.loggers.logger import Logger, rank_zero_experiment
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.rank_zero import rank_zero_only
label_desc: Use image node_id 6 for calling the CometLogger obj's underlying member method code with example usage: obj.finalize(status) without return types