[fix] bug in BatchEncoding.__getitem__ (#24293)

Co-authored-by: luchen <luchen@luchendeMBP.lan>
This commit is contained in:
jiangmingyan 2023-06-15 19:33:37 +08:00 committed by GitHub
parent 372f50030b
commit 6cd34d451c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -242,7 +242,7 @@ class BatchEncoding(UserDict):
elif self._encodings is not None:
return self._encodings[item]
elif isinstance(item, slice):
return {key: self.data[key][slice] for key in self.data.keys()}
return {key: self.data[key][item] for key in self.data.keys()}
else:
raise KeyError(
"Invalid key. Only three types of key are available: "