Repository: keras-team/keras-nlp

Issue:
Simplify docstring example of `TokenAndPositionEmbedding`
The current [docstring example](https://github.com/keras-team/keras-nlp/blob/3a951a9f5442b77a0c474bb8b61406f65c7ef924/keras_nlp/layers/token_and_position_embedding.py#L45) of `TokenAndPositionEmbedding` is a bit more complicated than needed and should better match newer examples like those in [`keras_nlp.models.BertBackbone`](https://github.com/keras-team/keras-nlp/blob/3a951a9f5442b77a0c474bb8b61406f65c7ef924/keras_nlp/models/bert/bert_backbone.py#L67).

Make the following changes to the docstring example:
* Create a real input of the correct shape using `tf.ones`
* Inline constant values like `"seq_length"` directly into the function calls

Be sure to check that your example runs on colab or your local machine!


Discussion:
can i work on this
Done @durganshyadav ! Check out our [contribution guide](https://github.com/keras-team/keras-nlp/blob/master/CONTRIBUTING.md) for general tips and welcome to KerasNLP!
ok i'll check out the guide thank you.
hello @jbischof if you don't mind please can you guide me as its my first contribution
@durganshyadav can you tell us where you're stuck? In general we're very short staffed so I'm sorry to say the amount of support we can offer is limited!
> @durganshyadav can you tell us where you're stuck? In general we're very short staffed so I'm sorry to say the amount of support we can offer is limited!

How can I start like where do I get the code.
Coz I am learning everything from scratch 
@durganshyadav the whole Github guide is good but the relevant section is https://docs.github.com/en/get-started/quickstart/contributing-to-projects
I want to work on it.
Sure, assigning to you @Neeshamraghav012 
I have worked on two examples,

First one is:

`
inputs = tf.ones(shape=(1, 50), dtype=tf.int64)

embedding_layer = keras_nlp.layers.TokenAndPositionEmbedding(
        vocabulary_size=10_000,
        sequence_length=50,
        embedding_dim=128,
)

outputs = embedding_layer(inputs)
`

And second one is:

`
vocab = ["[UNK]", "the", "qu", "##ick", "br", "##own", "fox", "."]
inputs = ["The quick brown fox."]
tokenizer = keras_nlp.tokenizers.WordPieceTokenizer(
     vocabulary=vocab,
     lowercase=True,
)

tokenized_input = tokenizer(inputs)

# Every embedding layer should be used after tokenization.
embedding_layer = keras_nlp.layers.TokenAndPositionEmbedding(
        vocabulary_size=10_000,
        sequence_length=50,
        embedding_dim=128,
)
outputs = embedding_layer(tokenized_input)
`

Which one will work best?
@jbischof please check!

Resolving patch:
diff --git a/keras_nlp/layers/token_and_position_embedding.py b/keras_nlp/layers/token_and_position_embedding.py
--- a/keras_nlp/layers/token_and_position_embedding.py
+++ b/keras_nlp/layers/token_and_position_embedding.py
@@ -47,14 +47,11 @@ class TokenAndPositionEmbedding(keras.layers.Layer):
 
     Examples:
     ```python
-    seq_length = 50
-    vocab_size = 5000
-    embed_dim = 128
-    inputs = keras.Input(shape=(seq_length,))
+    inputs = tf.ones(shape=(1, 50), dtype=tf.int64)
     embedding_layer = keras_nlp.layers.TokenAndPositionEmbedding(
-        vocabulary_size=vocab_size,
-        sequence_length=seq_length,
-        embedding_dim=embed_dim,
+        vocabulary_size=10_000,
+        sequence_length=50,
+        embedding_dim=128,
     )
     outputs = embedding_layer(inputs)
     ```


Test patch: