We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Refactor layer test to use pytest parameterized test
Currently we use a mix of unittests written in `pytest` style and tests using `tf.test.TestCase` in larq. In #313 I added some simple `pytest` fixtures that allow to run tests in both eager and graph mode.

The only part of the test suite that uses `tf.test.TestCase` are the [layer tests](https://github.com/larq/larq/blob/f6f9277a006f6cb07b1e5f9bc591a087f2261152/larq/layers_test.py#L73-L187) which rely on [`keras_parameterized.run_all_keras_modes`](https://github.com/tensorflow/tensorflow/blob/669080135924d204a1c67dd556223d794efbf664/tensorflow/python/keras/keras_parameterized.py#L176-L303)  and a forked/copied version of [`testing_utils. layer_test`](https://github.com/tensorflow/tensorflow/blob/669080135924d204a1c67dd556223d794efbf664/tensorflow/python/keras/testing_utils.py#L75-L261).

I think it would be a lot cleaner to write a simple [`pytest` fixture](https://pytest.org/en/latest/fixture.html#fixture) similar to #313 that allows us to run a normal [`pytest` parameterized test](https://pytest.org/en/latest/parametrize.html#pytest-mark-parametrize) in all Keras modes and adapt the layer tests to use it. That way we can get rid of `absl.testing` and some requirements on TensorFlow internals.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setup.py`
Content:
```
1 from setuptools import setup, find_packages
2 
3 
4 def readme():
5     with open("README.md", "r") as f:
6         return f.read()
7 
8 
9 setup(
10     name="larq",
11     version="0.7.4",
12     python_requires=">=3.6",
13     author="Plumerai",
14     author_email="lukas@plumerai.co.uk",
15     description="An Open Source Machine Learning Library for Training Binarized Neural Networks",
16     long_description=readme(),
17     long_description_content_type="text/markdown",
18     url="https://larq.dev/",
19     packages=find_packages(exclude=["larq.snapshots"]),
20     license="Apache 2.0",
21     install_requires=[
22         "numpy >= 1.15.4, < 2.0",
23         "terminaltables>=3.1.0",
24         "dataclasses ; python_version<'3.7'",
25     ],
26     extras_require={
27         "tensorflow": ["tensorflow>=1.14.0"],
28         "tensorflow_gpu": ["tensorflow-gpu>=1.14.0"],
29         "test": [
30             "absl-py==0.8.1",
31             "pytest==5.2.2",
32             "pytest-cov==2.8.1",
33             "pytest-xdist==1.30.0",
34             "snapshottest==0.5.1",
35         ],
36         "docs": [
37             "mkdocs==1.0.4",
38             "mkdocs-material==4.4.3",
39             "pymdown-extensions==6.1",
40             "mknotebooks==0.1.7",
41             "mkdocs-minify-plugin==0.2.1",
42             "larq-zoo==0.4.2",
43             "altair==3.2.0",
44             "pandas==0.25.3",
45         ],
46     },
47     classifiers=[
48         "Development Status :: 4 - Beta",
49         "Intended Audience :: Developers",
50         "Intended Audience :: Education",
51         "Intended Audience :: Science/Research",
52         "License :: OSI Approved :: Apache Software License",
53         "Programming Language :: Python :: 3",
54         "Programming Language :: Python :: 3 :: Only",
55         "Programming Language :: Python :: 3.6",
56         "Programming Language :: Python :: 3.7",
57         "Topic :: Scientific/Engineering",
58         "Topic :: Scientific/Engineering :: Mathematics",
59         "Topic :: Scientific/Engineering :: Artificial Intelligence",
60         "Topic :: Software Development",
61         "Topic :: Software Development :: Libraries",
62         "Topic :: Software Development :: Libraries :: Python Modules",
63     ],
64 )
65
```

Path: `larq/conftest.py`
Content:
```
1 import pytest
2 from tensorflow.python.eager import context
3 
4 
5 @pytest.fixture
6 def eager_mode():
7     """pytest fixture for running test in eager mode"""
8     with context.eager_mode():
9         yield
10 
11 
12 @pytest.fixture
13 def graph_mode():
14     """pytest fixture for running test in graph mode"""
15     with context.graph_mode():
16         yield
17 
18 
19 @pytest.fixture(params=["eager", "graph"])
20 def eager_and_graph_mode(request):
21     """pytest fixture for running test in eager and graph mode"""
22     with getattr(context, f"{request.param}_mode")():
23         yield request.param
24
```
--- 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()

```

diff --git a/larq/conftest.py b/larq/conftest.py
--- a/larq/conftest.py
+++ b/larq/conftest.py
@@ -1,4 +1,5 @@
 import pytest
+import tensorflow as tf
 from tensorflow.python.eager import context
 
 
@@ -21,3 +22,27 @@
     """pytest fixture for running test in eager and graph mode"""
     with getattr(context, f"{request.param}_mode")():
         yield request.param
+
+
+@pytest.fixture(params=["graph", "tf_eager", "tf_keras_eager"])
+def keras_should_run_eagerly(request):
+    """Fixture to run in graph and two eager modes.
+
+    The modes are:
+    - Graph mode
+    - TensorFlow eager and Keras eager
+    - TensorFlow eager and Keras not eager
+
+    The `tf.context` sets graph/eager mode for TensorFlow. The yield is True if Keras
+    should run eagerly.
+    """
+
+    if request.param == "graph":
+        if int(tf.__version__[0]) >= 2:
+            pytest.skip("Skipping graph mode for TensorFlow 2+.")
+
+        with context.graph_mode():
+            yield
+    else:
+        with context.eager_mode():
+            yield request.param == "tf_keras_eager"
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -27,7 +27,6 @@
         "tensorflow": ["tensorflow>=1.14.0"],
         "tensorflow_gpu": ["tensorflow-gpu>=1.14.0"],
         "test": [
-            "absl-py==0.8.1",
             "pytest==5.2.2",
             "pytest-cov==2.8.1",
             "pytest-xdist==1.30.0",

{"golden_diff": "diff --git a/larq/conftest.py b/larq/conftest.py\n--- a/larq/conftest.py\n+++ b/larq/conftest.py\n@@ -1,4 +1,5 @@\n import pytest\n+import tensorflow as tf\n from tensorflow.python.eager import context\n \n \n@@ -21,3 +22,27 @@\n     \"\"\"pytest fixture for running test in eager and graph mode\"\"\"\n     with getattr(context, f\"{request.param}_mode\")():\n         yield request.param\n+\n+\n+@pytest.fixture(params=[\"graph\", \"tf_eager\", \"tf_keras_eager\"])\n+def keras_should_run_eagerly(request):\n+    \"\"\"Fixture to run in graph and two eager modes.\n+\n+    The modes are:\n+    - Graph mode\n+    - TensorFlow eager and Keras eager\n+    - TensorFlow eager and Keras not eager\n+\n+    The `tf.context` sets graph/eager mode for TensorFlow. The yield is True if Keras\n+    should run eagerly.\n+    \"\"\"\n+\n+    if request.param == \"graph\":\n+        if int(tf.__version__[0]) >= 2:\n+            pytest.skip(\"Skipping graph mode for TensorFlow 2+.\")\n+\n+        with context.graph_mode():\n+            yield\n+    else:\n+        with context.eager_mode():\n+            yield request.param == \"tf_keras_eager\"\ndiff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -27,7 +27,6 @@\n         \"tensorflow\": [\"tensorflow>=1.14.0\"],\n         \"tensorflow_gpu\": [\"tensorflow-gpu>=1.14.0\"],\n         \"test\": [\n-            \"absl-py==0.8.1\",\n             \"pytest==5.2.2\",\n             \"pytest-cov==2.8.1\",\n             \"pytest-xdist==1.30.0\",\n", "issue": "Refactor layer test to use pytest parameterized test\nCurrently we use a mix of unittests written in `pytest` style and tests using `tf.test.TestCase` in larq. In #313 I added some simple `pytest` fixtures that allow to run tests in both eager and graph mode.\r\n\r\nThe only part of the test suite that uses `tf.test.TestCase` are the [layer tests](https://github.com/larq/larq/blob/f6f9277a006f6cb07b1e5f9bc591a087f2261152/larq/layers_test.py#L73-L187) which rely on [`keras_parameterized.run_all_keras_modes`](https://github.com/tensorflow/tensorflow/blob/669080135924d204a1c67dd556223d794efbf664/tensorflow/python/keras/keras_parameterized.py#L176-L303)  and a forked/copied version of [`testing_utils. layer_test`](https://github.com/tensorflow/tensorflow/blob/669080135924d204a1c67dd556223d794efbf664/tensorflow/python/keras/testing_utils.py#L75-L261).\r\n\r\nI think it would be a lot cleaner to write a simple [`pytest` fixture](https://pytest.org/en/latest/fixture.html#fixture) similar to #313 that allows us to run a normal [`pytest` parameterized test](https://pytest.org/en/latest/parametrize.html#pytest-mark-parametrize) in all Keras modes and adapt the layer tests to use it. That way we can get rid of `absl.testing` and some requirements on TensorFlow internals.\n", "before_files": [{"content": "from setuptools import setup, find_packages\n\n\ndef readme():\n    with open(\"README.md\", \"r\") as f:\n        return f.read()\n\n\nsetup(\n    name=\"larq\",\n    version=\"0.7.4\",\n    python_requires=\">=3.6\",\n    author=\"Plumerai\",\n    author_email=\"lukas@plumerai.co.uk\",\n    description=\"An Open Source Machine Learning Library for Training Binarized Neural Networks\",\n    long_description=readme(),\n    long_description_content_type=\"text/markdown\",\n    url=\"https://larq.dev/\",\n    packages=find_packages(exclude=[\"larq.snapshots\"]),\n    license=\"Apache 2.0\",\n    install_requires=[\n        \"numpy >= 1.15.4, < 2.0\",\n        \"terminaltables>=3.1.0\",\n        \"dataclasses ; python_version<'3.7'\",\n    ],\n    extras_require={\n        \"tensorflow\": [\"tensorflow>=1.14.0\"],\n        \"tensorflow_gpu\": [\"tensorflow-gpu>=1.14.0\"],\n        \"test\": [\n            \"absl-py==0.8.1\",\n            \"pytest==5.2.2\",\n            \"pytest-cov==2.8.1\",\n            \"pytest-xdist==1.30.0\",\n            \"snapshottest==0.5.1\",\n        ],\n        \"docs\": [\n            \"mkdocs==1.0.4\",\n            \"mkdocs-material==4.4.3\",\n            \"pymdown-extensions==6.1\",\n            \"mknotebooks==0.1.7\",\n            \"mkdocs-minify-plugin==0.2.1\",\n            \"larq-zoo==0.4.2\",\n            \"altair==3.2.0\",\n            \"pandas==0.25.3\",\n        ],\n    },\n    classifiers=[\n        \"Development Status :: 4 - Beta\",\n        \"Intended Audience :: Developers\",\n        \"Intended Audience :: Education\",\n        \"Intended Audience :: Science/Research\",\n        \"License :: OSI Approved :: Apache Software License\",\n        \"Programming Language :: Python :: 3\",\n        \"Programming Language :: Python :: 3 :: Only\",\n        \"Programming Language :: Python :: 3.6\",\n        \"Programming Language :: Python :: 3.7\",\n        \"Topic :: Scientific/Engineering\",\n        \"Topic :: Scientific/Engineering :: Mathematics\",\n        \"Topic :: Scientific/Engineering :: Artificial Intelligence\",\n        \"Topic :: Software Development\",\n        \"Topic :: Software Development :: Libraries\",\n        \"Topic :: Software Development :: Libraries :: Python Modules\",\n    ],\n)\n", "path": "setup.py"}, {"content": "import pytest\nfrom tensorflow.python.eager import context\n\n\n@pytest.fixture\ndef eager_mode():\n    \"\"\"pytest fixture for running test in eager mode\"\"\"\n    with context.eager_mode():\n        yield\n\n\n@pytest.fixture\ndef graph_mode():\n    \"\"\"pytest fixture for running test in graph mode\"\"\"\n    with context.graph_mode():\n        yield\n\n\n@pytest.fixture(params=[\"eager\", \"graph\"])\ndef eager_and_graph_mode(request):\n    \"\"\"pytest fixture for running test in eager and graph mode\"\"\"\n    with getattr(context, f\"{request.param}_mode\")():\n        yield request.param\n", "path": "larq/conftest.py"}], "after_files": [{"content": "from setuptools import setup, find_packages\n\n\ndef readme():\n    with open(\"README.md\", \"r\") as f:\n        return f.read()\n\n\nsetup(\n    name=\"larq\",\n    version=\"0.7.4\",\n    python_requires=\">=3.6\",\n    author=\"Plumerai\",\n    author_email=\"lukas@plumerai.co.uk\",\n    description=\"An Open Source Machine Learning Library for Training Binarized Neural Networks\",\n    long_description=readme(),\n    long_description_content_type=\"text/markdown\",\n    url=\"https://larq.dev/\",\n    packages=find_packages(exclude=[\"larq.snapshots\"]),\n    license=\"Apache 2.0\",\n    install_requires=[\n        \"numpy >= 1.15.4, < 2.0\",\n        \"terminaltables>=3.1.0\",\n        \"dataclasses ; python_version<'3.7'\",\n    ],\n    extras_require={\n        \"tensorflow\": [\"tensorflow>=1.14.0\"],\n        \"tensorflow_gpu\": [\"tensorflow-gpu>=1.14.0\"],\n        \"test\": [\n            \"pytest==5.2.2\",\n            \"pytest-cov==2.8.1\",\n            \"pytest-xdist==1.30.0\",\n            \"snapshottest==0.5.1\",\n        ],\n        \"docs\": [\n            \"mkdocs==1.0.4\",\n            \"mkdocs-material==4.4.3\",\n            \"pymdown-extensions==6.1\",\n            \"mknotebooks==0.1.7\",\n            \"mkdocs-minify-plugin==0.2.1\",\n            \"larq-zoo==0.4.2\",\n            \"altair==3.2.0\",\n            \"pandas==0.25.3\",\n        ],\n    },\n    classifiers=[\n        \"Development Status :: 4 - Beta\",\n        \"Intended Audience :: Developers\",\n        \"Intended Audience :: Education\",\n        \"Intended Audience :: Science/Research\",\n        \"License :: OSI Approved :: Apache Software License\",\n        \"Programming Language :: Python :: 3\",\n        \"Programming Language :: Python :: 3 :: Only\",\n        \"Programming Language :: Python :: 3.6\",\n        \"Programming Language :: Python :: 3.7\",\n        \"Topic :: Scientific/Engineering\",\n        \"Topic :: Scientific/Engineering :: Mathematics\",\n        \"Topic :: Scientific/Engineering :: Artificial Intelligence\",\n        \"Topic :: Software Development\",\n        \"Topic :: Software Development :: Libraries\",\n        \"Topic :: Software Development :: Libraries :: Python Modules\",\n    ],\n)\n", "path": "setup.py"}, {"content": "import pytest\nimport tensorflow as tf\nfrom tensorflow.python.eager import context\n\n\n@pytest.fixture\ndef eager_mode():\n    \"\"\"pytest fixture for running test in eager mode\"\"\"\n    with context.eager_mode():\n        yield\n\n\n@pytest.fixture\ndef graph_mode():\n    \"\"\"pytest fixture for running test in graph mode\"\"\"\n    with context.graph_mode():\n        yield\n\n\n@pytest.fixture(params=[\"eager\", \"graph\"])\ndef eager_and_graph_mode(request):\n    \"\"\"pytest fixture for running test in eager and graph mode\"\"\"\n    with getattr(context, f\"{request.param}_mode\")():\n        yield request.param\n\n\n@pytest.fixture(params=[\"graph\", \"tf_eager\", \"tf_keras_eager\"])\ndef keras_should_run_eagerly(request):\n    \"\"\"Fixture to run in graph and two eager modes.\n\n    The modes are:\n    - Graph mode\n    - TensorFlow eager and Keras eager\n    - TensorFlow eager and Keras not eager\n\n    The `tf.context` sets graph/eager mode for TensorFlow. The yield is True if Keras\n    should run eagerly.\n    \"\"\"\n\n    if request.param == \"graph\":\n        if int(tf.__version__[0]) >= 2:\n            pytest.skip(\"Skipping graph mode for TensorFlow 2+.\")\n\n        with context.graph_mode():\n            yield\n    else:\n        with context.eager_mode():\n            yield request.param == \"tf_keras_eager\"\n", "path": "larq/conftest.py"}]}