docstr: A new Experiment object defaults to 'default' unless a specific name is provided
  If a known name is already provided, then the file version is changed
  :param name:
  :param debug:
docstr_tok: ["A","new","Experiment","object","defaults","to","'default","'","unless","a","specific","name","is","provided","If","a","known","name","is","already","provided",",","then","the","file","version","is","changed",":","param","name",":",":","param","debug",":"]
code: def __init__(
      self,
      save_dir=None,
      name="default",
      debug=False,
      version=None,
      autosave=False,
      description=None,
      create_git_tag=False,
      rank=0,
      *args,
      **kwargs,
  ):
      """
      A new Experiment object defaults to 'default' unless a specific name is provided
      If a known name is already provided, then the file version is changed
      :param name:
      :param debug:
      """
  
      # change where the save dir is if requested
  
      if save_dir is not None:
          global _ROOT
          _ROOT = save_dir
  
      self.save_dir = save_dir
      self.tag_markdown_saved = False
      self.no_save_dir = save_dir is None
      self.metrics = []
      self.tags = {}
      self.name = name
      self.debug = debug
      self.version = version
      self.autosave = autosave
      self.description = description
      self.create_git_tag = create_git_tag
      self.exp_hash = "{}_v{}".format(self.name, version)
      self.created_at = str(datetime.utcnow())
      self.rank = rank
      self.process = os.getpid()
  
      # when debugging don't do anything else
      if debug:
          return
  
      # update version hash if we need to increase version on our own
      # we will increase the previous version, so do it now so the hash
      # is accurate
      if version is None:
          old_version = self.__get_last_experiment_version()
          self.exp_hash = "{}_v{}".format(self.name, old_version + 1)
          self.version = old_version + 1
  
      # create a new log file
      self.__init_cache_file_if_needed()
  
      # when we have a version, load it
      if self.version is not None:
          # when no version and no file, create it
          if not os.path.exists(self.__get_log_name()):
              self.__create_exp_file(self.version)
          else:
              # otherwise load it
              try:
                  self.__load()
              except Exception as e:
                  self.debug = True
      else:
          # if no version given, increase the version to a new exp
          # create the file if not exists
          old_version = self.__get_last_experiment_version()
          self.version = old_version
          self.__create_exp_file(self.version + 1)
  
      # create a git tag if requested
      if self.create_git_tag:
          desc = (
              description
              if description is not None
              else "no description"
          )
          tag_msg = "Test tube exp: {} - {}".format(self.name, desc)
          cmd = 'git tag -a tt_{} -m "{}"'.format(
              self.exp_hash, tag_msg
          )
          os.system(cmd)
          print(
              "Test tube created git tag:",
              "tt_{}".format(self.exp_hash),
          )
  
      # set the tensorboardx log path to the /tf folder in the exp folder
      log_dir = self.get_tensorboardx_path(self.name, self.version)
      # this is a fix for pytorch 1.1 since it does not have this attribute
      for attr, val in [
          ("purge_step", None),
          ("max_queue", 10),
          ("flush_secs", 120),
          ("filename_suffix", ""),
      ]:
          if not hasattr(self, attr):
              setattr(self, attr, val)
      super().__init__(log_dir=log_dir, *args, **kwargs)
  
imports: import contextlib
  import json
  import os
  import shutil
  from datetime import datetime
  import numpy
  import pandas
  from imageio import imwrite
  from tensorboard.compat.proto.event_pb2 import Event
  from tensorboard.compat.proto.event_pb2 import SessionLog
  from torch.utils.tensorboard import SummaryWriter, FileWriter
label_desc: Use image node_id 1 to create a new Experiment object from inherited base classes: SummaryWriter with example: obj = Experiment(save_dir, name, debug, version, autosave, description, create_git_tag, rank)