prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Setting of PYTHONHASHSEED has no effect
  <!-- 
  ### Common bugs:
  1. Tensorboard not showing in Jupyter-notebook see [issue 79](https://github.com/PyTorchLightning/pytorch-lightning/issues/79).    
  2. PyTorch 1.1.0 vs 1.2.0 support [see FAQ](https://github.com/PyTorchLightning/pytorch-lightning#faq)    
  -->
  
  ## 🐛 Bug
  (Previously submitted here: https://github.com/PyTorchLightning/pytorch-lightning/issues/1939, but I didn't use the correct template, so now I'm resubmitting)
  
  In https://github.com/PyTorchLightning/pytorch-lightning/blob/9045b6c599df3871da6aaaa310f62d3f1364c632/pytorch_lightning/trainer/seed.py#L32
  , `PYTHONHASHSEED` is assigned a value in order to ensure reproducability. However, this assignment has no effect. In fact, this assignment might mislead the user or any logging software into believing that `PYTHONHASHSEED` has a specific value, when in fact it has another.
  
  To see that setting `PYTHONHASHSEED` inside the current program has no effect, run the following two commands:
  ```
  PYTHONHASHSEED=1 python -c "import os; print(hash('a'))"
  PYTHONHASHSEED=1 python -c "import os; os.environ['PYTHONHASHSEED']='2'; print(hash('a'))"
  ```
  The commands should output the same value, meaning that setting `PYTHONHASHSEED` after the process has started has no effect.
  
  The following commands will likely output different values, also indicating that setting `PYTHONHASHSEED` after the process has started has no effect:
  ```
  unset PYTHONHASHSEED # make sure it is not already set
  python -c "import os; os.environ['PYTHONHASHSEED']='2'; print(hash('a'))"
  python -c "import os; os.environ['PYTHONHASHSEED']='2'; print(hash('a'))"
  ```
  
  <!-- A clear and concise description of what the bug is. -->
  
  ### To Reproduce
  
  Steps to reproduce the behavior:
  
  1. Start python terminal with `PYTHONHASHSEED=1 python`
  2. Run 
  ```python
  import pytorch_lightning as pl
  pl.seed_everything(100)
  print(hash('a'))
  # >>> 8432517439229126278
  ```
  3. Start new python terminal with `PYTHONHASHSEED=2 python`
  4. Run
  ```python
  import pytorch_lightning as pl
  pl.seed_everything(100)
  print(hash('a'))
  # >>> -8333094867672744108
  ```
  
  ### Expected behavior
  
  Expect output of `hash` function to be the same in both cases. The examples demonstrate that this is not possible.
  <!-- A clear and concise description of what you expected to happen. -->
  
  ### Environment
  
  ```
  * CUDA:
  	- GPU:
  	- available:         False
  	- version:           10.2
  * Packages:
  	- numpy:             1.18.5
  	- pyTorch_debug:     False
  	- pyTorch_version:   1.5.0
  	- pytorch-lightning: 0.7.6
  	- tensorboard:       2.2.2
  	- tqdm:              4.46.1
  * System:
  	- OS:                Linux
  	- architecture:
  		- 64bit
  		- ELF
  	- processor:         
  	- python:            3.8.3
  	- version:           #1 SMP PREEMPT Wed May 27 20:25:12 UTC 2020
  
  ```
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pytorch_lightning/utilities/seed.py`
  Content:
  ```
  1 # Copyright The PyTorch Lightning team.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 """Helper functions to help with reproducibility of models. """
  16 
  17 import os
  18 import random
  19 from typing import Optional
  20 
  21 import numpy as np
  22 import torch
  23 
  24 from pytorch_lightning import _logger as log
  25 
  26 
  27 def seed_everything(seed: Optional[int] = None) -> int:
  28     """
  29     Function that sets seed for pseudo-random number generators in:
  30     pytorch, numpy, python.random and sets PYTHONHASHSEED environment variable.
  31     In addition, sets the env variable `PL_GLOBAL_SEED` which will be passed to
  32     spawned subprocesses (e.g. ddp_spawn backend).
  33 
  34     Args:
  35         seed: the integer value seed for global random state in Lightning.
  36             If `None`, will read seed from `PL_GLOBAL_SEED` env variable
  37             or select it randomly.
  38     """
  39     max_seed_value = np.iinfo(np.uint32).max
  40     min_seed_value = np.iinfo(np.uint32).min
  41 
  42     try:
  43         if seed is None:
  44             seed = os.environ.get("PL_GLOBAL_SEED", _select_seed_randomly(min_seed_value, max_seed_value))
  45         seed = int(seed)
  46     except (TypeError, ValueError):
  47         seed = _select_seed_randomly(min_seed_value, max_seed_value)
  48 
  49     if (seed > max_seed_value) or (seed < min_seed_value):
  50         log.warning(
  51             f"{seed} is not in bounds, \
  52             numpy accepts from {min_seed_value} to {max_seed_value}"
  53         )
  54         seed = _select_seed_randomly(min_seed_value, max_seed_value)
  55 
  56     os.environ["PYTHONHASHSEED"] = str(seed)
  57     os.environ["PL_GLOBAL_SEED"] = str(seed)
  58     random.seed(seed)
  59     np.random.seed(seed)
  60     torch.manual_seed(seed)
  61     torch.cuda.manual_seed_all(seed)
  62     return seed
  63 
  64 
  65 def _select_seed_randomly(min_seed_value: int = 0, max_seed_value: int = 255) -> int:
  66     seed = random.randint(min_seed_value, max_seed_value)
  67     log.warning(f"No correct seed found, seed set to {seed}")
  68     return seed
  69
  ```
  --- 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/pytorch_lightning/utilities/seed.py b/pytorch_lightning/utilities/seed.py
  --- a/pytorch_lightning/utilities/seed.py
  +++ b/pytorch_lightning/utilities/seed.py
  @@ -27,7 +27,7 @@
   def seed_everything(seed: Optional[int] = None) -> int:
       """
       Function that sets seed for pseudo-random number generators in:
  -    pytorch, numpy, python.random and sets PYTHONHASHSEED environment variable.
  +    pytorch, numpy, python.random
       In addition, sets the env variable `PL_GLOBAL_SEED` which will be passed to
       spawned subprocesses (e.g. ddp_spawn backend).
   
  @@ -53,7 +53,6 @@
           )
           seed = _select_seed_randomly(min_seed_value, max_seed_value)
   
  -    os.environ["PYTHONHASHSEED"] = str(seed)
       os.environ["PL_GLOBAL_SEED"] = str(seed)
       random.seed(seed)
       np.random.seed(seed)
  
verification_info: {"golden_diff": "diff --git a/pytorch_lightning/utilities/seed.py b/pytorch_lightning/utilities/seed.py\n--- a/pytorch_lightning/utilities/seed.py\n+++ b/pytorch_lightning/utilities/seed.py\n@@ -27,7 +27,7 @@\n def seed_everything(seed: Optional[int] = None) -> int:\n     \"\"\"\n     Function that sets seed for pseudo-random number generators in:\n-    pytorch, numpy, python.random and sets PYTHONHASHSEED environment variable.\n+    pytorch, numpy, python.random\n     In addition, sets the env variable `PL_GLOBAL_SEED` which will be passed to\n     spawned subprocesses (e.g. ddp_spawn backend).\n \n@@ -53,7 +53,6 @@\n         )\n         seed = _select_seed_randomly(min_seed_value, max_seed_value)\n \n-    os.environ[\"PYTHONHASHSEED\"] = str(seed)\n     os.environ[\"PL_GLOBAL_SEED\"] = str(seed)\n     random.seed(seed)\n     np.random.seed(seed)\n", "issue": "Setting of PYTHONHASHSEED has no effect\n<!-- \r\n### Common bugs:\r\n1. Tensorboard not showing in Jupyter-notebook see [issue 79](https://github.com/PyTorchLightning/pytorch-lightning/issues/79).    \r\n2. PyTorch 1.1.0 vs 1.2.0 support [see FAQ](https://github.com/PyTorchLightning/pytorch-lightning#faq)    \r\n-->\r\n\r\n## \ud83d\udc1b Bug\r\n(Previously submitted here: https://github.com/PyTorchLightning/pytorch-lightning/issues/1939, but I didn't use the correct template, so now I'm resubmitting)\r\n\r\nIn https://github.com/PyTorchLightning/pytorch-lightning/blob/9045b6c599df3871da6aaaa310f62d3f1364c632/pytorch_lightning/trainer/seed.py#L32\r\n, `PYTHONHASHSEED` is assigned a value in order to ensure reproducability. However, this assignment has no effect. In fact, this assignment might mislead the user or any logging software into believing that `PYTHONHASHSEED` has a specific value, when in fact it has another.\r\n\r\nTo see that setting `PYTHONHASHSEED` inside the current program has no effect, run the following two commands:\r\n```\r\nPYTHONHASHSEED=1 python -c \"import os; print(hash('a'))\"\r\nPYTHONHASHSEED=1 python -c \"import os; os.environ['PYTHONHASHSEED']='2'; print(hash('a'))\"\r\n```\r\nThe commands should output the same value, meaning that setting `PYTHONHASHSEED` after the process has started has no effect.\r\n\r\nThe following commands will likely output different values, also indicating that setting `PYTHONHASHSEED` after the process has started has no effect:\r\n```\r\nunset PYTHONHASHSEED # make sure it is not already set\r\npython -c \"import os; os.environ['PYTHONHASHSEED']='2'; print(hash('a'))\"\r\npython -c \"import os; os.environ['PYTHONHASHSEED']='2'; print(hash('a'))\"\r\n```\r\n\r\n<!-- A clear and concise description of what the bug is. -->\r\n\r\n### To Reproduce\r\n\r\nSteps to reproduce the behavior:\r\n\r\n1. Start python terminal with `PYTHONHASHSEED=1 python`\r\n2. Run \r\n```python\r\nimport pytorch_lightning as pl\r\npl.seed_everything(100)\r\nprint(hash('a'))\r\n# >>> 8432517439229126278\r\n```\r\n3. Start new python terminal with `PYTHONHASHSEED=2 python`\r\n4. Run\r\n```python\r\nimport pytorch_lightning as pl\r\npl.seed_everything(100)\r\nprint(hash('a'))\r\n# >>> -8333094867672744108\r\n```\r\n\r\n### Expected behavior\r\n\r\nExpect output of `hash` function to be the same in both cases. The examples demonstrate that this is not possible.\r\n<!-- A clear and concise description of what you expected to happen. -->\r\n\r\n### Environment\r\n\r\n```\r\n* CUDA:\r\n\t- GPU:\r\n\t- available:         False\r\n\t- version:           10.2\r\n* Packages:\r\n\t- numpy:             1.18.5\r\n\t- pyTorch_debug:     False\r\n\t- pyTorch_version:   1.5.0\r\n\t- pytorch-lightning: 0.7.6\r\n\t- tensorboard:       2.2.2\r\n\t- tqdm:              4.46.1\r\n* System:\r\n\t- OS:                Linux\r\n\t- architecture:\r\n\t\t- 64bit\r\n\t\t- ELF\r\n\t- processor:         \r\n\t- python:            3.8.3\r\n\t- version:           #1 SMP PREEMPT Wed May 27 20:25:12 UTC 2020\r\n\r\n```\r\n\n", "before_files": [{"content": "# Copyright The PyTorch Lightning team.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Helper functions to help with reproducibility of models. \"\"\"\n\nimport os\nimport random\nfrom typing import Optional\n\nimport numpy as np\nimport torch\n\nfrom pytorch_lightning import _logger as log\n\n\ndef seed_everything(seed: Optional[int] = None) -> int:\n    \"\"\"\n    Function that sets seed for pseudo-random number generators in:\n    pytorch, numpy, python.random and sets PYTHONHASHSEED environment variable.\n    In addition, sets the env variable `PL_GLOBAL_SEED` which will be passed to\n    spawned subprocesses (e.g. ddp_spawn backend).\n\n    Args:\n        seed: the integer value seed for global random state in Lightning.\n            If `None`, will read seed from `PL_GLOBAL_SEED` env variable\n            or select it randomly.\n    \"\"\"\n    max_seed_value = np.iinfo(np.uint32).max\n    min_seed_value = np.iinfo(np.uint32).min\n\n    try:\n        if seed is None:\n            seed = os.environ.get(\"PL_GLOBAL_SEED\", _select_seed_randomly(min_seed_value, max_seed_value))\n        seed = int(seed)\n    except (TypeError, ValueError):\n        seed = _select_seed_randomly(min_seed_value, max_seed_value)\n\n    if (seed > max_seed_value) or (seed < min_seed_value):\n        log.warning(\n            f\"{seed} is not in bounds, \\\n            numpy accepts from {min_seed_value} to {max_seed_value}\"\n        )\n        seed = _select_seed_randomly(min_seed_value, max_seed_value)\n\n    os.environ[\"PYTHONHASHSEED\"] = str(seed)\n    os.environ[\"PL_GLOBAL_SEED\"] = str(seed)\n    random.seed(seed)\n    np.random.seed(seed)\n    torch.manual_seed(seed)\n    torch.cuda.manual_seed_all(seed)\n    return seed\n\n\ndef _select_seed_randomly(min_seed_value: int = 0, max_seed_value: int = 255) -> int:\n    seed = random.randint(min_seed_value, max_seed_value)\n    log.warning(f\"No correct seed found, seed set to {seed}\")\n    return seed\n", "path": "pytorch_lightning/utilities/seed.py"}], "after_files": [{"content": "# Copyright The PyTorch Lightning team.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Helper functions to help with reproducibility of models. \"\"\"\n\nimport os\nimport random\nfrom typing import Optional\n\nimport numpy as np\nimport torch\n\nfrom pytorch_lightning import _logger as log\n\n\ndef seed_everything(seed: Optional[int] = None) -> int:\n    \"\"\"\n    Function that sets seed for pseudo-random number generators in:\n    pytorch, numpy, python.random\n    In addition, sets the env variable `PL_GLOBAL_SEED` which will be passed to\n    spawned subprocesses (e.g. ddp_spawn backend).\n\n    Args:\n        seed: the integer value seed for global random state in Lightning.\n            If `None`, will read seed from `PL_GLOBAL_SEED` env variable\n            or select it randomly.\n    \"\"\"\n    max_seed_value = np.iinfo(np.uint32).max\n    min_seed_value = np.iinfo(np.uint32).min\n\n    try:\n        if seed is None:\n            seed = os.environ.get(\"PL_GLOBAL_SEED\", _select_seed_randomly(min_seed_value, max_seed_value))\n        seed = int(seed)\n    except (TypeError, ValueError):\n        seed = _select_seed_randomly(min_seed_value, max_seed_value)\n\n    if (seed > max_seed_value) or (seed < min_seed_value):\n        log.warning(\n            f\"{seed} is not in bounds, \\\n            numpy accepts from {min_seed_value} to {max_seed_value}\"\n        )\n        seed = _select_seed_randomly(min_seed_value, max_seed_value)\n\n    os.environ[\"PL_GLOBAL_SEED\"] = str(seed)\n    random.seed(seed)\n    np.random.seed(seed)\n    torch.manual_seed(seed)\n    torch.cuda.manual_seed_all(seed)\n    return seed\n\n\ndef _select_seed_randomly(min_seed_value: int = 0, max_seed_value: int = 255) -> int:\n    seed = random.randint(min_seed_value, max_seed_value)\n    log.warning(f\"No correct seed found, seed set to {seed}\")\n    return seed\n", "path": "pytorch_lightning/utilities/seed.py"}]}