prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  _audio_backends platform independent
  ## 🐛 Bug
  
  The constant [_audio_backends](https://github.com/pytorch/audio/blob/c29598d54185d73b4ed04103330573e190bbdb69/torchaudio/_backend.py#L12) is referenced by [BACKENDS](https://github.com/pytorch/audio/blob/0e5581cb2a9616205a00cbabf4c9a30613a1037f/test/common_utils.py#L10) in the common utilities of the test folder. [test_batch_mfcc](https://github.com/pytorch/audio/blob/0e5581cb2a9616205a00cbabf4c9a30613a1037f/test/test_batch_consistency.py#L181) is skipped if the 'sox' key is not present in that constant, but it always is. That means this test will be executed in environments where the package may not exist.
  
  ```
  (base) PS C:\Users\chris\dev\audio> python .\test\test_batch_consistency.py TestTransforms.test_batch_mfcc
  E
  ======================================================================
  ERROR: test_batch_mfcc (__main__.TestTransforms)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "C:\tools\Anaconda3\lib\contextlib.py", line 74, in inner
      return func(*args, **kwds)
    File ".\test\test_batch_consistency.py", line 185, in test_batch_mfcc
      waveform, _ = torchaudio.load(test_filepath)
    File "c:\users\chris\dev\audio\torchaudio\__init__.py", line 87, in load
      filetype=filetype,
    File "c:\users\chris\dev\audio\torchaudio\_sox_backend.py", line 38, in load
      import _torch_sox
  ModuleNotFoundError: No module named '_torch_sox'
  
  ----------------------------------------------------------------------
  Ran 1 test in 0.001s
  
  FAILED (errors=1)
  ```
  
  ## To Reproduce
  
  Steps to reproduce the behavior:
  
  1. Remove sox from your environment
  2. Run ```python test/test_batch_consistency.py TestTransform.test_batch_mfcc```
  
  I can provide more detailed information if required.
  
  ## Expected behavior
  
  The test should be skipped if sox is not available.
  
  ## Environment
  
  ```
  (base) PS C:\Users\chris\dev\audio> python .\collect_env_1.py
  Collecting environment information...
  PyTorch version: 1.6.0a0+8a60d8b
  Is debug build: No
  CUDA used to build PyTorch: None
  
  OS: Microsoft Windows 10 Home
  GCC version: Could not collect
  CMake version: version 3.14.0
  
  Python version: 3.7
  Is CUDA available: No
  CUDA runtime version: No CUDA
  GPU models and configuration: No CUDA
  Nvidia driver version: No CUDA
  cuDNN version: No CUDA
  
  Versions of relevant libraries:
  [pip] numpy==1.18.1
  [pip] numpydoc==0.9.2
  [pip] torch==1.6.0a0+8a60d8b
  [pip] torchaudio==0.5.0a0+5a75b63
  [conda] blas                      1.0                         mkl
  [conda] mkl                       2020.0                      166
  [conda] mkl-include               2020.0                      166
  [conda] mkl-service               2.3.0            py37hb782905_0
  [conda] mkl_fft                   1.0.15           py37h14836fe_0
  [conda] mkl_random                1.1.0            py37h675688f_0
  [conda] numpy                     1.18.1           py37h93ca92e_0
  [conda] numpy-base                1.18.1           py37hc3f5095_1
  [conda] numpydoc                  0.9.2                      py_0
  [conda] torch                     1.6.0a0+8a60d8b           dev_0    <develop>
  [conda] torchaudio                0.5.0a0+5a75b63           dev_0    <develop>
  ```
  ## Additional context
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `torchaudio/_backend.py`
  Content:
  ```
  1 from functools import wraps
  2 from typing import Any, List, Union
  3 
  4 import platform
  5 import torch
  6 from torch import Tensor
  7 
  8 from . import _soundfile_backend, _sox_backend
  9 
  10 
  11 _audio_backend = "soundfile" if platform.system() == "Windows" else "sox"
  12 _audio_backends = {"sox": _sox_backend, "soundfile": _soundfile_backend}
  13 
  14 
  15 def set_audio_backend(backend: str) -> None:
  16     """
  17     Specifies the package used to load.
  18     Args:
  19         backend (str): Name of the backend. One of {}.
  20     """.format(_audio_backends.keys())
  21     global _audio_backend
  22     if backend not in _audio_backends:
  23         raise ValueError(
  24             "Invalid backend '{}'. Options are {}.".format(backend, _audio_backends.keys())
  25         )
  26     _audio_backend = backend
  27 
  28 
  29 def get_audio_backend() -> str:
  30     """
  31     Gets the name of the package used to load.
  32     """
  33     return _audio_backend
  34 
  35 
  36 def _get_audio_backend_module() -> Any:
  37     """
  38     Gets the module backend to load.
  39     """
  40     backend = get_audio_backend()
  41     return _audio_backends[backend]
  42 
  43 
  44 def _audio_backend_guard(backends: Union[str, List[str]]) -> Any:
  45 
  46     if isinstance(backends, str):
  47         backends = [backends]
  48 
  49     def decorator(func):
  50         @wraps(func)
  51         def wrapper(*args, **kwargs):
  52             if get_audio_backend() not in backends:
  53                 raise RuntimeError("Function {} requires backend to be one of {}.".format(func.__name__, backends))
  54             return func(*args, **kwargs)
  55         return wrapper
  56 
  57     return decorator
  58 
  59 
  60 def check_input(src: Tensor) -> None:
  61     if not torch.is_tensor(src):
  62         raise TypeError('Expected a tensor, got %s' % type(src))
  63     if src.is_cuda:
  64         raise TypeError('Expected a CPU based tensor, got %s' % type(src))
  65
  ```
  --- 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/torchaudio/_backend.py b/torchaudio/_backend.py
  --- a/torchaudio/_backend.py
  +++ b/torchaudio/_backend.py
  @@ -8,8 +8,12 @@
   from . import _soundfile_backend, _sox_backend
   
   
  -_audio_backend = "soundfile" if platform.system() == "Windows" else "sox"
  -_audio_backends = {"sox": _sox_backend, "soundfile": _soundfile_backend}
  +if platform.system() == "Windows":
  +    _audio_backend = "soundfile"
  +    _audio_backends = {"soundfile": _soundfile_backend}
  +else:
  +    _audio_backend = "sox"
  +    _audio_backends = {"sox": _sox_backend, "soundfile": _soundfile_backend}
   
   
   def set_audio_backend(backend: str) -> None:
  
verification_info: {"golden_diff": "diff --git a/torchaudio/_backend.py b/torchaudio/_backend.py\n--- a/torchaudio/_backend.py\n+++ b/torchaudio/_backend.py\n@@ -8,8 +8,12 @@\n from . import _soundfile_backend, _sox_backend\n \n \n-_audio_backend = \"soundfile\" if platform.system() == \"Windows\" else \"sox\"\n-_audio_backends = {\"sox\": _sox_backend, \"soundfile\": _soundfile_backend}\n+if platform.system() == \"Windows\":\n+    _audio_backend = \"soundfile\"\n+    _audio_backends = {\"soundfile\": _soundfile_backend}\n+else:\n+    _audio_backend = \"sox\"\n+    _audio_backends = {\"sox\": _sox_backend, \"soundfile\": _soundfile_backend}\n \n \n def set_audio_backend(backend: str) -> None:\n", "issue": "_audio_backends platform independent\n## \ud83d\udc1b Bug\r\n\r\nThe constant [_audio_backends](https://github.com/pytorch/audio/blob/c29598d54185d73b4ed04103330573e190bbdb69/torchaudio/_backend.py#L12) is referenced by [BACKENDS](https://github.com/pytorch/audio/blob/0e5581cb2a9616205a00cbabf4c9a30613a1037f/test/common_utils.py#L10) in the common utilities of the test folder. [test_batch_mfcc](https://github.com/pytorch/audio/blob/0e5581cb2a9616205a00cbabf4c9a30613a1037f/test/test_batch_consistency.py#L181) is skipped if the 'sox' key is not present in that constant, but it always is. That means this test will be executed in environments where the package may not exist.\r\n\r\n```\r\n(base) PS C:\\Users\\chris\\dev\\audio> python .\\test\\test_batch_consistency.py TestTransforms.test_batch_mfcc\r\nE\r\n======================================================================\r\nERROR: test_batch_mfcc (__main__.TestTransforms)\r\n----------------------------------------------------------------------\r\nTraceback (most recent call last):\r\n  File \"C:\\tools\\Anaconda3\\lib\\contextlib.py\", line 74, in inner\r\n    return func(*args, **kwds)\r\n  File \".\\test\\test_batch_consistency.py\", line 185, in test_batch_mfcc\r\n    waveform, _ = torchaudio.load(test_filepath)\r\n  File \"c:\\users\\chris\\dev\\audio\\torchaudio\\__init__.py\", line 87, in load\r\n    filetype=filetype,\r\n  File \"c:\\users\\chris\\dev\\audio\\torchaudio\\_sox_backend.py\", line 38, in load\r\n    import _torch_sox\r\nModuleNotFoundError: No module named '_torch_sox'\r\n\r\n----------------------------------------------------------------------\r\nRan 1 test in 0.001s\r\n\r\nFAILED (errors=1)\r\n```\r\n\r\n## To Reproduce\r\n\r\nSteps to reproduce the behavior:\r\n\r\n1. Remove sox from your environment\r\n2. Run ```python test/test_batch_consistency.py TestTransform.test_batch_mfcc```\r\n\r\nI can provide more detailed information if required.\r\n\r\n## Expected behavior\r\n\r\nThe test should be skipped if sox is not available.\r\n\r\n## Environment\r\n\r\n```\r\n(base) PS C:\\Users\\chris\\dev\\audio> python .\\collect_env_1.py\r\nCollecting environment information...\r\nPyTorch version: 1.6.0a0+8a60d8b\r\nIs debug build: No\r\nCUDA used to build PyTorch: None\r\n\r\nOS: Microsoft Windows 10 Home\r\nGCC version: Could not collect\r\nCMake version: version 3.14.0\r\n\r\nPython version: 3.7\r\nIs CUDA available: No\r\nCUDA runtime version: No CUDA\r\nGPU models and configuration: No CUDA\r\nNvidia driver version: No CUDA\r\ncuDNN version: No CUDA\r\n\r\nVersions of relevant libraries:\r\n[pip] numpy==1.18.1\r\n[pip] numpydoc==0.9.2\r\n[pip] torch==1.6.0a0+8a60d8b\r\n[pip] torchaudio==0.5.0a0+5a75b63\r\n[conda] blas                      1.0                         mkl\r\n[conda] mkl                       2020.0                      166\r\n[conda] mkl-include               2020.0                      166\r\n[conda] mkl-service               2.3.0            py37hb782905_0\r\n[conda] mkl_fft                   1.0.15           py37h14836fe_0\r\n[conda] mkl_random                1.1.0            py37h675688f_0\r\n[conda] numpy                     1.18.1           py37h93ca92e_0\r\n[conda] numpy-base                1.18.1           py37hc3f5095_1\r\n[conda] numpydoc                  0.9.2                      py_0\r\n[conda] torch                     1.6.0a0+8a60d8b           dev_0    <develop>\r\n[conda] torchaudio                0.5.0a0+5a75b63           dev_0    <develop>\r\n```\r\n## Additional context\r\n\r\n\n", "before_files": [{"content": "from functools import wraps\nfrom typing import Any, List, Union\n\nimport platform\nimport torch\nfrom torch import Tensor\n\nfrom . import _soundfile_backend, _sox_backend\n\n\n_audio_backend = \"soundfile\" if platform.system() == \"Windows\" else \"sox\"\n_audio_backends = {\"sox\": _sox_backend, \"soundfile\": _soundfile_backend}\n\n\ndef set_audio_backend(backend: str) -> None:\n    \"\"\"\n    Specifies the package used to load.\n    Args:\n        backend (str): Name of the backend. One of {}.\n    \"\"\".format(_audio_backends.keys())\n    global _audio_backend\n    if backend not in _audio_backends:\n        raise ValueError(\n            \"Invalid backend '{}'. Options are {}.\".format(backend, _audio_backends.keys())\n        )\n    _audio_backend = backend\n\n\ndef get_audio_backend() -> str:\n    \"\"\"\n    Gets the name of the package used to load.\n    \"\"\"\n    return _audio_backend\n\n\ndef _get_audio_backend_module() -> Any:\n    \"\"\"\n    Gets the module backend to load.\n    \"\"\"\n    backend = get_audio_backend()\n    return _audio_backends[backend]\n\n\ndef _audio_backend_guard(backends: Union[str, List[str]]) -> Any:\n\n    if isinstance(backends, str):\n        backends = [backends]\n\n    def decorator(func):\n        @wraps(func)\n        def wrapper(*args, **kwargs):\n            if get_audio_backend() not in backends:\n                raise RuntimeError(\"Function {} requires backend to be one of {}.\".format(func.__name__, backends))\n            return func(*args, **kwargs)\n        return wrapper\n\n    return decorator\n\n\ndef check_input(src: Tensor) -> None:\n    if not torch.is_tensor(src):\n        raise TypeError('Expected a tensor, got %s' % type(src))\n    if src.is_cuda:\n        raise TypeError('Expected a CPU based tensor, got %s' % type(src))\n", "path": "torchaudio/_backend.py"}], "after_files": [{"content": "from functools import wraps\nfrom typing import Any, List, Union\n\nimport platform\nimport torch\nfrom torch import Tensor\n\nfrom . import _soundfile_backend, _sox_backend\n\n\nif platform.system() == \"Windows\":\n    _audio_backend = \"soundfile\"\n    _audio_backends = {\"soundfile\": _soundfile_backend}\nelse:\n    _audio_backend = \"sox\"\n    _audio_backends = {\"sox\": _sox_backend, \"soundfile\": _soundfile_backend}\n\n\ndef set_audio_backend(backend: str) -> None:\n    \"\"\"\n    Specifies the package used to load.\n    Args:\n        backend (str): Name of the backend. One of {}.\n    \"\"\".format(_audio_backends.keys())\n    global _audio_backend\n    if backend not in _audio_backends:\n        raise ValueError(\n            \"Invalid backend '{}'. Options are {}.\".format(backend, _audio_backends.keys())\n        )\n    _audio_backend = backend\n\n\ndef get_audio_backend() -> str:\n    \"\"\"\n    Gets the name of the package used to load.\n    \"\"\"\n    return _audio_backend\n\n\ndef _get_audio_backend_module() -> Any:\n    \"\"\"\n    Gets the module backend to load.\n    \"\"\"\n    backend = get_audio_backend()\n    return _audio_backends[backend]\n\n\ndef _audio_backend_guard(backends: Union[str, List[str]]) -> Any:\n\n    if isinstance(backends, str):\n        backends = [backends]\n\n    def decorator(func):\n        @wraps(func)\n        def wrapper(*args, **kwargs):\n            if get_audio_backend() not in backends:\n                raise RuntimeError(\"Function {} requires backend to be one of {}.\".format(func.__name__, backends))\n            return func(*args, **kwargs)\n        return wrapper\n\n    return decorator\n\n\ndef check_input(src: Tensor) -> None:\n    if not torch.is_tensor(src):\n        raise TypeError('Expected a tensor, got %s' % type(src))\n    if src.is_cuda:\n        raise TypeError('Expected a CPU based tensor, got %s' % type(src))\n", "path": "torchaudio/_backend.py"}]}