We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add compilation defaults for the MaskedLM task models
In https://github.com/keras-team/keras-nlp/issues/709 we added compilation defaults to all classification tasks. We should also do the same for all `XXMaskedLM` models. E.g. [bert](https://github.com/keras-team/keras-nlp/blob/master/keras_nlp/models/bert/bert_masked_lm.py). Here's the full list of models.

- [ ] `AlbertMaskedLM`
- [ ] `BertMaskedLM`
- [ ] `DebertV3MaskedLM`
- [ ] `DistilBertMaskedLM`
- [ ] `FNetMaskedLM`
- [ ] `RobertaMaskedLM`

https://github.com/keras-team/keras-nlp/pull/714 is a good template PR. We can probably just use Adam and `1e-5` or `2e-5` as a learning rate for now. Though a little experimentation for each model to make sure the task does converge would be helpful. This [colab](https://gist.github.com/mattdangerw/b16c257973762a0b4ab9a34f6a932cc1) may be a helpful starting place.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `keras_nlp/models/f_net/f_net_masked_lm.py`
Content:
```
1 # Copyright 2023 The KerasNLP Authors
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 #     https://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 import copy
15 
16 from tensorflow import keras
17 
18 from keras_nlp.api_export import keras_nlp_export
19 from keras_nlp.layers.masked_lm_head import MaskedLMHead
20 from keras_nlp.models.f_net.f_net_backbone import FNetBackbone
21 from keras_nlp.models.f_net.f_net_backbone import f_net_kernel_initializer
22 from keras_nlp.models.f_net.f_net_masked_lm_preprocessor import (
23     FNetMaskedLMPreprocessor,
24 )
25 from keras_nlp.models.f_net.f_net_presets import backbone_presets
26 from keras_nlp.models.task import Task
27 from keras_nlp.utils.python_utils import classproperty
28 
29 
30 @keras_nlp_export("keras_nlp.models.FNetMaskedLM")
31 class FNetMaskedLM(Task):
32     """An end-to-end FNet model for the masked language modeling task.
33 
34     This model will train FNet on a masked language modeling task.
35     The model will predict labels for a number of masked tokens in the
36     input data. For usage of this model with pre-trained weights, see the
37     `from_preset()` method.
38 
39     This model can optionally be configured with a `preprocessor` layer, in
40     which case inputs can be raw string features during `fit()`, `predict()`,
41     and `evaluate()`. Inputs will be tokenized and dynamically masked during
42     training and evaluation. This is done by default when creating the model
43     with `from_preset()`.
44 
45     Disclaimer: Pre-trained models are provided on an "as is" basis, without
46     warranties or conditions of any kind.
47 
48     Args:
49         backbone: A `keras_nlp.models.FNetBackbone` instance.
50         preprocessor: A `keras_nlp.models.FNetMaskedLMPreprocessor` or
51             `None`. If `None`, this model will not apply preprocessing, and
52             inputs should be preprocessed before calling the model.
53 
54     Example usage:
55 
56     Raw string inputs and pretrained backbone.
57     ```python
58     # Create a dataset with raw string features. Labels are inferred.
59     features = ["The quick brown fox jumped.", "I forgot my homework."]
60 
61     # Create a FNetMaskedLM with a pretrained backbone and further train
62     # on an MLM task.
63     masked_lm = keras_nlp.models.FNetMaskedLM.from_preset(
64         "f_net_base_en",
65     )
66     masked_lm.compile(
67         loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
68     )
69     masked_lm.fit(x=features, batch_size=2)
70     ```
71 
72     Preprocessed inputs and custom backbone.
73     ```python
74     # Create a preprocessed dataset where 0 is the mask token.
75     preprocessed_features = {
76         "token_ids": tf.constant(
77             [[1, 2, 0, 4, 0, 6, 7, 8]] * 2, shape=(2, 8)
78         ),
79         "segment_ids": tf.constant(
80             [[0, 0, 0, 1, 1, 1, 0, 0]] * 2, shape=(2, 8)
81         ),
82         "mask_positions": tf.constant([[2, 4]] * 2, shape=(2, 2))
83     }
84     # Labels are the original masked values.
85     labels = [[3, 5]] * 2
86 
87     # Randomly initialize a FNet encoder
88     backbone = keras_nlp.models.FNetBackbone(
89         vocabulary_size=50265,
90         num_layers=12,
91         hidden_dim=768,
92         intermediate_dim=3072,
93         max_sequence_length=12
94     )
95     # Create a FNet masked_lm and fit the data.
96     masked_lm = keras_nlp.models.FNetMaskedLM(
97         backbone,
98         preprocessor=None,
99     )
100     masked_lm.compile(
101         loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
102     )
103     masked_lm.fit(x=preprocessed_features, y=labels, batch_size=2)
104     ```
105     """
106 
107     def __init__(
108         self,
109         backbone,
110         preprocessor=None,
111         **kwargs,
112     ):
113         inputs = {
114             **backbone.input,
115             "mask_positions": keras.Input(
116                 shape=(None,), dtype="int32", name="mask_positions"
117             ),
118         }
119         backbone_outputs = backbone(backbone.input)
120         outputs = MaskedLMHead(
121             vocabulary_size=backbone.vocabulary_size,
122             embedding_weights=backbone.token_embedding.embeddings,
123             intermediate_activation="gelu",
124             kernel_initializer=f_net_kernel_initializer(),
125             name="mlm_head",
126         )(backbone_outputs["sequence_output"], inputs["mask_positions"])
127 
128         # Instantiate using Functional API Model constructor
129         super().__init__(
130             inputs=inputs,
131             outputs=outputs,
132             include_preprocessing=preprocessor is not None,
133             **kwargs,
134         )
135         # All references to `self` below this line
136         self.backbone = backbone
137         self.preprocessor = preprocessor
138 
139     @classproperty
140     def backbone_cls(cls):
141         return FNetBackbone
142 
143     @classproperty
144     def preprocessor_cls(cls):
145         return FNetMaskedLMPreprocessor
146 
147     @classproperty
148     def presets(cls):
149         return copy.deepcopy(backbone_presets)
150
```
--- 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/keras_nlp/models/f_net/f_net_masked_lm.py b/keras_nlp/models/f_net/f_net_masked_lm.py
--- a/keras_nlp/models/f_net/f_net_masked_lm.py
+++ b/keras_nlp/models/f_net/f_net_masked_lm.py
@@ -24,6 +24,7 @@
 )
 from keras_nlp.models.f_net.f_net_presets import backbone_presets
 from keras_nlp.models.task import Task
+from keras_nlp.utils.keras_utils import is_xla_compatible
 from keras_nlp.utils.python_utils import classproperty
 
 
@@ -135,6 +136,12 @@
         # All references to `self` below this line
         self.backbone = backbone
         self.preprocessor = preprocessor
+        self.compile(
+            loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
+            optimizer=keras.optimizers.Adam(5e-5),
+            weighted_metrics=keras.metrics.SparseCategoricalAccuracy(),
+            jit_compile=is_xla_compatible(self),
+        )
 
     @classproperty
     def backbone_cls(cls):

{"golden_diff": "diff --git a/keras_nlp/models/f_net/f_net_masked_lm.py b/keras_nlp/models/f_net/f_net_masked_lm.py\n--- a/keras_nlp/models/f_net/f_net_masked_lm.py\n+++ b/keras_nlp/models/f_net/f_net_masked_lm.py\n@@ -24,6 +24,7 @@\n )\n from keras_nlp.models.f_net.f_net_presets import backbone_presets\n from keras_nlp.models.task import Task\n+from keras_nlp.utils.keras_utils import is_xla_compatible\n from keras_nlp.utils.python_utils import classproperty\n \n \n@@ -135,6 +136,12 @@\n         # All references to `self` below this line\n         self.backbone = backbone\n         self.preprocessor = preprocessor\n+        self.compile(\n+            loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n+            optimizer=keras.optimizers.Adam(5e-5),\n+            weighted_metrics=keras.metrics.SparseCategoricalAccuracy(),\n+            jit_compile=is_xla_compatible(self),\n+        )\n \n     @classproperty\n     def backbone_cls(cls):\n", "issue": "Add compilation defaults for the MaskedLM task models\nIn https://github.com/keras-team/keras-nlp/issues/709 we added compilation defaults to all classification tasks. We should also do the same for all `XXMaskedLM` models. E.g. [bert](https://github.com/keras-team/keras-nlp/blob/master/keras_nlp/models/bert/bert_masked_lm.py). Here's the full list of models.\r\n\r\n- [ ] `AlbertMaskedLM`\r\n- [ ] `BertMaskedLM`\r\n- [ ] `DebertV3MaskedLM`\r\n- [ ] `DistilBertMaskedLM`\r\n- [ ] `FNetMaskedLM`\r\n- [ ] `RobertaMaskedLM`\r\n\r\nhttps://github.com/keras-team/keras-nlp/pull/714 is a good template PR. We can probably just use Adam and `1e-5` or `2e-5` as a learning rate for now. Though a little experimentation for each model to make sure the task does converge would be helpful. This [colab](https://gist.github.com/mattdangerw/b16c257973762a0b4ab9a34f6a932cc1) may be a helpful starting place.\n", "before_files": [{"content": "# Copyright 2023 The KerasNLP Authors\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#     https://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.\nimport copy\n\nfrom tensorflow import keras\n\nfrom keras_nlp.api_export import keras_nlp_export\nfrom keras_nlp.layers.masked_lm_head import MaskedLMHead\nfrom keras_nlp.models.f_net.f_net_backbone import FNetBackbone\nfrom keras_nlp.models.f_net.f_net_backbone import f_net_kernel_initializer\nfrom keras_nlp.models.f_net.f_net_masked_lm_preprocessor import (\n    FNetMaskedLMPreprocessor,\n)\nfrom keras_nlp.models.f_net.f_net_presets import backbone_presets\nfrom keras_nlp.models.task import Task\nfrom keras_nlp.utils.python_utils import classproperty\n\n\n@keras_nlp_export(\"keras_nlp.models.FNetMaskedLM\")\nclass FNetMaskedLM(Task):\n    \"\"\"An end-to-end FNet model for the masked language modeling task.\n\n    This model will train FNet on a masked language modeling task.\n    The model will predict labels for a number of masked tokens in the\n    input data. For usage of this model with pre-trained weights, see the\n    `from_preset()` method.\n\n    This model can optionally be configured with a `preprocessor` layer, in\n    which case inputs can be raw string features during `fit()`, `predict()`,\n    and `evaluate()`. Inputs will be tokenized and dynamically masked during\n    training and evaluation. This is done by default when creating the model\n    with `from_preset()`.\n\n    Disclaimer: Pre-trained models are provided on an \"as is\" basis, without\n    warranties or conditions of any kind.\n\n    Args:\n        backbone: A `keras_nlp.models.FNetBackbone` instance.\n        preprocessor: A `keras_nlp.models.FNetMaskedLMPreprocessor` or\n            `None`. If `None`, this model will not apply preprocessing, and\n            inputs should be preprocessed before calling the model.\n\n    Example usage:\n\n    Raw string inputs and pretrained backbone.\n    ```python\n    # Create a dataset with raw string features. Labels are inferred.\n    features = [\"The quick brown fox jumped.\", \"I forgot my homework.\"]\n\n    # Create a FNetMaskedLM with a pretrained backbone and further train\n    # on an MLM task.\n    masked_lm = keras_nlp.models.FNetMaskedLM.from_preset(\n        \"f_net_base_en\",\n    )\n    masked_lm.compile(\n        loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n    )\n    masked_lm.fit(x=features, batch_size=2)\n    ```\n\n    Preprocessed inputs and custom backbone.\n    ```python\n    # Create a preprocessed dataset where 0 is the mask token.\n    preprocessed_features = {\n        \"token_ids\": tf.constant(\n            [[1, 2, 0, 4, 0, 6, 7, 8]] * 2, shape=(2, 8)\n        ),\n        \"segment_ids\": tf.constant(\n            [[0, 0, 0, 1, 1, 1, 0, 0]] * 2, shape=(2, 8)\n        ),\n        \"mask_positions\": tf.constant([[2, 4]] * 2, shape=(2, 2))\n    }\n    # Labels are the original masked values.\n    labels = [[3, 5]] * 2\n\n    # Randomly initialize a FNet encoder\n    backbone = keras_nlp.models.FNetBackbone(\n        vocabulary_size=50265,\n        num_layers=12,\n        hidden_dim=768,\n        intermediate_dim=3072,\n        max_sequence_length=12\n    )\n    # Create a FNet masked_lm and fit the data.\n    masked_lm = keras_nlp.models.FNetMaskedLM(\n        backbone,\n        preprocessor=None,\n    )\n    masked_lm.compile(\n        loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n    )\n    masked_lm.fit(x=preprocessed_features, y=labels, batch_size=2)\n    ```\n    \"\"\"\n\n    def __init__(\n        self,\n        backbone,\n        preprocessor=None,\n        **kwargs,\n    ):\n        inputs = {\n            **backbone.input,\n            \"mask_positions\": keras.Input(\n                shape=(None,), dtype=\"int32\", name=\"mask_positions\"\n            ),\n        }\n        backbone_outputs = backbone(backbone.input)\n        outputs = MaskedLMHead(\n            vocabulary_size=backbone.vocabulary_size,\n            embedding_weights=backbone.token_embedding.embeddings,\n            intermediate_activation=\"gelu\",\n            kernel_initializer=f_net_kernel_initializer(),\n            name=\"mlm_head\",\n        )(backbone_outputs[\"sequence_output\"], inputs[\"mask_positions\"])\n\n        # Instantiate using Functional API Model constructor\n        super().__init__(\n            inputs=inputs,\n            outputs=outputs,\n            include_preprocessing=preprocessor is not None,\n            **kwargs,\n        )\n        # All references to `self` below this line\n        self.backbone = backbone\n        self.preprocessor = preprocessor\n\n    @classproperty\n    def backbone_cls(cls):\n        return FNetBackbone\n\n    @classproperty\n    def preprocessor_cls(cls):\n        return FNetMaskedLMPreprocessor\n\n    @classproperty\n    def presets(cls):\n        return copy.deepcopy(backbone_presets)\n", "path": "keras_nlp/models/f_net/f_net_masked_lm.py"}], "after_files": [{"content": "# Copyright 2023 The KerasNLP Authors\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#     https://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.\nimport copy\n\nfrom tensorflow import keras\n\nfrom keras_nlp.api_export import keras_nlp_export\nfrom keras_nlp.layers.masked_lm_head import MaskedLMHead\nfrom keras_nlp.models.f_net.f_net_backbone import FNetBackbone\nfrom keras_nlp.models.f_net.f_net_backbone import f_net_kernel_initializer\nfrom keras_nlp.models.f_net.f_net_masked_lm_preprocessor import (\n    FNetMaskedLMPreprocessor,\n)\nfrom keras_nlp.models.f_net.f_net_presets import backbone_presets\nfrom keras_nlp.models.task import Task\nfrom keras_nlp.utils.keras_utils import is_xla_compatible\nfrom keras_nlp.utils.python_utils import classproperty\n\n\n@keras_nlp_export(\"keras_nlp.models.FNetMaskedLM\")\nclass FNetMaskedLM(Task):\n    \"\"\"An end-to-end FNet model for the masked language modeling task.\n\n    This model will train FNet on a masked language modeling task.\n    The model will predict labels for a number of masked tokens in the\n    input data. For usage of this model with pre-trained weights, see the\n    `from_preset()` method.\n\n    This model can optionally be configured with a `preprocessor` layer, in\n    which case inputs can be raw string features during `fit()`, `predict()`,\n    and `evaluate()`. Inputs will be tokenized and dynamically masked during\n    training and evaluation. This is done by default when creating the model\n    with `from_preset()`.\n\n    Disclaimer: Pre-trained models are provided on an \"as is\" basis, without\n    warranties or conditions of any kind.\n\n    Args:\n        backbone: A `keras_nlp.models.FNetBackbone` instance.\n        preprocessor: A `keras_nlp.models.FNetMaskedLMPreprocessor` or\n            `None`. If `None`, this model will not apply preprocessing, and\n            inputs should be preprocessed before calling the model.\n\n    Example usage:\n\n    Raw string inputs and pretrained backbone.\n    ```python\n    # Create a dataset with raw string features. Labels are inferred.\n    features = [\"The quick brown fox jumped.\", \"I forgot my homework.\"]\n\n    # Create a FNetMaskedLM with a pretrained backbone and further train\n    # on an MLM task.\n    masked_lm = keras_nlp.models.FNetMaskedLM.from_preset(\n        \"f_net_base_en\",\n    )\n    masked_lm.compile(\n        loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n    )\n    masked_lm.fit(x=features, batch_size=2)\n    ```\n\n    Preprocessed inputs and custom backbone.\n    ```python\n    # Create a preprocessed dataset where 0 is the mask token.\n    preprocessed_features = {\n        \"token_ids\": tf.constant(\n            [[1, 2, 0, 4, 0, 6, 7, 8]] * 2, shape=(2, 8)\n        ),\n        \"segment_ids\": tf.constant(\n            [[0, 0, 0, 1, 1, 1, 0, 0]] * 2, shape=(2, 8)\n        ),\n        \"mask_positions\": tf.constant([[2, 4]] * 2, shape=(2, 2))\n    }\n    # Labels are the original masked values.\n    labels = [[3, 5]] * 2\n\n    # Randomly initialize a FNet encoder\n    backbone = keras_nlp.models.FNetBackbone(\n        vocabulary_size=50265,\n        num_layers=12,\n        hidden_dim=768,\n        intermediate_dim=3072,\n        max_sequence_length=12\n    )\n    # Create a FNet masked_lm and fit the data.\n    masked_lm = keras_nlp.models.FNetMaskedLM(\n        backbone,\n        preprocessor=None,\n    )\n    masked_lm.compile(\n        loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n    )\n    masked_lm.fit(x=preprocessed_features, y=labels, batch_size=2)\n    ```\n    \"\"\"\n\n    def __init__(\n        self,\n        backbone,\n        preprocessor=None,\n        **kwargs,\n    ):\n        inputs = {\n            **backbone.input,\n            \"mask_positions\": keras.Input(\n                shape=(None,), dtype=\"int32\", name=\"mask_positions\"\n            ),\n        }\n        backbone_outputs = backbone(backbone.input)\n        outputs = MaskedLMHead(\n            vocabulary_size=backbone.vocabulary_size,\n            embedding_weights=backbone.token_embedding.embeddings,\n            intermediate_activation=\"gelu\",\n            kernel_initializer=f_net_kernel_initializer(),\n            name=\"mlm_head\",\n        )(backbone_outputs[\"sequence_output\"], inputs[\"mask_positions\"])\n\n        # Instantiate using Functional API Model constructor\n        super().__init__(\n            inputs=inputs,\n            outputs=outputs,\n            include_preprocessing=preprocessor is not None,\n            **kwargs,\n        )\n        # All references to `self` below this line\n        self.backbone = backbone\n        self.preprocessor = preprocessor\n        self.compile(\n            loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n            optimizer=keras.optimizers.Adam(5e-5),\n            weighted_metrics=keras.metrics.SparseCategoricalAccuracy(),\n            jit_compile=is_xla_compatible(self),\n        )\n\n    @classproperty\n    def backbone_cls(cls):\n        return FNetBackbone\n\n    @classproperty\n    def preprocessor_cls(cls):\n        return FNetMaskedLMPreprocessor\n\n    @classproperty\n    def presets(cls):\n        return copy.deepcopy(backbone_presets)\n", "path": "keras_nlp/models/f_net/f_net_masked_lm.py"}]}