{"record":{"id":"295555689a4fcb3d","repo":"keras-team/keras","slug":"input-shapes-x1-shape-and-x2-shape-must-match","errorCode":null,"errorMessage":"Input shapes {x1.shape} and {x2.shape} must match for PSNR calculation. ","messagePattern":"Input shapes (.+?) and (.+?) must match for PSNR calculation\\. ","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/jax/nn.py","lineNumber":1446,"sourceCode":"        )\n    elif strategy == \"beam_search\":\n        return _ctc_beam_search_decode(\n            inputs,\n            sequence_lengths,\n            beam_width=beam_width,\n            top_paths=top_paths,\n            mask_index=mask_index,\n        )\n    else:\n        raise ValueError(\n            f\"Invalid strategy {strategy}. Supported values are \"\n            \"'greedy' and 'beam_search'.\"\n        )\n\n\ndef psnr(x1, x2, max_val):\n    if x1.shape != x2.shape:\n        raise ValueError(\n            f\"Input shapes {x1.shape} and {x2.shape} must \"\n            \"match for PSNR calculation. \"\n        )\n\n    max_val = convert_to_tensor(max_val, dtype=x2.dtype)\n    mse = jnp.mean(jnp.square(x1 - x2))\n    psnr = 20 * jnp.log10(max_val) - 10 * jnp.log10(mse)\n    return psnr\n\n\ndef _can_use_flash_attention(query, key, value, bias, raise_error=False):\n    \"\"\"Verify the availability of flash attention.\"\"\"\n    try:\n        from jax._src.cudnn.fused_attention_stablehlo import _normalize_layout\n        from jax._src.cudnn.fused_attention_stablehlo import (\n            check_compute_capability,\n        )\n        from jax._src.cudnn.fused_attention_stablehlo import check_cudnn_version","sourceCodeStart":1428,"sourceCodeEnd":1464,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/jax/nn.py#L1428-L1464","documentation":"Error \"Input shapes {x1.shape} and {x2.shape} must match for PSNR calculation. \" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/jax/nn.py:1446 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}