`XGLMForCausalLM` does not compute `position_ids` correctly when using `inputs_embeds`
Author: vfbd
Pull request: no

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version: 4.17.0.dev0
- Platform: Linux-5.4.144+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.7.12
- PyTorch version (GPU?): 1.10.0+cu102 (False)
- Tensorflow version (GPU?): 2.8.0 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help
@patil-suraj

## Information

Model I am using (Bert, XLNet ...): XGLM

The problem arises when using:
* [ ] the official example scripts: (give details below)
* [x] my own modified scripts: (give details below)

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [x] my own task or dataset: (give details below)

## To reproduce

Steps to reproduce the behavior:

Try inference on an XGLM model when using `inputs_embeds` as the input method to the `forward` function of `XGLMForCausalLM`, i.e. run this code:
```python
# Patch create_position_ids_from_inputs_embeds so that we can see the
# position IDs it outputs

if "PATCHED" not in globals():
    from transformers.models.xglm.modeling_xglm import XGLMSinusoidalPositionalEmbedding
    original_create_position_ids = XGLMSinusoidalPositionalEmbedding.create_position_ids_from_inputs_embeds
    def create_position_ids(*args, **kwargs):
        position_ids = original_create_position_ids(*args, **kwargs)
        print(position_ids)
        return position_ids
    XGLMSinusoidalPositionalEmbedding.create_position_ids_from_inputs_embeds = create_position_ids
PATCHED = True


# Try inference on an XGLM model

from transformers import XGLMTokenizer, XGLMForCausalLM

class CustomXGLMForCausalLM(XGLMForCausalLM):
    def forward(self, *args, **kwargs):
        if "input_ids" in kwargs and "inputs_embeds" not in kwargs:
            kwargs["inputs_embeds"] = model.model.embed_tokens(kwargs.pop("input_ids")) * model.model.embed_scale
        return super().forward(*args, **kwargs)

tokenizer = XGLMTokenizer.from_pretrained("facebook/xglm-564M")
model = CustomXGLMForCausalLM.from_pretrained("facebook/xglm-564M")

prompt = (
    "In a shocking finding, scientists discovered a herd of unicorns living in a remote, "
    "previously unexplored valley, in the Andes Mountains. Even more surprising to the "
    "researchers was the fact that the unicorns spoke perfect English."
)
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
gen_tokens = model.generate(
    input_ids=input_ids,
    do_sample=False,
    min_length=60,
    max_length=60,
)
```

## Expected behavior
The printed output should be as shown below because the position IDs should be increasing as the model generates tokens. The expected behavior is exhibited by other models such as GPT-Neo but not by this model.
```
tensor([[ 2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
         20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
         38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53]])
tensor([[54]])
tensor([[55]])
tensor([[56]])
tensor([[57]])
tensor([[58]])
tensor([[59]])
tensor([[60]])
```

## Actual behavior
```
tensor([[ 2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
         20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
         38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53]])
tensor([[2]])
tensor([[2]])
tensor([[2]])
tensor([[2]])
tensor([[2]])
tensor([[2]])
tensor([[2]])
```

Comments:
Good catch! Fix is here #15751