class_docstr: Log using `Neptune <https://neptune.ai>`_.
  
  Install it with pip:
  
  .. code-block:: bash
  
      pip install neptune
  
  or conda:
  
  .. code-block:: bash
  
      conda install -c conda-forge neptune-client
  
  **Quickstart**
  
  Pass a NeptuneLogger instance to the Trainer to log metadata with Neptune:
  
  .. code-block:: python
  
  
      from lightning.pytorch import Trainer
      from lightning.pytorch.loggers import NeptuneLogger
      import neptune
  
      neptune_logger = NeptuneLogger(
          api_key=neptune.ANONYMOUS_API_TOKEN,  # replace with your own
          project="common/pytorch-lightning-integration",  # format "workspace-name/project-name"
          tags=["training", "resnet"],  # optional
      )
      trainer = Trainer(max_epochs=10, logger=neptune_logger)
  
  **How to use NeptuneLogger?**
  
  Use the logger anywhere in your :class:`~lightning.pytorch.core.LightningModule` as follows:
  
  .. code-block:: python
  
      from neptune.types import File
      from lightning.pytorch import LightningModule
  
  
      class LitModel(LightningModule):
          def training_step(self, batch, batch_idx):
              # log metrics
              acc = ...
              self.append("train/loss", loss)
  
          def any_lightning_module_function_or_hook(self):
              # log images
              img = ...
              self.logger.experiment["train/misclassified_images"].append(File.as_image(img))
  
              # generic recipe
              metadata = ...
              self.logger.experiment["your/metadata/structure"] = metadata
  
  Note that the syntax ``self.logger.experiment["your/metadata/structure"].append(metadata)`` is specific to
  Neptune and extends the logger capabilities. It lets you log various types of metadata, such as
  scores, files, images, interactive visuals, and CSVs.
  Refer to the `Neptune docs <https://docs.neptune.ai/logging/methods>`_
  for details.
  You can also use the regular logger methods ``log_metrics()``, and ``log_hyperparams()`` with NeptuneLogger.
  
  **Log after fitting or testing is finished**
  
  You can log objects after the fitting or testing methods are finished:
  
  .. code-block:: python
  
      neptune_logger = NeptuneLogger(project="common/pytorch-lightning-integration")
  
      trainer = pl.Trainer(logger=neptune_logger)
      model = ...
      datamodule = ...
      trainer.fit(model, datamodule=datamodule)
      trainer.test(model, datamodule=datamodule)
  
      # Log objects after `fit` or `test` methods
      # model summary
      neptune_logger.log_model_summary(model=model, max_depth=-1)
  
      # generic recipe
      metadata = ...
      neptune_logger.experiment["your/metadata/structure"] = metadata
  
  **Log model checkpoints**
  
  If you have :class:`~lightning.pytorch.callbacks.ModelCheckpoint` configured,
  the Neptune logger automatically logs model checkpoints.
  Model weights will be uploaded to the "model/checkpoints" namespace in the Neptune run.
  You can disable this option with:
  
  .. code-block:: python
  
      neptune_logger = NeptuneLogger(log_model_checkpoints=False)
  
  **Pass additional parameters to the Neptune run**
  
  You can also pass ``neptune_run_kwargs`` to add details to the run, like ``tags`` or ``description``:
  
  .. testcode::
      :skipif: not _NEPTUNE_AVAILABLE
  
      from lightning.pytorch import Trainer
      from lightning.pytorch.loggers import NeptuneLogger
  
      neptune_logger = NeptuneLogger(
          project="common/pytorch-lightning-integration",
          name="lightning-run",
          description="mlp quick run with pytorch-lightning",
          tags=["mlp", "quick-run"],
      )
      trainer = Trainer(max_epochs=3, logger=neptune_logger)
  
  Check `run documentation <https://docs.neptune.ai/api/neptune/#init_run>`_
  for more info about additional run parameters.
  
  **Details about Neptune run structure**
  
  Runs can be viewed as nested dictionary-like structures that you can define in your code.
  Thanks to this you can easily organize your metadata in a way that is most convenient for you.
  
  The hierarchical structure that you apply to your metadata is reflected in the Neptune web app.
  
  See also:
      - Read about
        `what objects you can log to Neptune <https://docs.neptune.ai/logging/what_you_can_log/>`_.
      - Check out an `example run <https://app.neptune.ai/o/common/org/pytorch-lightning-integration/e/PTL-1/all>`_
        with multiple types of metadata logged.
      - For more detailed examples, see the
        `user guide <https://docs.neptune.ai/integrations/lightning/>`_.
  
  Args:
      api_key: Optional.
          Neptune API token, found on https://neptune.ai upon registration.
          You should save your token to the `NEPTUNE_API_TOKEN`
          environment variable and leave the api_key argument out of your code.
          Instructions: `Setting your API token <https://docs.neptune.ai/setup/setting_api_token/>`_.
      project: Optional.
          Name of a project in the form "workspace-name/project-name", for example "tom/mask-rcnn".
          If ``None``, the value of `NEPTUNE_PROJECT` environment variable is used.
          You need to create the project on https://neptune.ai first.
      name: Optional. Editable name of the run.
          The run name is displayed in the Neptune web app.
      run: Optional. Default is ``None``. A Neptune ``Run`` object.
          If specified, this existing run will be used for logging, instead of a new run being created.
          You can also pass a namespace handler object; for example, ``run["test"]``, in which case all
          metadata is logged under the "test" namespace inside the run.
      log_model_checkpoints: Optional. Default is ``True``. Log model checkpoint to Neptune.
          Works only if ``ModelCheckpoint`` is passed to the ``Trainer``.
      prefix: Optional. Default is ``"training"``. Root namespace for all metadata logging.
      \**neptune_run_kwargs: Additional arguments like ``tags``, ``description``, ``capture_stdout``, etc.
          used when a run is created.
  
  Raises:
      ModuleNotFoundError:
          If the required Neptune package is not installed.
      ValueError:
          If an argument passed to the logger's constructor is incorrect.
class_docstr_tok: ["Log","using","`","Neptune","<","https",":","\/\/neptune.ai",">","`","_",".","Install","it","with","pip",":","..","code-block",":",":","bash","pip","install","neptune","or","conda",":","..","code-block",":",":","bash","conda","install","-c","conda-forge","neptune-client","*","*","Quickstart","*","*","Pass","a","NeptuneLogger","instance","to","the","Trainer","to","log","metadata","with","Neptune",":","..","code-block",":",":","python","from","lightning.pytorch","import","Trainer","from","lightning.pytorch.loggers","import","NeptuneLogger","import","neptune","neptune_logger","=","NeptuneLogger","(","api_key=neptune.ANONYMOUS_API_TOKEN",",","#","replace","with","your","own","project=","''","common\/pytorch-lightning-integration","''",",","#","format","``","workspace-name\/project-name","''","tags=","[","``","training","''",",","``","resnet","''","]",",","#","optional",")","trainer","=","Trainer","(","max_epochs=10",",","logger=neptune_logger",")","*","*","How","to","use","NeptuneLogger","?","*","*","Use","the","logger","anywhere","in","your",":","class",":","`","~lightning.pytorch.core.LightningModule","`","as","follows",":","..","code-block",":",":","python","from","neptune.types","import","File","from","lightning.pytorch","import","LightningModule","class","LitModel","(","LightningModule",")",":","def","training_step","(","self",",","batch",",","batch_idx",")",":","#","log","metrics","acc","=","...","self.append","(","``","train\/loss","''",",","loss",")","def","any_lightning_module_function_or_hook","(","self",")",":","#","log","images","img","=","...","self.logger.experiment","[","``","train\/misclassified_images","''","]",".append","(","File.as_image","(","img",")",")","#","generic","recipe","metadata","=","...","self.logger.experiment","[","``","your\/metadata\/structure","''","]","=","metadata","Note","that","the","syntax","``","self.logger.experiment","[","``","your\/metadata\/structure","''","]",".append","(","metadata",")","``","is","specific","to","Neptune","and","extends","the","logger","capabilities",".","It","lets","you","log","various","types","of","metadata",",","such","as","scores",",","files",",","images",",","interactive","visuals",",","and","CSVs",".","Refer","to","the","`","Neptune","docs","<","https",":","\/\/docs.neptune.ai\/logging\/methods",">","`","_","for","details",".","You","can","also","use","the","regular","logger","methods","``","log_metrics","(",")","``",",","and","``","log_hyperparams","(",")","``","with","NeptuneLogger",".","*","*","Log","after","fitting","or","testing","is","finished","*","*","You","can","log","objects","after","the","fitting","or","testing","methods","are","finished",":","..","code-block",":",":","python","neptune_logger","=","NeptuneLogger","(","project=","''","common\/pytorch-lightning-integration","''",")","trainer","=","pl.Trainer","(","logger=neptune_logger",")","model","=","...","datamodule","=","...","trainer.fit","(","model",",","datamodule=datamodule",")","trainer.test","(","model",",","datamodule=datamodule",")","#","Log","objects","after","`","fit","`","or","`","test","`","methods","#","model","summary","neptune_logger.log_model_summary","(","model=model",",","max_depth=-1",")","#","generic","recipe","metadata","=","...","neptune_logger.experiment","[","``","your\/metadata\/structure","''","]","=","metadata","*","*","Log","model","checkpoints","*","*","If","you","have",":","class",":","`","~lightning.pytorch.callbacks.ModelCheckpoint","`","configured",",","the","Neptune","logger","automatically","logs","model","checkpoints",".","Model","weights","will","be","uploaded","to","the","``","model\/checkpoints","''","namespace","in","the","Neptune","run",".","You","can","disable","this","option","with",":","..","code-block",":",":","python","neptune_logger","=","NeptuneLogger","(","log_model_checkpoints=False",")","*","*","Pass","additional","parameters","to","the","Neptune","run","*","*","You","can","also","pass","``","neptune_run_kwargs","``","to","add","details","to","the","run",",","like","``","tags","``","or","``","description","``",":","..","testcode",":",":",":","skipif",":","not","_NEPTUNE_AVAILABLE","from","lightning.pytorch","import","Trainer","from","lightning.pytorch.loggers","import","NeptuneLogger","neptune_logger","=","NeptuneLogger","(","project=","''","common\/pytorch-lightning-integration","''",",","name=","''","lightning-run","''",",","description=","''","mlp","quick","run","with","pytorch-lightning","''",",","tags=","[","``","mlp","''",",","``","quick-run","''","]",",",")","trainer","=","Trainer","(","max_epochs=3",",","logger=neptune_logger",")","Check","`","run","documentation","<","https",":","\/\/docs.neptune.ai\/api\/neptune\/","#","init_run",">","`","_","for","more","info","about","additional","run","parameters",".","*","*","Details","about","Neptune","run","structure","*","*","Runs","can","be","viewed","as","nested","dictionary-like","structures","that","you","can","define","in","your","code",".","Thanks","to","this","you","can","easily","organize","your","metadata","in","a","way","that","is","most","convenient","for","you",".","The","hierarchical","structure","that","you","apply","to","your","metadata","is","reflected","in","the","Neptune","web","app",".","See","also",":","-","Read","about","`","what","objects","you","can","log","to","Neptune","<","https",":","\/\/docs.neptune.ai\/logging\/what_you_can_log\/",">","`","_",".","-","Check","out","an","`","example","run","<","https",":","\/\/app.neptune.ai\/o\/common\/org\/pytorch-lightning-integration\/e\/PTL-1\/all",">","`","_","with","multiple","types","of","metadata","logged",".","-","For","more","detailed","examples",",","see","the","`","user","guide","<","https",":","\/\/docs.neptune.ai\/integrations\/lightning\/",">","`","_",".","Args",":","api_key",":","Optional",".","Neptune","API","token",",","found","on","https",":","\/\/neptune.ai","upon","registration",".","You","should","save","your","token","to","the","`","NEPTUNE_API_TOKEN","`","environment","variable","and","leave","the","api_key","argument","out","of","your","code",".","Instructions",":","`","Setting","your","API","token","<","https",":","\/\/docs.neptune.ai\/setup\/setting_api_token\/",">","`","_",".","project",":","Optional",".","Name","of","a","project","in","the","form","``","workspace-name\/project-name","''",",","for","example","``","tom\/mask-rcnn","''",".","If","``","None","``",",","the","value","of","`","NEPTUNE_PROJECT","`","environment","variable","is","used",".","You","need","to","create","the","project","on","https",":","\/\/neptune.ai","first",".","name",":","Optional",".","Editable","name","of","the","run",".","The","run","name","is","displayed","in","the","Neptune","web","app",".","run",":","Optional",".","Default","is","``","None","``",".","A","Neptune","``","Run","``","object",".","If","specified",",","this","existing","run","will","be","used","for","logging",",","instead","of","a","new","run","being","created",".","You","can","also","pass","a","namespace","handler","object",";","for","example",",","``","run","[","``","test","''","]","``",",","in","which","case","all","metadata","is","logged","under","the","``","test","''","namespace","inside","the","run",".","log_model_checkpoints",":","Optional",".","Default","is","``","True","``",".","Log","model","checkpoint","to","Neptune",".","Works","only","if","``","ModelCheckpoint","``","is","passed","to","the","``","Trainer","``",".","prefix",":","Optional",".","Default","is","``","``","training","''","``",".","Root","namespace","for","all","metadata","logging",".","\\","*","*","neptune_run_kwargs",":","Additional","arguments","like","``","tags","``",",","``","description","``",",","``","capture_stdout","``",",","etc",".","used","when","a","run","is","created",".","Raises",":","ModuleNotFoundError",":","If","the","required","Neptune","package","is","not","installed",".","ValueError",":","If","an","argument","passed","to","the","logger","'s","constructor","is","incorrect","."]
docstr: Gets the save directory of the experiment which in this case is ``None`` because Neptune does not save
  locally.
  
  Returns:
      the root directory where experiment logs get saved
docstr_tok: ["Gets","the","save","directory","of","the","experiment","which","in","this","case","is","``","None","``","because","Neptune","does","not","save","locally",".","Returns",":","the","root","directory","where","experiment","logs","get","saved"]
code: def save_dir(self) -> Optional[str]:
      """Gets the save directory of the experiment which in this case is ``None`` because Neptune does not save
      locally.
  
      Returns:
          the root directory where experiment logs get saved
  
      """
      return os.path.join(os.getcwd(), ".neptune")
  
imports: import contextlib
  import logging
  import os
  from argparse import Namespace
  from typing import TYPE_CHECKING, Any, Dict, Generator, List, Optional, Set, Union
  from lightning_utilities.core.imports import RequirementCache
  from torch import Tensor
  from typing_extensions import override
  import lightning.pytorch
  from lightning.fabric.utilities.logger import _add_prefix, _convert_params, _sanitize_callable_params
  from lightning.pytorch.callbacks import Checkpoint
  from lightning.pytorch.loggers.logger import Logger, rank_zero_experiment
  from lightning.pytorch.utilities.model_summary import ModelSummary
  from lightning.pytorch.utilities.rank_zero import rank_zero_only
label_desc: Use image node_id 13 for calling the NeptuneLogger obj's underlying member method code with example usage: obj.save_dir() and returns: os