# IndexError: tuple index out of range problem

**URL:** <https://discuss.huggingface.co/t/indexerror-tuple-index-out-of-range-problem/14225>\
**Category:** 🤗Transformers\
**Created:** [January 30, 2022, 3:51am UTC](https://discuss.huggingface.co/t/indexerror-tuple-index-out-of-range-problem/14225 "2022-01-30T03:51:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![toyl](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@toyl](https://discuss.huggingface.co/u/toyl)\
**Post date:** [January 30, 2022, 3:51am UTC](https://discuss.huggingface.co/t/indexerror-tuple-index-out-of-range-problem/14225/1 "2022-01-30T03:51:00Z")

</div>

```auto
tokens_tensor = torch.tensor([indexed_tokens])
encode_layers,_ = BERTModel(tokens_tensor)
embedding =encode_layers[11].squeeze(0)

```

what is the equivalent manner for those lines if I need to import BERT from transformer instead Pytorch? as i got

```auto
/transformers/file_utils.py", line 2329, in __getitem__
    return self.to_tuple()[k]
IndexError: tuple index out of range

```

---

<div class="post-metadata">

**Author:** ![toyl](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@toyl](https://discuss.huggingface.co/u/toyl)\
**Post date:** [January 30, 2022, 1:47pm UTC](https://discuss.huggingface.co/t/indexerror-tuple-index-out-of-range-problem/14225/2 "2022-01-30T13:47:19Z")

</div>

is there any help please ?
