espnet3.contract.inference.validate_inference_outputs
Less than 1 minute
espnet3.contract.inference.validate_inference_outputs
espnet3.contract.inference.validate_inference_outputs(result, idx, contract, model, original, idx_key)
Validate one named output mapping for each input sample.
- Parameters:
- result – What the backend returned for
idx. - idx – One index or a list of indices.
- contract – The inference contract.
- model – The backend, for what it knows (its
sample_rate). - original – The original samples keyed by dataset index.
- idx_key – The name under which the sample identifier is attached.
- result – What the backend returned for
- Returns: One checked output mapping, or a list of them for a batch.
- Raises:ValueError – If the backend did not return one mapping per sample.
Examples
>>> contract = load_inference_contract(
... {
... "inputs": {"text": {"kind": "text"}},
... "outputs": {"text": {"kind": "text"}},
... }
... )
>>> validate_inference_outputs(
... {"text": "hi"}, 0, contract, None, {0: {}}, "utt_id"
... )
{'text': 'hi', 'utt_id': '0'}