prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  TensorBoardLogger and ModelCheckpoint are not using the same folder by default
  ## 🐛 Bug
  (master branch)
  By default, the TensorBoardLogger writes logs into `lightning_logs/0` but ModelCheckpoint writes checkpoint into `lightning_logs/version_0`.
  
  </issue>
  <code>
  [start of pytorch_lightning/logging/tensorboard.py]
  1 import os
  2 from warnings import warn
  3 from argparse import Namespace
  4 from pkg_resources import parse_version
  5 
  6 import torch
  7 import pandas as pd
  8 from torch.utils.tensorboard import SummaryWriter
  9 
  10 from .base import LightningLoggerBase, rank_zero_only
  11 
  12 
  13 class TensorBoardLogger(LightningLoggerBase):
  14     r"""
  15 
  16     Log to local file system in TensorBoard format
  17 
  18     Implemented using :class:`torch.utils.tensorboard.SummaryWriter`. Logs are saved to
  19     `os.path.join(save_dir, name, version)`
  20 
  21     Example
  22     --------
  23 
  24     .. code-block:: python
  25 
  26         logger = TensorBoardLogger("tb_logs", name="my_model")
  27         trainer = Trainer(logger=logger)
  28         trainer.train(model)
  29 
  30     Args:
  31         save_dir (str): Save directory
  32         name (str): Experiment name. Defaults to "default".
  33         version (int): Experiment version. If version is not specified the logger inspects the save
  34         directory for existing versions, then automatically assigns the next available version.
  35         \**kwargs  (dict): Other arguments are passed directly to the :class:`SummaryWriter` constructor.
  36 
  37     """
  38     NAME_CSV_TAGS = 'meta_tags.csv'
  39 
  40     def __init__(self, save_dir, name="default", version=None, **kwargs):
  41         super().__init__()
  42         self.save_dir = save_dir
  43         self._name = name
  44         self._version = version
  45 
  46         self._experiment = None
  47         self.tags = {}
  48         self.kwargs = kwargs
  49 
  50     @property
  51     def experiment(self):
  52         r"""
  53 
  54          Actual tensorboard object. To use tensorboard features do the following.
  55 
  56          Example::
  57 
  58              self.logger.experiment.some_tensorboard_function()
  59 
  60          """
  61         if self._experiment is not None:
  62             return self._experiment
  63 
  64         root_dir = os.path.join(self.save_dir, self.name)
  65         os.makedirs(root_dir, exist_ok=True)
  66         log_dir = os.path.join(root_dir, str(self.version))
  67         self._experiment = SummaryWriter(log_dir=log_dir, **self.kwargs)
  68         return self._experiment
  69 
  70     @rank_zero_only
  71     def log_hyperparams(self, params):
  72         if params is None:
  73             return
  74 
  75         # in case converting from namespace
  76         if isinstance(params, Namespace):
  77             params = vars(params)
  78         params = dict(params)
  79 
  80         if parse_version(torch.__version__) < parse_version("1.3.0"):
  81             warn(
  82                 f"Hyperparameter logging is not available for Torch version {torch.__version__}."
  83                 " Skipping log_hyperparams. Upgrade to Torch 1.3.0 or above to enable"
  84                 " hyperparameter logging."
  85             )
  86         else:
  87             # `add_hparams` requires both - hparams and metric
  88             self.experiment.add_hparams(hparam_dict=params, metric_dict={})
  89         # some alternative should be added
  90         self.tags.update(params)
  91 
  92     @rank_zero_only
  93     def log_metrics(self, metrics, step=None):
  94         for k, v in metrics.items():
  95             if isinstance(v, torch.Tensor):
  96                 v = v.item()
  97             self.experiment.add_scalar(k, v, step)
  98 
  99     @rank_zero_only
  100     def save(self):
  101         try:
  102             self.experiment.flush()
  103         except AttributeError:
  104             # you are using PT version (<v1.2) which does not have implemented flush
  105             self.experiment._get_file_writer().flush()
  106 
  107         # create a preudo standard path ala test-tube
  108         dir_path = os.path.join(self.save_dir, self.name, 'version_%s' % self.version)
  109         if not os.path.isdir(dir_path):
  110             dir_path = self.save_dir
  111         # prepare the file path
  112         meta_tags_path = os.path.join(dir_path, self.NAME_CSV_TAGS)
  113         # save the metatags file
  114         df = pd.DataFrame({'key': list(self.tags.keys()),
  115                            'value': list(self.tags.values())})
  116         df.to_csv(meta_tags_path, index=False)
  117 
  118     @rank_zero_only
  119     def finalize(self, status):
  120         self.save()
  121 
  122     @property
  123     def name(self):
  124         return self._name
  125 
  126     @property
  127     def version(self):
  128         if self._version is None:
  129             self._version = self._get_next_version()
  130         return self._version
  131 
  132     def _get_next_version(self):
  133         root_dir = os.path.join(self.save_dir, self.name)
  134         existing_versions = [
  135             int(d) for d in os.listdir(root_dir) if os.path.isdir(os.path.join(root_dir, d)) and d.isdigit()
  136         ]
  137         if len(existing_versions) == 0:
  138             return 0
  139         else:
  140             return max(existing_versions) + 1
  141
  [end of pytorch_lightning/logging/tensorboard.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/pytorch_lightning/logging/tensorboard.py b/pytorch_lightning/logging/tensorboard.py
  --- a/pytorch_lightning/logging/tensorboard.py
  +++ b/pytorch_lightning/logging/tensorboard.py
  @@ -63,7 +63,7 @@
   
           root_dir = os.path.join(self.save_dir, self.name)
           os.makedirs(root_dir, exist_ok=True)
  -        log_dir = os.path.join(root_dir, str(self.version))
  +        log_dir = os.path.join(root_dir, "version_" + str(self.version))
           self._experiment = SummaryWriter(log_dir=log_dir, **self.kwargs)
           return self._experiment
   
  @@ -131,9 +131,11 @@
   
       def _get_next_version(self):
           root_dir = os.path.join(self.save_dir, self.name)
  -        existing_versions = [
  -            int(d) for d in os.listdir(root_dir) if os.path.isdir(os.path.join(root_dir, d)) and d.isdigit()
  -        ]
  +        existing_versions = []
  +        for d in os.listdir(root_dir):
  +            if os.path.isdir(os.path.join(root_dir, d)) and d.startswith("version_"):
  +                existing_versions.append(int(d.split("_")[1]))
  +
           if len(existing_versions) == 0:
               return 0
           else:
  
verification_info: {"golden_diff": "diff --git a/pytorch_lightning/logging/tensorboard.py b/pytorch_lightning/logging/tensorboard.py\n--- a/pytorch_lightning/logging/tensorboard.py\n+++ b/pytorch_lightning/logging/tensorboard.py\n@@ -63,7 +63,7 @@\n \n         root_dir = os.path.join(self.save_dir, self.name)\n         os.makedirs(root_dir, exist_ok=True)\n-        log_dir = os.path.join(root_dir, str(self.version))\n+        log_dir = os.path.join(root_dir, \"version_\" + str(self.version))\n         self._experiment = SummaryWriter(log_dir=log_dir, **self.kwargs)\n         return self._experiment\n \n@@ -131,9 +131,11 @@\n \n     def _get_next_version(self):\n         root_dir = os.path.join(self.save_dir, self.name)\n-        existing_versions = [\n-            int(d) for d in os.listdir(root_dir) if os.path.isdir(os.path.join(root_dir, d)) and d.isdigit()\n-        ]\n+        existing_versions = []\n+        for d in os.listdir(root_dir):\n+            if os.path.isdir(os.path.join(root_dir, d)) and d.startswith(\"version_\"):\n+                existing_versions.append(int(d.split(\"_\")[1]))\n+\n         if len(existing_versions) == 0:\n             return 0\n         else:\n", "issue": "TensorBoardLogger and ModelCheckpoint are not using the same folder by default\n## \ud83d\udc1b Bug\r\n(master branch)\r\nBy default, the TensorBoardLogger writes logs into `lightning_logs/0` but ModelCheckpoint writes checkpoint into `lightning_logs/version_0`.\n", "before_files": [{"content": "import os\nfrom warnings import warn\nfrom argparse import Namespace\nfrom pkg_resources import parse_version\n\nimport torch\nimport pandas as pd\nfrom torch.utils.tensorboard import SummaryWriter\n\nfrom .base import LightningLoggerBase, rank_zero_only\n\n\nclass TensorBoardLogger(LightningLoggerBase):\n    r\"\"\"\n\n    Log to local file system in TensorBoard format\n\n    Implemented using :class:`torch.utils.tensorboard.SummaryWriter`. Logs are saved to\n    `os.path.join(save_dir, name, version)`\n\n    Example\n    --------\n\n    .. code-block:: python\n\n        logger = TensorBoardLogger(\"tb_logs\", name=\"my_model\")\n        trainer = Trainer(logger=logger)\n        trainer.train(model)\n\n    Args:\n        save_dir (str): Save directory\n        name (str): Experiment name. Defaults to \"default\".\n        version (int): Experiment version. If version is not specified the logger inspects the save\n        directory for existing versions, then automatically assigns the next available version.\n        \\**kwargs  (dict): Other arguments are passed directly to the :class:`SummaryWriter` constructor.\n\n    \"\"\"\n    NAME_CSV_TAGS = 'meta_tags.csv'\n\n    def __init__(self, save_dir, name=\"default\", version=None, **kwargs):\n        super().__init__()\n        self.save_dir = save_dir\n        self._name = name\n        self._version = version\n\n        self._experiment = None\n        self.tags = {}\n        self.kwargs = kwargs\n\n    @property\n    def experiment(self):\n        r\"\"\"\n\n         Actual tensorboard object. To use tensorboard features do the following.\n\n         Example::\n\n             self.logger.experiment.some_tensorboard_function()\n\n         \"\"\"\n        if self._experiment is not None:\n            return self._experiment\n\n        root_dir = os.path.join(self.save_dir, self.name)\n        os.makedirs(root_dir, exist_ok=True)\n        log_dir = os.path.join(root_dir, str(self.version))\n        self._experiment = SummaryWriter(log_dir=log_dir, **self.kwargs)\n        return self._experiment\n\n    @rank_zero_only\n    def log_hyperparams(self, params):\n        if params is None:\n            return\n\n        # in case converting from namespace\n        if isinstance(params, Namespace):\n            params = vars(params)\n        params = dict(params)\n\n        if parse_version(torch.__version__) < parse_version(\"1.3.0\"):\n            warn(\n                f\"Hyperparameter logging is not available for Torch version {torch.__version__}.\"\n                \" Skipping log_hyperparams. Upgrade to Torch 1.3.0 or above to enable\"\n                \" hyperparameter logging.\"\n            )\n        else:\n            # `add_hparams` requires both - hparams and metric\n            self.experiment.add_hparams(hparam_dict=params, metric_dict={})\n        # some alternative should be added\n        self.tags.update(params)\n\n    @rank_zero_only\n    def log_metrics(self, metrics, step=None):\n        for k, v in metrics.items():\n            if isinstance(v, torch.Tensor):\n                v = v.item()\n            self.experiment.add_scalar(k, v, step)\n\n    @rank_zero_only\n    def save(self):\n        try:\n            self.experiment.flush()\n        except AttributeError:\n            # you are using PT version (<v1.2) which does not have implemented flush\n            self.experiment._get_file_writer().flush()\n\n        # create a preudo standard path ala test-tube\n        dir_path = os.path.join(self.save_dir, self.name, 'version_%s' % self.version)\n        if not os.path.isdir(dir_path):\n            dir_path = self.save_dir\n        # prepare the file path\n        meta_tags_path = os.path.join(dir_path, self.NAME_CSV_TAGS)\n        # save the metatags file\n        df = pd.DataFrame({'key': list(self.tags.keys()),\n                           'value': list(self.tags.values())})\n        df.to_csv(meta_tags_path, index=False)\n\n    @rank_zero_only\n    def finalize(self, status):\n        self.save()\n\n    @property\n    def name(self):\n        return self._name\n\n    @property\n    def version(self):\n        if self._version is None:\n            self._version = self._get_next_version()\n        return self._version\n\n    def _get_next_version(self):\n        root_dir = os.path.join(self.save_dir, self.name)\n        existing_versions = [\n            int(d) for d in os.listdir(root_dir) if os.path.isdir(os.path.join(root_dir, d)) and d.isdigit()\n        ]\n        if len(existing_versions) == 0:\n            return 0\n        else:\n            return max(existing_versions) + 1\n", "path": "pytorch_lightning/logging/tensorboard.py"}]}