# Buggy code
def __init__(
    self,
    api_key: Optional[str] = None,
    project_name: Optional[str] = None,
    close_after_fit: Optional[bool] = True,
    offline_mode: bool = False,
    experiment_name: Optional[str] = None,
    upload_source_files: Optional[List[str]] = None,
    params: Optional[Dict[str, Any]] = None,
    properties: Optional[Dict[str, Any]] = None,
    tags: Optional[List[str]] = None,
    **kwargs,
):
    super().__init__()
    self.api_key = api_key
    self.project_name = project_name
    self.offline_mode = offline_mode
    self.close_after_fit = close_after_fit
    self.experiment_name = experiment_name
    self.upload_source_files = upload_source_files
    self.params = params
    self.properties = properties
    self.tags = tags
    self._experiment = None
    self._kwargs = kwargs

    if offline_mode:
        self.mode = "offline"
        neptune.init(
            project_qualified_name="dry-run/project", backend=neptune.OfflineBackend()
        )
    else:
        self.mode = "online"
        neptune.init(api_token=self.api_key, project_qualified_name=self.project_name)

    log.info(f"NeptuneLogger was initialized in {self.mode} mode")


# Traceback (Exception)
Traceback (most recent call last):
File "pl.py", line 146, in <module>
main()
File "pl.py", line 103, in main
trainer.fit(model)
File "/home/hirune/anaconda3/envs/PANDA/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 751, in fit
mp.spawn(self.ddp_train, nprocs=self.num_processes, args=(model,))
File "/home/hirune/anaconda3/envs/PANDA/lib/python3.7/site-packages/torch/multiprocessing/spawn.py", line 200, in spawn
return start_processes(fn, args, nprocs, join, daemon, start_method='spawn')
File "/home/hirune/anaconda3/envs/PANDA/lib/python3.7/site-packages/torch/multiprocessing/spawn.py", line 158, in start_processes
while not context.join():
File "/home/hirune/anaconda3/envs/PANDA/lib/python3.7/site-packages/torch/multiprocessing/spawn.py", line 119, in join
raise Exception(msg)
Exception:

-- Process 1 terminated with the following error:
Traceback (most recent call last):
File "/home/hirune/anaconda3/envs/PANDA/lib/python3.7/site-packages/torch/multiprocessing/spawn.py", line 20, in _wrap
fn(i, *args)
File "/home/hirune/anaconda3/envs/PANDA/lib/python3.7/site-packages/pytorch_lightning/trainer/distrib_data_parallel.py", line 370, in ddp_train
self.run_pretrain_routine(model)
File "/home/hirune/anaconda3/envs/PANDA/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 871, in run_pretrain_routine
self.configure_checkpoint_callback()
File "/home/hirune/anaconda3/envs/PANDA/lib/python3.7/site-packages/pytorch_lightning/trainer/callback_config.py", line 54, in configure_checkpoint_callback
self.logger.name,
File "/home/hirune/anaconda3/envs/PANDA/lib/python3.7/site-packages/pytorch_lightning/loggers/neptune.py", line 267, in name
return self.experiment.name
File "/home/hirune/anaconda3/envs/PANDA/lib/python3.7/site-packages/pytorch_lightning/loggers/neptune.py", line 230, in experiment
**self._kwargs)
File "/home/hirune/anaconda3/envs/PANDA/lib/python3.7/site-packages/neptune/__init__.py", line 222, in create_experiment
raise Uninitialized()
neptune.exceptions.Uninitialized: You must initialize neptune-client first. For more information, please visit: https://github.com/neptune-ai/neptune-client#initialize-neptune

# Fixed code
def __init__(
    self,
    api_key: Optional[str] = None,
    project_name: Optional[str] = None,
    close_after_fit: Optional[bool] = True,
    offline_mode: bool = False,
    experiment_name: Optional[str] = None,
    upload_source_files: Optional[List[str]] = None,
    params: Optional[Dict[str, Any]] = None,
    properties: Optional[Dict[str, Any]] = None,
    tags: Optional[List[str]] = None,
    **kwargs,
):
    super().__init__()
    self.api_key = api_key
    self.project_name = project_name
    self.offline_mode = offline_mode
    self.close_after_fit = close_after_fit
    self.experiment_name = experiment_name
    self.upload_source_files = upload_source_files
    self.params = params
    self.properties = properties
    self.tags = tags
    self._kwargs = kwargs
    self._experiment_id = None
    self._experiment = self._create_or_get_experiment()

    log.info(
        f"NeptuneLogger will work in {'offline' if self.offline_mode else 'online'} mode"
    )