# How to convert a list of Batchencoding to a BatchEncoding

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-convert-a-list-of-batchencoding-to-a-batchencoding%2F4664%3E%5C
**Category:** Beginners\
**Created:** [March 19, 2021, 4:35am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-convert-a-list-of-batchencoding-to-a-batchencoding%2F4664 "2021-03-19T04:35:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![harikc456](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harikc456](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fharikc456)%5C
**Post date:** [March 19, 2021, 4:35am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-convert-a-list-of-batchencoding-to-a-batchencoding%2F4664%2F1 "2021-03-19T04:35:35Z")

</div>

I have a list of BatchEncoding, I need to convert it into a format that Huggingface models accepts it

```auto
context_input_tensor = []
passage_ids = []
while len(passage_ids) < batch_size:
    idx = random.randint(0, num_questions)
    question_tensor, passage_id = questions[idx]
    if passage_id in passage_ids:
      continue
    passage_ids.append(passage_id)
    context_input_tensor.append(passages_dict[passage_id])

```

The `context_input_tensor` is a list which contains `BatchEncoding` type objects. What should I do  
If I pass the `context_input_tensor` as it is I get a `TypeError: forward() missing 2 required positional arguments: 'query_input_ids' and 'query_attention_mask'` I was able to solve the issue by creating two different tensors and stacking `'query_input_ids' `and `'query_attention_mask'`. Is there a better way to do this ?
