If the key is a string, get the value of the dict associated to `key` ('input_ids', 'attention_mask'...) If the key is an integer, get the EncodingFast for batch item with index `key`
(self, item: Union[int, str])
| 167 | return self._encodings is not None |
| 168 | |
| 169 | def __getitem__(self, item: Union[int, str]) -> EncodingFast: |
| 170 | """ If the key is a string, get the value of the dict associated to `key` ('input_ids', 'attention_mask'...) |
| 171 | If the key is an integer, get the EncodingFast for batch item with index `key` |
| 172 | """ |
| 173 | if isinstance(item, str): |
| 174 | return self.data[item] |
| 175 | elif self._encodings is not None: |
| 176 | return self._encodings[item] |
| 177 | else: |
| 178 | raise KeyError( |
| 179 | "Indexing with integers (to access backend Encoding for a given batch index) " |
| 180 | "is not available when using Python based tokenizers" |
| 181 | ) |
| 182 | |
| 183 | def __getattr__(self, item: str): |
| 184 | try: |
nothing calls this directly
no outgoing calls
no test coverage detected