prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Deprecate GELU 
  Per https://github.com/tensorflow/community/pull/252, oonce  https://github.com/tensorflow/tensorflow/pull/41178 merges we'll need to deprecate our GELU for versions of TensorFlow that include it within core.
  
  --- 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/layers/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 """Implements GELU activation."""
  16 
  17 import tensorflow as tf
  18 from tensorflow_addons.activations import gelu
  19 from typeguard import typechecked
  20 
  21 
  22 @tf.keras.utils.register_keras_serializable(package="Addons")
  23 class GELU(tf.keras.layers.Layer):
  24     """Gaussian Error Linear Unit.
  25 
  26     A smoother version of ReLU generally used
  27     in the BERT or BERT architecture based models.
  28     Original paper: https://arxiv.org/abs/1606.08415
  29 
  30     Input shape:
  31         Arbitrary. Use the keyword argument `input_shape`
  32         (tuple of integers, does not include the samples axis)
  33         when using this layer as the first layer in a model.
  34 
  35     Output shape:
  36         Same shape as the input.
  37     """
  38 
  39     @typechecked
  40     def __init__(self, approximate: bool = True, **kwargs):
  41         super().__init__(**kwargs)
  42         self.approximate = approximate
  43         self.supports_masking = True
  44 
  45     def call(self, inputs):
  46         return gelu(inputs, approximate=self.approximate)
  47 
  48     def get_config(self):
  49         config = {"approximate": self.approximate}
  50         base_config = super().get_config()
  51         return {**base_config, **config}
  52 
  53     def compute_output_shape(self, input_shape):
  54         return input_shape
  55
  ```
  
  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 from tensorflow_addons.utils.resource_loader import LazySO
  22 from tensorflow_addons import options
  23 
  24 _activation_so = LazySO("custom_ops/activations/_activation_ops.so")
  25 
  26 
  27 @tf.keras.utils.register_keras_serializable(package="Addons")
  28 def gelu(x: types.TensorLike, approximate: bool = True) -> tf.Tensor:
  29     """Gaussian Error Linear Unit.
  30 
  31     Computes gaussian error linear:
  32     `0.5 * x * (1 + tanh(sqrt(2 / pi) * (x + 0.044715 * x^3)))` or
  33     `x * P(X <= x) = 0.5 * x * (1 + erf(x / sqrt(2)))`, where P(X) ~ N(0, 1),
  34     depending on whether approximation is enabled.
  35 
  36     See [Gaussian Error Linear Units (GELUs)](https://arxiv.org/abs/1606.08415)
  37     and [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding](https://arxiv.org/abs/1810.04805).
  38 
  39     Args:
  40         x: A `Tensor`. Must be one of the following types:
  41             `float16`, `float32`, `float64`.
  42         approximate: bool, whether to enable approximation.
  43     Returns:
  44         A `Tensor`. Has the same type as `x`.
  45     """
  46     x = tf.convert_to_tensor(x)
  47 
  48     if not options.TF_ADDONS_PY_OPS:
  49         try:
  50             return _gelu_custom_op(x, approximate)
  51         except tf.errors.NotFoundError:
  52             options.warn_fallback("gelu")
  53 
  54     return _gelu_py(x, approximate)
  55 
  56 
  57 def _gelu_custom_op(x, approximate):
  58     warnings.warn(
  59         "The activations custom ops are deprecated and will be removed in TensorFlow Addons "
  60         "v0.12.0. \nPlease use the pure python version of Gelu instead by using the "
  61         "`TF_ADDONS_PY_OPS` flag. \nFor more info about this flag, see "
  62         "https://github.com/tensorflow/addons#gpucpu-custom-ops ",
  63         DeprecationWarning,
  64     )
  65     return _activation_so.ops.addons_gelu(x, approximate)
  66 
  67 
  68 @tf.RegisterGradient("Addons>Gelu")
  69 def _gelu_grad(op, grad):
  70     return _activation_so.ops.addons_gelu_grad(
  71         grad, op.inputs[0], op.get_attr("approximate")
  72     )
  73 
  74 
  75 def _gelu_py(x: types.TensorLike, approximate: bool = True) -> tf.Tensor:
  76     x = tf.convert_to_tensor(x)
  77     if approximate:
  78         pi = tf.cast(math.pi, x.dtype)
  79         coeff = tf.cast(0.044715, x.dtype)
  80         return 0.5 * x * (1.0 + tf.tanh(tf.sqrt(2.0 / pi) * (x + coeff * tf.pow(x, 3))))
  81     else:
  82         return 0.5 * x * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0), x.dtype)))
  83
  ```
  --- 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
  @@ -43,6 +43,12 @@
       Returns:
           A `Tensor`. Has the same type as `x`.
       """
  +    warnings.warn(
  +        "gelu activation has been migrated to core TensorFlow, "
  +        "and will be deprecated in Addons 0.12.",
  +        DeprecationWarning,
  +    )
  +
       x = tf.convert_to_tensor(x)
   
       if not options.TF_ADDONS_PY_OPS:
  diff --git a/tensorflow_addons/layers/gelu.py b/tensorflow_addons/layers/gelu.py
  --- a/tensorflow_addons/layers/gelu.py
  +++ b/tensorflow_addons/layers/gelu.py
  @@ -14,6 +14,8 @@
   # ==============================================================================
   """Implements GELU activation."""
   
  +import warnings
  +
   import tensorflow as tf
   from tensorflow_addons.activations import gelu
   from typeguard import typechecked
  @@ -38,6 +40,12 @@
   
       @typechecked
       def __init__(self, approximate: bool = True, **kwargs):
  +        warnings.warn(
  +            "gelu activation has been migrated to core TensorFlow, "
  +            "and will be deprecated in Addons 0.12.",
  +            DeprecationWarning,
  +        )
  +
           super().__init__(**kwargs)
           self.approximate = approximate
           self.supports_masking = True
  
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@@ -43,6 +43,12 @@\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.12.\",\n+        DeprecationWarning,\n+    )\n+\n     x = tf.convert_to_tensor(x)\n \n     if not options.TF_ADDONS_PY_OPS:\ndiff --git a/tensorflow_addons/layers/gelu.py b/tensorflow_addons/layers/gelu.py\n--- a/tensorflow_addons/layers/gelu.py\n+++ b/tensorflow_addons/layers/gelu.py\n@@ -14,6 +14,8 @@\n # ==============================================================================\n \"\"\"Implements GELU activation.\"\"\"\n \n+import warnings\n+\n import tensorflow as tf\n from tensorflow_addons.activations import gelu\n from typeguard import typechecked\n@@ -38,6 +40,12 @@\n \n     @typechecked\n     def __init__(self, approximate: bool = True, **kwargs):\n+        warnings.warn(\n+            \"gelu activation has been migrated to core TensorFlow, \"\n+            \"and will be deprecated in Addons 0.12.\",\n+            DeprecationWarning,\n+        )\n+\n         super().__init__(**kwargs)\n         self.approximate = approximate\n         self.supports_masking = True\n", "issue": "Deprecate GELU \nPer https://github.com/tensorflow/community/pull/252, oonce  https://github.com/tensorflow/tensorflow/pull/41178 merges we'll need to deprecate our GELU for versions of TensorFlow that include it within core.\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\"\"\"Implements GELU activation.\"\"\"\n\nimport tensorflow as tf\nfrom tensorflow_addons.activations import gelu\nfrom typeguard import typechecked\n\n\n@tf.keras.utils.register_keras_serializable(package=\"Addons\")\nclass GELU(tf.keras.layers.Layer):\n    \"\"\"Gaussian Error Linear Unit.\n\n    A smoother version of ReLU generally used\n    in the BERT or BERT architecture based models.\n    Original paper: https://arxiv.org/abs/1606.08415\n\n    Input shape:\n        Arbitrary. Use the keyword argument `input_shape`\n        (tuple of integers, does not include the samples axis)\n        when using this layer as the first layer in a model.\n\n    Output shape:\n        Same shape as the input.\n    \"\"\"\n\n    @typechecked\n    def __init__(self, approximate: bool = True, **kwargs):\n        super().__init__(**kwargs)\n        self.approximate = approximate\n        self.supports_masking = True\n\n    def call(self, inputs):\n        return gelu(inputs, approximate=self.approximate)\n\n    def get_config(self):\n        config = {\"approximate\": self.approximate}\n        base_config = super().get_config()\n        return {**base_config, **config}\n\n    def compute_output_shape(self, input_shape):\n        return input_shape\n", "path": "tensorflow_addons/layers/gelu.py"}, {"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 tensorflow_addons.utils.resource_loader import LazySO\nfrom tensorflow_addons import options\n\n_activation_so = LazySO(\"custom_ops/activations/_activation_ops.so\")\n\n\n@tf.keras.utils.register_keras_serializable(package=\"Addons\")\ndef gelu(x: types.TensorLike, approximate: bool = True) -> tf.Tensor:\n    \"\"\"Gaussian Error Linear Unit.\n\n    Computes gaussian error linear:\n    `0.5 * x * (1 + tanh(sqrt(2 / pi) * (x + 0.044715 * x^3)))` or\n    `x * P(X <= x) = 0.5 * x * (1 + erf(x / sqrt(2)))`, where P(X) ~ N(0, 1),\n    depending on whether approximation is enabled.\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    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    x = tf.convert_to_tensor(x)\n\n    if not options.TF_ADDONS_PY_OPS:\n        try:\n            return _gelu_custom_op(x, approximate)\n        except tf.errors.NotFoundError:\n            options.warn_fallback(\"gelu\")\n\n    return _gelu_py(x, approximate)\n\n\ndef _gelu_custom_op(x, approximate):\n    warnings.warn(\n        \"The activations custom ops are deprecated and will be removed in TensorFlow Addons \"\n        \"v0.12.0. \\nPlease use the pure python version of Gelu instead by using the \"\n        \"`TF_ADDONS_PY_OPS` flag. \\nFor more info about this flag, see \"\n        \"https://github.com/tensorflow/addons#gpucpu-custom-ops \",\n        DeprecationWarning,\n    )\n    return _activation_so.ops.addons_gelu(x, approximate)\n\n\n@tf.RegisterGradient(\"Addons>Gelu\")\ndef _gelu_grad(op, grad):\n    return _activation_so.ops.addons_gelu_grad(\n        grad, op.inputs[0], op.get_attr(\"approximate\")\n    )\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\"\"\"Implements GELU activation.\"\"\"\n\nimport warnings\n\nimport tensorflow as tf\nfrom tensorflow_addons.activations import gelu\nfrom typeguard import typechecked\n\n\n@tf.keras.utils.register_keras_serializable(package=\"Addons\")\nclass GELU(tf.keras.layers.Layer):\n    \"\"\"Gaussian Error Linear Unit.\n\n    A smoother version of ReLU generally used\n    in the BERT or BERT architecture based models.\n    Original paper: https://arxiv.org/abs/1606.08415\n\n    Input shape:\n        Arbitrary. Use the keyword argument `input_shape`\n        (tuple of integers, does not include the samples axis)\n        when using this layer as the first layer in a model.\n\n    Output shape:\n        Same shape as the input.\n    \"\"\"\n\n    @typechecked\n    def __init__(self, approximate: bool = True, **kwargs):\n        warnings.warn(\n            \"gelu activation has been migrated to core TensorFlow, \"\n            \"and will be deprecated in Addons 0.12.\",\n            DeprecationWarning,\n        )\n\n        super().__init__(**kwargs)\n        self.approximate = approximate\n        self.supports_masking = True\n\n    def call(self, inputs):\n        return gelu(inputs, approximate=self.approximate)\n\n    def get_config(self):\n        config = {\"approximate\": self.approximate}\n        base_config = super().get_config()\n        return {**base_config, **config}\n\n    def compute_output_shape(self, input_shape):\n        return input_shape\n", "path": "tensorflow_addons/layers/gelu.py"}, {"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 tensorflow_addons.utils.resource_loader import LazySO\nfrom tensorflow_addons import options\n\n_activation_so = LazySO(\"custom_ops/activations/_activation_ops.so\")\n\n\n@tf.keras.utils.register_keras_serializable(package=\"Addons\")\ndef gelu(x: types.TensorLike, approximate: bool = True) -> tf.Tensor:\n    \"\"\"Gaussian Error Linear Unit.\n\n    Computes gaussian error linear:\n    `0.5 * x * (1 + tanh(sqrt(2 / pi) * (x + 0.044715 * x^3)))` or\n    `x * P(X <= x) = 0.5 * x * (1 + erf(x / sqrt(2)))`, where P(X) ~ N(0, 1),\n    depending on whether approximation is enabled.\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    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.12.\",\n        DeprecationWarning,\n    )\n\n    x = tf.convert_to_tensor(x)\n\n    if not options.TF_ADDONS_PY_OPS:\n        try:\n            return _gelu_custom_op(x, approximate)\n        except tf.errors.NotFoundError:\n            options.warn_fallback(\"gelu\")\n\n    return _gelu_py(x, approximate)\n\n\ndef _gelu_custom_op(x, approximate):\n    warnings.warn(\n        \"The activations custom ops are deprecated and will be removed in TensorFlow Addons \"\n        \"v0.12.0. \\nPlease use the pure python version of Gelu instead by using the \"\n        \"`TF_ADDONS_PY_OPS` flag. \\nFor more info about this flag, see \"\n        \"https://github.com/tensorflow/addons#gpucpu-custom-ops \",\n        DeprecationWarning,\n    )\n    return _activation_so.ops.addons_gelu(x, approximate)\n\n\n@tf.RegisterGradient(\"Addons>Gelu\")\ndef _gelu_grad(op, grad):\n    return _activation_so.ops.addons_gelu_grad(\n        grad, op.inputs[0], op.get_attr(\"approximate\")\n    )\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"}]}