We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
GPflow2 set_default_float and set_default_int accept tf dtypes but that breaks code
Some functions such as the Gauss-Hermite quadrature code call `numpy_array.astype(default_float())`, which fails if `default_float()` returns a *tensorflow* dtype such as `tf.float64` instead of `np.float64`. However, `gpflow.config.set_default_float()` explicitly allows both numpy and tensorflow dtypes as arguments.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `gpflow/config/__config__.py`
Content:
```
1 import contextlib
2 import enum
3 import os
4 from dataclasses import dataclass, field, replace
5 from typing import Dict, Optional, Union
6 
7 import numpy as np
8 import tabulate
9 import tensorflow as tf
10 import tensorflow_probability as tfp
11 
12 
13 __all__ = [
14     "Config", "as_context", "config", "set_config",
15     "default_float", "set_default_float",
16     "default_int", "set_default_int",
17     "default_jitter", "set_default_jitter",
18     "default_positive_bijector", "set_default_positive_bijector",
19     "default_positive_minimum", "set_default_positive_minimum",
20     "default_summary_fmt", "set_default_summary_fmt",
21     "positive_bijector_type_map"
22 ]
23 
24 
25 __config = None
26 
27 
28 class _Values(enum.Enum):
29     """Setting's names collection with default values. The `name` method returns name
30     of the environment variable. E.g. for `SUMMARY_FMT` field the environment variable
31     will be `GPFLOW_SUMMARY_FMT`."""
32     INT = np.int32
33     FLOAT = np.float64
34     POSITIVE_BIJECTOR = "softplus"
35     POSITIVE_MINIMUM = None
36     SUMMARY_FMT = None
37     JITTER = 1e-6
38 
39     @property
40     def name(self):
41         return f"GPFLOW_{super().name}"
42 
43 
44 def default(value: _Values):
45     """Checks if value is set in the environment."""
46     return os.getenv(value.name, default=value.value)
47 
48 
49 @dataclass(frozen=True)
50 class Config:
51     """
52     Immutable object for storing global GPflow settings
53 
54     Args:
55         int: Integer data type, int32 or int64.
56         float: Float data type, float32 or float64
57         jitter: Jitter value. Mainly used for for making badly conditioned matrices more stable.
58             Default value is `1e-6`.
59         positive_bijector: Method for positive bijector, either "softplus" or "exp".
60             Default is "softplus".
61         positive_minimum: Lower level for the positive transformation.
62         summary_fmt: Summary format for module printing.
63     """
64 
65     int: type = field(default_factory=lambda: default(_Values.INT))
66     float: type = field(default_factory=lambda: default(_Values.FLOAT))
67     jitter: float = field(default_factory=lambda: default(_Values.JITTER))
68     positive_bijector: str = field(default_factory=lambda: default(_Values.POSITIVE_BIJECTOR))
69     positive_minimum: float = field(default_factory=lambda: default(_Values.POSITIVE_MINIMUM))
70     summary_fmt: str = field(default_factory=lambda: default(_Values.SUMMARY_FMT))
71 
72 
73 def config() -> Config:
74     """Returns current active config."""
75     return __config
76 
77 
78 def default_int():
79     return config().int
80 
81 
82 def default_float():
83     return config().float
84 
85 
86 def default_jitter():
87     return config().jitter
88 
89 
90 def default_positive_bijector():
91     return config().positive_bijector
92 
93 
94 def default_positive_minimum():
95     return config().positive_minimum
96 
97 
98 def default_summary_fmt():
99     return config().summary_fmt
100 
101 
102 def set_config(new_config: Config):
103     """Update GPflow config"""
104     global __config
105     __config = new_config
106 
107 
108 def set_default_int(value_type):
109     try:
110         tf_dtype = tf.as_dtype(value_type)  # Test that it's a tensorflow-valid dtype
111     except TypeError:
112         raise TypeError(f"{value_type} is not a valid tf or np dtype")
113 
114     if not tf_dtype.is_integer:
115         raise TypeError(f"{value_type} is not an integer dtype")
116 
117     set_config(replace(config(), int=value_type))
118 
119 
120 def set_default_float(value_type):
121     try:
122         tf_dtype = tf.as_dtype(value_type)  # Test that it's a tensorflow-valid dtype
123     except TypeError:
124         raise TypeError(f"{value_type} is not a valid tf or np dtype")
125 
126     if not tf_dtype.is_floating:
127         raise TypeError(f"{value_type} is not a float dtype")
128 
129     set_config(replace(config(), float=value_type))
130 
131 
132 def set_default_jitter(value: float):
133     if not (isinstance(value, (tf.Tensor, np.ndarray)) and len(value.shape) == 0) and \
134             not isinstance(value, float):
135         raise TypeError("Expected float32 or float64 scalar value")
136 
137     if value < 0:
138         raise ValueError("Jitter must be non-negative")
139 
140     set_config(replace(config(), jitter=value))
141 
142 
143 def set_default_positive_bijector(value: str):
144     type_map = positive_bijector_type_map()
145     if isinstance(value, str):
146         value = value.lower()
147     if value not in type_map:
148         raise ValueError(f"`{value}` not in set of valid bijectors: {sorted(type_map)}")
149 
150     set_config(replace(config(), positive_bijector=value))
151 
152 
153 def set_default_positive_minimum(value: float):
154     if not (isinstance(value, (tf.Tensor, np.ndarray)) and len(value.shape) == 0) and \
155             not isinstance(value, float):
156         raise TypeError("Expected float32 or float64 scalar value")
157 
158     if value < 0:
159         raise ValueError("Value must be non-negative")
160 
161     set_config(replace(config(), positive_minimum=value))
162 
163 
164 def set_default_summary_fmt(value: str):
165     formats = tabulate.tabulate_formats + ['notebook', None]
166     if value not in formats:
167         raise ValueError(f"Summary does not support '{value}' format")
168 
169     set_config(replace(config(), summary_fmt=value))
170 
171 
172 def positive_bijector_type_map() -> Dict[str, type]:
173     return {
174         "exp": tfp.bijectors.Exp,
175         "softplus": tfp.bijectors.Softplus,
176     }
177 
178 
179 @contextlib.contextmanager
180 def as_context(temporary_config: Optional[Config] = None):
181     """Ensure that global configs defaults, with a context manager. Useful for testing."""
182     current_config = config()
183     temporary_config = replace(current_config) if temporary_config is None else temporary_config
184     try:
185         set_config(temporary_config)
186         yield
187     finally:
188         set_config(current_config)
189 
190 
191 # Set global config.
192 set_config(Config())
193
```
--- 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/gpflow/config/__config__.py b/gpflow/config/__config__.py
--- a/gpflow/config/__config__.py
+++ b/gpflow/config/__config__.py
@@ -114,7 +114,7 @@
     if not tf_dtype.is_integer:
         raise TypeError(f"{value_type} is not an integer dtype")
 
-    set_config(replace(config(), int=value_type))
+    set_config(replace(config(), int=tf_dtype.as_numpy_dtype))
 
 
 def set_default_float(value_type):
@@ -126,7 +126,7 @@
     if not tf_dtype.is_floating:
         raise TypeError(f"{value_type} is not a float dtype")
 
-    set_config(replace(config(), float=value_type))
+    set_config(replace(config(), float=tf_dtype.as_numpy_dtype))
 
 
 def set_default_jitter(value: float):

{"golden_diff": "diff --git a/gpflow/config/__config__.py b/gpflow/config/__config__.py\n--- a/gpflow/config/__config__.py\n+++ b/gpflow/config/__config__.py\n@@ -114,7 +114,7 @@\n     if not tf_dtype.is_integer:\n         raise TypeError(f\"{value_type} is not an integer dtype\")\n \n-    set_config(replace(config(), int=value_type))\n+    set_config(replace(config(), int=tf_dtype.as_numpy_dtype))\n \n \n def set_default_float(value_type):\n@@ -126,7 +126,7 @@\n     if not tf_dtype.is_floating:\n         raise TypeError(f\"{value_type} is not a float dtype\")\n \n-    set_config(replace(config(), float=value_type))\n+    set_config(replace(config(), float=tf_dtype.as_numpy_dtype))\n \n \n def set_default_jitter(value: float):\n", "issue": "GPflow2 set_default_float and set_default_int accept tf dtypes but that breaks code\nSome functions such as the Gauss-Hermite quadrature code call `numpy_array.astype(default_float())`, which fails if `default_float()` returns a *tensorflow* dtype such as `tf.float64` instead of `np.float64`. However, `gpflow.config.set_default_float()` explicitly allows both numpy and tensorflow dtypes as arguments.\n", "before_files": [{"content": "import contextlib\nimport enum\nimport os\nfrom dataclasses import dataclass, field, replace\nfrom typing import Dict, Optional, Union\n\nimport numpy as np\nimport tabulate\nimport tensorflow as tf\nimport tensorflow_probability as tfp\n\n\n__all__ = [\n    \"Config\", \"as_context\", \"config\", \"set_config\",\n    \"default_float\", \"set_default_float\",\n    \"default_int\", \"set_default_int\",\n    \"default_jitter\", \"set_default_jitter\",\n    \"default_positive_bijector\", \"set_default_positive_bijector\",\n    \"default_positive_minimum\", \"set_default_positive_minimum\",\n    \"default_summary_fmt\", \"set_default_summary_fmt\",\n    \"positive_bijector_type_map\"\n]\n\n\n__config = None\n\n\nclass _Values(enum.Enum):\n    \"\"\"Setting's names collection with default values. The `name` method returns name\n    of the environment variable. E.g. for `SUMMARY_FMT` field the environment variable\n    will be `GPFLOW_SUMMARY_FMT`.\"\"\"\n    INT = np.int32\n    FLOAT = np.float64\n    POSITIVE_BIJECTOR = \"softplus\"\n    POSITIVE_MINIMUM = None\n    SUMMARY_FMT = None\n    JITTER = 1e-6\n\n    @property\n    def name(self):\n        return f\"GPFLOW_{super().name}\"\n\n\ndef default(value: _Values):\n    \"\"\"Checks if value is set in the environment.\"\"\"\n    return os.getenv(value.name, default=value.value)\n\n\n@dataclass(frozen=True)\nclass Config:\n    \"\"\"\n    Immutable object for storing global GPflow settings\n\n    Args:\n        int: Integer data type, int32 or int64.\n        float: Float data type, float32 or float64\n        jitter: Jitter value. Mainly used for for making badly conditioned matrices more stable.\n            Default value is `1e-6`.\n        positive_bijector: Method for positive bijector, either \"softplus\" or \"exp\".\n            Default is \"softplus\".\n        positive_minimum: Lower level for the positive transformation.\n        summary_fmt: Summary format for module printing.\n    \"\"\"\n\n    int: type = field(default_factory=lambda: default(_Values.INT))\n    float: type = field(default_factory=lambda: default(_Values.FLOAT))\n    jitter: float = field(default_factory=lambda: default(_Values.JITTER))\n    positive_bijector: str = field(default_factory=lambda: default(_Values.POSITIVE_BIJECTOR))\n    positive_minimum: float = field(default_factory=lambda: default(_Values.POSITIVE_MINIMUM))\n    summary_fmt: str = field(default_factory=lambda: default(_Values.SUMMARY_FMT))\n\n\ndef config() -> Config:\n    \"\"\"Returns current active config.\"\"\"\n    return __config\n\n\ndef default_int():\n    return config().int\n\n\ndef default_float():\n    return config().float\n\n\ndef default_jitter():\n    return config().jitter\n\n\ndef default_positive_bijector():\n    return config().positive_bijector\n\n\ndef default_positive_minimum():\n    return config().positive_minimum\n\n\ndef default_summary_fmt():\n    return config().summary_fmt\n\n\ndef set_config(new_config: Config):\n    \"\"\"Update GPflow config\"\"\"\n    global __config\n    __config = new_config\n\n\ndef set_default_int(value_type):\n    try:\n        tf_dtype = tf.as_dtype(value_type)  # Test that it's a tensorflow-valid dtype\n    except TypeError:\n        raise TypeError(f\"{value_type} is not a valid tf or np dtype\")\n\n    if not tf_dtype.is_integer:\n        raise TypeError(f\"{value_type} is not an integer dtype\")\n\n    set_config(replace(config(), int=value_type))\n\n\ndef set_default_float(value_type):\n    try:\n        tf_dtype = tf.as_dtype(value_type)  # Test that it's a tensorflow-valid dtype\n    except TypeError:\n        raise TypeError(f\"{value_type} is not a valid tf or np dtype\")\n\n    if not tf_dtype.is_floating:\n        raise TypeError(f\"{value_type} is not a float dtype\")\n\n    set_config(replace(config(), float=value_type))\n\n\ndef set_default_jitter(value: float):\n    if not (isinstance(value, (tf.Tensor, np.ndarray)) and len(value.shape) == 0) and \\\n            not isinstance(value, float):\n        raise TypeError(\"Expected float32 or float64 scalar value\")\n\n    if value < 0:\n        raise ValueError(\"Jitter must be non-negative\")\n\n    set_config(replace(config(), jitter=value))\n\n\ndef set_default_positive_bijector(value: str):\n    type_map = positive_bijector_type_map()\n    if isinstance(value, str):\n        value = value.lower()\n    if value not in type_map:\n        raise ValueError(f\"`{value}` not in set of valid bijectors: {sorted(type_map)}\")\n\n    set_config(replace(config(), positive_bijector=value))\n\n\ndef set_default_positive_minimum(value: float):\n    if not (isinstance(value, (tf.Tensor, np.ndarray)) and len(value.shape) == 0) and \\\n            not isinstance(value, float):\n        raise TypeError(\"Expected float32 or float64 scalar value\")\n\n    if value < 0:\n        raise ValueError(\"Value must be non-negative\")\n\n    set_config(replace(config(), positive_minimum=value))\n\n\ndef set_default_summary_fmt(value: str):\n    formats = tabulate.tabulate_formats + ['notebook', None]\n    if value not in formats:\n        raise ValueError(f\"Summary does not support '{value}' format\")\n\n    set_config(replace(config(), summary_fmt=value))\n\n\ndef positive_bijector_type_map() -> Dict[str, type]:\n    return {\n        \"exp\": tfp.bijectors.Exp,\n        \"softplus\": tfp.bijectors.Softplus,\n    }\n\n\n@contextlib.contextmanager\ndef as_context(temporary_config: Optional[Config] = None):\n    \"\"\"Ensure that global configs defaults, with a context manager. Useful for testing.\"\"\"\n    current_config = config()\n    temporary_config = replace(current_config) if temporary_config is None else temporary_config\n    try:\n        set_config(temporary_config)\n        yield\n    finally:\n        set_config(current_config)\n\n\n# Set global config.\nset_config(Config())\n", "path": "gpflow/config/__config__.py"}], "after_files": [{"content": "import contextlib\nimport enum\nimport os\nfrom dataclasses import dataclass, field, replace\nfrom typing import Dict, Optional, Union\n\nimport numpy as np\nimport tabulate\nimport tensorflow as tf\nimport tensorflow_probability as tfp\n\n\n__all__ = [\n    \"Config\", \"as_context\", \"config\", \"set_config\",\n    \"default_float\", \"set_default_float\",\n    \"default_int\", \"set_default_int\",\n    \"default_jitter\", \"set_default_jitter\",\n    \"default_positive_bijector\", \"set_default_positive_bijector\",\n    \"default_positive_minimum\", \"set_default_positive_minimum\",\n    \"default_summary_fmt\", \"set_default_summary_fmt\",\n    \"positive_bijector_type_map\"\n]\n\n\n__config = None\n\n\nclass _Values(enum.Enum):\n    \"\"\"Setting's names collection with default values. The `name` method returns name\n    of the environment variable. E.g. for `SUMMARY_FMT` field the environment variable\n    will be `GPFLOW_SUMMARY_FMT`.\"\"\"\n    INT = np.int32\n    FLOAT = np.float64\n    POSITIVE_BIJECTOR = \"softplus\"\n    POSITIVE_MINIMUM = None\n    SUMMARY_FMT = None\n    JITTER = 1e-6\n\n    @property\n    def name(self):\n        return f\"GPFLOW_{super().name}\"\n\n\ndef default(value: _Values):\n    \"\"\"Checks if value is set in the environment.\"\"\"\n    return os.getenv(value.name, default=value.value)\n\n\n@dataclass(frozen=True)\nclass Config:\n    \"\"\"\n    Immutable object for storing global GPflow settings\n\n    Args:\n        int: Integer data type, int32 or int64.\n        float: Float data type, float32 or float64\n        jitter: Jitter value. Mainly used for for making badly conditioned matrices more stable.\n            Default value is `1e-6`.\n        positive_bijector: Method for positive bijector, either \"softplus\" or \"exp\".\n            Default is \"softplus\".\n        positive_minimum: Lower level for the positive transformation.\n        summary_fmt: Summary format for module printing.\n    \"\"\"\n\n    int: type = field(default_factory=lambda: default(_Values.INT))\n    float: type = field(default_factory=lambda: default(_Values.FLOAT))\n    jitter: float = field(default_factory=lambda: default(_Values.JITTER))\n    positive_bijector: str = field(default_factory=lambda: default(_Values.POSITIVE_BIJECTOR))\n    positive_minimum: float = field(default_factory=lambda: default(_Values.POSITIVE_MINIMUM))\n    summary_fmt: str = field(default_factory=lambda: default(_Values.SUMMARY_FMT))\n\n\ndef config() -> Config:\n    \"\"\"Returns current active config.\"\"\"\n    return __config\n\n\ndef default_int():\n    return config().int\n\n\ndef default_float():\n    return config().float\n\n\ndef default_jitter():\n    return config().jitter\n\n\ndef default_positive_bijector():\n    return config().positive_bijector\n\n\ndef default_positive_minimum():\n    return config().positive_minimum\n\n\ndef default_summary_fmt():\n    return config().summary_fmt\n\n\ndef set_config(new_config: Config):\n    \"\"\"Update GPflow config\"\"\"\n    global __config\n    __config = new_config\n\n\ndef set_default_int(value_type):\n    try:\n        tf_dtype = tf.as_dtype(value_type)  # Test that it's a tensorflow-valid dtype\n    except TypeError:\n        raise TypeError(f\"{value_type} is not a valid tf or np dtype\")\n\n    if not tf_dtype.is_integer:\n        raise TypeError(f\"{value_type} is not an integer dtype\")\n\n    set_config(replace(config(), int=tf_dtype.as_numpy_dtype))\n\n\ndef set_default_float(value_type):\n    try:\n        tf_dtype = tf.as_dtype(value_type)  # Test that it's a tensorflow-valid dtype\n    except TypeError:\n        raise TypeError(f\"{value_type} is not a valid tf or np dtype\")\n\n    if not tf_dtype.is_floating:\n        raise TypeError(f\"{value_type} is not a float dtype\")\n\n    set_config(replace(config(), float=tf_dtype.as_numpy_dtype))\n\n\ndef set_default_jitter(value: float):\n    if not (isinstance(value, (tf.Tensor, np.ndarray)) and len(value.shape) == 0) and \\\n            not isinstance(value, float):\n        raise TypeError(\"Expected float32 or float64 scalar value\")\n\n    if value < 0:\n        raise ValueError(\"Jitter must be non-negative\")\n\n    set_config(replace(config(), jitter=value))\n\n\ndef set_default_positive_bijector(value: str):\n    type_map = positive_bijector_type_map()\n    if isinstance(value, str):\n        value = value.lower()\n    if value not in type_map:\n        raise ValueError(f\"`{value}` not in set of valid bijectors: {sorted(type_map)}\")\n\n    set_config(replace(config(), positive_bijector=value))\n\n\ndef set_default_positive_minimum(value: float):\n    if not (isinstance(value, (tf.Tensor, np.ndarray)) and len(value.shape) == 0) and \\\n            not isinstance(value, float):\n        raise TypeError(\"Expected float32 or float64 scalar value\")\n\n    if value < 0:\n        raise ValueError(\"Value must be non-negative\")\n\n    set_config(replace(config(), positive_minimum=value))\n\n\ndef set_default_summary_fmt(value: str):\n    formats = tabulate.tabulate_formats + ['notebook', None]\n    if value not in formats:\n        raise ValueError(f\"Summary does not support '{value}' format\")\n\n    set_config(replace(config(), summary_fmt=value))\n\n\ndef positive_bijector_type_map() -> Dict[str, type]:\n    return {\n        \"exp\": tfp.bijectors.Exp,\n        \"softplus\": tfp.bijectors.Softplus,\n    }\n\n\n@contextlib.contextmanager\ndef as_context(temporary_config: Optional[Config] = None):\n    \"\"\"Ensure that global configs defaults, with a context manager. Useful for testing.\"\"\"\n    current_config = config()\n    temporary_config = replace(current_config) if temporary_config is None else temporary_config\n    try:\n        set_config(temporary_config)\n        yield\n    finally:\n        set_config(current_config)\n\n\n# Set global config.\nset_config(Config())\n", "path": "gpflow/config/__config__.py"}]}