prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Improvement proposal for TensorBoard integration
  ## Motivation
  
  - Improve the display of TensorBoard
  
  ## Description
  
  ### 1. Trial ID
  
  I guess using directory name as trial ID is helpful to find a good trial.
  Current integration uses default hash.
  
  **Current display**
  ![スクリーンショット 2020-09-12 10 17 18](https://user-images.githubusercontent.com/2109535/92984505-84261d80-f4e5-11ea-87c1-fef52051fe2e.png)
  
  **Proposal**
  ![スクリーンショット 2020-09-12 10 08 48](https://user-images.githubusercontent.com/2109535/92984484-6658b880-f4e5-11ea-9121-40a572cd42cc.png)
  
  
  ### 2. Use trial number as horizontal axis
  
  **Current display**
  ![スクリーンショット 2020-09-12 10 17 32](https://user-images.githubusercontent.com/2109535/92984554-e121d380-f4e5-11ea-8b0a-da55aa7ff437.png)
  
  **Proposal**
  ![スクリーンショット 2020-09-12 10 05 14](https://user-images.githubusercontent.com/2109535/92984571-0c0c2780-f4e6-11ea-897d-8929ba510234.png)
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `optuna/integration/tensorboard.py`
  Content:
  ```
  1 import os
  2 from typing import Dict
  3 
  4 import optuna
  5 from optuna._experimental import experimental
  6 from optuna._imports import try_import
  7 
  8 with try_import() as _imports:
  9     from tensorboard.plugins.hparams import api as hp
  10     import tensorflow as tf
  11 
  12 
  13 @experimental("2.0.0")
  14 class TensorBoardCallback(object):
  15     """Callback to track Optuna trials with TensorBoard.
  16 
  17     This callback adds relevant information that is tracked by Optuna to TensorBoard.
  18 
  19     See `the example <https://github.com/optuna/optuna/blob/master/
  20     examples/tensorboard_simple.py>`_.
  21 
  22     Args:
  23         dirname:
  24             Directory to store TensorBoard logs.
  25         metric_name:
  26             Name of the metric. Since the metric itself is just a number,
  27             `metric_name` can be used to give it a name. So you know later
  28             if it was roc-auc or accuracy.
  29 
  30     """
  31 
  32     def __init__(self, dirname: str, metric_name: str) -> None:
  33         _imports.check()
  34         self._dirname = dirname
  35         self._metric_name = metric_name
  36         self._hp_params = dict()  # type: Dict[str, hp.HParam]
  37 
  38     def __call__(self, study: optuna.study.Study, trial: optuna.trial.FrozenTrial) -> None:
  39         if len(self._hp_params) == 0:
  40             self._initialization(study)
  41         if trial.state != optuna.trial.TrialState.COMPLETE:
  42             return
  43         trial_value = trial.value if trial.value is not None else float("nan")
  44         hparams = dict()
  45         for param_name, param_value in trial.params.items():
  46             if param_name not in self._hp_params:
  47                 self._add_distributions(trial.distributions)
  48             hparams[self._hp_params[param_name]] = param_value
  49         run_name = "trial-%d" % trial.number
  50         run_dir = os.path.join(self._dirname, run_name)
  51         with tf.summary.create_file_writer(run_dir).as_default():
  52             hp.hparams(hparams)  # record the values used in this trial
  53             tf.summary.scalar(self._metric_name, trial_value, step=1)
  54 
  55     def _add_distributions(
  56         self, distributions: Dict[str, optuna.distributions.BaseDistribution]
  57     ) -> None:
  58         for param_name, param_distribution in distributions.items():
  59             if isinstance(param_distribution, optuna.distributions.UniformDistribution):
  60                 self._hp_params[param_name] = hp.HParam(
  61                     param_name, hp.RealInterval(param_distribution.low, param_distribution.high)
  62                 )
  63             elif isinstance(param_distribution, optuna.distributions.LogUniformDistribution):
  64                 self._hp_params[param_name] = hp.HParam(
  65                     param_name, hp.RealInterval(param_distribution.low, param_distribution.high)
  66                 )
  67             elif isinstance(param_distribution, optuna.distributions.DiscreteUniformDistribution):
  68                 self._hp_params[param_name] = hp.HParam(
  69                     param_name, hp.Discrete(param_distribution.low, param_distribution.high)
  70                 )
  71             elif isinstance(param_distribution, optuna.distributions.IntUniformDistribution):
  72                 self._hp_params[param_name] = hp.HParam(
  73                     param_name, hp.IntInterval(param_distribution.low, param_distribution.high)
  74                 )
  75             elif isinstance(param_distribution, optuna.distributions.CategoricalDistribution):
  76                 self._hp_params[param_name] = hp.HParam(
  77                     param_name, hp.Discrete(param_distribution.choices)
  78                 )
  79             else:
  80                 distribution_list = [
  81                     optuna.distributions.UniformDistribution.__name__,
  82                     optuna.distributions.LogUniformDistribution.__name__,
  83                     optuna.distributions.DiscreteUniformDistribution.__name__,
  84                     optuna.distributions.IntUniformDistribution.__name__,
  85                     optuna.distributions.CategoricalDistribution.__name__,
  86                 ]
  87                 raise NotImplementedError(
  88                     "The distribution {} is not implemented. "
  89                     "The parameter distribution should be one of the {}".format(
  90                         param_distribution, distribution_list
  91                     )
  92                 )
  93 
  94     def _initialization(self, study: optuna.Study) -> None:
  95         completed_trials = [
  96             trial
  97             for trial in study.get_trials(deepcopy=False)
  98             if trial.state == optuna.trial.TrialState.COMPLETE
  99         ]
  100         for trial in completed_trials:
  101             self._add_distributions(trial.distributions)
  102
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/optuna/integration/tensorboard.py b/optuna/integration/tensorboard.py
  --- a/optuna/integration/tensorboard.py
  +++ b/optuna/integration/tensorboard.py
  @@ -49,8 +49,8 @@
           run_name = "trial-%d" % trial.number
           run_dir = os.path.join(self._dirname, run_name)
           with tf.summary.create_file_writer(run_dir).as_default():
  -            hp.hparams(hparams)  # record the values used in this trial
  -            tf.summary.scalar(self._metric_name, trial_value, step=1)
  +            hp.hparams(hparams, trial_id=run_name)  # record the values used in this trial
  +            tf.summary.scalar(self._metric_name, trial_value, step=trial.number)
   
       def _add_distributions(
           self, distributions: Dict[str, optuna.distributions.BaseDistribution]
  
verification_info: {"golden_diff": "diff --git a/optuna/integration/tensorboard.py b/optuna/integration/tensorboard.py\n--- a/optuna/integration/tensorboard.py\n+++ b/optuna/integration/tensorboard.py\n@@ -49,8 +49,8 @@\n         run_name = \"trial-%d\" % trial.number\n         run_dir = os.path.join(self._dirname, run_name)\n         with tf.summary.create_file_writer(run_dir).as_default():\n-            hp.hparams(hparams)  # record the values used in this trial\n-            tf.summary.scalar(self._metric_name, trial_value, step=1)\n+            hp.hparams(hparams, trial_id=run_name)  # record the values used in this trial\n+            tf.summary.scalar(self._metric_name, trial_value, step=trial.number)\n \n     def _add_distributions(\n         self, distributions: Dict[str, optuna.distributions.BaseDistribution]\n", "issue": "Improvement proposal for TensorBoard integration\n## Motivation\r\n\r\n- Improve the display of TensorBoard\r\n\r\n## Description\r\n\r\n### 1. Trial ID\r\n\r\nI guess using directory name as trial ID is helpful to find a good trial.\r\nCurrent integration uses default hash.\r\n\r\n**Current display**\r\n![\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2020-09-12 10 17 18](https://user-images.githubusercontent.com/2109535/92984505-84261d80-f4e5-11ea-87c1-fef52051fe2e.png)\r\n\r\n**Proposal**\r\n![\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2020-09-12 10 08 48](https://user-images.githubusercontent.com/2109535/92984484-6658b880-f4e5-11ea-9121-40a572cd42cc.png)\r\n\r\n\r\n### 2. Use trial number as horizontal axis\r\n\r\n**Current display**\r\n![\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2020-09-12 10 17 32](https://user-images.githubusercontent.com/2109535/92984554-e121d380-f4e5-11ea-8b0a-da55aa7ff437.png)\r\n\r\n**Proposal**\r\n![\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2020-09-12 10 05 14](https://user-images.githubusercontent.com/2109535/92984571-0c0c2780-f4e6-11ea-897d-8929ba510234.png)\r\n\n", "before_files": [{"content": "import os\nfrom typing import Dict\n\nimport optuna\nfrom optuna._experimental import experimental\nfrom optuna._imports import try_import\n\nwith try_import() as _imports:\n    from tensorboard.plugins.hparams import api as hp\n    import tensorflow as tf\n\n\n@experimental(\"2.0.0\")\nclass TensorBoardCallback(object):\n    \"\"\"Callback to track Optuna trials with TensorBoard.\n\n    This callback adds relevant information that is tracked by Optuna to TensorBoard.\n\n    See `the example <https://github.com/optuna/optuna/blob/master/\n    examples/tensorboard_simple.py>`_.\n\n    Args:\n        dirname:\n            Directory to store TensorBoard logs.\n        metric_name:\n            Name of the metric. Since the metric itself is just a number,\n            `metric_name` can be used to give it a name. So you know later\n            if it was roc-auc or accuracy.\n\n    \"\"\"\n\n    def __init__(self, dirname: str, metric_name: str) -> None:\n        _imports.check()\n        self._dirname = dirname\n        self._metric_name = metric_name\n        self._hp_params = dict()  # type: Dict[str, hp.HParam]\n\n    def __call__(self, study: optuna.study.Study, trial: optuna.trial.FrozenTrial) -> None:\n        if len(self._hp_params) == 0:\n            self._initialization(study)\n        if trial.state != optuna.trial.TrialState.COMPLETE:\n            return\n        trial_value = trial.value if trial.value is not None else float(\"nan\")\n        hparams = dict()\n        for param_name, param_value in trial.params.items():\n            if param_name not in self._hp_params:\n                self._add_distributions(trial.distributions)\n            hparams[self._hp_params[param_name]] = param_value\n        run_name = \"trial-%d\" % trial.number\n        run_dir = os.path.join(self._dirname, run_name)\n        with tf.summary.create_file_writer(run_dir).as_default():\n            hp.hparams(hparams)  # record the values used in this trial\n            tf.summary.scalar(self._metric_name, trial_value, step=1)\n\n    def _add_distributions(\n        self, distributions: Dict[str, optuna.distributions.BaseDistribution]\n    ) -> None:\n        for param_name, param_distribution in distributions.items():\n            if isinstance(param_distribution, optuna.distributions.UniformDistribution):\n                self._hp_params[param_name] = hp.HParam(\n                    param_name, hp.RealInterval(param_distribution.low, param_distribution.high)\n                )\n            elif isinstance(param_distribution, optuna.distributions.LogUniformDistribution):\n                self._hp_params[param_name] = hp.HParam(\n                    param_name, hp.RealInterval(param_distribution.low, param_distribution.high)\n                )\n            elif isinstance(param_distribution, optuna.distributions.DiscreteUniformDistribution):\n                self._hp_params[param_name] = hp.HParam(\n                    param_name, hp.Discrete(param_distribution.low, param_distribution.high)\n                )\n            elif isinstance(param_distribution, optuna.distributions.IntUniformDistribution):\n                self._hp_params[param_name] = hp.HParam(\n                    param_name, hp.IntInterval(param_distribution.low, param_distribution.high)\n                )\n            elif isinstance(param_distribution, optuna.distributions.CategoricalDistribution):\n                self._hp_params[param_name] = hp.HParam(\n                    param_name, hp.Discrete(param_distribution.choices)\n                )\n            else:\n                distribution_list = [\n                    optuna.distributions.UniformDistribution.__name__,\n                    optuna.distributions.LogUniformDistribution.__name__,\n                    optuna.distributions.DiscreteUniformDistribution.__name__,\n                    optuna.distributions.IntUniformDistribution.__name__,\n                    optuna.distributions.CategoricalDistribution.__name__,\n                ]\n                raise NotImplementedError(\n                    \"The distribution {} is not implemented. \"\n                    \"The parameter distribution should be one of the {}\".format(\n                        param_distribution, distribution_list\n                    )\n                )\n\n    def _initialization(self, study: optuna.Study) -> None:\n        completed_trials = [\n            trial\n            for trial in study.get_trials(deepcopy=False)\n            if trial.state == optuna.trial.TrialState.COMPLETE\n        ]\n        for trial in completed_trials:\n            self._add_distributions(trial.distributions)\n", "path": "optuna/integration/tensorboard.py"}], "after_files": [{"content": "import os\nfrom typing import Dict\n\nimport optuna\nfrom optuna._experimental import experimental\nfrom optuna._imports import try_import\n\nwith try_import() as _imports:\n    from tensorboard.plugins.hparams import api as hp\n    import tensorflow as tf\n\n\n@experimental(\"2.0.0\")\nclass TensorBoardCallback(object):\n    \"\"\"Callback to track Optuna trials with TensorBoard.\n\n    This callback adds relevant information that is tracked by Optuna to TensorBoard.\n\n    See `the example <https://github.com/optuna/optuna/blob/master/\n    examples/tensorboard_simple.py>`_.\n\n    Args:\n        dirname:\n            Directory to store TensorBoard logs.\n        metric_name:\n            Name of the metric. Since the metric itself is just a number,\n            `metric_name` can be used to give it a name. So you know later\n            if it was roc-auc or accuracy.\n\n    \"\"\"\n\n    def __init__(self, dirname: str, metric_name: str) -> None:\n        _imports.check()\n        self._dirname = dirname\n        self._metric_name = metric_name\n        self._hp_params = dict()  # type: Dict[str, hp.HParam]\n\n    def __call__(self, study: optuna.study.Study, trial: optuna.trial.FrozenTrial) -> None:\n        if len(self._hp_params) == 0:\n            self._initialization(study)\n        if trial.state != optuna.trial.TrialState.COMPLETE:\n            return\n        trial_value = trial.value if trial.value is not None else float(\"nan\")\n        hparams = dict()\n        for param_name, param_value in trial.params.items():\n            if param_name not in self._hp_params:\n                self._add_distributions(trial.distributions)\n            hparams[self._hp_params[param_name]] = param_value\n        run_name = \"trial-%d\" % trial.number\n        run_dir = os.path.join(self._dirname, run_name)\n        with tf.summary.create_file_writer(run_dir).as_default():\n            hp.hparams(hparams, trial_id=run_name)  # record the values used in this trial\n            tf.summary.scalar(self._metric_name, trial_value, step=trial.number)\n\n    def _add_distributions(\n        self, distributions: Dict[str, optuna.distributions.BaseDistribution]\n    ) -> None:\n        for param_name, param_distribution in distributions.items():\n            if isinstance(param_distribution, optuna.distributions.UniformDistribution):\n                self._hp_params[param_name] = hp.HParam(\n                    param_name, hp.RealInterval(param_distribution.low, param_distribution.high)\n                )\n            elif isinstance(param_distribution, optuna.distributions.LogUniformDistribution):\n                self._hp_params[param_name] = hp.HParam(\n                    param_name, hp.RealInterval(param_distribution.low, param_distribution.high)\n                )\n            elif isinstance(param_distribution, optuna.distributions.DiscreteUniformDistribution):\n                self._hp_params[param_name] = hp.HParam(\n                    param_name, hp.Discrete(param_distribution.low, param_distribution.high)\n                )\n            elif isinstance(param_distribution, optuna.distributions.IntUniformDistribution):\n                self._hp_params[param_name] = hp.HParam(\n                    param_name, hp.IntInterval(param_distribution.low, param_distribution.high)\n                )\n            elif isinstance(param_distribution, optuna.distributions.CategoricalDistribution):\n                self._hp_params[param_name] = hp.HParam(\n                    param_name, hp.Discrete(param_distribution.choices)\n                )\n            else:\n                distribution_list = [\n                    optuna.distributions.UniformDistribution.__name__,\n                    optuna.distributions.LogUniformDistribution.__name__,\n                    optuna.distributions.DiscreteUniformDistribution.__name__,\n                    optuna.distributions.IntUniformDistribution.__name__,\n                    optuna.distributions.CategoricalDistribution.__name__,\n                ]\n                raise NotImplementedError(\n                    \"The distribution {} is not implemented. \"\n                    \"The parameter distribution should be one of the {}\".format(\n                        param_distribution, distribution_list\n                    )\n                )\n\n    def _initialization(self, study: optuna.Study) -> None:\n        completed_trials = [\n            trial\n            for trial in study.get_trials(deepcopy=False)\n            if trial.state == optuna.trial.TrialState.COMPLETE\n        ]\n        for trial in completed_trials:\n            self._add_distributions(trial.distributions)\n", "path": "optuna/integration/tensorboard.py"}]}