[fix] bug in BatchEncoding.__getitem__ (#24293)
Co-authored-by: luchen <luchen@luchendeMBP.lan>
This commit is contained in:
@@ -242,7 +242,7 @@ class BatchEncoding(UserDict):
|
|||||||
elif self._encodings is not None:
|
elif self._encodings is not None:
|
||||||
return self._encodings[item]
|
return self._encodings[item]
|
||||||
elif isinstance(item, slice):
|
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:
|
else:
|
||||||
raise KeyError(
|
raise KeyError(
|
||||||
"Invalid key. Only three types of key are available: "
|
"Invalid key. Only three types of key are available: "
|
||||||
|
|||||||
Reference in New Issue
Block a user