class_docstr: Upload all code files to wandb as an artifact, at the beginning of the run.
class_docstr_tok: ["Upload","all","code","files","to","wandb","as","an","artifact",",","at","the","beginning","of","the","run","."]
code: def on_train_start(self, trainer, pl_module):
      logger = get_wandb_logger(trainer=trainer)
      experiment = logger.experiment
  
      code = wandb.Artifact("project-source", type="code")
  
      if self.use_git:
          # get .git folder
          # https://alexwlchan.net/2020/11/a-python-function-to-ignore-a-path-with-git-info-exclude/
          git_dir_path = Path(
              subprocess.check_output(["git", "rev-parse", "--git-dir"])
              .strip()
              .decode("utf8")
          ).resolve()
  
          for path in Path(self.code_dir).resolve().rglob("*"):
              if (
                  path.is_file()
                  # ignore files in .git
                  and not str(path).startswith(
                      str(git_dir_path)
                  )  # noqa: W503
                  # ignore files ignored by git
                  and (  # noqa: W503
                      subprocess.run(
                          ["git", "check-ignore", "-q", str(path)]
                      ).returncode
                      == 1
                  )
              ):
                  code.add_file(
                      str(path),
                      name=str(path.relative_to(self.code_dir)),
                  )
  
      else:
          for path in Path(self.code_dir).resolve().rglob("*.py"):
              code.add_file(
                  str(path), name=str(path.relative_to(self.code_dir))
              )
  
      experiment.log_artifact(code)
  
imports: import subprocess
  from pathlib import Path
  from typing import List
  import matplotlib.pyplot
  import seaborn
  import torch
  import wandb
  from pytorch_lightning import Callback, Trainer
  from pytorch_lightning.loggers import LoggerCollection, WandbLogger
  from pytorch_lightning.utilities import rank_zero_only
  from sklearn import metrics
  from sklearn.metrics import f1_score, precision_score, recall_score
label_desc: Use image node_id 2 for calling the UploadCodeAsArtifact obj's underlying member method code with example usage: obj.on_train_start(trainer, pl_module) without return types