# Confusion about using .clone

**URL:** <https://discuss.pytorch.org/t/confusion-about-using-clone/39673>\
**Category:** Uncategorized\
**Created:** [March 12, 2019, 8:20pm UTC](https://discuss.pytorch.org/t/confusion-about-using-clone/39673 "2019-03-12T20:20:15Z")\
**Posts on this page:** 1\
**Page:** 2

<div class="post-metadata">

**Author:** ![Nils\_Smitham86](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/n/f17d59/32.png) [@Nils\_Smitham86](https://discuss.pytorch.org/u/Nils_Smitham86)\
**Post date:** [March 16, 2024, 7:53am UTC](https://discuss.pytorch.org/t/confusion-about-using-clone/39673/21 "2024-03-16T07:53:47Z")

</div>

nope, a more realistic application of clone is in seq2seq model, which related to more than one decode steps.

look at this code from huggingface bart seq2seq model:

> <https://github.com/huggingface/transformers/blob/main/src/transformers/models/bart/modeling_bart.py#L1559>

> <https://github.com/huggingface/transformers/blob/main/src/transformers/models/bart/modeling_bart.py#L100>

there are two branch from input\_ids, the first is itself , the second is the decoder\_input\_ids, which needs shift operation with inplace modification on input\_ids. On the other hand, the forward function need keep gradient for all input\_ids element, as well as input\_ids element in decoder\_input\_ids.

so you should use clone in this occasion

> **[What is the correct form of decoder\_input\_ids for LEDForConditionalGeneration?](https://discuss.huggingface.co/t/what-is-the-correct-form-of-decoder-input-ids-for-ledforconditionalgeneration/7947)**
>
> I have been looking into the articles on the web, but unfortunately I cannot find the clear answer. I guess one of them is the correct decoder\_input\_ids (label should be decoder\_input\_ids\[1:\] ?): 1) ...... 2) ...... 3) ...... Thanks in advance. ...

[Previous page](https://discuss.pytorch.org/t/confusion-about-using-clone/39673.md?page=1)
