class_docstr: `Neptune <https://neptune.ai/>`_ handler to log metrics, model/optimizer parameters and gradients during training
  and validation. It can also log model checkpoints to Neptune.
  
  .. code-block:: bash
  
      pip install neptune
  
  Args:
      api_token: Neptune API token, found on https://neptune.ai -> User menu -> "Get your API token".
         If None, the value of the NEPTUNE_API_TOKEN environment variable is used. To keep your token
         secure, you should set it to the environment variable rather than including it in your code.
      project: Name of a Neptune project, in the form "workspace-name/project-name".
         For example "tom/mnist-classification".
         If None, the value of the NEPTUNE_PROJECT environment variable is used.
      **kwargs: Other arguments to be passed to the `init_run()` function.
  
  Examples:
      .. code-block:: python
  
          from ignite.contrib.handlers.neptune_logger import *
  
          # Create a logger
          # Note: We are using the API token for anonymous logging. You can pass your own token, or save it as an
          # environment variable and leave out the api_token argument.
  
          npt_logger = NeptuneLogger(
              api_token="ANONYMOUS",
              project="common/pytorch-ignite-integration",
              name="cnn-mnist",  # Optional,
              tags=["pytorch-ignite", "minst"],  # Optional
          )
  
          # Attach the logger to the trainer to log training loss at each iteration.
          npt_logger.attach_output_handler(
              trainer,
              event_name=Events.ITERATION_COMPLETED,
              tag="training",
              output_transform=lambda loss: {"loss": loss},
          )
  
          # Attach the logger to the evaluator on the training dataset and log NLL
          # and accuracy metrics after each epoch.
          # We set up `global_step_transform=global_step_from_engine(trainer)` to take the epoch
          # of the `trainer` instead of `train_evaluator`.
          npt_logger.attach_output_handler(
              train_evaluator,
              event_name=Events.EPOCH_COMPLETED,
              tag="training",
              metric_names=["nll", "accuracy"],
              global_step_transform=global_step_from_engine(trainer),
          )
  
          # Attach the logger to the evaluator on the validation dataset and log NLL and accuracy metrics after
          # each epoch. We set up `global_step_transform=global_step_from_engine(trainer)` to take the epoch of the
          # `trainer` instead of `evaluator`.
          npt_logger.attach_output_handler(
              evaluator,
              event_name=Events.EPOCH_COMPLETED,
              tag="validation",
              metric_names=["nll", "accuracy"],
              global_step_transform=global_step_from_engine(trainer),
          )
  
          # Attach the logger to the trainer to log optimizer parameters, such as learning rate at each iteration.
          npt_logger.attach_opt_params_handler(
              trainer,
              event_name=Events.ITERATION_STARTED,
              optimizer=optimizer,
              param_name="lr",  # optional
          )
  
          # Attach the logger to the trainer to log model's weights norm after each iteration.
          npt_logger.attach(
              trainer,
              event_name=Events.ITERATION_COMPLETED,
              log_handler=WeightsScalarHandler(model),
          )
  
      Explore runs with Neptune tracking here:
      https://app.neptune.ai/o/common/org/pytorch-ignite-integration/
  
      You can also save model checkpoints to a Neptune:
  
      .. code-block:: python
  
          from ignite.handlers import Checkpoint
  
  
          def score_function(engine):
              return engine.state.metrics["accuracy"]
  
  
          to_save = {"model": model}
          handler = Checkpoint(
              to_save,
              NeptuneSaver(npt_logger), n_saved=2,
              filename_prefix="best",
              score_function=score_function,
              score_name="validation_accuracy",
              global_step_transform=global_step_from_engine(trainer),
          )
          validation_evaluator.add_event_handler(Events.COMPLETED, handler)
  
      It is also possible to use the logger as a context manager:
  
      .. code-block:: python
  
          from ignite.contrib.handlers.neptune_logger import *
  
          with NeptuneLogger() as npt_logger:
              trainer = Engine(update_fn)
              # Attach the logger to the trainer to log training loss at each iteration
              npt_logger.attach_output_handler(
                  trainer,
                  event_name=Events.ITERATION_COMPLETED,
                  tag="training",
                  output_transform=lambda loss: {"loss": loss},
              )
code: def close(self) -> None:
      self.experiment.stop()
  
imports: import tempfile
  import warnings
  from typing import Any, Callable, List, Mapping, Optional, Union
  import torch
  from torch.optim import Optimizer
  import ignite.distributed
  from ignite import __version__
  from ignite.contrib.handlers.base_logger import BaseLogger, BaseOptimizerParamsHandler, BaseOutputHandler, BaseWeightsScalarHandler
  from ignite.engine import Engine, Events
  from ignite.handlers import global_step_from_engine
  from ignite.handlers.checkpoint import BaseSaveHandler
label_desc: Use image node_id 5 for calling the NeptuneLogger obj's underlying member method code with example usage: obj.close() without return types