Unverified Commit a5be9541 authored by David del Río Medina's avatar David del Río Medina Committed by GitHub
Browse files

Replace assertion with ValueError exception (#14006)

parent cc360649
...@@ -84,9 +84,11 @@ class FlaxLogitsProcessorList(list): ...@@ -84,9 +84,11 @@ class FlaxLogitsProcessorList(list):
for processor in self: for processor in self:
function_args = inspect.signature(processor.__call__).parameters function_args = inspect.signature(processor.__call__).parameters
if len(function_args) > 3: if len(function_args) > 3:
assert all( if not all(arg in kwargs for arg in list(function_args.keys())[2:]):
arg in kwargs for arg in list(function_args.keys())[2:] raise ValueError(
), f"Make sure that all the required parameters: {list(function_args.keys())} for {processor.__class__} are passed to the logits processor." f"Make sure that all the required parameters: {list(function_args.keys())} for "
f"{processor.__class__} are passed to the logits processor."
)
scores = processor(input_ids, scores, cur_len, **kwargs) scores = processor(input_ids, scores, cur_len, **kwargs)
else: else:
scores = processor(input_ids, scores, cur_len) scores = processor(input_ids, scores, cur_len)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment