prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Drop GELU for 0.13 release
  https://www.tensorflow.org/api_docs/python/tf/keras/activations/gelu will be available in TF2.4. Deprecation warning is already set for our upcming 0.12 release
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `tensorflow_addons/activations/gelu.py`
  Content:
  ```
  1 # Copyright 2019 The TensorFlow Authors. All Rights Reserved.
  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 
  16 import tensorflow as tf
  17 import math
  18 import warnings
  19 
  20 from tensorflow_addons.utils import types
  21 
  22 
  23 @tf.keras.utils.register_keras_serializable(package="Addons")
  24 def gelu(x: types.TensorLike, approximate: bool = True) -> tf.Tensor:
  25     r"""Gaussian Error Linear Unit.
  26 
  27     Computes gaussian error linear:
  28 
  29     $$
  30     \mathrm{gelu}(x) = x \Phi(x),
  31     $$
  32 
  33     where
  34 
  35     $$
  36     \Phi(x) = \frac{1}{2} \left[ 1 + \mathrm{erf}(\frac{x}{\sqrt{2}}) \right]$
  37     $$
  38 
  39     when `approximate` is `False`; or
  40 
  41     $$
  42     \Phi(x) = \frac{x}{2} \left[ 1 + \tanh(\sqrt{\frac{2}{\pi}} \cdot (x + 0.044715 \cdot x^3)) \right]
  43     $$
  44 
  45     when `approximate` is `True`.
  46 
  47     See [Gaussian Error Linear Units (GELUs)](https://arxiv.org/abs/1606.08415)
  48     and [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding](https://arxiv.org/abs/1810.04805).
  49 
  50     Usage:
  51 
  52     >>> tfa.options.TF_ADDONS_PY_OPS = True
  53     >>> x = tf.constant([-1.0, 0.0, 1.0])
  54     >>> tfa.activations.gelu(x, approximate=False)
  55     <tf.Tensor: shape=(3,), dtype=float32, numpy=array([-0.15865529,  0.        ,  0.8413447 ], dtype=float32)>
  56     >>> tfa.activations.gelu(x, approximate=True)
  57     <tf.Tensor: shape=(3,), dtype=float32, numpy=array([-0.158808,  0.      ,  0.841192], dtype=float32)>
  58 
  59     Args:
  60         x: A `Tensor`. Must be one of the following types:
  61             `float16`, `float32`, `float64`.
  62         approximate: bool, whether to enable approximation.
  63     Returns:
  64         A `Tensor`. Has the same type as `x`.
  65     """
  66     warnings.warn(
  67         "gelu activation has been migrated to core TensorFlow, "
  68         "and will be deprecated in Addons 0.13.",
  69         DeprecationWarning,
  70     )
  71 
  72     x = tf.convert_to_tensor(x)
  73 
  74     return _gelu_py(x, approximate)
  75 
  76 
  77 def _gelu_py(x: types.TensorLike, approximate: bool = True) -> tf.Tensor:
  78     x = tf.convert_to_tensor(x)
  79     if approximate:
  80         pi = tf.cast(math.pi, x.dtype)
  81         coeff = tf.cast(0.044715, x.dtype)
  82         return 0.5 * x * (1.0 + tf.tanh(tf.sqrt(2.0 / pi) * (x + coeff * tf.pow(x, 3))))
  83     else:
  84         return 0.5 * x * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0), x.dtype)))
  85
  ```
  --- 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/tensorflow_addons/activations/gelu.py b/tensorflow_addons/activations/gelu.py
  --- a/tensorflow_addons/activations/gelu.py
  +++ b/tensorflow_addons/activations/gelu.py
  @@ -18,6 +18,7 @@
   import warnings
   
   from tensorflow_addons.utils import types
  +from distutils.version import LooseVersion
   
   
   @tf.keras.utils.register_keras_serializable(package="Addons")
  @@ -47,6 +48,9 @@
       See [Gaussian Error Linear Units (GELUs)](https://arxiv.org/abs/1606.08415)
       and [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding](https://arxiv.org/abs/1810.04805).
   
  +    Note that `approximate` will default to `False` from TensorFlow version 2.4 onwards.
  +    Consider using `tf.nn.gelu` instead.
  +
       Usage:
   
       >>> tfa.options.TF_ADDONS_PY_OPS = True
  @@ -54,7 +58,7 @@
       >>> tfa.activations.gelu(x, approximate=False)
       <tf.Tensor: shape=(3,), dtype=float32, numpy=array([-0.15865529,  0.        ,  0.8413447 ], dtype=float32)>
       >>> tfa.activations.gelu(x, approximate=True)
  -    <tf.Tensor: shape=(3,), dtype=float32, numpy=array([-0.158808,  0.      ,  0.841192], dtype=float32)>
  +    <tf.Tensor: shape=(3,), dtype=float32, numpy=array([-0.15880796,  0.        ,  0.841192  ], dtype=float32)>
   
       Args:
           x: A `Tensor`. Must be one of the following types:
  @@ -71,7 +75,15 @@
   
       x = tf.convert_to_tensor(x)
   
  -    return _gelu_py(x, approximate)
  +    if LooseVersion(tf.__version__) >= "2.4":
  +        gelu_op = tf.nn.gelu
  +        warnings.warn(
  +            "Default value of `approximate` is changed from `True` to `False`"
  +        )
  +    else:
  +        gelu_op = _gelu_py
  +
  +    return gelu_op(x, approximate)
   
   
   def _gelu_py(x: types.TensorLike, approximate: bool = True) -> tf.Tensor:
  
verification_info: {"golden_diff": "diff --git a/tensorflow_addons/activations/gelu.py b/tensorflow_addons/activations/gelu.py\n--- a/tensorflow_addons/activations/gelu.py\n+++ b/tensorflow_addons/activations/gelu.py\n@@ -18,6 +18,7 @@\n import warnings\n \n from tensorflow_addons.utils import types\n+from distutils.version import LooseVersion\n \n \n @tf.keras.utils.register_keras_serializable(package=\"Addons\")\n@@ -47,6 +48,9 @@\n     See [Gaussian Error Linear Units (GELUs)](https://arxiv.org/abs/1606.08415)\n     and [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding](https://arxiv.org/abs/1810.04805).\n \n+    Note that `approximate` will default to `False` from TensorFlow version 2.4 onwards.\n+    Consider using `tf.nn.gelu` instead.\n+\n     Usage:\n \n     >>> tfa.options.TF_ADDONS_PY_OPS = True\n@@ -54,7 +58,7 @@\n     >>> tfa.activations.gelu(x, approximate=False)\n     <tf.Tensor: shape=(3,), dtype=float32, numpy=array([-0.15865529,  0.        ,  0.8413447 ], dtype=float32)>\n     >>> tfa.activations.gelu(x, approximate=True)\n-    <tf.Tensor: shape=(3,), dtype=float32, numpy=array([-0.158808,  0.      ,  0.841192], dtype=float32)>\n+    <tf.Tensor: shape=(3,), dtype=float32, numpy=array([-0.15880796,  0.        ,  0.841192  ], dtype=float32)>\n \n     Args:\n         x: A `Tensor`. Must be one of the following types:\n@@ -71,7 +75,15 @@\n \n     x = tf.convert_to_tensor(x)\n \n-    return _gelu_py(x, approximate)\n+    if LooseVersion(tf.__version__) >= \"2.4\":\n+        gelu_op = tf.nn.gelu\n+        warnings.warn(\n+            \"Default value of `approximate` is changed from `True` to `False`\"\n+        )\n+    else:\n+        gelu_op = _gelu_py\n+\n+    return gelu_op(x, approximate)\n \n \n def _gelu_py(x: types.TensorLike, approximate: bool = True) -> tf.Tensor:\n", "issue": "Drop GELU for 0.13 release\nhttps://www.tensorflow.org/api_docs/python/tf/keras/activations/gelu will be available in TF2.4. Deprecation warning is already set for our upcming 0.12 release\n", "before_files": [{"content": "# Copyright 2019 The TensorFlow Authors. All Rights Reserved.\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\nimport tensorflow as tf\nimport math\nimport warnings\n\nfrom tensorflow_addons.utils import types\n\n\n@tf.keras.utils.register_keras_serializable(package=\"Addons\")\ndef gelu(x: types.TensorLike, approximate: bool = True) -> tf.Tensor:\n    r\"\"\"Gaussian Error Linear Unit.\n\n    Computes gaussian error linear:\n\n    $$\n    \\mathrm{gelu}(x) = x \\Phi(x),\n    $$\n\n    where\n\n    $$\n    \\Phi(x) = \\frac{1}{2} \\left[ 1 + \\mathrm{erf}(\\frac{x}{\\sqrt{2}}) \\right]$\n    $$\n\n    when `approximate` is `False`; or\n\n    $$\n    \\Phi(x) = \\frac{x}{2} \\left[ 1 + \\tanh(\\sqrt{\\frac{2}{\\pi}} \\cdot (x + 0.044715 \\cdot x^3)) \\right]\n    $$\n\n    when `approximate` is `True`.\n\n    See [Gaussian Error Linear Units (GELUs)](https://arxiv.org/abs/1606.08415)\n    and [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding](https://arxiv.org/abs/1810.04805).\n\n    Usage:\n\n    >>> tfa.options.TF_ADDONS_PY_OPS = True\n    >>> x = tf.constant([-1.0, 0.0, 1.0])\n    >>> tfa.activations.gelu(x, approximate=False)\n    <tf.Tensor: shape=(3,), dtype=float32, numpy=array([-0.15865529,  0.        ,  0.8413447 ], dtype=float32)>\n    >>> tfa.activations.gelu(x, approximate=True)\n    <tf.Tensor: shape=(3,), dtype=float32, numpy=array([-0.158808,  0.      ,  0.841192], dtype=float32)>\n\n    Args:\n        x: A `Tensor`. Must be one of the following types:\n            `float16`, `float32`, `float64`.\n        approximate: bool, whether to enable approximation.\n    Returns:\n        A `Tensor`. Has the same type as `x`.\n    \"\"\"\n    warnings.warn(\n        \"gelu activation has been migrated to core TensorFlow, \"\n        \"and will be deprecated in Addons 0.13.\",\n        DeprecationWarning,\n    )\n\n    x = tf.convert_to_tensor(x)\n\n    return _gelu_py(x, approximate)\n\n\ndef _gelu_py(x: types.TensorLike, approximate: bool = True) -> tf.Tensor:\n    x = tf.convert_to_tensor(x)\n    if approximate:\n        pi = tf.cast(math.pi, x.dtype)\n        coeff = tf.cast(0.044715, x.dtype)\n        return 0.5 * x * (1.0 + tf.tanh(tf.sqrt(2.0 / pi) * (x + coeff * tf.pow(x, 3))))\n    else:\n        return 0.5 * x * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0), x.dtype)))\n", "path": "tensorflow_addons/activations/gelu.py"}], "after_files": [{"content": "# Copyright 2019 The TensorFlow Authors. All Rights Reserved.\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\nimport tensorflow as tf\nimport math\nimport warnings\n\nfrom tensorflow_addons.utils import types\nfrom distutils.version import LooseVersion\n\n\n@tf.keras.utils.register_keras_serializable(package=\"Addons\")\ndef gelu(x: types.TensorLike, approximate: bool = True) -> tf.Tensor:\n    r\"\"\"Gaussian Error Linear Unit.\n\n    Computes gaussian error linear:\n\n    $$\n    \\mathrm{gelu}(x) = x \\Phi(x),\n    $$\n\n    where\n\n    $$\n    \\Phi(x) = \\frac{1}{2} \\left[ 1 + \\mathrm{erf}(\\frac{x}{\\sqrt{2}}) \\right]$\n    $$\n\n    when `approximate` is `False`; or\n\n    $$\n    \\Phi(x) = \\frac{x}{2} \\left[ 1 + \\tanh(\\sqrt{\\frac{2}{\\pi}} \\cdot (x + 0.044715 \\cdot x^3)) \\right]\n    $$\n\n    when `approximate` is `True`.\n\n    See [Gaussian Error Linear Units (GELUs)](https://arxiv.org/abs/1606.08415)\n    and [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding](https://arxiv.org/abs/1810.04805).\n\n    Note that `approximate` will default to `False` from TensorFlow version 2.4 onwards.\n    Consider using `tf.nn.gelu` instead.\n\n    Usage:\n\n    >>> tfa.options.TF_ADDONS_PY_OPS = True\n    >>> x = tf.constant([-1.0, 0.0, 1.0])\n    >>> tfa.activations.gelu(x, approximate=False)\n    <tf.Tensor: shape=(3,), dtype=float32, numpy=array([-0.15865529,  0.        ,  0.8413447 ], dtype=float32)>\n    >>> tfa.activations.gelu(x, approximate=True)\n    <tf.Tensor: shape=(3,), dtype=float32, numpy=array([-0.15880796,  0.        ,  0.841192  ], dtype=float32)>\n\n    Args:\n        x: A `Tensor`. Must be one of the following types:\n            `float16`, `float32`, `float64`.\n        approximate: bool, whether to enable approximation.\n    Returns:\n        A `Tensor`. Has the same type as `x`.\n    \"\"\"\n    warnings.warn(\n        \"gelu activation has been migrated to core TensorFlow, \"\n        \"and will be deprecated in Addons 0.13.\",\n        DeprecationWarning,\n    )\n\n    x = tf.convert_to_tensor(x)\n\n    if LooseVersion(tf.__version__) >= \"2.4\":\n        gelu_op = tf.nn.gelu\n        warnings.warn(\n            \"Default value of `approximate` is changed from `True` to `False`\"\n        )\n    else:\n        gelu_op = _gelu_py\n\n    return gelu_op(x, approximate)\n\n\ndef _gelu_py(x: types.TensorLike, approximate: bool = True) -> tf.Tensor:\n    x = tf.convert_to_tensor(x)\n    if approximate:\n        pi = tf.cast(math.pi, x.dtype)\n        coeff = tf.cast(0.044715, x.dtype)\n        return 0.5 * x * (1.0 + tf.tanh(tf.sqrt(2.0 / pi) * (x + coeff * tf.pow(x, 3))))\n    else:\n        return 0.5 * x * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0), x.dtype)))\n", "path": "tensorflow_addons/activations/gelu.py"}]}