This class can be used to create a list of :class:`~transformers.LogitsProcessor` or :class:`~transformers.LogitsWarper` to subsequently process a :obj:`scores` input tensor. This class inherits from list and adds a specific `__call__` method to apply each :class:`~transformers.LogitsPr
| 400 | |
| 401 | |
| 402 | class LogitsProcessorList(list): |
| 403 | """ |
| 404 | This class can be used to create a list of :class:`~transformers.LogitsProcessor` or |
| 405 | :class:`~transformers.LogitsWarper` to subsequently process a :obj:`scores` input tensor. This class inherits from |
| 406 | list and adds a specific `__call__` method to apply each :class:`~transformers.LogitsProcessor` or |
| 407 | :class:`~transformers.LogitsProcessor` to the inputs. |
| 408 | """ |
| 409 | |
| 410 | def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor: |
| 411 | for processor in self: |
| 412 | scores = processor(input_ids, scores) |
| 413 | return scores |
| 414 | |
| 415 | |
| 416 | class MinLengthLogitsProcessor(LogitsProcessor): |