{"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.12.13"},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceType":"competition","sourceId":154281},{"sourceType":"datasetVersion","sourceId":18229736},{"sourceType":"datasetVersion","sourceId":18673450},{"sourceType":"datasetVersion","sourceId":18673646},{"sourceType":"datasetVersion","sourceId":18706996},{"sourceType":"datasetVersion","sourceId":18715672},{"sourceType":"datasetVersion","sourceId":18716507},{"sourceType":"datasetVersion","sourceId":18757740},{"sourceType":"datasetVersion","sourceId":18839182},{"sourceType":"datasetVersion","sourceId":18842180},{"sourceType":"datasetVersion","sourceId":18875869},{"sourceType":"datasetVersion","sourceId":18956429},{"sourceType":"datasetVersion","sourceId":19003959},{"sourceType":"kernelVersion","sourceId":342671664},{"sourceType":"kernelVersion","sourceId":342849430},{"sourceType":"modelInstanceVersion","sourceId":4533},{"sourceType":"modelInstanceVersion","sourceId":4534}],"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false},"papermill":{"default_parameters":{},"duration":380.293612,"end_time":"2026-08-20T11:36:44.820286+00:00","environment_variables":{},"exception":null,"input_path":"__notebook__.ipynb","output_path":"__notebook__.ipynb","parameters":{},"start_time":"2026-08-20T11:30:24.526674+00:00","version":"2.7.0"},"widgets":{"application/vnd.jupyter.widget-state+json":{"state":{"00ae49624d67439c8c5e1aa9ec9f72a2":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_5f5b38775cc8468bb5e95909bb8fc78f","placeholder":"​","style":"IPY_MODEL_691556ac40864aff901b4e6b8b8d80bf","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"00d2b1e3b7a7434195d9436a919a67dc":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_29e634dba15a437eb131e955a63a4b59","IPY_MODEL_2a2d995841cb4186bbeb623b2b93dc29","IPY_MODEL_2ee14f66ed1247f89851728d4b458578"],"layout":"IPY_MODEL_ca76ce4106c64c6d950f97c45a03502f","tabbable":null,"tooltip":null}},"0192d35f87064184b9d48bbc324c1b3c":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"038efc4823a1425a998b8e5db5755a0d":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"03c5f429e7ae42e18ca844d407722733":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_e1d5a8f091404a8caa64d3eae8cd601d","placeholder":"​","style":"IPY_MODEL_2b8b10738320465ebd594fb1786db3d5","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 978.35it/s, Materializing param=layernorm.weight]"}},"0671434222f042cba18f0e242444fef9":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"0a2c5c4d2163487f9bb673f626a2faf4":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"0a9f758efa724422b2925a2d16500cef":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"0bb1ab736cba4d41b8be4a6fad3ae80c":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"0d3f615adba8440487686621b2d578cd":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"0db62ef1defe41718963053f171cd529":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_2016a612b79c4986ba66b6477fb06f2e","IPY_MODEL_381eb91ed30a415cb46cf0e7039ef148","IPY_MODEL_d99a8aca7bdc4c7da565cea67a423df3"],"layout":"IPY_MODEL_23f7a01ca49a433eb217afcbe4699825","tabbable":null,"tooltip":null}},"0ff0a4b6ed624f6e9fe408dcb106bb8d":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"1006e8f8f04f4bacabe64a1f5fe554e5":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_42d09391f71f46b49e1e682a79dc8498","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_7714b622588b46719d153febb9687426","tabbable":null,"tooltip":null,"value":223}},"12e15604a2374d72bec82b227b265520":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"1301f18827bc4781ae3c54b12eb2324b":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"1319bf25b78546d6b8c9944c4b72b7d0":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_ca63093f3aa44bd79df462be9153a525","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_ea6db06efd5a40159f84f1f637d5648c","tabbable":null,"tooltip":null,"value":223}},"141b6f9e182742ed9c742880b43872f6":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_18dba73f8e18481598d44b0343f65ca4","placeholder":"​","style":"IPY_MODEL_0d3f615adba8440487686621b2d578cd","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"143f55ffc8c0407d961e99fccae9bdeb":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"1686affcb2ee48f19ffa3cf453b8f94a":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"170a810115644b6c94c5ae923374faee":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"18dba73f8e18481598d44b0343f65ca4":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"1a0bd4082a78483e8f022918dd0fcb84":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"1ab214c0a9114574aa4f759ebe9f74eb":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_00ae49624d67439c8c5e1aa9ec9f72a2","IPY_MODEL_732ab36f95134f1d9bcd243c3888e771","IPY_MODEL_9ee2540e284d4bbcb6b4f11d5dc96065"],"layout":"IPY_MODEL_0a9f758efa724422b2925a2d16500cef","tabbable":null,"tooltip":null}},"1aef8eb9b8874e8d94f2f32ae9388787":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"1b355a96253949f0b50497cb18b7bd1d":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"1b76aafc62b34f6581e5249e276eaa0b":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"1bdbf3c1440743baa911e395f3f21b64":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"1bea5507647f4d1aa4e54e1e6d759134":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_6985959fa0a44a03837153cdc028cea8","placeholder":"​","style":"IPY_MODEL_59cb64e0de3940b998e6a0cb293baa1a","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"1dde232cfdb14eaba105cec8e0dd3d6f":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"1e238cded2174c98949b8cb0eec03a5a":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_8897f4c7a013483d9ddeeb2351a7db8c","placeholder":"​","style":"IPY_MODEL_917cf91f83054098b3492ed60d877b55","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 1133.76it/s, Materializing param=layernorm.weight]"}},"2016a612b79c4986ba66b6477fb06f2e":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_170a810115644b6c94c5ae923374faee","placeholder":"​","style":"IPY_MODEL_afff97fabb714ad0b11a51f913a16bd8","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"206b61e46184424cafa0fe785c5ad5a9":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_372fb28e36614308838d36b63fbee2d6","IPY_MODEL_5f89818dd6d047249b23045abfb4fbc2","IPY_MODEL_772be9c5e22e43a9a34973470dd2935d"],"layout":"IPY_MODEL_ac74aedbe1774857a10e85bb88928a64","tabbable":null,"tooltip":null}},"21ddeea79f8a4568971e64fe3cec3fb9":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_edfa55c38cc04cac9bbe94b291ecc99b","placeholder":"​","style":"IPY_MODEL_d86cb85cc616487dbe716f000b303d37","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 1105.43it/s, Materializing param=layernorm.weight]"}},"22504d5fa5314b1899791d7e7af7715b":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_53d63cb2127744bc9b70df610c9dd91f","IPY_MODEL_6999307df43b4ea5b458c41c94d81b2c","IPY_MODEL_e8d0529a988d4e03a1df37999f1e6de2"],"layout":"IPY_MODEL_e2b51f549d2b443a9fa3f33205f0664a","tabbable":null,"tooltip":null}},"234640dffa9e441298be9e5caa1346f3":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_ce997b135c1d4ff7afc5078f829f7a75","placeholder":"​","style":"IPY_MODEL_430c062dc36541f295a9118ecc5c3709","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 914.66it/s, Materializing param=layernorm.weight]"}},"23f7a01ca49a433eb217afcbe4699825":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"2647f0bbbef54064b1f334a8b68cb252":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"28b4e0a7c50b4e2bbc07adacab9754e0":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"29e634dba15a437eb131e955a63a4b59":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_411b537887c14c1c81a4082967b0742c","placeholder":"​","style":"IPY_MODEL_560cb1fb91b6400bbf6f98b5c7573fce","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"2a2d995841cb4186bbeb623b2b93dc29":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_0192d35f87064184b9d48bbc324c1b3c","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_1dde232cfdb14eaba105cec8e0dd3d6f","tabbable":null,"tooltip":null,"value":223}},"2b238fa4051c4b918d2a2af349900fa5":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"2b8b10738320465ebd594fb1786db3d5":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"2d21c5062f6a443694d2d65a3746f719":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_4d458849505641cbbd30d415d6e02066","IPY_MODEL_7af8b988a2a64717a66bb8646c8a21a1","IPY_MODEL_e6c0a83ff5ab4ba792d3b27593095791"],"layout":"IPY_MODEL_5c9a58dc33534b3b821daa54bfa0cc52","tabbable":null,"tooltip":null}},"2ee14f66ed1247f89851728d4b458578":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_6304c8dbe5c74d42b62fb6ee98ea7c55","placeholder":"​","style":"IPY_MODEL_5e1ef81c51c94c44808adabf8807a973","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 987.01it/s, Materializing param=layernorm.weight]"}},"2fed673712f542959712a902ece6b5f0":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"30befc95cb4d4720a2aac7ce6023462e":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"311785c100834ec78e5c63ecc5437f09":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"321b1ba29f054021873775fa9234b7ad":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"32ba02c538fd46d7a5807220540f8901":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"3549e0fbcc3e4b049aabd052129456b5":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"367538fc3c974a54a7804b0b2c0eeb2b":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"36d8317b0e7240a79f9c5dec08a40951":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"37262b3c715b49cca6e15eb96b8914a4":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"372fb28e36614308838d36b63fbee2d6":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_d5ac2645a2234cd8b193b0643148d7e5","placeholder":"​","style":"IPY_MODEL_1b76aafc62b34f6581e5249e276eaa0b","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"381eb91ed30a415cb46cf0e7039ef148":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_c003d8850c7148f9a5edeb67f5f0edf5","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_8e9511e5c97a40a2b37db5ff0f8ea717","tabbable":null,"tooltip":null,"value":223}},"38ee9286e56247e8b3a236b7463f6e17":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_680531a260ab4a0f9ab797a0e979f041","placeholder":"​","style":"IPY_MODEL_4822f0d4bf74466ead7aded3a6955a33","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"3de9570638854cb2bb8aafd4b59a7e37":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_7c8640d0d6754a03b2ea2c7e65cca3e0","IPY_MODEL_b451cfd690a844feba838f0b9fc98d60","IPY_MODEL_61162a9a481b4219ab7b2aca55853f25"],"layout":"IPY_MODEL_c66034c031e14ddba76831269dd0eb3c","tabbable":null,"tooltip":null}},"3f31ffa1268c43768fae3bd361c81942":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"3fbbab1fdbc2440ead6aaf0c4180365d":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_141b6f9e182742ed9c742880b43872f6","IPY_MODEL_b6a649728a614feb803fc9c790f2b258","IPY_MODEL_5e8ec66bb06e45f18e68c647d19c5043"],"layout":"IPY_MODEL_a650476286084134939bd289367febde","tabbable":null,"tooltip":null}},"40b28afb68334d368245e3b957d978ce":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"410dd1a20b3a4537aef9fcc37c4fa82f":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_f2164ad30294466ea02730b5ea47a659","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_675a70fd59814da9b81cecfad14eb0c5","tabbable":null,"tooltip":null,"value":223}},"411b537887c14c1c81a4082967b0742c":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"42d09391f71f46b49e1e682a79dc8498":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"430c062dc36541f295a9118ecc5c3709":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"435a160792764374b4f138dfb80b6443":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_1686affcb2ee48f19ffa3cf453b8f94a","placeholder":"​","style":"IPY_MODEL_40b28afb68334d368245e3b957d978ce","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"47c912c406904d5e9b2bf97ea73ce270":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_bd3183571cca44018da34d26068198b2","placeholder":"​","style":"IPY_MODEL_4a1a8ac67bf242078008f7ae898d9ba1","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 906.47it/s, Materializing param=layernorm.weight]"}},"4822f0d4bf74466ead7aded3a6955a33":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"487fe118383f4d15884c47a67c7a71e4":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"498f1e92efc34cf7826182ce08a0230c":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_d0ceed20f82145f0babba953886a65e8","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_4ab0ce443a384c519aa34153eca29a84","tabbable":null,"tooltip":null,"value":223}},"4a1a8ac67bf242078008f7ae898d9ba1":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"4ab0ce443a384c519aa34153eca29a84":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"4b32cbcf83b14b9fabeae2ffe1a9dd79":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"4d458849505641cbbd30d415d6e02066":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_add56e490cbf41c6b25ade1580d4fedc","placeholder":"​","style":"IPY_MODEL_36d8317b0e7240a79f9c5dec08a40951","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"4e8d83dac5f24116a247b66f1497d951":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_143f55ffc8c0407d961e99fccae9bdeb","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_9e5764f57ab342bcb5a261d24b45d651","tabbable":null,"tooltip":null,"value":223}},"4f3f4d4005a04e83949e59f906ed15ca":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_8b9df91902b04e8e93cb55ebf0474d14","placeholder":"​","style":"IPY_MODEL_2647f0bbbef54064b1f334a8b68cb252","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 1062.01it/s, Materializing param=layernorm.weight]"}},"53d63cb2127744bc9b70df610c9dd91f":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_81f650b099c64683b50f221e89b8f8b1","placeholder":"​","style":"IPY_MODEL_f725209d8001489e96d62a65def546af","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"5478c0636f0d423fa4ba9529e4ede579":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_9b1c74b6bb4f401eb03830c972e5d606","placeholder":"​","style":"IPY_MODEL_bc3d0be575bf4d389b8ec15892c08d4e","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"560cb1fb91b6400bbf6f98b5c7573fce":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"58f1d9c5b4894a37a6e8ad70502c34af":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"58f904a6d73941ada6e26cce327e6d93":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"59cb64e0de3940b998e6a0cb293baa1a":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"5c9a58dc33534b3b821daa54bfa0cc52":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"5d7aa0ed4d104380b457fd09f8f4f0a9":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"5dba5f1b4dbe46b589541b838ef26c3a":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"5e1ef81c51c94c44808adabf8807a973":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"5e8ec66bb06e45f18e68c647d19c5043":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_e2d500d7430e4ec48d848bc52491bb47","placeholder":"​","style":"IPY_MODEL_c1ad4a967fae439bb217263fc4236c6f","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 1096.01it/s, Materializing param=layernorm.weight]"}},"5f51564ab254494592300031cc29f693":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_d64cdde058134e809ac8154f45b6a8dc","placeholder":"​","style":"IPY_MODEL_a36be17649484ce5b420979112668fca","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 1088.42it/s, Materializing param=layernorm.weight]"}},"5f5b38775cc8468bb5e95909bb8fc78f":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"5f89818dd6d047249b23045abfb4fbc2":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_7d01f99b45d64454afb3372e8dd2385c","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_12e15604a2374d72bec82b227b265520","tabbable":null,"tooltip":null,"value":223}},"61162a9a481b4219ab7b2aca55853f25":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_321b1ba29f054021873775fa9234b7ad","placeholder":"​","style":"IPY_MODEL_a1899676cf1340879561e6df7aef226c","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 1073.06it/s, Materializing param=layernorm.weight]"}},"625927557d354ff19483b2652e3dcf1c":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_625e8744bb1b4931ae6be8a72d5f9e0a","placeholder":"​","style":"IPY_MODEL_32ba02c538fd46d7a5807220540f8901","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"625e8744bb1b4931ae6be8a72d5f9e0a":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"6304c8dbe5c74d42b62fb6ee98ea7c55":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"65498a077b944c13935a090a56aaff37":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_58f1d9c5b4894a37a6e8ad70502c34af","placeholder":"​","style":"IPY_MODEL_b5faa8c4002e4fa08f180ca5c8ff3950","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 825.43it/s, Materializing param=layernorm.weight]"}},"6626a30cbd6b41628c7723c9a0523659":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"66870ef402d0465ba3914456738da067":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"66ce77baf98e442d9804418f6fbfc02d":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_b42bc8eeae754b8a97827796c6d737ae","placeholder":"​","style":"IPY_MODEL_a1e5b459c6c94a3baa949ada65deb14f","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 950.99it/s, Materializing param=layernorm.weight]"}},"675a70fd59814da9b81cecfad14eb0c5":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"67bba9b0b50347929e1d2b611c7a1336":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_9a399a99c16b4e8a9326c5557b99f519","placeholder":"​","style":"IPY_MODEL_d82ffa9e24134be6965d81bcc8345f9d","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"680531a260ab4a0f9ab797a0e979f041":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"68c4822d45e542bb8242e64f8e3478df":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"691556ac40864aff901b4e6b8b8d80bf":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"6985959fa0a44a03837153cdc028cea8":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"6999307df43b4ea5b458c41c94d81b2c":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_8fd73c666c6e4dd9b47e73db8b259dd2","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_d42800344d634fbbb8017d70d6446bd2","tabbable":null,"tooltip":null,"value":223}},"69a836f1822f4335808f4860e70936df":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"732ab36f95134f1d9bcd243c3888e771":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_b31c595819ae4ed68226fb783fb1da92","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_4b32cbcf83b14b9fabeae2ffe1a9dd79","tabbable":null,"tooltip":null,"value":223}},"758c9f4f09cd47b18ce7ebf4826b8a1d":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_bea7dc55c10645e18d3d08ecfe4dca55","IPY_MODEL_77a9c12831004269810ab56209a9224d","IPY_MODEL_66ce77baf98e442d9804418f6fbfc02d"],"layout":"IPY_MODEL_ece7619a44c24542a55a0dbe72e44bde","tabbable":null,"tooltip":null}},"769d5bde08694ce7bdec124c0e494d01":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"7714b622588b46719d153febb9687426":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"772be9c5e22e43a9a34973470dd2935d":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_8d59272216434f3f912c03c65670d034","placeholder":"​","style":"IPY_MODEL_7b36d5c6f8a94a089e8d5277f5ebdf80","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 1132.19it/s, Materializing param=layernorm.weight]"}},"77a9c12831004269810ab56209a9224d":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_487fe118383f4d15884c47a67c7a71e4","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_b34f8eef70764ea093291b385630d6f6","tabbable":null,"tooltip":null,"value":223}},"77fcd7a5b67b4fcabaa3184475b74249":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_d92c164d32b54fc8afa149e0e1963ba9","IPY_MODEL_d2fe5aadcbfc42bb8842a58ce5715274","IPY_MODEL_a11278dc96a144e6aadaa48957c06105"],"layout":"IPY_MODEL_1301f18827bc4781ae3c54b12eb2324b","tabbable":null,"tooltip":null}},"782b799764ad4046a9fd891638adb496":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"7a6e635f92f24a4b9918b211bfa39c83":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_1a0bd4082a78483e8f022918dd0fcb84","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_0ff0a4b6ed624f6e9fe408dcb106bb8d","tabbable":null,"tooltip":null,"value":223}},"7af8b988a2a64717a66bb8646c8a21a1":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_8f196be1203c487183af01bdc05aa022","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_9a8bccfd6bab40c5b8766b20fcad735f","tabbable":null,"tooltip":null,"value":223}},"7b36d5c6f8a94a089e8d5277f5ebdf80":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"7c81f76837904725a8f483bc2bd91afe":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"7c8640d0d6754a03b2ea2c7e65cca3e0":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_58f904a6d73941ada6e26cce327e6d93","placeholder":"​","style":"IPY_MODEL_e1a3deb7952741d7b5dffea8df3bd832","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"7cb2c83431cc4dcc8dd6d792d62b8c67":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"7d01f99b45d64454afb3372e8dd2385c":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"7deef9a69e5e44f0bd547a77b9091a44":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"81f650b099c64683b50f221e89b8f8b1":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"82fd266c2c75436abc20033139622c79":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"8359a1c771384bdda84c4e3fee7be86e":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_de05dcaf33f74451af49676d0856d117","placeholder":"​","style":"IPY_MODEL_cccf4ec377cb4bf6be673ce5f9464588","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 1004.25it/s, Materializing param=layernorm.weight]"}},"8897f4c7a013483d9ddeeb2351a7db8c":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"8af69b4d4927435d96f9f78c1ea3d048":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_e50e7ab350ad4b4bbeb2defa00453a46","placeholder":"​","style":"IPY_MODEL_68c4822d45e542bb8242e64f8e3478df","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 921.66it/s, Materializing param=layernorm.weight]"}},"8b9df91902b04e8e93cb55ebf0474d14":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"8d59272216434f3f912c03c65670d034":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"8e8c46ae0fcd4f9a875b37a88a187f3b":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_5dba5f1b4dbe46b589541b838ef26c3a","placeholder":"​","style":"IPY_MODEL_b15ad388999f47eda92f66e91261a151","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"8e9511e5c97a40a2b37db5ff0f8ea717":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"8ec1d8c94ab14bf4911f5932db638a4e":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"8f196be1203c487183af01bdc05aa022":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"8fd73c666c6e4dd9b47e73db8b259dd2":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"9059d8ed365f40fa9ceadbbc046b3dd0":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_1bea5507647f4d1aa4e54e1e6d759134","IPY_MODEL_1319bf25b78546d6b8c9944c4b72b7d0","IPY_MODEL_8359a1c771384bdda84c4e3fee7be86e"],"layout":"IPY_MODEL_a404dd3356ac4682a55d89753b9b87fa","tabbable":null,"tooltip":null}},"917cf91f83054098b3492ed60d877b55":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"92a3053099074d828980d0bdb46ace1c":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_67bba9b0b50347929e1d2b611c7a1336","IPY_MODEL_410dd1a20b3a4537aef9fcc37c4fa82f","IPY_MODEL_4f3f4d4005a04e83949e59f906ed15ca"],"layout":"IPY_MODEL_7cb2c83431cc4dcc8dd6d792d62b8c67","tabbable":null,"tooltip":null}},"92b4d4bcb5f143da9925e737515f8816":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"98167d708c1f4d9c89416e3ee02ad080":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"9841fe6c7d5a441584340efef9cc29ec":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"9a399a99c16b4e8a9326c5557b99f519":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"9a8bccfd6bab40c5b8766b20fcad735f":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"9b1c74b6bb4f401eb03830c972e5d606":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"9ba770713ebe4ec19d3c3dc3d98b6516":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_b4d7a50549974851ac61e34a961071f8","IPY_MODEL_fda3645daecf41c283b859ab5a9ce78f","IPY_MODEL_234640dffa9e441298be9e5caa1346f3"],"layout":"IPY_MODEL_6626a30cbd6b41628c7723c9a0523659","tabbable":null,"tooltip":null}},"9e5764f57ab342bcb5a261d24b45d651":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"9ee2540e284d4bbcb6b4f11d5dc96065":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_aa9cfc9bc5ac40f48cee8e999faadba9","placeholder":"​","style":"IPY_MODEL_28b4e0a7c50b4e2bbc07adacab9754e0","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 1113.73it/s, Materializing param=layernorm.weight]"}},"a11278dc96a144e6aadaa48957c06105":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_2fed673712f542959712a902ece6b5f0","placeholder":"​","style":"IPY_MODEL_b49fbb1771b14335bc465d872f6930af","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 1082.02it/s, Materializing param=layernorm.weight]"}},"a1899676cf1340879561e6df7aef226c":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"a1e5b459c6c94a3baa949ada65deb14f":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"a36be17649484ce5b420979112668fca":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"a404dd3356ac4682a55d89753b9b87fa":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"a47804ada3a04881ab8ce9dbb4d512e0":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"a650476286084134939bd289367febde":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"aa9cfc9bc5ac40f48cee8e999faadba9":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"ac74aedbe1774857a10e85bb88928a64":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"add56e490cbf41c6b25ade1580d4fedc":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"ae2908a646bd49b2bdd080e89a35d2c6":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_bfd08c5dad6c458091c11003e3d00a69","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_2b238fa4051c4b918d2a2af349900fa5","tabbable":null,"tooltip":null,"value":223}},"afff97fabb714ad0b11a51f913a16bd8":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"b11694290d924575a264a3c185a5f4a4":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"b15ad388999f47eda92f66e91261a151":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"b1c778bfa94543f88f3dd02786c29b35":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"b217e8b160e141f78f18ab84e4a51cbd":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_5478c0636f0d423fa4ba9529e4ede579","IPY_MODEL_ae2908a646bd49b2bdd080e89a35d2c6","IPY_MODEL_65498a077b944c13935a090a56aaff37"],"layout":"IPY_MODEL_66870ef402d0465ba3914456738da067","tabbable":null,"tooltip":null}},"b31c595819ae4ed68226fb783fb1da92":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"b34f8eef70764ea093291b385630d6f6":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"b42bc8eeae754b8a97827796c6d737ae":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"b451cfd690a844feba838f0b9fc98d60":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_1bdbf3c1440743baa911e395f3f21b64","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_5d7aa0ed4d104380b457fd09f8f4f0a9","tabbable":null,"tooltip":null,"value":223}},"b49fbb1771b14335bc465d872f6930af":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"b4d7a50549974851ac61e34a961071f8":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_98167d708c1f4d9c89416e3ee02ad080","placeholder":"​","style":"IPY_MODEL_367538fc3c974a54a7804b0b2c0eeb2b","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"b5a72bbd1d7a481f8f9b52afabea7a86":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_435a160792764374b4f138dfb80b6443","IPY_MODEL_7a6e635f92f24a4b9918b211bfa39c83","IPY_MODEL_5f51564ab254494592300031cc29f693"],"layout":"IPY_MODEL_3549e0fbcc3e4b049aabd052129456b5","tabbable":null,"tooltip":null}},"b5faa8c4002e4fa08f180ca5c8ff3950":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"b6a649728a614feb803fc9c790f2b258":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_a47804ada3a04881ab8ce9dbb4d512e0","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_9841fe6c7d5a441584340efef9cc29ec","tabbable":null,"tooltip":null,"value":223}},"b9c58ca4009f43a8b8f584e9f66fd1f7":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"ba1e9bbee24542e3b517801483b1d787":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_fe7419eedd7549b3878a53e3b035813a","IPY_MODEL_ce9dd3c1d853417196759b2130726dc0","IPY_MODEL_21ddeea79f8a4568971e64fe3cec3fb9"],"layout":"IPY_MODEL_37262b3c715b49cca6e15eb96b8914a4","tabbable":null,"tooltip":null}},"bba7488cb7014fdba9c5f1f848fe6e2f":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"bc3d0be575bf4d389b8ec15892c08d4e":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"bd3183571cca44018da34d26068198b2":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"bd6888408d68475fb597422f85255fa5":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_92b4d4bcb5f143da9925e737515f8816","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_b11694290d924575a264a3c185a5f4a4","tabbable":null,"tooltip":null,"value":223}},"bea7dc55c10645e18d3d08ecfe4dca55":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_b9c58ca4009f43a8b8f584e9f66fd1f7","placeholder":"​","style":"IPY_MODEL_1b355a96253949f0b50497cb18b7bd1d","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"bf37e2b4c7fc4bf68de31dd0abc25408":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"bfd08c5dad6c458091c11003e3d00a69":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"c003d8850c7148f9a5edeb67f5f0edf5":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"c1ad4a967fae439bb217263fc4236c6f":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"c66034c031e14ddba76831269dd0eb3c":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"c6640af69c464f36a2097084f0aad8e8":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_e50a27240a4d491c8c0a1d7ec9ab4daf","IPY_MODEL_1006e8f8f04f4bacabe64a1f5fe554e5","IPY_MODEL_03c5f429e7ae42e18ca844d407722733"],"layout":"IPY_MODEL_782b799764ad4046a9fd891638adb496","tabbable":null,"tooltip":null}},"c9192f856c1547529497081f8f91f907":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"ca63093f3aa44bd79df462be9153a525":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"ca76ce4106c64c6d950f97c45a03502f":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"cccf4ec377cb4bf6be673ce5f9464588":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"ce997b135c1d4ff7afc5078f829f7a75":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"ce9dd3c1d853417196759b2130726dc0":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_f263db6a6a404632ba889382bdc73a82","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_ef2530973c714d7e8fd132107462d6c9","tabbable":null,"tooltip":null,"value":223}},"cec13885d51343feabdfcd1cf55aef2f":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"d0ceed20f82145f0babba953886a65e8":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"d2fe5aadcbfc42bb8842a58ce5715274":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_0bb1ab736cba4d41b8be4a6fad3ae80c","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_3f31ffa1268c43768fae3bd361c81942","tabbable":null,"tooltip":null,"value":223}},"d42800344d634fbbb8017d70d6446bd2":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"d5ac2645a2234cd8b193b0643148d7e5":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"d64cdde058134e809ac8154f45b6a8dc":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"d82ffa9e24134be6965d81bcc8345f9d":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"d86cb85cc616487dbe716f000b303d37":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"d92c164d32b54fc8afa149e0e1963ba9":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_0a2c5c4d2163487f9bb673f626a2faf4","placeholder":"​","style":"IPY_MODEL_1aef8eb9b8874e8d94f2f32ae9388787","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"d99a8aca7bdc4c7da565cea67a423df3":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_cec13885d51343feabdfcd1cf55aef2f","placeholder":"​","style":"IPY_MODEL_69a836f1822f4335808f4860e70936df","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 839.97it/s, Materializing param=layernorm.weight]"}},"dd0addd05e1d4d63be6c3d5258639104":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_38ee9286e56247e8b3a236b7463f6e17","IPY_MODEL_498f1e92efc34cf7826182ce08a0230c","IPY_MODEL_47c912c406904d5e9b2bf97ea73ce270"],"layout":"IPY_MODEL_82fd266c2c75436abc20033139622c79","tabbable":null,"tooltip":null}},"de05dcaf33f74451af49676d0856d117":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"e1a3deb7952741d7b5dffea8df3bd832":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"e1d5a8f091404a8caa64d3eae8cd601d":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"e2b51f549d2b443a9fa3f33205f0664a":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"e2d500d7430e4ec48d848bc52491bb47":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"e50a27240a4d491c8c0a1d7ec9ab4daf":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_8ec1d8c94ab14bf4911f5932db638a4e","placeholder":"​","style":"IPY_MODEL_30befc95cb4d4720a2aac7ce6023462e","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}},"e50e7ab350ad4b4bbeb2defa00453a46":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"e5a210ef231e448baafecd246ffe0ade":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_625927557d354ff19483b2652e3dcf1c","IPY_MODEL_bd6888408d68475fb597422f85255fa5","IPY_MODEL_8af69b4d4927435d96f9f78c1ea3d048"],"layout":"IPY_MODEL_bf37e2b4c7fc4bf68de31dd0abc25408","tabbable":null,"tooltip":null}},"e6c0a83ff5ab4ba792d3b27593095791":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_0671434222f042cba18f0e242444fef9","placeholder":"​","style":"IPY_MODEL_b1c778bfa94543f88f3dd02786c29b35","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 1089.51it/s, Materializing param=layernorm.weight]"}},"e8d0529a988d4e03a1df37999f1e6de2":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_bba7488cb7014fdba9c5f1f848fe6e2f","placeholder":"​","style":"IPY_MODEL_038efc4823a1425a998b8e5db5755a0d","tabbable":null,"tooltip":null,"value":" 223/223 [00:00&lt;00:00, 897.37it/s, Materializing param=layernorm.weight]"}},"ea6db06efd5a40159f84f1f637d5648c":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"ece7619a44c24542a55a0dbe72e44bde":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"edfa55c38cc04cac9bbe94b291ecc99b":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"ef2530973c714d7e8fd132107462d6c9":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"f2164ad30294466ea02730b5ea47a659":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"f263db6a6a404632ba889382bdc73a82":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"f409a85a425f4cb39f66abc1a7a9f15b":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_8e8c46ae0fcd4f9a875b37a88a187f3b","IPY_MODEL_4e8d83dac5f24116a247b66f1497d951","IPY_MODEL_1e238cded2174c98949b8cb0eec03a5a"],"layout":"IPY_MODEL_311785c100834ec78e5c63ecc5437f09","tabbable":null,"tooltip":null}},"f725209d8001489e96d62a65def546af":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"fda3645daecf41c283b859ab5a9ce78f":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_769d5bde08694ce7bdec124c0e494d01","max":223,"min":0,"orientation":"horizontal","style":"IPY_MODEL_c9192f856c1547529497081f8f91f907","tabbable":null,"tooltip":null,"value":223}},"fe7419eedd7549b3878a53e3b035813a":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_7c81f76837904725a8f483bc2bd91afe","placeholder":"​","style":"IPY_MODEL_7deef9a69e5e44f0bd547a77b9091a44","tabbable":null,"tooltip":null,"value":"Loading weights: 100%"}}},"version_major":2,"version_minor":0}}},"nbformat_minor":4,"nbformat":4,"cells":[{"id":"415f55d5","cell_type":"markdown","source":"## Stage 1 — DINOv2 / primary MRI ensemble","metadata":{"papermill":{"duration":0.028555,"end_time":"2026-08-20T11:30:27.369527+00:00","exception":false,"start_time":"2026-08-20T11:30:27.340972+00:00","status":"completed"},"tags":[]}},{"id":"26972bdc-31f6-485f-bfb5-2bc7c12ceb0f","cell_type":"code","source":"import os\n\n# V15 Robust submission configuration\nos.environ[\"V15_USE_PUBLIC_FRONTIER\"] = \"0\"\nos.environ[\"V14_USE_PASS2_PRIORS\"] = \"0\"\nos.environ[\"V14_ENABLE_HGB_CHALLENGER\"] = \"1\"\n\n# Development/retraining tools must remain disabled during submission\nos.environ[\"RUN_V15_BUILD_FOLDS\"] = \"0\"\nos.environ[\"RUN_V15_LABELER_EVAL\"] = \"0\"\nos.environ[\"RUN_V15_FIT_WEIGHTS\"] = \"0\"\n\nprint(\"V15 Robust configuration installed\")\nprint(\"V15_USE_PUBLIC_FRONTIER =\", os.environ[\"V15_USE_PUBLIC_FRONTIER\"])\nprint(\"V14_USE_PASS2_PRIORS =\", os.environ[\"V14_USE_PASS2_PRIORS\"])\nprint(\"V14_ENABLE_HGB_CHALLENGER =\", os.environ[\"V14_ENABLE_HGB_CHALLENGER\"])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-22T08:46:49.17355Z","iopub.execute_input":"2026-08-22T08:46:49.174117Z","iopub.status.idle":"2026-08-22T08:46:49.179684Z","shell.execute_reply.started":"2026-08-22T08:46:49.174084Z","shell.execute_reply":"2026-08-22T08:46:49.178953Z"}},"outputs":[],"execution_count":null},{"id":"08ae2902","cell_type":"code","source":"from __future__ import annotations\nimport os\nimport gc\nimport hashlib\nimport json\nimport re\nimport time\nimport traceback\nimport threading\nfrom concurrent.futures import ThreadPoolExecutor\nfrom pathlib import Path\nimport numpy as np\nimport pandas as pd\nimport pydicom\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nASSET = Path('/kaggle/input/datasets/tonylica/rsna-knee-bend-dinov3-0917-repro-assets')\nROOT = Path('/kaggle/input/competitions/rsna-knee-abnormality-detection')\nDINO = Path('/kaggle/input/models/metaresearch/dinov2/pytorch/small/1')\nT0 = time.time()\nDEVS = [torch.device(f'cuda:{i}') for i in range(torch.cuda.device_count())]\nSEED = 2026\n# V15: ship the OOF-weighted DINO blend by default. Set V15_USE_PUBLIC_FRONTIER=1\n# to reproduce the V13/V14 behavior of shipping the public-LB-selected variant.\nV15_USE_PUBLIC_FRONTIER = os.environ.get('V15_USE_PUBLIC_FRONTIER', '0') == '1'\nTARGETS = ['ACL', 'MCL', 'Medial Meniscus', 'Lateral Meniscus', 'Medial OA', 'Lateral OA', 'PF OA', 'Effusion', 'Synovitis', \"Baker's\", 'Contusion', 'Fracture']\nCROP_MM = 130.0\nCACHE_IMG = 336\nGROUP = 3\nN_GROUP_MAX = 1\nCACHE_FRACTION = 0.45\nCACHE_BUDGET_MAX_GB = 24.0\nCACHE_BUDGET_GB = 12.0\nTEST_SHARE = 0.3\nHDR_THREADS = 16\nPIX_THREADS = 12\nORDER_THREADS = 32\nORDER_BUDGET_S = 5400\nAUG_ROT_DEG = 8.0\nAUG_SCALE = 0.08\nAUG_SHIFT = 0.05\nAUG_INTENSITY = 0.1\nLAT_MIN_OFFSET_MM = 20.0\nSLICE_BAND = (0.2, 0.8)\nRULES_NATIVE = {'order': 'normal', 'lat': 'centre', 'slot_fallback': False, 'decode_fill': 'nearest'}\nRULES_LEGACY = {'order': 'dominant_axis', 'lat': 'corner_x', 'slot_fallback': True, 'decode_fill': 'zero'}\nRULES = dict(RULES_NATIVE)\nLEGACY_LAT_OFFSET_MM = 5.0\nEVAL_BATCH = 8\nTIME_BUDGET = 8.0 * 3600\nSLOTS_RECOVERED = [('SAG_FLUID_FS', 'Sagittal', True, True), ('COR_FLUID_FS', 'Coronal', True, True), ('AX_FLUID_FS', 'Axial', True, True), ('SAG_FLUID_NOFS', 'Sagittal', True, False), ('COR_T1', 'Coronal', False, False), ('SAG_T1', 'Sagittal', False, False)]\nSLOTS_PUBLIC = [('SAG_FLUID', 'Sagittal', None, True), ('COR_FLUID', 'Coronal', None, True), ('AX_FLUID', 'Axial', None, True), ('SAG_STRUCT', 'Sagittal', None, False), ('COR_STRUCT', 'Coronal', None, False), ('AX_STRUCT', 'Axial', None, False)]\nSLOT_SCHEME = os.environ.get('SLOT_SCHEME', 'recovered')\nSLOTS = SLOTS_PUBLIC if SLOT_SCHEME == 'public' else SLOTS_RECOVERED\nN_SLOT = len(SLOTS)\nPOOL_PARTS = {'cls_mean': 2, 'cls_mean_focal': 3}\nSLOT_PRIOR_TABLE = {'ACL': (0, 3, 5), 'MCL': (1, 4), 'Medial Meniscus': (0, 1, 3, 4), 'Lateral Meniscus': (0, 1, 3, 4), 'Medial OA': (1, 4, 5), 'Lateral OA': (1, 4, 5), 'PF OA': (0, 2, 5), 'Effusion': (0, 2), 'Synovitis': (0, 2), \"Baker's\": (0,), 'Contusion': (0, 1, 2), 'Fracture': (0, 1, 2, 4, 5)}\nSLOT_PRIOR_STRENGTH = 0.55\nFATSAT_OPTS = {'FS', 'FATSAT', 'FAT_SAT', 'FSAT'}\n_SEP = re.compile('[_\\\\-.]')\n_FATSAT_RX = re.compile('\\\\bfs\\\\b|fatsat|fat sat|\\\\bstir\\\\b|\\\\bspair\\\\b|\\\\bspir\\\\b|\\\\bwe\\\\b|water excit|\\\\btirm\\\\b|\\\\bsting\\\\b|\\\\bfatsup\\\\b')\n_T1_RX = re.compile('\\\\bt1\\\\b|\\\\bt1w\\\\b')\n_T2_RX = re.compile('\\\\bt2\\\\b|\\\\bt2w\\\\b')\n_PD_RX = re.compile('\\\\bpd\\\\b|\\\\bpdw\\\\b|proton|\\\\bdp\\\\b|dens')\n\ndef log(msg):\n    print(f'[{time.time() - T0:7.1f}s] {msg}', flush=True)\nIMG = CACHE_IMG\n\ndef available_gb():\n    try:\n        with open('/proc/meminfo') as fh:\n            info = {k.strip(): v for k, v in (l.split(':', 1) for l in fh if ':' in l)}\n        return int(info['MemAvailable'].split()[0]) / 1024 ** 2\n    except Exception:\n        return CACHE_BUDGET_GB / CACHE_FRACTION\n\ndef plan_cache(n_study, n_test=0):\n    avail = available_gb()\n    budget = min(avail * CACHE_FRACTION, CACHE_BUDGET_MAX_GB)\n    n_total = n_study + max(n_test, int(TEST_SHARE * n_study))\n    per_slice = n_total * N_SLOT * IMG * IMG\n    afford = int(budget * 1024 ** 3 // max(per_slice, 1))\n    groups = max(1, min(N_GROUP_MAX, afford // GROUP))\n    log(f'memory: {avail:.1f} GB available, {budget:.1f} GB to the cache; sizing for {n_study} train + {n_total - n_study} test studies -> {groups} group(s) of {GROUP} = {groups * GROUP} slices per slot' + (f' (wanted {N_GROUP_MAX})' if groups < N_GROUP_MAX else ''))\n    return groups\nN_GROUP = plan_cache(len(pd.read_csv(ROOT / 'train.csv')), len(pd.read_csv(ROOT / 'test.csv')))\nCACHE_SLICES = GROUP * N_GROUP\nHDR_TAGS = ['SeriesDescription', 'SequenceName', 'ScanOptions', 'ScanningSequence', 'RepetitionTime', 'EchoTime', 'Laterality', 'PixelSpacing', 'Rows', 'Columns', 'RescaleSlope', 'RescaleIntercept', 'ImagePositionPatient', 'ImageOrientationPatient']\n\ndef _hdr_vec(s, n):\n    if not isinstance(s, str):\n        return None\n    try:\n        v = [float(x) for x in s.split('|')]\n    except ValueError:\n        return None\n    return np.array(v) if len(v) >= n else None\n\ndef side_from_geometry(h):\n    cx = {}\n    for r in h.itertuples(index=False):\n        ipp = _hdr_vec(getattr(r, 'ImagePositionPatient', None), 3)\n        iop = _hdr_vec(getattr(r, 'ImageOrientationPatient', None), 6)\n        ps = _hdr_vec(getattr(r, 'PixelSpacing', None), 2)\n        rows, cols = (getattr(r, 'Rows', None), getattr(r, 'Columns', None))\n        if ipp is None or iop is None or ps is None or (not rows) or (not cols):\n            continue\n        try:\n            c = ipp[:3] + iop[:3] * ps[1] * float(cols) / 2 + iop[3:6] * ps[0] * float(rows) / 2\n        except (TypeError, ValueError):\n            continue\n        cx.setdefault(r.StudyInstanceUID, []).append(float(c[0]))\n    out = {}\n    for st, xs in cx.items():\n        m = float(np.median(xs))\n        out[st] = None if abs(m) < LAT_MIN_OFFSET_MM else 'R' if m < 0 else 'L'\n    return out\n\ndef side_from_corner_x(h):\n    out = {}\n    for st, g in h.groupby('StudyInstanceUID'):\n        xs = []\n        for r in g.itertuples(index=False):\n            ipp = _hdr_vec(getattr(r, 'ImagePositionPatient', None), 3)\n            if ipp is not None and np.isfinite(ipp).all():\n                xs.append(float(ipp[0]))\n        if not xs:\n            out[st] = None\n            continue\n        x = float(np.median(xs))\n        out[st] = None if abs(x) < LEGACY_LAT_OFFSET_MM else 'R' if x < 0 else 'L'\n    return out\n\ndef lat_of(h, tag=''):\n    geo = side_from_corner_x(h) if RULES['lat'] == 'corner_x' else side_from_geometry(h)\n    d, n_tag, n_geo, n_none, n_disagree = ({}, 0, 0, 0, 0)\n    for st, g in h.groupby('StudyInstanceUID'):\n        v = [str(x).strip().upper() for x in g['Laterality'].dropna()]\n        if RULES['lat'] == 'corner_x' and 'ImageLaterality' in g.columns:\n            v += [str(x).strip().upper() for x in g['ImageLaterality'].dropna()]\n        v = [x[0] for x in v if x and x[0] in ('L', 'R')]\n        side = v[0] if v else None\n        if side is not None:\n            n_tag += 1\n            if geo.get(st) is not None and geo[st] != side:\n                n_disagree += 1\n        else:\n            side = geo.get(st)\n            n_geo += side is not None\n            n_none += side is None\n        d[st] = side\n    log(f'{tag}laterality: {n_tag} from the tag, {n_geo} from geometry, {n_none} unresolved; tag and geometry disagree on {n_disagree} ({n_disagree / max(n_tag, 1):.1%} of the tagged)')\n    return d\n\ndef probe(item):\n    split, study, series, path = item\n    row = {'split': split, 'StudyInstanceUID': study, 'SeriesInstanceUID': series, 'dir': path}\n    try:\n        files = sorted((e.name for e in os.scandir(path) if e.name.endswith('.dcm')))\n        row['files'] = files\n        row['n_slices'] = len(files)\n        if not files:\n            return row\n        ds = pydicom.dcmread(os.path.join(path, files[len(files) // 2]), stop_before_pixels=True, force=True)\n        for t in HDR_TAGS:\n            v = getattr(ds, t, None)\n            if v is None:\n                row[t] = None\n            elif isinstance(v, (list, tuple)) or type(v).__name__ == 'MultiValue':\n                row[t] = '|'.join((str(x) for x in v))\n            else:\n                row[t] = str(v)\n    except Exception as exc:\n        row['err'] = str(exc)[:120]\n    return row\n\ndef walk(split):\n    base = ROOT / split\n    items = []\n    if not base.is_dir():\n        return pd.DataFrame(columns=['split', 'StudyInstanceUID', 'SeriesInstanceUID', 'dir', 'files', 'n_slices'] + HDR_TAGS)\n    for study in os.scandir(base):\n        if study.is_dir():\n            for series in os.scandir(study.path):\n                if series.is_dir():\n                    items.append((split, study.name, series.name, series.path))\n    with ThreadPoolExecutor(max_workers=HDR_THREADS) as pool:\n        rows = list(pool.map(probe, items))\n    return pd.DataFrame(rows)\n\ndef annotate(df):\n    desc = df['SeriesDescription'].fillna('') + ' ' + df['SequenceName'].fillna('')\n    desc = desc.str.lower().str.replace(_SEP, ' ', regex=True)\n    opts = df['ScanOptions'].fillna('').str.upper().str.split('|')\n    opts_fs = opts.apply(lambda ts: any((t.strip() in FATSAT_OPTS for t in ts)))\n    df['fatsat'] = desc.str.contains(_FATSAT_RX) | opts_fs\n    tr = pd.to_numeric(df['RepetitionTime'], errors='coerce')\n    te = pd.to_numeric(df['EchoTime'], errors='coerce')\n    gre = df['ScanningSequence'].fillna('').str.upper().str.contains('GR')\n    t1, t2, pdw = (desc.str.contains(_T1_RX), desc.str.contains(_T2_RX), desc.str.contains(_PD_RX))\n    df['weight'] = np.where(t1 & ~t2 & ~pdw, 'T1', np.where(t2 & ~pdw, 'T2', np.where(pdw, 'PD', np.where(gre, 'GRE', np.where(tr < 800, 'T1', np.where(te > 60, 'T2', np.where(tr >= 800, 'PD', 'UNK')))))))\n    df['fluid'] = np.isin(df['weight'], ['PD', 'T2'])\n    df['px'] = pd.to_numeric(df['PixelSpacing'].fillna('').str.split('|').str[0].replace('', np.nan), errors='coerce')\n    return df\n\ndef pick_slots(series_df, plane_map):\n    series_df = series_df.copy()\n    series_df['plane'] = series_df['SeriesInstanceUID'].map(plane_map)\n    out = {}\n    for study, g in series_df.groupby('StudyInstanceUID'):\n        chosen = {}\n        for name, plane, fluid, fs in SLOTS:\n            sel = (g['plane'] == plane) & (g['fatsat'] == fs)\n            if fluid is not None:\n                sel &= g['fluid'] == fluid\n            cand = g[sel]\n            if len(cand) == 0 and RULES['slot_fallback'] and (fluid is False):\n                cand = g[(g['plane'] == plane) & ~g['fatsat']]\n            if len(cand):\n                chosen[name] = cand.sort_values('n_slices', ascending=False).iloc[0]\n        out[study] = chosen\n    return out\nORDER_TAGS = [(32, 50), (32, 55), (32, 19)]\nDECODE_FAILED = []\n\ndef _natural_key(name):\n    return tuple((int(x) if x.isdigit() else x.lower() for x in re.split('(\\\\d+)', str(name))))\n\ndef _order_dominant_axis(rec):\n    files, d = (rec['files'], rec['dir'])\n    rows = []\n    for pos, f in enumerate(files):\n        ipp = inst = None\n        try:\n            ds = pydicom.dcmread(os.path.join(d, f), force=True, stop_before_pixels=True, specific_tags=['ImagePositionPatient', 'InstanceNumber'])\n            raw = getattr(ds, 'ImagePositionPatient', None)\n            if raw is not None and len(raw) >= 3:\n                c = np.asarray(raw[:3], dtype=np.float64)\n                if np.isfinite(c).all():\n                    ipp = c\n            n = getattr(ds, 'InstanceNumber', None)\n            if n is not None:\n                inst = float(n)\n        except Exception:\n            pass\n        rows.append((f, ipp, inst, pos))\n    placed = [r for r in rows if r[1] is not None]\n    need = max(2, int(0.8 * len(rows)))\n    if len(placed) >= need:\n        xyz = np.stack([r[1] for r in placed])\n        axis = int(np.argmax(np.ptp(xyz, axis=0)))\n        spare = float(np.nanmedian(xyz[:, axis]))\n        rows.sort(key=lambda r: (float(r[1][axis]) if r[1] is not None else spare, r[2] if r[2] is not None else float('inf'), r[3]))\n    elif sum((r[2] is not None for r in rows)) >= need:\n        rows.sort(key=lambda r: (r[2] if r[2] is not None else float('inf'), r[3]))\n    else:\n        rows.sort(key=lambda r: _natural_key(r[0]))\n    return ([r[0] for r in rows], True)\n\ndef order_slices(rec):\n    if RULES['order'] == 'dominant_axis':\n        return _order_dominant_axis(rec)\n    files, d = (rec['files'], rec['dir'])\n    keyed = []\n    for f in files:\n        k = None\n        try:\n            ds = pydicom.dcmread(os.path.join(d, f), force=True, stop_before_pixels=True, specific_tags=ORDER_TAGS)\n            iop = np.asarray(ds.ImageOrientationPatient, dtype=float)\n            ipp = np.asarray(ds.ImagePositionPatient, dtype=float)\n            k = float(np.dot(ipp, np.cross(iop[:3], iop[3:])))\n        except Exception:\n            try:\n                k = float(ds.InstanceNumber)\n            except Exception:\n                k = None\n        keyed.append((k, f))\n    if any((k is None for k, _ in keyed)):\n        return (files, False)\n    return ([f for _, f in sorted(keyed, key=lambda t: t[0])], True)\n\ndef read_slot(rec, n_slice=None, out_size=None):\n    n_slice = GROUP if n_slice is None else n_slice\n    out_size = IMG if out_size is None else out_size\n    files, d, px = (rec.get('ordered') or rec['files'], rec['dir'], rec['px'])\n    n = len(files)\n    if n == 0:\n        return None\n    lo, hi = (int(SLICE_BAND[0] * (n - 1)), int(SLICE_BAND[1] * (n - 1)))\n    idx = np.unique(np.linspace(lo, hi, n_slice).astype(int)) if hi > lo else np.array([n // 2])\n    while len(idx) < n_slice:\n        idx = np.append(idx, idx[-1])\n    planes = []\n    for i in idx[:n_slice]:\n        try:\n            ds = pydicom.dcmread(os.path.join(d, files[int(i)]), force=True)\n            a = ds.pixel_array.astype(np.float32)\n            sl = float(getattr(ds, 'RescaleSlope', 1) or 1)\n            ic = float(getattr(ds, 'RescaleIntercept', 0) or 0)\n            a = a * sl + ic\n        except Exception:\n            a = None\n        planes.append(a)\n    got = [k for k, p in enumerate(planes) if p is not None]\n    if RULES['decode_fill'] == 'zero':\n        if not got:\n            DECODE_FAILED.append(rec.get('SeriesInstanceUID', d))\n        planes = [np.zeros((out_size, out_size), np.float32) if p is None else p for p in planes]\n        got = list(range(len(planes)))\n    if not got:\n        DECODE_FAILED.append(rec.get('SeriesInstanceUID', d))\n        return None\n    if len(got) < len(planes):\n        DECODE_FAILED.append(rec.get('SeriesInstanceUID', d))\n        for k, p in enumerate(planes):\n            if p is None:\n                planes[k] = planes[min(got, key=lambda j: abs(j - k))]\n    shp = planes[0].shape\n    planes = [p if p.shape == shp else np.zeros(shp, np.float32) for p in planes]\n    vol = np.stack(planes)\n    if px and np.isfinite(px) and (px > 0):\n        want = int(round(CROP_MM / px))\n        h, w = shp\n        if 16 < want < min(h, w):\n            cy, cx = (h // 2, w // 2)\n            half = want // 2\n            vol = vol[:, max(0, cy - half):cy + half, max(0, cx - half):cx + half]\n    lo_v, hi_v = np.percentile(vol, [1, 99])\n    vol = np.clip((vol - lo_v) / max(hi_v - lo_v, 1e-06), 0, 1)\n    t = torch.from_numpy(np.ascontiguousarray(vol)).unsqueeze(0)\n    t = F.interpolate(t, size=(out_size, out_size), mode='bilinear', align_corners=False)\n    return (t.squeeze(0) * 255).round().clamp(0, 255).to(torch.uint8)\n\ndef normalise_laterality(img, plane, lat):\n    if lat != 'R':\n        return img\n    if plane in ('Coronal', 'Axial'):\n        return torch.flip(img, dims=[-1])\n    return torch.flip(img, dims=[0])\nORDER_CACHE = os.environ.get('RSNA_ORDER_CACHE') or None\n\ndef build_cache(slot_map, plane_map, lat_map, tag):\n    studies = sorted(slot_map)\n    sidx = {s: i for i, s in enumerate(studies)}\n    cache = np.zeros((len(studies), N_SLOT, CACHE_SLICES, IMG, IMG), np.uint8)\n    mask = np.zeros((len(studies), N_SLOT), np.float32)\n    log(f'{tag}: cache {cache.shape} = {cache.nbytes / 1024 ** 3:.1f} GB')\n    jobs = [(st, k, plane, slot_map[st][name]) for st in studies for k, (name, plane, _, _) in enumerate(SLOTS) if name in slot_map[st]]\n    n_job = len(jobs)\n    t_ord = time.time()\n    n_slice_total = sum((len(j[3]['files']) for j in jobs))\n    log(f'{tag}: ordering {len(jobs)} slot-series ({n_slice_total} slice headers)')\n    ok = done = 0\n    CHUNK_O = 1024\n    seen = {}\n    if ORDER_CACHE and Path(ORDER_CACHE).is_file():\n        try:\n            import json as _json\n            seen = _json.loads(Path(ORDER_CACHE).read_text())\n        except (OSError, ValueError):\n            seen = {}\n        hit = 0\n        for _, _, _, rec in jobs:\n            e = seen.get(rec['SeriesInstanceUID'])\n            if e and len(e['files']) == len(rec['files']):\n                rec['ordered'] = e['files']\n                ok += int(e['good'])\n                hit += 1\n        jobs = [j for j in jobs if 'ordered' not in j[3]]\n        log(f'{tag}: {hit} slot-series ordered from {ORDER_CACHE}, {len(jobs)} to read')\n    with ThreadPoolExecutor(max_workers=ORDER_THREADS) as pool:\n        for c0 in range(0, len(jobs), CHUNK_O):\n            block = jobs[c0:c0 + CHUNK_O]\n            for (_, _, _, rec), (files, good) in zip(block, pool.map(lambda j: order_slices(j[3]), block)):\n                rec['ordered'] = files\n                ok += int(good)\n                done += 1\n                if ORDER_CACHE:\n                    seen[rec['SeriesInstanceUID']] = {'files': files, 'good': bool(good)}\n            budget = min(ORDER_BUDGET_S, max(60.0, (TIME_BUDGET - (time.time() - T0)) * 0.35))\n            if time.time() - t_ord > budget:\n                log(f'{tag}: ordering budget spent at {done}/{len(jobs)}; the rest keep file order')\n                break\n    if ORDER_CACHE and done:\n        import json as _json\n        _t = Path(ORDER_CACHE).with_suffix('.tmp')\n        _t.write_text(_json.dumps(seen))\n        _t.replace(Path(ORDER_CACHE))\n    log(f'{tag}: ordered {ok}/{n_job} by geometry ({n_job - ok} kept arbitrary) in {time.time() - t_ord:.0f}s')\n    jobs = [(st, k, plane, slot_map[st][name]) for st in studies for k, (name, plane, _, _) in enumerate(SLOTS) if name in slot_map[st]]\n    log(f'{tag}: decoding {len(jobs)} slot-series')\n    n_failed_before = len(DECODE_FAILED)\n    CHUNK = 512\n    done = 0\n    with ThreadPoolExecutor(max_workers=PIX_THREADS) as pool:\n        for c0 in range(0, len(jobs), CHUNK):\n            block = jobs[c0:c0 + CHUNK]\n            for (st, k, plane, _), img in zip(block, pool.map(lambda j: read_slot(j[3], CACHE_SLICES, IMG), block)):\n                done += 1\n                if img is None:\n                    continue\n                cache[sidx[st], k] = normalise_laterality(img, plane, lat_map.get(st)).numpy()\n                mask[sidx[st], k] = 1.0\n            if done % 4096 < CHUNK:\n                log(f'  {tag} {done}/{len(jobs)}')\n            if time.time() - T0 > TIME_BUDGET:\n                log(f'  {tag}: time budget reached during decode')\n                break\n    n_failed = len(DECODE_FAILED) - n_failed_before\n    log(f'{tag}: {int(mask.sum())}/{len(jobs)} slots filled' + (f'; {n_failed} series had a slice that would not decode' if n_failed else ''))\n    gc.collect()\n    return (studies, cache, mask)\n\nclass SlotHead(nn.Module):\n\n    def __init__(self, dim, n_slot, n_out, hidden=256, p=0.2, prior=False):\n        super().__init__()\n        self.proj = nn.Sequential(nn.LayerNorm(dim), nn.Linear(dim, hidden), nn.GELU())\n        self.slot_emb = nn.Parameter(torch.randn(n_slot, hidden) * 0.02)\n        self.query = nn.Parameter(torch.randn(n_out, hidden) * 0.02)\n        self.drop = nn.Dropout(p)\n        self.out = nn.Linear(hidden, n_out)\n        self.hidden = hidden\n        p_ = torch.zeros(n_out, n_slot)\n        if prior and n_slot == len(SLOTS) and (n_out == len(TARGETS)):\n            for t, slots in SLOT_PRIOR_TABLE.items():\n                if t in TARGETS:\n                    p_[TARGETS.index(t), list(slots)] = SLOT_PRIOR_STRENGTH\n        self.prior = prior\n        if prior:\n            self.register_buffer('slot_prior', p_)\n\n    def forward(self, x, mask):\n        h = self.proj(x) + self.slot_emb\n        att = torch.einsum('bsh,oh->bos', h, self.query) / self.hidden ** 0.5\n        if self.prior:\n            att = att + self.slot_prior.unsqueeze(0)\n        att = att.masked_fill(mask.unsqueeze(1) < 0.5, -10000.0).softmax(-1)\n        ctx = self.drop(torch.einsum('bos,bsh->boh', att, h))\n        return (ctx * self.out.weight.unsqueeze(0)).sum(-1) + self.out.bias\n\nclass Model(nn.Module):\n\n    def __init__(self, backbone, dim, pool='cls_mean', prior=False):\n        super().__init__()\n        self.backbone = backbone\n        self.pool = pool\n        self.head = SlotHead(dim * POOL_PARTS[pool], N_SLOT, len(TARGETS), prior=prior)\n        self.register_buffer('mean', torch.tensor([0.485, 0.456, 0.406]).view(1, 3, 1, 1))\n        self.register_buffer('std', torch.tensor([0.229, 0.224, 0.225]).view(1, 3, 1, 1))\n\n    def forward(self, imgs, mask, img_size=None):\n        B, S = imgs.shape[:2]\n        x = imgs.reshape(B * S, *imgs.shape[2:]).float().div_(255.0)\n        if img_size is not None and img_size != x.shape[-1]:\n            x = F.interpolate(x, size=(img_size, img_size), mode='bilinear', align_corners=False)\n        x = (x - self.mean) / self.std\n        out = self.backbone(pixel_values=x).last_hidden_state\n        patch = out[:, 1:]\n        parts = [out[:, 0], patch.mean(1)]\n        if self.pool == 'cls_mean_focal':\n            k = max(1, patch.shape[1] // 8)\n            parts.append(patch.topk(k, dim=1).values.mean(1))\n        feat = torch.cat(parts, dim=1).reshape(B, S, -1)\n        return self.head(feat, mask)\n\ndef build_model(unfreeze_last, source=None, variant='small', pool='cls_mean', prior=False):\n    from transformers import AutoModel\n    p = source if source is not None else find_dinov2(variant)\n    if p is None:\n        raise FileNotFoundError('DINOv2 weights not attached')\n    bb = AutoModel.from_pretrained(str(p))\n    n_layer = len(bb.encoder.layer)\n    for prm in bb.parameters():\n        prm.requires_grad = False\n    for blk in bb.encoder.layer[max(0, n_layer - unfreeze_last):]:\n        for prm in blk.parameters():\n            prm.requires_grad = True\n    for prm in bb.layernorm.parameters():\n        prm.requires_grad = True\n    dim = bb.config.hidden_size\n    trainable = sum((p.numel() for p in bb.parameters() if p.requires_grad))\n    log(f'backbone: {n_layer} blocks, last {unfreeze_last} trainable ({trainable / 1000000.0:.1f}M params), feature dim {dim * POOL_PARTS[pool]}')\n    return Model(bb, dim, pool=pool, prior=prior)\nFINGERPRINT_TOL = 0.002\n\ndef fingerprint(model, dev, img_size, n_slot=None, group=None, seed=None):\n    n_slot = N_SLOT if n_slot is None else n_slot\n    group = GROUP if group is None else group\n    seed = SEED if seed is None else seed\n    g = torch.Generator().manual_seed(seed)\n    imgs = torch.randint(0, 256, (2, n_slot, group, img_size, img_size), generator=g, dtype=torch.uint8).to(dev)\n    mask = torch.ones(2, n_slot, device=dev)\n    mask[1, -1] = 0.0\n    was_training = model.training\n    model.eval()\n    with torch.no_grad():\n        out = model(imgs, mask, img_size).float().cpu().numpy()\n    if was_training:\n        model.train()\n    return out\n\ndef check_fingerprint(model, dev, img_size, expected, tol=FINGERPRINT_TOL, tag=''):\n    got = fingerprint(model, dev, img_size)\n    exp = np.asarray(expected, np.float32)\n    if got.shape != exp.shape:\n        raise WeightsError(f'{tag}fingerprint shape {got.shape} != stored {exp.shape}: the architecture is not the one these weights were fitted to')\n    d = float(np.abs(got - exp).max())\n    if d > tol:\n        raise WeightsError(f'{tag}fingerprint differs by {d:.4g} (tolerance {tol:g}). The weights load but do not compute what they computed when fitted - preprocessing, resolution or architecture has moved between the two runs.')\n    log(f'{tag}fingerprint matches within {d:.2g}')\n    return d\n\nclass WeightsError(RuntimeError):\n    pass\nTTA_OVERLAP = True\nTTA_POOL = 'prob'\nPUBLIC_FRONTIER_TARGET_POOL = {'Fracture': 'max', 'Contusion': 'max', 'Medial Meniscus': 'max', 'Lateral Meniscus': 'max', 'ACL': 'top2', 'MCL': 'top2', \"Baker's\": 'max'}\nTTA_TARGET_POOL = {**PUBLIC_FRONTIER_TARGET_POOL, 'Synovitis': 'original_mean'}\nLEGACY_FOLD_SOFTPOOL_BETA = {'ACL': 6.0, 'MCL': 6.0, 'Medial Meniscus': 8.0, 'Lateral Meniscus': 8.0, \"Baker's\": 8.0, 'Contusion': 8.0, 'Fracture': 10.0}\nLEGACY_FOLD_SOFTPOOL_ALPHA = {'ACL': 0.2, 'MCL': 0.2, 'Medial Meniscus': 0.25, 'Lateral Meniscus': 0.25, \"Baker's\": 0.2, 'Contusion': 0.2, 'Fracture': 0.15}\n\ndef window_starts(n_slice, group, overlap=None):\n    overlap = TTA_OVERLAP if overlap is None else overlap\n    if overlap and n_slice >= group:\n        return list(range(n_slice - group + 1))\n    return [g * group for g in range(max(n_slice // group, 1))]\n\ndef apply_target_window_pool(values, probs, logits, original_probs, mapping, target_idx):\n    for target, mode in mapping.items():\n        j = target_idx[target]\n        if mode == 'max':\n            values[:, j] = probs[:, :, j].max(0).values\n        elif mode == 'mean':\n            values[:, j] = probs[:, :, j].mean(0)\n        elif mode == 'logit_mean':\n            values[:, j] = torch.sigmoid(logits[:, :, j].mean(0))\n        elif mode == 'original_mean':\n            values[:, j] = original_probs[:, :, j].mean(0)\n        elif mode in ('top2', 'top3'):\n            k = min(int(mode[3:]), probs.shape[0])\n            values[:, j] = probs[:, :, j].topk(k, dim=0).values.mean(0)\n        else:\n            raise ValueError(f'unknown TTA pooling mode for {target}: {mode}')\n    return values\n\ndef legacy_fold_soft_window_pool(original_probs, target_idx):\n    values = original_probs.mean(0).clone()\n    for target, beta in LEGACY_FOLD_SOFTPOOL_BETA.items():\n        j = target_idx[target]\n        x = original_probs[:, :, j]\n        weight = torch.softmax(float(beta) * x, dim=0)\n        values[:, j] = (weight * x).sum(0)\n    return values\n\n@torch.no_grad()\ndef predict_member(model, cache, mask, idx, dev, img_size, group=None, pool=None, starts=None, jitter=False, jitter_seed=SEED, return_public_frontier=False):\n    group = GROUP if group is None else group\n    pool = TTA_POOL if pool is None else pool\n    starts = window_starts(cache.shape[2], group) if starts is None else list(starts)\n    if not starts:\n        raise ValueError('predict_member was given no windows to average over')\n    target_idx = {t: j for j, t in enumerate(TARGETS)}\n    unknown = (set(TTA_TARGET_POOL) | set(PUBLIC_FRONTIER_TARGET_POOL)) - set(target_idx)\n    if unknown:\n        raise ValueError(f'unknown target(s) in TTA_TARGET_POOL: {unknown}')\n    jitter_gen = torch.Generator(device=dev)\n    jitter_gen.manual_seed(int(jitter_seed) % (2 ** 63 - 1))\n    model.eval()\n    out, public_frontier_out, public_soft_out = ([], [], [])\n    for b in range(0, len(idx), EVAL_BATCH):\n        sel = idx[b:b + EVAL_BATCH]\n        m = torch.from_numpy(mask[sel]).to(dev)\n        win_probs, win_logits, win_original_probs = ([], [], [])\n        for st in starts:\n            rows = torch.from_numpy(np.ascontiguousarray(cache[sel, :, st:st + group])).to(dev)\n            views = [rows] + ([augment(rows, generator=jitter_gen)] if jitter else [])\n            view_probs, view_logits = ([], [])\n            for view in views:\n                with torch.autocast('cuda', enabled=dev.type == 'cuda'):\n                    z = model(view, m, img_size).float()\n                view_logits.append(z)\n                view_probs.append(torch.sigmoid(z))\n            win_logits.append(torch.stack(view_logits).mean(0))\n            win_probs.append(torch.stack(view_probs).mean(0))\n            win_original_probs.append(view_probs[0])\n        probs = torch.stack(win_probs)\n        logits = torch.stack(win_logits)\n        original_probs = torch.stack(win_original_probs)\n        v = torch.sigmoid(logits.mean(0)) if pool == 'logit' else probs.mean(0)\n        v = apply_target_window_pool(v, probs, logits, original_probs, TTA_TARGET_POOL, target_idx)\n        out.append(v.cpu().numpy())\n        if return_public_frontier:\n            public_v = apply_target_window_pool(original_probs.mean(0), original_probs, logits, original_probs, PUBLIC_FRONTIER_TARGET_POOL, target_idx)\n            public_frontier_out.append(public_v.cpu().numpy())\n            public_soft = legacy_fold_soft_window_pool(original_probs, target_idx)\n            public_soft_out.append(public_soft.cpu().numpy())\n    primary = np.concatenate(out) if out else np.zeros((0, len(TARGETS)), np.float32)\n    if not return_public_frontier:\n        return primary\n    public_frontier = np.concatenate(public_frontier_out) if public_frontier_out else np.zeros((0, len(TARGETS)), np.float32)\n    public_soft = np.concatenate(public_soft_out) if public_soft_out else np.zeros((0, len(TARGETS)), np.float32)\n    return (primary, public_frontier, public_soft)\nBUILD_LOCK = threading.Lock()\nSTATE_LOCK = threading.Lock()\n\ndef _run_member(path, m, dev, Cte, Mte, idx, starts, jitter):\n    t0 = time.time()\n    with BUILD_LOCK:\n        if 'state' in m:\n            state, fp = (m['state'], None)\n        else:\n            ck = torch.load(Path(path) / m['file'], map_location='cpu', weights_only=False)\n            state, fp = (ck['model'], ck.get('fingerprint'))\n        model = build_model(int(m['config']['unfreeze_last']), variant=m['config']['variant'], pool=m['config'].get('pool', 'cls_mean'), prior=bool(m['config'].get('prior', False))).to(dev)\n        model.load_state_dict(state)\n        if fp is not None:\n            check_fingerprint(model, dev, IMG, fp, tag=f\"{m['id']}: \")\n        else:\n            log(f\"  {m['id']}: no stored fingerprint (legacy bundle) -- accepted at reduced weight\")\n    t_ready = time.time()\n    jitter_seed = SEED + int(hashlib.sha256(str(m['id']).encode()).hexdigest()[:8], 16)\n    public_member = 'state' not in m\n    predicted = predict_member(model, Cte, Mte, idx, dev, IMG, starts=starts, jitter=jitter, jitter_seed=jitter_seed, return_public_frontier=public_member)\n    if public_member:\n        p, public_p, public_soft = predicted\n    else:\n        p, public_p, public_soft = (predicted, None, None)\n    t_done = time.time()\n    del model, state\n    gc.collect()\n    if dev.type == 'cuda':\n        with torch.cuda.device(dev):\n            torch.cuda.empty_cache()\n    passes = len(starts) * (2 if jitter else 1)\n    return (p, public_p, public_soft, (t_ready - t0, (t_done - t_ready) / max(passes, 1)))\n\ndef _combine(per_member):\n    all_ids = sorted({s for m in per_member for s in m['ids']})\n    pos = {s: i for i, s in enumerate(all_ids)}\n    acc = np.zeros((len(all_ids), len(TARGETS)), np.float64)\n    tot = np.zeros(len(TARGETS), np.float64)\n    for m in per_member:\n        target_weight = m.get('target_weight')\n        w = np.asarray(target_weight if target_weight is not None else [float(m.get('weight', 1.0))] * len(TARGETS), dtype=np.float64)\n        if w.shape != (len(TARGETS),) or np.any(w < 0):\n            raise ValueError(f\"invalid target weights for {m.get('id')}: {w}\")\n        r = pd.DataFrame(m['pred']).rank(pct=True).to_numpy()\n        acc[[pos[s] for s in m['ids']]] += r * w[None, :]\n        tot += w\n    if np.any(tot <= 0):\n        raise ValueError(f'at least one target has no ensemble vote: {tot}')\n    return (all_ids, acc / tot[None, :])\n\ndef combine_public_members_by_fold(per_member, pred_key='pred'):\n    all_ids = sorted({study for member in per_member for study in member['ids']})\n    position = {study: i for i, study in enumerate(all_ids)}\n    groups = {}\n    for i, member in enumerate(per_member):\n        fold = member.get('fold')\n        key = f'fold_{fold}' if fold is not None else f'member_{i}'\n        groups.setdefault(key, []).append(member)\n    fold_ranks, diagnostics = ([], [])\n    for key, members_in_fold in sorted(groups.items()):\n        matrices = []\n        for member in members_in_fold:\n            values = np.full((len(all_ids), len(TARGETS)), np.nan, np.float64)\n            values[[position[study] for study in member['ids']]] = np.asarray(member[pred_key], np.float64)\n            if np.isnan(values).any():\n                raise WeightsError(f\"{member.get('id')}: incomplete {pred_key} coverage\")\n            matrices.append(values)\n        raw_fold_mean = np.mean(matrices, axis=0)\n        fold_ranks.append(pd.DataFrame(raw_fold_mean).rank(method='average', pct=True).to_numpy(np.float64))\n        diagnostics.append({'ensemble_group': key, 'members': len(members_in_fold)})\n    if len(fold_ranks) != 5:\n        raise WeightsError(f'legacy branch requires five folds, found {len(fold_ranks)}')\n    return (all_ids, np.mean(fold_ranks, axis=0), pd.DataFrame(diagnostics))\n\ndef blend_legacy_frontier_and_soft(frontier_rank, soft_rank):\n    output = np.asarray(frontier_rank, np.float64).copy()\n    for j, target in enumerate(TARGETS):\n        alpha = float(LEGACY_FOLD_SOFTPOOL_ALPHA.get(target, 0.0))\n        if alpha:\n            output[:, j] = (1.0 - alpha) * frontier_rank[:, j] + alpha * soft_rank[:, j]\n    return output\n\ndef infer_from_package(path, dev=None):\n    man = json.loads((Path(path) / 'manifest.json').read_text())\n    members = man['members']\n    log(f'weights package: {len(members)} member(s) from {path}; {len(DEVS)} device(s)')\n    test_df = pd.read_csv(ROOT / 'test.csv')\n    test_series = pd.read_csv(ROOT / 'test_series.csv')\n    plane_map = dict(zip(test_series['SeriesInstanceUID'], test_series['Anatomical_Plane']))\n    hte = annotate(walk('test_series'))\n    log(f'test header pass: {len(hte)} series')\n    groups = {}\n    for m in members:\n        groups.setdefault(m['pixel_group'], []).append(m)\n    groups.update(legacy_group_members())\n    per_member, public_frontier_members = ([], [])\n    est = {'fixed': None, 'win': None}\n\n    def bank(m, ids, pred, starts, jitter, public_pred=None, public_soft=None):\n        if float(np.std(pred)) < 1e-09:\n            log(f\"  {m['id']}: degenerate predictions; not banked\")\n            return\n        with STATE_LOCK:\n            per_member.append({'id': m['id'], 'fold': m.get('fold'), 'ids': ids, 'pred': pred, 'weight': m.get('weight', 1.0), 'target_weight': m.get('target_weight'), 'holdout': m.get('holdout')})\n            if public_pred is not None and len(starts) == len(starts_full):\n                if float(np.std(public_pred)) < 1e-09:\n                    raise WeightsError(f\"{m['id']}: degenerate public-frontier prediction\")\n                public_frontier_members.append({'id': m['id'], 'fold': m.get('fold'), 'ids': ids, 'pred': public_pred, 'soft_pred': public_soft})\n            elif public_pred is not None:\n                log(f\"  {m['id']}: public-frontier vote omitted because only {len(starts)} / {len(starts_full)} windows completed\")\n            all_ids, acc = _combine(per_member)\n            write_submission(acc, all_ids, test_df, 'submission.csv')\n            log(f\"  banked {m['id']} fold {m.get('fold', '?')} ({len(starts)} window(s){(', jitter' if jitter else '')}); submission.csv = weighted rank mean of {len(per_member)} member(s)\")\n    for gi, (key, gm) in enumerate(groups.items(), 1):\n        cfg = json.loads(key)\n        adopt_config_globals(cfg)\n        log(f\"decode group {gi}/{len(groups)}: {cfg['img']}px x {cfg['slices']} slices, crop {cfg['crop_mm']} mm -> {len(gm)} member(s)\")\n        st_te, Cte, Mte = build_cache(pick_slots(hte, plane_map), plane_map, lat_of(hte, 'test '), f'test g{gi}')\n        idx = np.arange(len(st_te))\n        starts_full = window_starts(Cte.shape[2], GROUP)\n        pending = sorted(gm, key=lambda m: -(m.get('holdout') or 0))\n        left_after = sum((len(g) for j, (_, g) in enumerate(groups.items(), 1) if j > gi))\n\n        def pop_next():\n            with STATE_LOCK:\n                if not pending:\n                    return (None, None, False)\n                left = TIME_BUDGET - (time.time() - T0)\n                remaining = len(pending) + left_after\n                slots_left = -(-remaining // len(DEVS))\n                starts, jit = (starts_full, False)\n                if est['fixed'] is not None and est['win'] is not None:\n                    afford = max(left * 0.9, 0.0)\n                    room = afford / max(slots_left, 1)\n                    if est['fixed'] + est['win'] > room:\n                        log(f'  {left / 60:.0f} min left: surrendering {len(pending)} member(s); not one more fits')\n                        pending.clear()\n                        return (None, None, False)\n                    jit = est['fixed'] + 2 * len(starts_full) * est['win'] <= room * 0.6\n                    per_win = est['win'] * (2 if jit else 1)\n                    n_win = int((room - est['fixed']) / per_win) if per_win > 0 else len(starts_full)\n                    n_win = max(1, min(len(starts_full), n_win))\n                    if n_win < len(starts_full):\n                        mid = (len(starts_full) - n_win) // 2\n                        starts = starts_full[mid:mid + n_win]\n                return (pending.pop(0), starts, jit)\n\n        def worker(dev):\n            others = [d for d in DEVS if d is not dev]\n            while True:\n                m, starts, jit = pop_next()\n                if m is None:\n                    return\n                for attempt, d in enumerate([dev] + others[:1]):\n                    try:\n                        p, public_p, public_soft, (fs, ws) = _run_member(path, m, d, Cte, Mte, idx, starts, jit)\n                        with STATE_LOCK:\n                            est['fixed'], est['win'] = (fs, ws)\n                        bank(m, st_te, p, starts, jit, public_p, public_soft)\n                        break\n                    except Exception as exc:\n                        log(f\"  MEMBER {m['id']} failed on {d} ({type(exc).__name__}: {exc}); \" + ('retrying on peer device' if attempt == 0 and others else 'dropped -- costs one vote, not the run'))\n                        if d.type == 'cuda':\n                            with torch.cuda.device(d):\n                                torch.cuda.empty_cache()\n        threads = [threading.Thread(target=worker, args=(d,)) for d in DEVS]\n        for t in threads:\n            t.start()\n        for t in threads:\n            t.join()\n        del Cte, Mte\n        gc.collect()\n    if not per_member:\n        raise WeightsError('no member produced predictions; submission stays at 0.5')\n    all_ids, acc = _combine(per_member)\n    sub = write_submission(acc, all_ids, test_df, 'submission.csv')\n    log(f'final submission.csv = weighted rank mean of {len(per_member)} member(s); {sub.shape}; nulls {int(sub[TARGETS].isna().sum().sum())}')\n    if len(public_frontier_members) == len(members):\n        frontier_ids, frontier_acc = _combine(public_frontier_members)\n        frontier_sub = write_submission(frontier_acc, frontier_ids, test_df, 'submission_public_0899.csv')\n        log(f'submission_public_0899.csv = exact no-jitter public-frontier rank mean of {len(public_frontier_members)} member(s); {frontier_sub.shape}; nulls {int(frontier_sub[TARGETS].isna().sum().sum())}')\n        fold_ids, fold_frontier, fold_diagnostics = combine_public_members_by_fold(public_frontier_members, 'pred')\n        soft_ids, fold_soft, _ = combine_public_members_by_fold(public_frontier_members, 'soft_pred')\n        if fold_ids != soft_ids:\n            raise WeightsError('legacy hard/soft study order mismatch')\n        legacy_prediction = blend_legacy_frontier_and_soft(fold_frontier, fold_soft)\n        legacy_sub = write_submission(legacy_prediction, fold_ids, test_df, 'submission_legacy_fold_blend.csv')\n        fold_diagnostics.to_csv('legacy_fold_diagnostics.csv', index=False)\n        log(f'legacy DINO aggregation written from five folds; {legacy_sub.shape}')\n    else:\n        log(f'public-frontier fallback not emitted: {len(public_frontier_members)} / {len(members)} required public members completed')\n    return sub\n\ndef adopt_config_globals(cfg):\n    global IMG, CACHE_IMG, GROUP, CACHE_SLICES, N_GROUP, CROP_MM, SLICE_BAND, RULES\n    CACHE_IMG = IMG = int(cfg['img'])\n    GROUP = int(cfg['group'])\n    CACHE_SLICES = int(cfg['slices'])\n    N_GROUP = max(CACHE_SLICES // GROUP, 1)\n    CROP_MM = float(cfg['crop_mm'])\n    SLICE_BAND = tuple((float(x) for x in cfg['band']))\n    rules = cfg.get('rules') or RULES_NATIVE\n    unknown = {k: v for k, v in rules.items() if k not in RULES_NATIVE or v not in (RULES_NATIVE[k], RULES_LEGACY[k])}\n    if unknown:\n        raise WeightsError(f'the members record pixel rules this pipeline cannot reproduce: {unknown}')\n    RULES = {**RULES_NATIVE, **rules}\n    if [s[0] for s in SLOTS] != list(cfg['slots']):\n        raise WeightsError(f\"the members were fitted on slots {cfg['slots']} and this pipeline defines {[s[0] for s in SLOTS]}; a weight would be read against the wrong slot\")\n\ndef augment(imgs, generator=None):\n    lead = imgs.shape[:-3]\n    x = imgs.reshape(-1, *imgs.shape[-3:]).float()\n    n, dev = (x.shape[0], x.device)\n    rot = (torch.rand(n, device=dev, generator=generator) - 0.5) * 2 * (AUG_ROT_DEG * np.pi / 180)\n    sc = 1.0 + torch.rand(n, device=dev, generator=generator) * AUG_SCALE\n    tx = (torch.rand(n, device=dev, generator=generator) - 0.5) * 2 * AUG_SHIFT\n    ty = (torch.rand(n, device=dev, generator=generator) - 0.5) * 2 * AUG_SHIFT\n    cos, sin = (torch.cos(rot) / sc, torch.sin(rot) / sc)\n    theta = torch.zeros(n, 2, 3, device=dev, dtype=torch.float32)\n    theta[:, 0, 0], theta[:, 0, 1], theta[:, 0, 2] = (cos, -sin, tx)\n    theta[:, 1, 0], theta[:, 1, 1], theta[:, 1, 2] = (sin, cos, ty)\n    grid = F.affine_grid(theta, x.shape, align_corners=False)\n    x = F.grid_sample(x, grid, mode='bilinear', padding_mode='border', align_corners=False)\n    scale = 1.0 + (torch.rand(n, 1, 1, 1, device=dev, generator=generator) - 0.5) * 2 * AUG_INTENSITY\n    x = (x * scale).clamp(0, 255)\n    return x.reshape(*lead, *x.shape[-3:]).to(imgs.dtype)\n\ndef write_submission(pred, studies, test_df, path):\n    sub = pd.DataFrame(pd.DataFrame(pred).rank(pct=True).values, columns=TARGETS)\n    sub.insert(0, 'StudyInstanceUID', studies)\n    sub = test_df[['StudyInstanceUID']].merge(sub, on='StudyInstanceUID', how='left')\n    sub[TARGETS] = sub[TARGETS].fillna(0.5)\n    sub.to_csv(path, index=False)\n    return sub\n\ndef find_dinov2(variant='small'):\n    if not (DINO / 'config.json').is_file():\n        raise FileNotFoundError(DINO)\n    return DINO\n\ndef legacy_group_members():\n    return {}\n\ndef run_dinov2():\n    global V8_D2_WEIGHTED_FRAME, V8_D2_SOFT_FRAME, V8_D2_PUBLIC_FRAME\n\n    path = ASSET / 'rsna-knee-weights'\n    infer_from_package(path, DEVS[0])\n\n    work = Path('/kaggle/working')\n    weighted_path = work / 'submission.csv'\n    public_path = work / 'submission_public_0899.csv'\n    soft_path = work / 'submission_legacy_fold_blend.csv'\n\n    if not public_path.is_file():\n        raise RuntimeError('public DINOv2 frontier was not produced')\n\n    V8_D2_WEIGHTED_FRAME = pd.read_csv(\n        weighted_path,\n        dtype={'StudyInstanceUID': str},\n    )\n    V8_D2_PUBLIC_FRAME = pd.read_csv(\n        public_path,\n        dtype={'StudyInstanceUID': str},\n    )\n\n    if soft_path.is_file():\n        V8_D2_SOFT_FRAME = pd.read_csv(\n            soft_path,\n            dtype={'StudyInstanceUID': str},\n        )\n    else:\n        V8_D2_SOFT_FRAME = V8_D2_PUBLIC_FRAME.copy()\n\n    if V15_USE_PUBLIC_FRONTIER:\n        # V13/V14 parity: the public-frontier variant becomes the shipped base.\n        public_path.replace(weighted_path)\n    else:\n        log('V15: keeping OOF-weighted DINO blend as submission base '\n            '(public-frontier variant retained only as an in-memory frame)')\n\n    for name in (\n        'submission_legacy_fold_blend.csv',\n        'legacy_fold_diagnostics.csv',\n    ):\n        candidate = work / name\n        if candidate.is_file():\n            candidate.unlink()\n\nrun_dinov2()","metadata":{"execution":{"iopub.status.busy":"2026-08-22T08:46:49.601849Z","iopub.execute_input":"2026-08-22T08:46:49.602413Z","iopub.status.idle":"2026-08-22T08:47:50.843765Z","shell.execute_reply.started":"2026-08-22T08:46:49.602371Z","shell.execute_reply":"2026-08-22T08:47:50.842874Z"},"papermill":{"duration":72.955289,"end_time":"2026-08-20T11:31:40.350779+00:00","exception":false,"start_time":"2026-08-20T11:30:27.39549+00:00","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"fb719d0d","cell_type":"markdown","source":"## Stage 2 — 16-slice / six-slot image model family\n\nThis stage is preserved from V13 to avoid changing a working prediction source while the V14 refactor focuses on duplicated preprocessing and auditable ensembling.\n","metadata":{"papermill":{"duration":0.029872,"end_time":"2026-08-20T11:31:40.410619+00:00","exception":false,"start_time":"2026-08-20T11:31:40.380747+00:00","status":"completed"},"tags":[]}},{"id":"396621e4","cell_type":"code","source":"_A5_SAVED = dict(globals())\nimport gc, os, time, warnings\nfrom concurrent.futures import ProcessPoolExecutor, as_completed\nfrom pathlib import Path\nimport cv2\nimport numpy as np\nimport pandas as pd\nimport pydicom\nimport timm\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nwarnings.filterwarnings('ignore')\ncv2.setNumThreads(1)\nCROP_MM = 130.0\nSIZE = 336\nSLICE_BAND = (0.12, 0.88)\nN_SLICE = 16\nINTENSITY = 'slice'\nSLOTS = [('Sagittal', 1), ('Sagittal', 0), ('Coronal', 1), ('Coronal', 0), ('Axial', 1), ('Axial', 0)]\nN_SLOT = len(SLOTS)\nLABELS = ['ACL', 'MCL', 'Medial Meniscus', 'Lateral Meniscus', 'Medial OA', 'Lateral OA', 'PF OA', 'Effusion', 'Synovitis', \"Baker's\", 'Contusion', 'Fracture']\nCOMP = Path('/kaggle/input/competitions/rsna-knee-abnormality-detection')\nCKPT = ASSET / 'knee-mri-fold-weights'\nDEV = 'cuda' if torch.cuda.is_available() else 'cpu'\nprint(f'competition : {COMP}')\nprint(f'checkpoints : {CKPT}')\nprint(f'device      : {DEV}')\nfor i in range(torch.cuda.device_count() if DEV == 'cuda' else 0):\n    cc = torch.cuda.get_device_capability(i)\n    print(f'  gpu{i}       : {torch.cuda.get_device_name(i)} sm_{cc[0]}{cc[1]}, {torch.cuda.get_device_properties(i).total_memory / 2 ** 30:.0f} GiB, native bf16={cc >= (8, 0)}')\nSERIES_ROOT = COMP / 'test_series'\nif not SERIES_ROOT.exists():\n    SERIES_ROOT = COMP / 'train_series'\nprint('series root:', SERIES_ROOT)\n\ndef ordered_files(sdir, cap=64):\n    keyed = []\n    for f in sdir.glob('*.dcm'):\n        try:\n            ds = pydicom.dcmread(str(f), stop_before_pixels=True)\n            keyed.append((int(ds.InstanceNumber), str(f)))\n        except Exception:\n            continue\n        if len(keyed) >= cap * 4:\n            break\n    return [f for _, f in sorted(keyed)]\n\ndef series_side(path):\n    try:\n        return float(pydicom.dcmread(path, stop_before_pixels=True).ImagePositionPatient[0])\n    except Exception:\n        return 0.0\n\ndef read_crop(path):\n    try:\n        ds = pydicom.dcmread(path)\n        arr = ds.pixel_array.astype(np.float32)\n    except Exception:\n        return None\n    try:\n        ps = float(ds.PixelSpacing[0])\n    except Exception:\n        ps = CROP_MM / max(arr.shape)\n    half = int(round(CROP_MM / ps / 2))\n    cy, cx = (arr.shape[0] // 2, arr.shape[1] // 2)\n    y0, y1 = (max(0, cy - half), min(arr.shape[0], cy + half))\n    x0, x1 = (max(0, cx - half), min(arr.shape[1], cx + half))\n    crop = arr[y0:y1, x0:x1]\n    return None if crop.size == 0 else crop\n\ndef window(crop, lo, hi, flip):\n    c = np.clip((crop - lo) / max(hi - lo, 1e-06), 0, 1)\n    img = cv2.resize(c, (SIZE, SIZE), interpolation=cv2.INTER_AREA)\n    return img[:, ::-1].copy() if flip else img\n\ndef render(path, flip):\n    crop = read_crop(path)\n    if crop is None:\n        return None\n    lo, hi = np.percentile(crop[::4, ::4], [1, 99])\n    return window(crop, lo, hi, flip)\n\ndef build_study(args):\n    idx, study, recs = args\n    out = np.zeros((N_SLOT, N_SLICE, SIZE, SIZE), np.uint8)\n    mask = np.zeros(N_SLOT, np.uint8)\n    rows = pd.DataFrame(recs)\n    if len(rows):\n        for s_i, (plane, fs) in enumerate(SLOTS):\n            sub = rows[(rows.Anatomical_Plane == plane) & (rows.Fat_Suppression == fs)]\n            if sub.empty:\n                continue\n            files = ordered_files(SERIES_ROOT / study / sub.iloc[0].SeriesInstanceUID)\n            if not files:\n                continue\n            flip = plane != 'Sagittal' and series_side(files[0]) < 0\n            lo, hi = SLICE_BAND\n            i0 = int(round(lo * (len(files) - 1)))\n            i1 = int(round(hi * (len(files) - 1)))\n            avail = list(range(i0, i1 + 1))\n            if len(avail) >= N_SLICE:\n                picks = [avail[int(round(t))] for t in np.linspace(0, len(avail) - 1, N_SLICE)]\n                off = 0\n            else:\n                picks, off = (avail, (N_SLICE - len(avail)) // 2)\n            if INTENSITY == 'series':\n                crops = [read_crop(files[p]) for p in picks]\n                got = [x for x in crops if x is not None]\n                if got:\n                    samp = np.concatenate([x[::4, ::4].ravel() for x in got])\n                    lo_, hi_ = np.percentile(samp, [1, 99])\n                    for c, x in enumerate(crops):\n                        if x is None:\n                            x = read_crop(files[min(len(files) - 1, picks[c] + 1)])\n                        if x is not None:\n                            out[s_i, off + c] = (window(x, lo_, hi_, flip) * 255).astype(np.uint8)\n            else:\n                for c, p in enumerate(picks):\n                    img = render(files[p], flip)\n                    if img is None:\n                        img = render(files[min(len(files) - 1, p + 1)], flip)\n                    if img is not None:\n                        out[s_i, off + c] = (img * 255).astype(np.uint8)\n            mask[s_i] = len(picks)\n    return (idx, out, mask)\nsub_df = pd.read_csv(COMP / 'sample_submission.csv')\nser_csv = pd.read_csv(COMP / 'test_series.csv')\nif not (COMP / 'test_series').exists():\n    ser_csv = pd.read_csv(COMP / 'train_series.csv')\nser_csv = ser_csv.loc[:, ~ser_csv.columns.duplicated()]\nstudies = sub_df.StudyInstanceUID.tolist()\nby = {s: g.to_dict('records') for s, g in ser_csv[ser_csv.StudyInstanceUID.isin(set(studies))].groupby('StudyInstanceUID')}\nprint(f'{len(studies):,} test studies, {len(by):,} with series metadata')\nN_SLOT_TYPES, MASK_IDX = (6, 0)\n\ndef segment_softmax(scores, sidx, B):\n    T, K = scores.shape\n    idx = sidx.unsqueeze(1).expand(-1, K)\n    m = torch.full((B, K), float('-inf'), device=scores.device, dtype=scores.dtype)\n    m = m.scatter_reduce(0, idx, scores, reduce='amax', include_self=True)\n    e = (scores - m[sidx]).exp()\n    s = torch.zeros(B, K, device=scores.device, dtype=scores.dtype).index_add_(0, sidx, e)\n    return e / s[sidx].clamp(min=1e-06)\n\nclass MeanMaxPool(nn.Module):\n\n    def forward(self, f, sidx, B, slot=None, return_attn=False):\n        D = f.shape[1]\n        cnt = torch.zeros(B, device=f.device, dtype=f.dtype).index_add_(0, sidx, torch.ones(f.shape[0], device=f.device, dtype=f.dtype))\n        mean = torch.zeros(B, D, device=f.device, dtype=f.dtype).index_add_(0, sidx, f)\n        mean = mean / cnt.clamp(min=1).unsqueeze(1)\n        mx = torch.full((B, D), -10000.0, device=f.device, dtype=f.dtype)\n        mx = mx.scatter_reduce(0, sidx.unsqueeze(1).expand(-1, D), f, reduce='amax', include_self=True)\n        return (torch.cat([mean, mx], 1), None)\n\nclass LabelAttentionPool(nn.Module):\n\n    def __init__(self, d, n_labels=12, n_heads=4, slot_bias=True):\n        super().__init__()\n        self.d, self.k, self.h = (d, n_labels, n_heads)\n        self.q = nn.Parameter(torch.randn(n_labels, d) * 0.02)\n        self.key, self.val = (nn.Linear(d, d), nn.Linear(d, d))\n        self.slot_bias = nn.Parameter(torch.zeros(n_labels, N_SLOT_TYPES + 1)) if slot_bias else None\n\n    def forward(self, f, sidx, B, slot=None, return_attn=False):\n        scores = self.key(f) @ self.q.t() / self.d ** 0.5\n        if self.slot_bias is not None and slot is not None:\n            scores = scores + self.slot_bias.t()[slot]\n        a = segment_softmax(scores, sidx, B)\n        out = torch.zeros(B, self.k, self.d, device=f.device, dtype=f.dtype)\n        out = out.index_add_(0, sidx, a.unsqueeze(-1) * self.val(f).unsqueeze(1))\n        return (out, a)\n\nclass TokenXAttnPool(nn.Module):\n\n    def __init__(self, d, n_labels=12, n_heads=6, dropout=0.2):\n        super().__init__()\n        self.d, self.k = (d, n_labels)\n        self.q = nn.Parameter(torch.randn(n_labels, d) * 0.02)\n        self.slot_emb = nn.Embedding(N_SLOT_TYPES + 1, d, padding_idx=0)\n        self.kv_norm = nn.LayerNorm(d)\n        self.attn = nn.MultiheadAttention(d, n_heads, dropout=dropout, batch_first=True)\n\n    def forward(self, tok, sidx, B, slot=None, return_attn=False):\n        T, N, D = tok.shape\n        cnt = torch.bincount(sidx, minlength=B)\n        S = int(cnt.max().item())\n        starts = torch.cumsum(cnt, 0) - cnt\n        pos = torch.arange(T, device=tok.device) - starts[sidx]\n        kv = tok + self.slot_emb(slot).unsqueeze(1)\n        pad = tok.new_zeros(B, S, N, D)\n        pad[sidx, pos] = kv\n        keep = torch.zeros(B, S, dtype=torch.bool, device=tok.device)\n        keep[sidx, pos] = True\n        kpm = ~keep.repeat_interleave(N, dim=1)\n        pad = self.kv_norm(pad.reshape(B, S * N, D))\n        q = self.q.unsqueeze(0).expand(B, -1, -1)\n        att, w = self.attn(q, pad, pad, key_padding_mask=kpm, need_weights=return_attn, average_attn_weights=True)\n        cls = tok[:, 0]\n        mean = torch.zeros(B, D, device=tok.device, dtype=tok.dtype).index_add_(0, sidx, cls) / cnt.clamp(min=1).unsqueeze(1)\n        mx = torch.full((B, D), -10000.0, device=tok.device, dtype=tok.dtype)\n        mx = mx.scatter_reduce(0, sidx.unsqueeze(1).expand(-1, D), cls, reduce='amax', include_self=True)\n        base = torch.cat([mean, mx], 1).unsqueeze(1).expand(-1, self.k, -1)\n        return (torch.cat([att, base], -1), w)\n\nclass ViTSlotToken(nn.Module):\n\n    def __init__(self, vit, n_cat, dim=None):\n        super().__init__()\n        self.vit = vit\n        d = dim or vit.embed_dim\n        self.tok = nn.Embedding(n_cat + 1, d, padding_idx=MASK_IDX)\n        self.num_features = vit.num_features\n        self._orig_prefix = getattr(vit, 'num_prefix_tokens', 1)\n        vit.num_prefix_tokens = self._orig_prefix + 1\n        for blk in vit.blocks:\n            a = getattr(blk, 'attn', None)\n            if a is not None and hasattr(a, 'num_prefix_tokens'):\n                a.num_prefix_tokens = a.num_prefix_tokens + 1\n\n    @staticmethod\n    def _maybe(mod, x):\n        return x if mod is None else mod(x)\n\n    def forward_features(self, x, cat):\n        v = self.vit\n        x = v.patch_embed(x)\n        pos = v._pos_embed(x)\n        rope = None\n        if isinstance(pos, tuple):\n            x, rope = pos\n        else:\n            x = pos\n        x = self._maybe(getattr(v, 'patch_drop', None), x)\n        x = self._maybe(getattr(v, 'norm_pre', None), x)\n        npt = self._orig_prefix\n        tok = self.tok(cat).unsqueeze(1)\n        x = torch.cat([x[:, :npt], tok, x[:, npt:]], dim=1)\n        if rope is not None:\n            if getattr(v, 'rope_mixed', False):\n                for i, blk in enumerate(v.blocks):\n                    x = blk(x, rope=rope[i])\n            else:\n                for blk in v.blocks:\n                    x = blk(x, rope=rope)\n        else:\n            x = v.blocks(x)\n        return v.norm(x)\n\n    def forward_head(self, x, pre_logits=True):\n        return self.vit.forward_head(x, pre_logits=pre_logits)\nIMAGENET_MEAN = (0.485, 0.456, 0.406)\nIMAGENET_STD = (0.229, 0.224, 0.225)\n\nclass _GatedDepthBlock(nn.Module):\n\n    def __init__(self, n_slice, dropout=0.0, ls_init=0.1):\n        super().__init__()\n        self.norm = nn.GroupNorm(1, n_slice)\n        self.v = nn.Conv2d(n_slice, n_slice, 1)\n        self.g = nn.Conv2d(n_slice, n_slice, 1)\n        self.out = nn.Conv2d(n_slice, n_slice, 1)\n        self.gamma = nn.Parameter(torch.full((n_slice, 1, 1), ls_init))\n        self.drop = nn.Dropout2d(dropout) if dropout else nn.Identity()\n\n    def forward(self, x):\n        z = self.norm(x)\n        return x + self.gamma * self.drop(self.out(self.v(z) * F.silu(self.g(z))))\n\nclass DepthCompress(nn.Module):\n\n    def __init__(self, n_slice=16, out_ch=3, depth=1, dropout=0.0, ls_init=0.1, imagenet=True, proj_noise=0.25):\n        super().__init__()\n        self.imagenet = imagenet\n        self.blocks = nn.ModuleList([_GatedDepthBlock(n_slice, dropout, ls_init) for _ in range(depth)])\n        self.proj = nn.Conv2d(n_slice, out_ch, 1, bias=True)\n        if imagenet:\n            self.register_buffer('mu', torch.tensor(IMAGENET_MEAN).view(1, -1, 1, 1))\n            self.register_buffer('sd', torch.tensor(IMAGENET_STD).view(1, -1, 1, 1))\n\n    def forward(self, x):\n        keep = (x.amax(dim=1, keepdim=True) > 0).to(x.dtype)\n        z = x\n        for b in self.blocks:\n            z = b(z)\n        z = self.proj(z)\n        if self.imagenet:\n            z = (z - self.mu.to(z.dtype)) / self.sd.to(z.dtype)\n        return z * keep\nN_PLANE, N_CONTRAST = (3, 2)\n_PLANE_OF = lambda s: torch.clamp(s - 1, 0, 5) // 2\n_CONTRAST_OF = lambda s: torch.clamp(s - 1, 0, 5) % 2\n\nclass SlotDepthMixer(nn.Module):\n\n    def __init__(self, n_slice=16, ksize=5, alpha_max=0.25):\n        super().__init__()\n        self.n_slice, self.ksize, self.r = (n_slice, ksize, ksize // 2)\n        self.alpha_max = alpha_max\n        b = torch.tensor([1.0, 4.0, 6.0, 4.0, 1.0])\n        self.register_buffer('base', b.log()[self.r:])\n        n_u = self.r + 1\n        self.shared = nn.Parameter(torch.zeros(n_u))\n        self.plane_k = nn.Parameter(torch.zeros(N_PLANE, n_u))\n        self.contrast_k = nn.Parameter(torch.zeros(N_CONTRAST, n_u))\n        self.g0 = nn.Parameter(torch.zeros(()))\n        self.gate_p = nn.Parameter(torch.zeros(N_PLANE))\n        self.gate_c = nn.Parameter(torch.zeros(N_CONTRAST))\n        idx = torch.arange(n_slice)\n        self.register_buffer('off', idx[None, :] - idx[:, None])\n\n    def kernel(self, slot):\n        p, c = (_PLANE_OF(slot), _CONTRAST_OF(slot))\n        half = self.base + self.shared + self.plane_k[p] + self.contrast_k[c]\n        full = torch.cat([half.flip(-1)[..., :self.r], half], dim=-1)\n        return F.softmax(full, dim=-1)\n\n    def alpha(self, slot):\n        p, c = (_PLANE_OF(slot), _CONTRAST_OF(slot))\n        return self.alpha_max * torch.tanh(self.g0 + self.gate_p[p] + self.gate_c[c])\n\n    def forward(self, x, slot, vmask):\n        T, S, H, W = x.shape\n        if vmask is None:\n            raise ValueError('stem=mixer requires the padding mask')\n        k = self.kernel(slot)\n        v = vmask.to(k.dtype)\n        d = self.off + self.r\n        inb = (d >= 0) & (d < self.ksize)\n        kk = k[:, d.clamp(0, self.ksize - 1)] * inb\n        M = kk * v[:, None, :]\n        den = M.sum(-1, keepdim=True)\n        eye = torch.eye(S, device=x.device, dtype=M.dtype).expand(T, S, S)\n        ok = (den > 1e-06) & v[:, :, None].bool()\n        M = torch.where(ok, M / den.clamp(min=1e-06), eye)\n        a = self.alpha(slot)[:, None, None]\n        Aop = ((1.0 - a) * eye + a * M).to(x.dtype)\n        if x.is_contiguous(memory_format=torch.channels_last) and (not x.is_contiguous()):\n            y = torch.bmm(x.permute(0, 2, 3, 1).reshape(T, H * W, S), Aop.transpose(1, 2))\n            return y.reshape(T, H, W, S).permute(0, 3, 1, 2)\n        return torch.bmm(Aop, x.reshape(T, S, H * W)).reshape(T, S, H, W)\n\ndef _seg_mean_max(v, sidx, B):\n    D = v.shape[1]\n    cnt = torch.zeros(B, device=v.device, dtype=v.dtype).index_add_(0, sidx, torch.ones(v.shape[0], device=v.device, dtype=v.dtype))\n    mean = torch.zeros(B, D, device=v.device, dtype=v.dtype).index_add_(0, sidx, v)\n    mean = mean / cnt.clamp(min=1).unsqueeze(1)\n    mx = torch.full((B, D), -10000.0, device=v.device, dtype=v.dtype)\n    mx = mx.scatter_reduce(0, sidx.unsqueeze(1).expand(-1, D), v, reduce='amax', include_self=True)\n    return torch.cat([mean, mx], 1)\n\ndef _pad_kv(x, sidx, B, norm):\n    T, P, D = x.shape\n    cnt = torch.bincount(sidx, minlength=B)\n    S = int(cnt.max().item())\n    starts = torch.cumsum(cnt, 0) - cnt\n    pos = torch.arange(T, device=x.device) - starts[sidx]\n    pad = x.new_zeros(B, S, P, D)\n    pad[sidx, pos] = x\n    keep = torch.zeros(B, S, dtype=torch.bool, device=x.device)\n    keep[sidx, pos] = True\n    return (norm(pad.reshape(B, S * P, D)), ~keep.repeat_interleave(P, dim=1))\n\nclass _GatedDelta(nn.Module):\n\n    def __init__(self, d, n_labels, n_heads, dropout):\n        super().__init__()\n        self.q = nn.Parameter(torch.randn(n_labels, d) * 0.02)\n        self.kv_norm = nn.LayerNorm(d)\n        self.attn = nn.MultiheadAttention(d, n_heads, dropout=dropout, batch_first=True)\n        self.d_norm = nn.LayerNorm(d)\n        self.dw = nn.Parameter(torch.randn(n_labels, d) * (1.0 / d ** 0.5))\n        self.db = nn.Parameter(torch.zeros(n_labels))\n        self.gate = nn.Parameter(torch.zeros(n_labels))\n\n    def delta(self, pat, sidx, B, return_attn):\n        kv, kpm = _pad_kv(pat, sidx, B, self.kv_norm)\n        q = self.q.unsqueeze(0).expand(B, -1, -1)\n        att, w = self.attn(q, kv, kv, key_padding_mask=kpm, need_weights=return_attn, average_attn_weights=True)\n        return ((self.d_norm(att) * self.dw).sum(-1) + self.db, w)\n\nclass TokenResidualPool(_GatedDelta):\n\n    def __init__(self, d, n_labels=12, n_heads=6, pe=64, dropout=0.2):\n        super().__init__(d, n_labels, n_heads, dropout)\n        self.base = nn.Sequential(nn.LayerNorm(2 * d + pe), nn.Dropout(dropout), nn.Linear(2 * d + pe, n_labels))\n\n    def forward(self, tok, slot, sidx, B, pres, return_attn=False):\n        base = self.base(torch.cat([_seg_mean_max(tok[:, 1:].mean(1), sidx, B), pres], 1))\n        d_, w = self.delta(tok[:, 1:], sidx, B, return_attn)\n        return (base + self.gate * d_, w)\n\nclass CodexResidualPool(_GatedDelta):\n\n    def __init__(self, d, n_labels=12, n_heads=6, pe=64, dropout=0.2):\n        super().__init__(d, n_labels, n_heads, dropout)\n        self.base = nn.Sequential(nn.LayerNorm(2 * d + pe), nn.Dropout(dropout), nn.Linear(2 * d + pe, n_labels))\n\n    def forward(self, tok, slot, sidx, B, pres, return_attn=False):\n        base = self.base(torch.cat([_seg_mean_max(tok[:, 0], sidx, B), pres], 1))\n        d_, w = self.delta(tok[:, 1:], sidx, B, return_attn)\n        return (base + self.gate * d_, w)\n\nclass ClsAddPool(nn.Module):\n\n    def __init__(self, d, n_labels=12, pe=64, dropout=0.2):\n        super().__init__()\n        self.net = nn.Sequential(nn.LayerNorm(4 * d + pe), nn.Dropout(dropout), nn.Linear(4 * d + pe, n_labels))\n\n    def forward(self, tok, slot, sidx, B, pres, return_attn=False):\n        return (self.net(torch.cat([_seg_mean_max(tok[:, 1:].mean(1), sidx, B), _seg_mean_max(tok[:, 0], sidx, B), pres], 1)), None)\n\nclass Readout(nn.Module):\n\n    def __init__(self, pool, d, n_labels=12, pe=64):\n        super().__init__()\n        self.pool_kind, self.k = (pool, n_labels)\n        self.pres_emb = nn.Embedding(N_SLOT_TYPES + 1, pe, padding_idx=0)\n        if pool in ('xres', 'clsadd', 'xcodex'):\n            self.pool = {'xres': TokenResidualPool, 'clsadd': ClsAddPool, 'xcodex': CodexResidualPool}[pool](d, n_labels, pe=pe)\n        elif pool in ('attn', 'xattn'):\n            if pool == 'xattn':\n                self.pool = TokenXAttnPool(d, n_labels)\n                wd = 3 * d + pe\n            else:\n                self.pool = LabelAttentionPool(d, n_labels)\n                wd = d + pe\n            self.norm = nn.LayerNorm(wd)\n            self.w = nn.Parameter(torch.randn(n_labels, wd) * (1.0 / wd ** 0.5))\n            self.b = nn.Parameter(torch.zeros(n_labels))\n        else:\n            self.pool = MeanMaxPool()\n            self.net = nn.Sequential(nn.LayerNorm(2 * d + pe), nn.Dropout(0.2), nn.Linear(2 * d + pe, n_labels))\n        self.drop = nn.Dropout(0.2)\n\n    def forward(self, f, slot, sidx, B, return_attn=False):\n        pe = self.pres_emb(slot)\n        pres = torch.zeros(B, pe.shape[1], device=f.device, dtype=f.dtype).index_add_(0, sidx, pe)\n        if self.pool_kind in ('xres', 'clsadd', 'xcodex'):\n            return self.pool(f, slot, sidx, B, pres)[0]\n        pooled, attn = self.pool(f, sidx, B, slot=slot, return_attn=return_attn)\n        if self.pool_kind in ('attn', 'xattn'):\n            x = torch.cat([pooled, pres.unsqueeze(1).expand(-1, self.k, -1)], -1)\n            x = self.drop(self.norm(x))\n            return (x * self.w).sum(-1) + self.b\n        return self.net(torch.cat([pooled, pres], 1))\n\nclass Net(nn.Module):\n\n    def __init__(self, enc, cond, n_meta=0, pool='mean_max', stem='native', n_slice=16):\n        super().__init__()\n        self.enc, self.cond = (enc, cond)\n        self.compress = DepthCompress(n_slice, 3) if stem == 'compress' else None\n        self.mixer = SlotDepthMixer(n_slice) if stem == 'mixer' else None\n        self.tokens = pool in ('xattn', 'xres', 'clsadd', 'xcodex')\n        D = enc.num_features\n        self.meta_mlp = nn.Sequential(nn.LayerNorm(n_meta), nn.Linear(n_meta, 128), nn.GELU(), nn.Linear(128, D)) if n_meta > 0 else None\n        self.readout = Readout(pool, D)\n        if cond == 'post':\n            self.slot_emb = nn.Embedding(N_SLOT_TYPES + 1, D, padding_idx=MASK_IDX)\n\n    def forward(self, im, slot, smeta, sidx, B, vm=None):\n        if self.mixer is not None:\n            im = self.mixer(im, slot, vm)\n        if self.compress is not None:\n            im = self.compress(im)\n        f = self.enc.forward_features(im, slot) if self.cond == 'token' else self.enc.forward_features(im)\n        if self.tokens:\n            inner = getattr(self.enc, 'vit', self.enc)\n            orig = getattr(self.enc, '_orig_prefix', getattr(inner, 'num_prefix_tokens', 1))\n            f = torch.cat([f[:, :1], f[:, orig:]], 1)\n        else:\n            f = self.enc.forward_head(f, pre_logits=True)\n            if f.dim() > 2:\n                f = f.flatten(1)\n        ex = (lambda v: v.unsqueeze(1)) if self.tokens else lambda v: v\n        if self.cond == 'post':\n            f = f + ex(self.slot_emb(slot))\n        if self.meta_mlp is not None and smeta.shape[1] > 0:\n            mt = self.meta_mlp(smeta)\n            f = torch.cat([f, mt.unsqueeze(1)], 1) if self.tokens else f + mt\n        return self.readout(f, slot, sidx, B)\nmodels = []\nfor ckpt_path in sorted(CKPT.glob('*_f*.pt')):\n    z = torch.load(ckpt_path, map_location='cpu', weights_only=False)\n    cfg = z['cfg']\n    _stem = cfg.get('stem', 'native')\n    _in = 3 if _stem == 'compress' else cfg.get('n_slice', 16)\n    enc = timm.create_model(cfg['backbone'], pretrained=False, num_classes=0, in_chans=_in, **{'img_size': cfg['img']} if 'vit_' in cfg['backbone'] else {})\n    if cfg['cond'] == 'token':\n        enc = ViTSlotToken(enc, N_SLOT_TYPES)\n    m = Net(enc, cfg['cond'], cfg.get('n_meta', 0), cfg['pool'], stem=_stem, n_slice=cfg.get('n_slice', 16))\n    missing, unexpected = m.load_state_dict(z['state_dict'], strict=False)\n    assert not missing, f'missing {missing[:5]}'\n    assert not unexpected, f'unexpected {unexpected[:5]}'\n    models.append(m.eval())\n    print(f\"loaded {ckpt_path.name}  fold {z['fold']}  {cfg['backbone']} pool={cfg['pool']} meta={cfg['meta']}\")\nCFG = cfg\nassert CFG.get('n_meta', 0) == 0, f\"checkpoint expects {CFG['n_meta']} metadata features -- build slot_meta for the TEST studies and pass it to predict() before submitting\"\nprint(f\"\\n{len(models)} fold models ready | input norm: {CFG.get('norm', 'none')}\")\nAMP_PREF = 'bf16'\n\ndef amp_for(dev):\n    if not str(dev).startswith('cuda'):\n        return (torch.float32, False)\n    cc = torch.cuda.get_device_capability(dev)\n    if AMP_PREF == 'bf16':\n        return (torch.bfloat16, True)\n    if AMP_PREF == 'fp16':\n        return (torch.float16, True)\n    if AMP_PREF == 'fp32':\n        return (torch.float32, False)\n    return (torch.bfloat16 if cc >= (8, 0) else torch.float16, True)\nAMP_DT, AMP_ON = amp_for(DEV)\nWORKERS = max(1, min(4, os.cpu_count() or 4))\nCHUNK = 48\nMICRO = 8\nmodels = [m.to(DEV).eval() for m in models]\nprint(f\"device {DEV} | amp {str(AMP_DT).split('.')[-1]} (on={AMP_ON}) | workers {WORKERS} | chunk {CHUNK} | micro {MICRO}\")\n\ndef _norm_(im):\n    k = CFG.get('norm', 'none')\n    if k == 'zscore':\n        m = (im > 0).float()\n        n = m.sum(dim=(1, 2, 3), keepdim=True).clamp(min=1.0)\n        mu = (im * m).sum(dim=(1, 2, 3), keepdim=True) / n\n        var = (((im - mu) * m) ** 2).sum(dim=(1, 2, 3), keepdim=True) / n\n        return (im - mu) / (var.sqrt() + 1e-06) * m\n    if k == 'imagenet':\n        m = (im > 0).float()\n        return (im - 0.485) / 0.229 * m\n    return im\n\n@torch.no_grad()\ndef _micro(images, masks):\n    dev = DEV\n    ims, slots, sidx, vms = ([], [], [], [])\n    for b in range(len(masks)):\n        present = np.nonzero(masks[b] > 0)[0]\n        if len(present) == 0:\n            continue\n        blk = images[b][present]\n        ims.append(torch.from_numpy(blk))\n        vms.append(torch.from_numpy(blk.reshape(blk.shape[0], blk.shape[1], -1).max(2) > 0))\n        slots.append(torch.from_numpy(present + 1).long())\n        sidx.append(torch.full((len(present),), b, dtype=torch.long))\n    out = np.full((len(models), len(masks), len(LABELS)), np.nan, np.float32)\n    if not ims:\n        return out\n    im = _norm_(torch.cat(ims).to(dev, non_blocking=True).float().div_(255.0))\n    sl = torch.cat(slots).to(dev)\n    si = torch.cat(sidx).to(dev)\n    vm = torch.cat(vms).to(dev)\n    sm = torch.zeros(len(sl), CFG.get('n_meta', 0), device=dev)\n    per = torch.zeros(len(models), len(masks), len(LABELS), device=dev, dtype=torch.float32)\n    with torch.autocast('cuda' if str(dev).startswith('cuda') else 'cpu', dtype=AMP_DT, enabled=AMP_ON):\n        for fold_index, model in enumerate(models):\n            per[fold_index] = torch.sigmoid(model(im, sl, sm, si, len(masks), vm=vm).float())\n    got = per.cpu().numpy()\n    keep = np.array([(masks[b] > 0).any() for b in range(len(masks))])\n    out[:, keep] = got[:, keep]\n    return out\n\ndef predict(images, masks):\n    out = np.full((len(models), len(masks), len(LABELS)), np.nan, np.float32)\n    for a in range(0, len(masks), MICRO):\n        b = min(a + MICRO, len(masks))\n        out[:, a:b] = _micro(images[a:b], masks[a:b])\n    return out\npreds = np.full((len(models), len(studies), len(LABELS)), np.nan, np.float32)\nt0, done = (time.time(), 0)\nwith ProcessPoolExecutor(max_workers=WORKERS) as ex:\n    for c0 in range(0, len(studies), CHUNK):\n        block = studies[c0:c0 + CHUNK]\n        imgs = np.zeros((len(block), N_SLOT, N_SLICE, SIZE, SIZE), np.uint8)\n        msks = np.zeros((len(block), N_SLOT), np.uint8)\n        futs = [ex.submit(build_study, (i, s, by.get(s, []))) for i, s in enumerate(block)]\n        for f in as_completed(futs):\n            try:\n                i, a, k = f.result()\n                imgs[i], msks[i] = (a, k)\n            except Exception as e:\n                print(f'  study failed: {type(e).__name__}: {e}')\n        preds[:, c0:c0 + len(block)] = predict(imgs, msks)\n        done += len(block)\n        el = time.time() - t0\n        print(f'  {done:,}/{len(studies):,}  {el / 60:.1f}m  eta {el / done * (len(studies) - done) / 60:.1f}m', flush=True)\n        del imgs, msks\n        gc.collect()\nprint(f'\\ninference done in {(time.time() - t0) / 60:.1f} min')\nA5_W = 0.45\nA5_LABELS = list(LABELS)\n_a5_ok = np.isfinite(preds).all(axis=(0, 2))\n\n_a5_rank_mean = np.zeros((len(studies), len(LABELS)), np.float64)\n_v8_fold_ranks = []\n\nfor fold_index in range(preds.shape[0]):\n    fold = preds[fold_index][_a5_ok]\n    ordinal = fold.argsort(0).argsort(0).astype(np.float64)\n    rank = ordinal / max(len(fold) - 1, 1)\n    _a5_rank_mean[_a5_ok] += rank\n\n    full_rank = np.full(\n        (len(studies), len(LABELS)),\n        np.nan,\n        np.float64,\n    )\n    full_rank[_a5_ok] = rank\n    _v8_fold_ranks.append(full_rank)\n\n_a5_rank_mean /= preds.shape[0]\n_a5_rank_mean[~_a5_ok] = np.nan\n\n_v8_prob_mean = np.nanmean(preds, axis=0)\n_v8_prob_rank = np.full_like(_a5_rank_mean, np.nan, dtype=np.float64)\n\nif _a5_ok.any():\n    _v8_prob_rank[_a5_ok] = pd.DataFrame(\n        _v8_prob_mean[_a5_ok],\n        columns=A5_LABELS,\n    ).rank(\n        method='average',\n        pct=True,\n    ).to_numpy(np.float64)\n\n_v8_stack = np.stack(_v8_fold_ranks)\n_v8_stability = np.zeros(len(LABELS), np.float64)\n_v8_pairs = 0\n\nfor _i in range(len(_v8_stack)):\n    for _j in range(_i + 1, len(_v8_stack)):\n        for _t in range(len(LABELS)):\n            _x = _v8_stack[_i, _a5_ok, _t]\n            _y = _v8_stack[_j, _a5_ok, _t]\n            if len(_x) > 2 and np.std(_x) > 0 and np.std(_y) > 0:\n                _v8_stability[_t] += float(np.corrcoef(_x, _y)[0, 1])\n        _v8_pairs += 1\n\n_v8_stability /= max(_v8_pairs, 1)\n\nA5_PREDS = dict(\n    zip(\n        sub_df['StudyInstanceUID'].astype(str),\n        _a5_rank_mean.astype(np.float32),\n    )\n)\nV8_D3_PROB_PREDS = dict(\n    zip(\n        sub_df['StudyInstanceUID'].astype(str),\n        _v8_prob_rank.astype(np.float32),\n    )\n)\nV8_D3_STABILITY = _v8_stability.astype(np.float64)\n\nfor _a5k, _a5v in _A5_SAVED.items():\n    globals()[_a5k] = _a5v\ndel _A5_SAVED, _a5k, _a5v\n\n_a5_sub = pd.read_csv(\n    '/kaggle/working/submission.csv',\n    dtype={'StudyInstanceUID': str},\n)\nassert _a5_sub.columns.tolist()[1:] == A5_LABELS, 'submission schema drift'\n\nif A5_W > 0:\n    _ids = _a5_sub['StudyInstanceUID'].astype(str).tolist()\n\n    _a5_ours = np.stack([A5_PREDS[_u] for _u in _ids])\n    _a5_prob = np.stack([V8_D3_PROB_PREDS[_u] for _u in _ids])\n\n    _a5_base_rank = _a5_sub[A5_LABELS].rank(\n        method='average',\n        pct=True,\n    )\n    _a5_ours_rank = pd.DataFrame(\n        _a5_ours,\n        columns=A5_LABELS,\n        index=_a5_sub.index,\n    ).rank(\n        method='average',\n        pct=True,\n    )\n\n    V8_D2_PUBLIC_RANK = _a5_base_rank.to_numpy(np.float64)\n    V8_D3_FOLD_RANK = _a5_ours_rank.to_numpy(np.float64)\n    V8_D3_PROB_RANK = pd.DataFrame(\n        _a5_prob,\n        columns=A5_LABELS,\n        index=_a5_sub.index,\n    ).rank(\n        method='average',\n        pct=True,\n    ).to_numpy(np.float64)\n\n    def _v8_align_frame(frame):\n        aligned = _a5_sub[['StudyInstanceUID']].merge(\n            frame[['StudyInstanceUID'] + A5_LABELS],\n            on='StudyInstanceUID',\n            how='left',\n            validate='one_to_one',\n        )\n        values = aligned[A5_LABELS].rank(\n            method='average',\n            pct=True,\n        ).to_numpy(np.float64)\n        if not np.isfinite(values).all():\n            raise RuntimeError('V8 DINO alternative alignment failed')\n        return values\n\n    V8_D2_WEIGHTED_RANK = _v8_align_frame(V8_D2_WEIGHTED_FRAME)\n    V8_D2_SOFT_RANK = _v8_align_frame(V8_D2_SOFT_FRAME)\n\n    _a5_sub[A5_LABELS] = (\n        (1.0 - A5_W) * _a5_base_rank\n        + A5_W * _a5_ours_rank\n    )\n\n    assert np.isfinite(_a5_sub[A5_LABELS].to_numpy()).all()\n    _a5_sub.to_csv('/kaggle/working/submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2026-08-22T08:47:50.845498Z","iopub.execute_input":"2026-08-22T08:47:50.846181Z","iopub.status.idle":"2026-08-22T08:48:02.503709Z","shell.execute_reply.started":"2026-08-22T08:47:50.846138Z","shell.execute_reply":"2026-08-22T08:48:02.502677Z"},"papermill":{"duration":13.991347,"end_time":"2026-08-20T11:31:54.431743+00:00","exception":false,"start_time":"2026-08-20T11:31:40.440396+00:00","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"dbabcb3b","cell_type":"markdown","source":"## Stage 3A — RadImageNet encoder, heads, and V8 utilities","metadata":{"papermill":{"duration":0.029417,"end_time":"2026-08-20T11:31:54.490866+00:00","exception":false,"start_time":"2026-08-20T11:31:54.461449+00:00","status":"completed"},"tags":[]}},{"id":"c73294fa","cell_type":"code","source":"from __future__ import annotations\nimport contextlib as _rad_contextlib\nimport gc as _rad_gc\nimport hashlib as _rad_hashlib\nimport json as _rad_json\nimport os as _rad_os\nimport re as _rad_re\nimport time as _rad_time\nfrom concurrent.futures import ThreadPoolExecutor as _RadThreadPool\nfrom pathlib import Path as _RadPath\nimport numpy as _rad_np\nimport pandas as _rad_pd\nimport pydicom as _rad_pydicom\nimport torch as _rad_torch\nimport torch.nn as _rad_nn\nimport torch.nn.functional as _rad_F\nfrom torchvision.models import resnet50 as _rad_resnet50\n_RAD_LABELS = ['ACL', 'MCL', 'Medial Meniscus', 'Lateral Meniscus', 'Medial OA', 'Lateral OA', 'PF OA', 'Effusion', 'Synovitis', \"Baker's\", 'Contusion', 'Fracture']\n_RAD_ALPHA = 0.5\n_RAD_EXCLUDE = (\"Baker's\", 'Fracture')\n_RAD_REFERENCE_HEADS_SHA256 = '0f465649799ecfbccaac1767844639e7ced44e1bc9babde6e4bac7c5d9b89eaa'\n_RAD_ENCODER_SHA256 = '08629f7e7bd3e29b8ee9522ca3f65ce4d010a7ddf74f0ea3c7e3f3d0bbab0734'\n_RAD_E13_HEADS_SHA256 = 'ad9f19af73bfdf4e49263c0e45060dc3cb239e1195039b26dc8c0a3a6bcd1a8a'\n_RAD_E13_MEMBER_WEIGHT = 0.5\n_RAD_V48_SECOND_ALPHA = 0.15\n\n# V14 behavior switches.\n# Defaults preserve the V13/V11 scoring route while making expensive preprocessing reusable.\nV14_REUSE_TEST_HEADERS = True\nV14_ENABLE_HGB_CHALLENGER = _rad_os.environ.get('V14_ENABLE_HGB_CHALLENGER', '1') == '1'\n# V15 default: hand-tuned per-target prior nudges OFF. Set V14_USE_PASS2_PRIORS=1 for parity.\nV14_USE_PASS2_PRIORS = _rad_os.environ.get('V14_USE_PASS2_PRIORS', '0') == '1'\nV14_LOG_STAGE_TIMES = True\n_RAD_TOKEN_DIM, _RAD_HEAD_DIM = (2048, 512)\n_RAD_E11_SLOTS = [('SAG_NOFS', 'Sagittal', None, False), ('COR_NOFS', 'Coronal', None, False), ('AX_NOFS', 'Axial', None, False), ('SAG_FS', 'Sagittal', None, True)]\n_RAD_E11_CROP_MM = 130.0\n_RAD_E13_SLOTS = [('SAG_FS', 'Sagittal', None, True), ('COR_FS', 'Coronal', None, True), ('AX_FS', 'Axial', None, True), ('SAG_NOFS', 'Sagittal', None, False)]\n_RAD_E13_CROP_MM = 130.0\n_RAD_E13_CACHE_SLICES = 8\n_RAD_E13_IMG = 224\nSLOTS = [('SAG_FS', 'Sagittal', None, True), ('COR_FS', 'Coronal', None, True), ('AX_FS', 'Axial', None, True)]\nN_SLOT = len(SLOTS)\nCACHE_SLICES = 8\n\ndef _rad_sha256(path, chunk=8 << 20):\n    digest = _rad_hashlib.sha256()\n    with open(path, 'rb') as handle:\n        for block in iter(lambda: handle.read(chunk), b''):\n            digest.update(block)\n    return digest.hexdigest()\n\ndef _rad_find_file(name, expected_sha=None, explicit_env=None):\n    files = {_RAD_ENCODER_SHA256: ASSET / 'resnet-50-radimagenet-marwan/ResNet50.pt', _RAD_REFERENCE_HEADS_SHA256: ASSET / 'rsna-knee-e9-radimagenet-heads-v15/v52_radimagenet_heads.pt', _RAD_E13_HEADS_SHA256: ASSET / 'kernel-sources/rsna-knee-e13-train/rsna_rad_e11/v52_e11_heads.pt'}\n    path = files.get(expected_sha)\n    if path is None or not path.is_file():\n        raise FileNotFoundError(name)\n    if _rad_sha256(path) != expected_sha:\n        raise RuntimeError(f'hash mismatch for {path}')\n    return path\n\nclass _RadEncoder(_rad_nn.Module):\n\n    def __init__(self):\n        super().__init__()\n        self.backbone = _rad_nn.Sequential(*list(_rad_resnet50(weights=None).children())[:-2])\n\n    def forward(self, image):\n        return self.backbone(image).mean(dim=(2, 3))\n\nclass _RadHead(_rad_nn.Module):\n\n    def __init__(self):\n        super().__init__()\n        self.project = _rad_nn.Sequential(_rad_nn.LayerNorm(_RAD_TOKEN_DIM), _rad_nn.Linear(_RAD_TOKEN_DIM, _RAD_HEAD_DIM), _rad_nn.GELU())\n        self.plane = _rad_nn.Parameter(_rad_torch.randn(N_SLOT, _RAD_HEAD_DIM) * 0.01)\n        self.position = _rad_nn.Parameter(_rad_torch.randn(CACHE_SLICES, _RAD_HEAD_DIM) * 0.01)\n        self.query = _rad_nn.Parameter(_rad_torch.randn(len(_RAD_LABELS), _RAD_HEAD_DIM) * 0.02)\n        self.attn = _rad_nn.MultiheadAttention(_RAD_HEAD_DIM, 8, dropout=0.1, batch_first=True)\n        self.fuse = _rad_nn.Sequential(_rad_nn.LayerNorm(_RAD_HEAD_DIM * 4), _rad_nn.Linear(_RAD_HEAD_DIM * 4, _RAD_HEAD_DIM), _rad_nn.GELU(), _rad_nn.Dropout(0.15))\n        self.weight = _rad_nn.Parameter(_rad_torch.randn(len(_RAD_LABELS), _RAD_HEAD_DIM) * 0.02)\n        self.bias = _rad_nn.Parameter(_rad_torch.zeros(len(_RAD_LABELS)))\n\n    def forward(self, feature, mask):\n        token = self.project(feature.float())\n        token = token.view(len(token), N_SLOT, CACHE_SLICES, _RAD_HEAD_DIM)\n        token = token + self.plane[None, :, None] + self.position[None, None]\n        token = token.flatten(1, 2)\n        key_padding = mask <= 0\n        all_empty = key_padding.all(1)\n        if all_empty.any():\n            key_padding = key_padding.clone()\n            key_padding[all_empty, 0] = False\n        query = self.query.unsqueeze(0).expand(len(token), -1, -1)\n        attended = query + self.attn(query, token, token, key_padding_mask=key_padding, need_weights=False)[0]\n        denominator = mask.sum(1, keepdim=True).clamp_min(1).unsqueeze(-1)\n        mean = (token * mask.unsqueeze(-1)).sum(1, keepdim=True) / denominator\n        mean = mean.expand(-1, len(_RAD_LABELS), -1)\n        fused = self.fuse(_rad_torch.cat([attended, mean, _rad_torch.abs(attended - mean), attended * mean], dim=-1))\n        return (fused * self.weight.unsqueeze(0)).sum(-1) + self.bias\n\ndef _rad_load_public_heads(device, expected_sha):\n    heads_path = _rad_find_file('v52_radimagenet_heads.pt', expected_sha)\n    payload = _rad_torch.load(heads_path, map_location='cpu', weights_only=True)\n    expected = {'version': 'v52-radimagenet-resnet50-official-1', 'targets': _RAD_LABELS, 'encoder_sha256': _RAD_ENCODER_SHA256, 'encoder_source_commit': '0ce16f7375db4236e646829d1eca61cdb4282133', 'img': 224, 'slices_per_plane': 8, 'feature': 'global_average_pool'}\n    for key, value in expected.items():\n        if payload.get(key) != value:\n            raise RuntimeError(f'public-v15 head contract drift for {key}')\n    folds = payload.get('folds')\n    if not isinstance(folds, list) or len(folds) != 5:\n        raise RuntimeError('public-v15 bundle requires exactly five heads')\n    if sorted((int(record.get('fold', -1)) for record in folds)) != list(range(5)):\n        raise RuntimeError('public-v15 fold identity drift')\n    heads = []\n    for record in folds:\n        head = _RadHead().to(device).eval()\n        head.load_state_dict(record['state_dict'], strict=True)\n        heads.append(head)\n    return (heads, str(heads_path))\n\ndef _rad_load_e13_heads(device):\n    heads_path = _rad_find_file('v52_e11_heads.pt', _RAD_E13_HEADS_SHA256)\n    payload = _rad_torch.load(heads_path, map_location='cpu', weights_only=False)\n    expected = {'version': 'e11-radimagenet-resnet50-diverse-1', 'targets': _RAD_LABELS, 'encoder_sha256': _RAD_ENCODER_SHA256, 'slots': [list(slot) for slot in _RAD_E13_SLOTS], 'crop_mm': _RAD_E13_CROP_MM, 'img': _RAD_E13_IMG, 'slices_per_plane': _RAD_E13_CACHE_SLICES, 'feature': 'global_average_pool'}\n    for key, value in expected.items():\n        if payload.get(key) != value:\n            raise RuntimeError(f'E13 head contract drift for {key}')\n    folds = payload.get('folds')\n    if not isinstance(folds, list) or len(folds) != 5:\n        raise RuntimeError('E13 bundle requires exactly five heads')\n    if sorted((int(record.get('fold', -1)) for record in folds)) != list(range(5)):\n        raise RuntimeError('E13 fold identity drift')\n    heads = []\n    for record in folds:\n        head = _RadHead().to(device).eval()\n        head.load_state_dict(record['state_dict'], strict=True)\n        heads.append(head)\n    return (heads, str(heads_path))\n\n@_rad_torch.inference_mode()\ndef _rad_encode(encoder, pixels, slot_mask, device):\n    n, slots, slices, height, width = pixels.shape\n    features = _rad_np.zeros((n, slots * slices, _RAD_TOKEN_DIM), _rad_np.float16)\n    token_mask = _rad_np.repeat(slot_mask[:, :, None], slices, axis=2).reshape(n, -1)\n    valid = _rad_np.flatnonzero(token_mask.reshape(-1) > 0)\n    flat = pixels.reshape(-1, height, width)\n    batch = 192 if device.type == 'cuda' and _rad_torch.cuda.device_count() > 1 else 96 if device.type == 'cuda' else 8\n    for start in range(0, len(valid), batch):\n        indices = valid[start:start + batch]\n        image = _rad_torch.from_numpy(flat[indices]).to(device).float().div_(127.5).sub_(1.0)\n        image = image.unsqueeze(1).expand(-1, 3, -1, -1).contiguous()\n        amp = _rad_torch.autocast('cuda') if device.type == 'cuda' else _rad_contextlib.nullcontext()\n        with amp:\n            feature = encoder(image)\n        values = feature.float().cpu().numpy()\n        if not _rad_np.isfinite(values).all():\n            raise RuntimeError('V36 non-finite RadImageNet feature')\n        features.reshape(-1, _RAD_TOKEN_DIM)[indices] = values.astype(_rad_np.float16)\n    return (features, token_mask.astype(_rad_np.float32))\n\n@_rad_torch.inference_mode()\ndef _rad_predict_head(head, features, masks, device, batch=64):\n    predictions = []\n    for start in range(0, len(features), batch):\n        image = _rad_torch.from_numpy(features[start:start + batch]).to(device)\n        mask = _rad_torch.from_numpy(masks[start:start + batch]).to(device)\n        amp = _rad_torch.autocast('cuda') if device.type == 'cuda' else _rad_contextlib.nullcontext()\n        with amp:\n            predictions.append(_rad_torch.sigmoid(head(image, mask)).float().cpu())\n    return _rad_torch.cat(predictions).numpy()\n\ndef _rad_rank_columns(values):\n    return _rad_pd.DataFrame(_rad_np.asarray(values, dtype=_rad_np.float64)).rank(method='average', pct=True).to_numpy(_rad_np.float64)\n\ndef _rad_validate(frame, expected_ids):\n    if frame.columns.tolist() != ['StudyInstanceUID', *_RAD_LABELS]:\n        raise RuntimeError('V36 submission schema drift')\n    ids = frame['StudyInstanceUID'].astype(str).tolist()\n    if ids != list(map(str, expected_ids)) or len(ids) != len(set(ids)):\n        raise RuntimeError('V36 submission study identity/order drift')\n    values = frame[_RAD_LABELS].to_numpy(_rad_np.float64)\n    if not _rad_np.isfinite(values).all() or values.min() < 0 or values.max() > 1:\n        raise RuntimeError('V36 invalid submission values')\n\n_V8_LOCALIZED = {\n    \"ACL\",\n    \"MCL\",\n    \"Medial Meniscus\",\n    \"Lateral Meniscus\",\n    \"Baker's\",\n    \"Contusion\",\n    \"Fracture\",\n}\n\n\ndef _v8_rank_bank(predictions):\n    return _rad_np.stack([\n        _rad_rank_columns(p)\n        for p in predictions\n    ])\n\n\ndef _v8_target_stability(predictions):\n    bank = _v8_rank_bank(predictions)\n    result = _rad_np.zeros(len(_RAD_LABELS), _rad_np.float64)\n    count = 0\n\n    for a in range(len(bank)):\n        for b in range(a + 1, len(bank)):\n            for target in range(len(_RAD_LABELS)):\n                x = bank[a, :, target]\n                y = bank[b, :, target]\n                if len(x) > 2 and _rad_np.std(x) > 0 and _rad_np.std(y) > 0:\n                    result[target] += float(_rad_np.corrcoef(x, y)[0, 1])\n            count += 1\n\n    return result / max(count, 1)\n\n\ndef _v8_robust_z(values, floor=0.015):\n    values = _rad_np.asarray(values, _rad_np.float64)\n    center = float(_rad_np.median(values))\n    mad = float(\n        _rad_np.median(_rad_np.abs(values - center))\n    ) * 1.4826\n    scale = max(mad, float(floor))\n    return (values - center) / scale\n\n\ndef _v8_consensus(predictions):\n    probability = _rad_np.mean(\n        _rad_np.stack(predictions),\n        axis=0,\n    )\n    probability_rank = _rad_rank_columns(probability)\n    fold_rank = _v8_rank_bank(predictions).mean(axis=0)\n    consensus = _rad_rank_columns(\n        0.90 * probability_rank\n        + 0.10 * fold_rank\n    )\n    stability = _v8_target_stability(predictions)\n    return probability_rank, consensus, stability\n\n\ndef _v8_extract_metric_vector(record):\n    candidates = []\n\n    def visit(value, path=\"\"):\n        if isinstance(value, dict):\n            for key, child in value.items():\n                visit(child, f\"{path}/{key}\".lower())\n            return\n\n        if isinstance(value, (list, tuple, _rad_np.ndarray)):\n            try:\n                array = _rad_np.asarray(value, _rad_np.float64)\n            except Exception:\n                return\n\n            if (\n                array.ndim == 1\n                and len(array) == len(_RAD_LABELS)\n                and _rad_np.isfinite(array).all()\n                and any(\n                    token in path\n                    for token in (\"auc\", \"metric\", \"score\", \"valid\", \"/val\")\n                )\n                and not any(\n                    token in path\n                    for token in (\"weight\", \"threshold\", \"prior\", \"preval\", \"loss\")\n                )\n            ):\n                candidates.append((path, array))\n\n    visit(record)\n\n    if not candidates:\n        return None\n\n    candidates.sort(\n        key=lambda item: (\n            0 if \"auc\" in item[0] else 1,\n            len(item[0]),\n        )\n    )\n    return candidates[0][1]\n\n\ndef _v8_bundle_metrics(path):\n    try:\n        payload = _rad_torch.load(\n            path,\n            map_location=\"cpu\",\n            weights_only=False,\n        )\n    except Exception:\n        return None\n\n    folds = payload.get(\"folds\")\n    if not isinstance(folds, list):\n        return None\n\n    vectors = []\n    for record in folds:\n        vector = _v8_extract_metric_vector(record)\n        if vector is None:\n            return None\n        vectors.append(vector)\n\n    if not vectors:\n        return None\n\n    return _rad_np.mean(_rad_np.stack(vectors), axis=0)\n\n\ndef _v8_discover_oof_auc(kind):\n    roots = [\n        ASSET,\n        _RadPath(\"/kaggle/input/kernel-sources\"),\n    ]\n    paths = []\n\n    for root in roots:\n        if not root.exists():\n            continue\n        try:\n            paths.extend(root.rglob(\"*oof*.csv\"))\n        except Exception:\n            pass\n\n    try:\n        from sklearn.metrics import roc_auc_score\n    except Exception:\n        return None\n\n    train = _rad_pd.read_csv(\n        ROOT / \"train.csv\",\n        dtype={\"StudyInstanceUID\": str},\n    )\n\n    best = None\n    best_n = -1\n\n    for path in paths:\n        text = str(path).lower()\n\n        if kind == \"e13\":\n            if not (\"e13\" in text or \"e11\" in text):\n                continue\n        else:\n            if \"e13\" in text or \"e11\" in text:\n                continue\n            if not (\n                \"e9\" in text\n                or \"radimagenet\" in text\n                or \"public\" in text\n            ):\n                continue\n\n        try:\n            frame = _rad_pd.read_csv(\n                path,\n                dtype={\"StudyInstanceUID\": str},\n            )\n        except Exception:\n            continue\n\n        if (\n            \"StudyInstanceUID\" not in frame.columns\n            or not set(_RAD_LABELS).issubset(frame.columns)\n        ):\n            continue\n\n        merged = train[\n            [\"StudyInstanceUID\"] + _RAD_LABELS\n        ].merge(\n            frame[[\"StudyInstanceUID\"] + _RAD_LABELS],\n            on=\"StudyInstanceUID\",\n            how=\"inner\",\n            suffixes=(\"_gold\", \"_pred\"),\n        )\n\n        auc = _rad_np.full(\n            len(_RAD_LABELS),\n            _rad_np.nan,\n            _rad_np.float64,\n        )\n        usable = 0\n\n        for j, target in enumerate(_RAD_LABELS):\n            y = _rad_pd.to_numeric(\n                merged[f\"{target}_gold\"],\n                errors=\"coerce\",\n            ).to_numpy()\n            p = _rad_pd.to_numeric(\n                merged[f\"{target}_pred\"],\n                errors=\"coerce\",\n            ).to_numpy()\n\n            mask = _rad_np.isfinite(y) & _rad_np.isfinite(p)\n\n            if (\n                mask.sum() >= 8\n                and len(_rad_np.unique(y[mask])) == 2\n            ):\n                auc[j] = roc_auc_score(y[mask], p[mask])\n                usable += int(mask.sum())\n\n        if _rad_np.isfinite(auc).sum() >= 8 and usable > best_n:\n            best = auc\n            best_n = usable\n\n    return best\n\n\ndef _v8_parent_specialist(baseline_rank):\n    output = _rad_np.asarray(\n        baseline_rank,\n        _rad_np.float64,\n    ).copy()\n\n    d2_soft = globals().get(\"V8_D2_SOFT_RANK\")\n    d2_weighted = globals().get(\"V8_D2_WEIGHTED_RANK\")\n    d3_probability = globals().get(\"V8_D3_PROB_RANK\")\n\n    if d2_soft is None or d2_weighted is None or d3_probability is None:\n        return output\n\n    d3_stability = _rad_np.asarray(\n        globals().get(\n            \"V8_D3_STABILITY\",\n            _rad_np.ones(len(_RAD_LABELS)),\n        ),\n        _rad_np.float64,\n    )\n    d3_z = _v8_robust_z(d3_stability, floor=0.02)\n\n    for j, target in enumerate(_RAD_LABELS):\n        soft_w = 0.055 if target in _V8_LOCALIZED else 0.015\n        prob_w = float(\n            _rad_np.clip(\n                0.022 + 0.012 * _rad_np.tanh(d3_z[j]),\n                0.008,\n                0.038,\n            )\n        )\n        weighted_w = 0.018 if target in _V8_LOCALIZED else 0.008\n\n        total = soft_w + prob_w + weighted_w\n\n        output[:, j] = (\n            (1.0 - total) * baseline_rank[:, j]\n            + soft_w * d2_soft[:, j]\n            + prob_w * d3_probability[:, j]\n            + weighted_w * d2_weighted[:, j]\n        )\n\n    return _rad_rank_columns(output)\n\n\n\n# ----------------------- V10 OOF meta stack -----------------------\n","metadata":{"execution":{"iopub.status.busy":"2026-08-22T08:48:02.505117Z","iopub.execute_input":"2026-08-22T08:48:02.505427Z","iopub.status.idle":"2026-08-22T08:48:02.556082Z","shell.execute_reply.started":"2026-08-22T08:48:02.505402Z","shell.execute_reply":"2026-08-22T08:48:02.555421Z"},"papermill":{"duration":0.084813,"end_time":"2026-08-20T11:31:54.605818+00:00","exception":false,"start_time":"2026-08-20T11:31:54.521005+00:00","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"17f63a80","cell_type":"markdown","source":"## Stage 3B — V10 OOF Ridge/meta-stack utilities","metadata":{"papermill":{"duration":0.032503,"end_time":"2026-08-20T11:31:54.668516+00:00","exception":false,"start_time":"2026-08-20T11:31:54.636013+00:00","status":"completed"},"tags":[]}},{"id":"c3ec3c1b","cell_type":"code","source":"def _v10_find_artifact(filename):\n    matches = []\n\n    # Search attached datasets/kernel outputs while pruning the enormous\n    # competition DICOM trees. This keeps startup deterministic.\n    root = _RadPath(\"/kaggle/input\")\n    if root.exists():\n        for current, dirs, files in os.walk(root):\n            dirs[:] = [\n                d for d in dirs\n                if d not in (\n                    \"train_series\",\n                    \"test_series\",\n                    \".git\",\n                    \"__pycache__\",\n                )\n            ]\n            if filename in files:\n                candidate = (\n                    _RadPath(current)\n                    / filename\n                )\n                if candidate.is_file():\n                    matches.append(\n                        candidate\n                    )\n\n    work = _RadPath(\n        \"/kaggle/working\"\n    )\n    if work.exists():\n        candidate = work / filename\n        if candidate.is_file():\n            matches.append(\n                candidate\n            )\n        for child in work.iterdir():\n            if not child.is_dir():\n                continue\n            nested = child / filename\n            if nested.is_file():\n                matches.append(\n                    nested\n                )\n\n    if not matches:\n        return None\n\n    unique = {}\n    for candidate in matches:\n        try:\n            key = str(\n                candidate.resolve()\n            )\n        except Exception:\n            key = str(candidate)\n        unique[key] = candidate\n\n    ordered = sorted(\n        unique.values(),\n        key=lambda p: (\n            len(p.parts),\n            str(p),\n        ),\n    )\n    return ordered\n\n\ndef _v10_rank(matrix):\n    return _rad_rank_columns(\n        _rad_np.asarray(\n            matrix,\n            dtype=_rad_np.float64,\n        )\n    )\n\n\ndef _v10_protocol_features(series, ids):\n    ids = [str(x) for x in ids]\n    frame = series.copy()\n    frame[\"StudyInstanceUID\"] = (\n        frame[\"StudyInstanceUID\"]\n        .astype(str)\n    )\n\n    result = _rad_pd.DataFrame(\n        index=_rad_pd.Index(\n            ids,\n            name=\"StudyInstanceUID\",\n        )\n    )\n\n    grouped = frame.groupby(\n        \"StudyInstanceUID\",\n        sort=False,\n    )\n\n    result[\"series_total\"] = (\n        grouped.size()\n        .reindex(result.index)\n        .fillna(0)\n    )\n\n    if \"Anatomical_Plane\" in frame.columns:\n        for plane in (\n            \"Sagittal\",\n            \"Coronal\",\n            \"Axial\",\n        ):\n            count = (\n                frame[\n                    frame[\"Anatomical_Plane\"]\n                    .astype(str)\n                    .eq(plane)\n                ]\n                .groupby(\n                    \"StudyInstanceUID\"\n                )\n                .size()\n            )\n            result[\n                f\"plane_{plane.lower()}\"\n            ] = (\n                count\n                .reindex(result.index)\n                .fillna(0)\n            )\n\n    for flag_name in (\n        \"Fat_Suppression\",\n        \"Fluid_Sensitive\",\n    ):\n        if flag_name not in frame.columns:\n            continue\n\n        numeric = _rad_pd.to_numeric(\n            frame[flag_name],\n            errors=\"coerce\",\n        ).fillna(0)\n\n        flag_frame = frame[\n            numeric > 0\n        ]\n\n        total = (\n            flag_frame.groupby(\n                \"StudyInstanceUID\"\n            )\n            .size()\n        )\n        result[\n            flag_name.lower()\n        ] = (\n            total\n            .reindex(result.index)\n            .fillna(0)\n        )\n\n        if \"Anatomical_Plane\" in frame.columns:\n            for plane in (\n                \"Sagittal\",\n                \"Coronal\",\n                \"Axial\",\n            ):\n                count = (\n                    flag_frame[\n                        flag_frame[\n                            \"Anatomical_Plane\"\n                        ]\n                        .astype(str)\n                        .eq(plane)\n                    ]\n                    .groupby(\n                        \"StudyInstanceUID\"\n                    )\n                    .size()\n                )\n                result[\n                    f\"{flag_name.lower()}_\"\n                    f\"{plane.lower()}\"\n                ] = (\n                    count\n                    .reindex(result.index)\n                    .fillna(0)\n                )\n\n    values = result.to_numpy(\n        dtype=_rad_np.float64\n    )\n\n    if values.shape[1] == 0:\n        return _rad_np.zeros(\n            (len(ids), 1),\n            dtype=_rad_np.float64,\n        )\n\n    return values\n\n\ndef _v10_demographic_features(frame, ids):\n    ids = [str(x) for x in ids]\n    if \"StudyInstanceUID\" not in frame.columns:\n        return _rad_np.zeros(\n            (len(ids), 3),\n            dtype=_rad_np.float64,\n        )\n\n    base = frame.copy()\n    base[\"StudyInstanceUID\"] = (\n        base[\"StudyInstanceUID\"]\n        .astype(str)\n    )\n    base = (\n        _rad_pd.DataFrame(\n            {\"StudyInstanceUID\": ids}\n        )\n        .merge(\n            base,\n            on=\"StudyInstanceUID\",\n            how=\"left\",\n            validate=\"one_to_one\",\n        )\n    )\n\n    sex = (\n        base[\"PatientSex\"]\n        .astype(str)\n        .str.upper()\n        if \"PatientSex\" in base.columns\n        else _rad_pd.Series(\n            [\"\"] * len(base)\n        )\n    )\n\n    return _rad_np.stack(\n        [\n            sex.eq(\"M\").to_numpy(\n                _rad_np.float64\n            ),\n            sex.eq(\"F\").to_numpy(\n                _rad_np.float64\n            ),\n            (\n                ~sex.isin(\n                    [\"M\", \"F\"]\n                )\n            ).to_numpy(\n                _rad_np.float64\n            ),\n        ],\n        axis=1,\n    )\n\n\ndef _v10_load_oof():\n    \"\"\"\n    Load three genuinely out-of-fold model families:\n      1. E2 DINOv2 ensemble\n      2. public RadImageNet family\n      3. diverse E11 RadImageNet family\n\n    The function is intentionally strict. Any contract mismatch disables\n    V10 and leaves the already valid V8 prediction untouched.\n    \"\"\"\n    npz_candidates = (\n        _v10_find_artifact(\n            \"oof.npz\"\n        )\n        or []\n    )\n    rad_candidates = (\n        _v10_find_artifact(\n            \"v52_oof.csv\"\n        )\n        or []\n    )\n    e11_candidates = (\n        _v10_find_artifact(\n            \"v52_e11_oof.csv\"\n        )\n        or []\n    )\n\n    if (\n        not npz_candidates\n        or not rad_candidates\n        or not e11_candidates\n    ):\n        return None\n\n    train = _rad_pd.read_csv(\n        ROOT / \"train.csv\",\n        dtype={\n            \"StudyInstanceUID\": str\n        },\n    )\n    ids = (\n        train[\"StudyInstanceUID\"]\n        .astype(str)\n        .to_numpy()\n    )\n\n    bundle_data = None\n\n    for path in npz_candidates:\n        try:\n            with _rad_np.load(\n                path,\n                allow_pickle=False,\n            ) as bundle:\n                required = {\n                    \"ids\",\n                    \"pred\",\n                    \"y_derived\",\n                    \"gold_mask\",\n                    \"targets\",\n                }\n                if not required.issubset(\n                    bundle.files\n                ):\n                    continue\n\n                targets = (\n                    bundle[\"targets\"]\n                    .astype(str)\n                    .tolist()\n                )\n                bundle_ids = (\n                    bundle[\"ids\"]\n                    .astype(str)\n                )\n\n                if targets != list(\n                    _RAD_LABELS\n                ):\n                    continue\n                if not _rad_np.array_equal(\n                    bundle_ids,\n                    ids,\n                ):\n                    continue\n\n                bundle_data = {\n                    \"pred\": bundle[\n                        \"pred\"\n                    ].astype(\n                        _rad_np.float64\n                    ),\n                    \"y\": bundle[\n                        \"y_derived\"\n                    ].astype(\n                        _rad_np.float64\n                    ),\n                    \"gold\": bundle[\n                        \"gold_mask\"\n                    ].astype(bool),\n                    \"path\": str(path),\n                }\n                break\n        except Exception:\n            continue\n\n    if bundle_data is None:\n        return None\n\n    def load_csv(\n        candidates,\n        require_fold=True,\n    ):\n        for path in candidates:\n            try:\n                frame = _rad_pd.read_csv(\n                    path,\n                    dtype={\n                        \"StudyInstanceUID\": str\n                    },\n                )\n            except Exception:\n                continue\n\n            if not {\n                \"StudyInstanceUID\",\n                *_RAD_LABELS,\n            }.issubset(\n                frame.columns\n            ):\n                continue\n\n            aligned = (\n                train[\n                    [\"StudyInstanceUID\"]\n                ]\n                .merge(\n                    frame,\n                    on=\"StudyInstanceUID\",\n                    how=\"left\",\n                    validate=\"one_to_one\",\n                )\n            )\n\n            if aligned[\n                _RAD_LABELS\n            ].isna().any().any():\n                continue\n\n            if (\n                require_fold\n                and \"fold\"\n                not in aligned.columns\n            ):\n                continue\n\n            return (\n                aligned,\n                str(path),\n            )\n\n        return (\n            None,\n            None,\n        )\n\n    rad_frame, rad_path = load_csv(\n        rad_candidates\n    )\n    e11_frame, e11_path = load_csv(\n        e11_candidates\n    )\n\n    if (\n        rad_frame is None\n        or e11_frame is None\n    ):\n        return None\n\n    gold = bundle_data[\"gold\"]\n\n    official_gold = (\n        train[\n            _RAD_LABELS\n        ]\n        .notna()\n        .all(axis=1)\n        .to_numpy()\n    )\n\n    if not _rad_np.array_equal(\n        gold,\n        official_gold,\n    ):\n        return None\n\n    y = bundle_data[\"y\"].copy()\n\n    if (\n        y.shape\n        != (\n            len(train),\n            len(_RAD_LABELS),\n        )\n        or bundle_data[\"pred\"].shape\n        != (\n            len(train),\n            len(_RAD_LABELS),\n        )\n    ):\n        return None\n\n    # Replace any non-finite weak target with the neutral value. Gold rows\n    # are overwritten immediately below by official labels.\n    y = _rad_np.where(\n        _rad_np.isfinite(y),\n        y,\n        0.5,\n    )\n\n    # Official labels always override report-derived targets.\n    y[gold] = (\n        train.loc[\n            gold,\n            _RAD_LABELS,\n        ]\n        .to_numpy(\n            _rad_np.float64\n        )\n    )\n\n    fold = _rad_pd.to_numeric(\n        e11_frame[\"fold\"],\n        errors=\"coerce\",\n    ).to_numpy()\n\n    if not _rad_np.isfinite(\n        fold\n    ).all():\n        return None\n\n    fold = fold.astype(\n        _rad_np.int64\n    )\n\n    base = _v10_rank(\n        bundle_data[\"pred\"]\n    )\n    public = _v10_rank(\n        rad_frame[\n            _RAD_LABELS\n        ].to_numpy(\n            _rad_np.float64\n        )\n    )\n    pass2 = _v10_rank(\n        e11_frame[\n            _RAD_LABELS\n        ].to_numpy(\n            _rad_np.float64\n        )\n    )\n\n    train_series = _rad_pd.read_csv(\n        ROOT / \"train_series.csv\",\n        dtype={\n            \"StudyInstanceUID\": str,\n            \"SeriesInstanceUID\": str,\n        },\n    )\n\n    protocol = _v10_protocol_features(\n        train_series,\n        ids,\n    )\n    demographics = (\n        _v10_demographic_features(\n            train,\n            ids,\n        )\n    )\n\n    return {\n        \"train\": train,\n        \"ids\": ids,\n        \"y\": y,\n        \"gold\": gold,\n        \"fold\": fold,\n        \"base\": base,\n        \"public\": public,\n        \"pass2\": pass2,\n        \"protocol\": protocol,\n        \"demographics\": demographics,\n        \"paths\": {\n            \"base\": bundle_data[\n                \"path\"\n            ],\n            \"public\": rad_path,\n            \"pass2\": e11_path,\n        },\n    }\n\n\ndef _v10_design(\n    base,\n    public,\n    pass2,\n    protocol,\n    demographics,\n):\n    base = _rad_np.asarray(\n        base,\n        _rad_np.float64,\n    )\n    public = _rad_np.asarray(\n        public,\n        _rad_np.float64,\n    )\n    pass2 = _rad_np.asarray(\n        pass2,\n        _rad_np.float64,\n    )\n\n    injury = base[\n        :,\n        [\n            _RAD_LABELS.index(\"ACL\"),\n            _RAD_LABELS.index(\"MCL\"),\n            _RAD_LABELS.index(\"Contusion\"),\n            _RAD_LABELS.index(\"Fracture\"),\n        ],\n    ].mean(axis=1, keepdims=True)\n\n    meniscus = base[\n        :,\n        [\n            _RAD_LABELS.index(\n                \"Medial Meniscus\"\n            ),\n            _RAD_LABELS.index(\n                \"Lateral Meniscus\"\n            ),\n        ],\n    ].mean(axis=1, keepdims=True)\n\n    oa = base[\n        :,\n        [\n            _RAD_LABELS.index(\n                \"Medial OA\"\n            ),\n            _RAD_LABELS.index(\n                \"Lateral OA\"\n            ),\n            _RAD_LABELS.index(\n                \"PF OA\"\n            ),\n        ],\n    ].mean(axis=1, keepdims=True)\n\n    inflammatory = base[\n        :,\n        [\n            _RAD_LABELS.index(\n                \"Effusion\"\n            ),\n            _RAD_LABELS.index(\n                \"Synovitis\"\n            ),\n            _RAD_LABELS.index(\n                \"Baker's\"\n            ),\n        ],\n    ].mean(axis=1, keepdims=True)\n\n    return _rad_np.concatenate(\n        [\n            base,\n            public,\n            pass2,\n            public - base,\n            pass2 - base,\n            injury,\n            meniscus,\n            oa,\n            inflammatory,\n            _rad_np.asarray(\n                protocol,\n                _rad_np.float64,\n            ),\n            _rad_np.asarray(\n                demographics,\n                _rad_np.float64,\n            ),\n        ],\n        axis=1,\n    )\n\n\ndef _v10_fit_ridge(\n    x,\n    y,\n    sample_weight,\n    alpha=22.0,\n):\n    from sklearn.linear_model import Ridge\n\n    x = _rad_np.asarray(\n        x,\n        _rad_np.float64,\n    )\n    y = _rad_np.asarray(\n        y,\n        _rad_np.float64,\n    )\n    weight = _rad_np.asarray(\n        sample_weight,\n        _rad_np.float64,\n    )\n\n    mean = x.mean(\n        axis=0,\n        keepdims=True,\n    )\n    scale = x.std(\n        axis=0,\n        keepdims=True,\n    )\n    scale = _rad_np.where(\n        scale > 1e-7,\n        scale,\n        1.0,\n    )\n\n    z = (\n        x - mean\n    ) / scale\n\n    model = Ridge(\n        alpha=float(alpha),\n        fit_intercept=True,\n    )\n    model.fit(\n        z,\n        y,\n        sample_weight=weight,\n    )\n\n    return (\n        model,\n        mean,\n        scale,\n    )\n\n\ndef _v10_predict_ridge(\n    fitted,\n    x,\n):\n    model, mean, scale = fitted\n    x = _rad_np.asarray(\n        x,\n        _rad_np.float64,\n    )\n    z = (\n        x - mean\n    ) / scale\n    return model.predict(z)\n\n\ndef _v10_target_auc(y, p):\n    from sklearn.metrics import (\n        roc_auc_score\n    )\n\n    y = _rad_np.asarray(y)\n    p = _rad_np.asarray(p)\n\n    mask = (\n        _rad_np.isfinite(y)\n        & _rad_np.isfinite(p)\n    )\n\n    if (\n        mask.sum() < 4\n        or len(\n            _rad_np.unique(\n                y[mask]\n            )\n        ) < 2\n    ):\n        return _rad_np.nan\n\n    return float(\n        roc_auc_score(\n            y[mask],\n            p[mask],\n        )\n    )\n\n\ndef _v10_bootstrap_positive_fraction(\n    y,\n    anchor,\n    candidate,\n    seed,\n    repeats=240,\n):\n    y = _rad_np.asarray(y)\n    anchor = _rad_np.asarray(anchor)\n    candidate = _rad_np.asarray(candidate)\n\n    positive = _rad_np.flatnonzero(\n        y > 0.5\n    )\n    negative = _rad_np.flatnonzero(\n        y <= 0.5\n    )\n\n    if (\n        len(positive) < 2\n        or len(negative) < 2\n    ):\n        return 0.0\n\n    rng = _rad_np.random.default_rng(\n        int(seed)\n    )\n    gains = []\n\n    for _ in range(int(repeats)):\n        pos = rng.choice(\n            positive,\n            size=len(positive),\n            replace=True,\n        )\n        neg = rng.choice(\n            negative,\n            size=len(negative),\n            replace=True,\n        )\n        index = _rad_np.concatenate(\n            [pos, neg]\n        )\n\n        base_auc = _v10_target_auc(\n            y[index],\n            anchor[index],\n        )\n        new_auc = _v10_target_auc(\n            y[index],\n            candidate[index],\n        )\n\n        if (\n            _rad_np.isfinite(\n                base_auc\n            )\n            and _rad_np.isfinite(\n                new_auc\n            )\n        ):\n            gains.append(\n                new_auc - base_auc\n            )\n\n    if not gains:\n        return 0.0\n\n    gains = _rad_np.asarray(\n        gains,\n        _rad_np.float64,\n    )\n    return float(\n        (gains > 0).mean()\n    )\n\n\ndef _v10_meta_stack(\n    test_base,\n    test_public,\n    test_pass2,\n    test_ids,\n):\n    \"\"\"\n    Cross-fitted, label-dependency-aware stacking.\n\n    The stack is trained on model OOF predictions rather than in-sample\n    predictions. All weak rows are available for fitting; the 58 official\n    rows receive much larger weight. A target gets non-zero deployment\n    weight only when its cross-fitted gold prediction improves the OOF\n    anchor with bootstrap support.\n    \"\"\"\n    data = _v10_load_oof()\n\n    if data is None:\n        return (\n            None,\n            _rad_np.zeros(\n                len(_RAD_LABELS),\n                _rad_np.float64,\n            ),\n        )\n\n    train = data[\"train\"]\n    y = data[\"y\"]\n    gold = data[\"gold\"]\n    fold = data[\"fold\"]\n\n    x_train = _v10_design(\n        data[\"base\"],\n        data[\"public\"],\n        data[\"pass2\"],\n        data[\"protocol\"],\n        data[\"demographics\"],\n    )\n\n    test_series = _rad_pd.read_csv(\n        ROOT / \"test_series.csv\",\n        dtype={\n            \"StudyInstanceUID\": str,\n            \"SeriesInstanceUID\": str,\n        },\n    )\n    test_frame = _rad_pd.read_csv(\n        ROOT / \"test.csv\",\n        dtype={\n            \"StudyInstanceUID\": str\n        },\n    )\n\n    test_protocol = (\n        _v10_protocol_features(\n            test_series,\n            test_ids,\n        )\n    )\n    test_demographics = (\n        _v10_demographic_features(\n            test_frame,\n            test_ids,\n        )\n    )\n\n    x_test = _v10_design(\n        test_base,\n        test_public,\n        test_pass2,\n        test_protocol,\n        test_demographics,\n    )\n\n    # Approximation of the strong pre-E13 OOF route.\n    oof_e10 = _v10_rank(\n        0.50 * data[\"base\"]\n        + 0.50 * data[\"public\"]\n    )\n    oof_anchor = _v10_rank(\n        0.85 * oof_e10\n        + 0.15 * data[\"pass2\"]\n    )\n\n    meta_cross = _rad_np.full(\n        y.shape,\n        _rad_np.nan,\n        _rad_np.float64,\n    )\n\n    # Weak report labels get lower weight when close to 0.5.\n    weak_conf = (\n        0.40\n        + 1.60\n        * _rad_np.abs(\n            y - 0.5\n        )\n        * 2.0\n    )\n    weak_conf = _rad_np.clip(\n        weak_conf,\n        0.40,\n        2.0,\n    )\n\n    unique_folds = sorted(\n        int(v)\n        for v in _rad_np.unique(\n            fold[gold]\n        )\n        if int(v) >= 0\n    )\n\n    if len(unique_folds) < 3:\n        return (\n            None,\n            _rad_np.zeros(\n                len(_RAD_LABELS),\n                _rad_np.float64,\n            ),\n        )\n\n    for outer in unique_folds:\n        train_mask = (\n            fold != int(outer)\n        )\n        valid_mask = (\n            gold\n            & (fold == int(outer))\n        )\n\n        if not valid_mask.any():\n            continue\n\n        for target in range(\n            len(_RAD_LABELS)\n        ):\n            target_y = y[:, target]\n            weight = weak_conf[\n                :, target\n            ].copy()\n\n            # Official labels dominate the weak report targets.\n            weight[gold] = 14.0\n\n            fitted = _v10_fit_ridge(\n                x_train[train_mask],\n                target_y[train_mask],\n                weight[train_mask],\n                alpha=24.0,\n            )\n\n            meta_cross[\n                valid_mask,\n                target,\n            ] = _v10_predict_ridge(\n                fitted,\n                x_train[valid_mask],\n            )\n\n    gold_index = _rad_np.flatnonzero(\n        gold\n    )\n\n    if not _rad_np.isfinite(\n        meta_cross[\n            gold_index\n        ]\n    ).all():\n        return (\n            None,\n            _rad_np.zeros(\n                len(_RAD_LABELS),\n                _rad_np.float64,\n            ),\n        )\n\n    meta_cross_rank = _v10_rank(\n        meta_cross[\n            gold_index\n        ]\n    )\n    anchor_gold = _v10_rank(\n        oof_anchor[\n            gold_index\n        ]\n    )\n    gold_y = y[\n        gold_index\n    ]\n\n    deployment = _rad_np.zeros(\n        len(_RAD_LABELS),\n        _rad_np.float64,\n    )\n\n    grid = _rad_np.asarray(\n        [\n            0.00,\n            0.05,\n            0.10,\n            0.15,\n            0.20,\n            0.25,\n            0.30,\n        ],\n        _rad_np.float64,\n    )\n\n    for target in range(\n        len(_RAD_LABELS)\n    ):\n        truth = gold_y[\n            :, target\n        ]\n\n        base_auc = _v10_target_auc(\n            truth,\n            anchor_gold[\n                :, target\n            ],\n        )\n\n        if not _rad_np.isfinite(\n            base_auc\n        ):\n            continue\n\n        best_weight = 0.0\n        best_auc = base_auc\n\n        for weight in grid[1:]:\n            candidate = (\n                (1.0 - weight)\n                * anchor_gold[\n                    :, target\n                ]\n                + weight\n                * meta_cross_rank[\n                    :, target\n                ]\n            )\n\n            auc = _v10_target_auc(\n                truth,\n                candidate,\n            )\n\n            # Small complexity penalty discourages large meta votes.\n            penalized = (\n                auc\n                - 0.0025\n                * float(weight)\n            )\n\n            current = (\n                best_auc\n                - 0.0025\n                * float(best_weight)\n            )\n\n            if penalized > current:\n                best_auc = auc\n                best_weight = float(\n                    weight\n                )\n\n        if best_weight <= 0:\n            continue\n\n        best_candidate = (\n            (1.0 - best_weight)\n            * anchor_gold[\n                :, target\n            ]\n            + best_weight\n            * meta_cross_rank[\n                :, target\n            ]\n        )\n\n        improvement = (\n            best_auc - base_auc\n        )\n\n        support = (\n            _v10_bootstrap_positive_fraction(\n                truth,\n                anchor_gold[\n                    :, target\n                ],\n                best_candidate,\n                seed=1017 + target,\n            )\n        )\n\n        # Conservative gate: only deploy signal that is visible in\n        # cross-fitted official labels and stable to class-stratified\n        # bootstrap resampling.\n        if (\n            improvement >= 0.006\n            and support >= 0.62\n        ):\n            deployment[target] = min(\n                best_weight,\n                0.28,\n            )\n        elif (\n            improvement >= 0.003\n            and support >= 0.58\n        ):\n            deployment[target] = min(\n                best_weight,\n                0.12,\n            )\n\n    # Expose the exact cross-fitted V10 gold ordering for the next\n    # meta layer. This is validation-only state; it is never written out.\n    v10_gold_final = _v10_rank(\n        (\n            1.0\n            - deployment\n        )[None, :]\n        * anchor_gold\n        + deployment[None, :]\n        * meta_cross_rank\n    )\n\n    globals()[\"V11_V10_GOLD_CONTEXT\"] = {\n        \"gold_index\": gold_index.copy(),\n        \"gold_y\": gold_y.copy(),\n        \"gold_fold\": fold[gold_index].copy(),\n        \"v10_gold\": v10_gold_final.copy(),\n        \"deployment\": deployment.copy(),\n    }\n\n    if not (\n        deployment > 0\n    ).any():\n        return (\n            None,\n            deployment,\n        )\n\n    meta_test = _rad_np.zeros(\n        (\n            len(test_ids),\n            len(_RAD_LABELS),\n        ),\n        _rad_np.float64,\n    )\n\n    for target in range(\n        len(_RAD_LABELS)\n    ):\n        target_y = y[:, target]\n        weight = weak_conf[\n            :, target\n        ].copy()\n        weight[gold] = 14.0\n\n        fitted = _v10_fit_ridge(\n            x_train,\n            target_y,\n            weight,\n            alpha=24.0,\n        )\n\n        meta_test[\n            :, target\n        ] = _v10_predict_ridge(\n            fitted,\n            x_test,\n        )\n\n    return (\n        _v10_rank(\n            meta_test\n        ),\n        deployment,\n    )\n\n\n\n\n# ----------------------- V11 graph + nonlinear OOF stack -----------------------\n","metadata":{"execution":{"iopub.status.busy":"2026-08-22T08:48:02.557265Z","iopub.execute_input":"2026-08-22T08:48:02.557592Z","iopub.status.idle":"2026-08-22T08:48:02.611062Z","shell.execute_reply.started":"2026-08-22T08:48:02.557571Z","shell.execute_reply":"2026-08-22T08:48:02.610429Z"},"papermill":{"duration":0.095021,"end_time":"2026-08-20T11:31:54.795491+00:00","exception":false,"start_time":"2026-08-20T11:31:54.70047+00:00","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"ab9e6623","cell_type":"markdown","source":"## Stage 3C — V11 nonlinear challenger\n\nThe HGB challenger is preserved but can now be disabled with `V14_ENABLE_HGB_CHALLENGER=False`.\n","metadata":{"papermill":{"duration":0.030905,"end_time":"2026-08-20T11:31:54.858589+00:00","exception":false,"start_time":"2026-08-20T11:31:54.827684+00:00","status":"completed"},"tags":[]}},{"id":"f01700fa","cell_type":"code","source":"def _v11_label_graph(y):\n    \"\"\"\n    Learn a conservative positive label-correlation graph.\n\n    The diagonal is removed so a target cannot simply copy itself.\n    Only the strongest four positive neighbours per target survive.\n    \"\"\"\n    values = _rad_np.asarray(\n        y,\n        dtype=_rad_np.float64,\n    )\n\n    if values.ndim != 2 or values.shape[1] != len(_RAD_LABELS):\n        return _rad_np.zeros(\n            (len(_RAD_LABELS), len(_RAD_LABELS)),\n            dtype=_rad_np.float64,\n        )\n\n    corr = _rad_np.corrcoef(\n        values,\n        rowvar=False,\n    )\n    corr = _rad_np.nan_to_num(\n        corr,\n        nan=0.0,\n        posinf=0.0,\n        neginf=0.0,\n    )\n    corr = _rad_np.maximum(\n        corr,\n        0.0,\n    )\n    _rad_np.fill_diagonal(\n        corr,\n        0.0,\n    )\n\n    graph = _rad_np.zeros_like(\n        corr,\n        dtype=_rad_np.float64,\n    )\n\n    for target in range(\n        len(_RAD_LABELS)\n    ):\n        row = corr[target]\n        order = _rad_np.argsort(\n            row\n        )[::-1]\n        kept = [\n            int(index)\n            for index in order\n            if row[index] >= 0.05\n        ][:4]\n\n        if kept:\n            graph[\n                target,\n                kept,\n            ] = row[kept]\n\n    # Symmetric shrinkage makes the graph less dependent on one noisy\n    # report-derived direction.\n    graph = 0.5 * (\n        graph\n        + graph.T\n    )\n\n    denom = graph.sum(\n        axis=1,\n        keepdims=True,\n    )\n    denom = _rad_np.where(\n        denom > 1e-8,\n        denom,\n        1.0,\n    )\n    graph = graph / denom\n\n    # Keep label propagation as a feature, not a dominant prediction.\n    return 0.80 * graph\n\n\ndef _v11_design(\n    base,\n    public,\n    pass2,\n    protocol,\n    demographics,\n    graph,\n):\n    base = _rad_np.asarray(\n        base,\n        _rad_np.float64,\n    )\n    public = _rad_np.asarray(\n        public,\n        _rad_np.float64,\n    )\n    pass2 = _rad_np.asarray(\n        pass2,\n        _rad_np.float64,\n    )\n\n    core = _v10_design(\n        base,\n        public,\n        pass2,\n        protocol,\n        demographics,\n    )\n\n    stack = _rad_np.stack(\n        [\n            base,\n            public,\n            pass2,\n        ],\n        axis=2,\n    )\n\n    consensus = stack.mean(\n        axis=2\n    )\n    disagreement = stack.std(\n        axis=2\n    )\n    spread = (\n        stack.max(axis=2)\n        - stack.min(axis=2)\n    )\n\n    # Low-order cross-family interactions help the linear learner, while\n    # HGB can use them as explicit agreement/reliability signals.\n    pair_product = _rad_np.concatenate(\n        [\n            base * public,\n            base * pass2,\n            public * pass2,\n        ],\n        axis=1,\n    )\n\n    graph = _rad_np.asarray(\n        graph,\n        _rad_np.float64,\n    )\n\n    graph_base = (\n        base\n        @ graph.T\n    )\n    graph_public = (\n        public\n        @ graph.T\n    )\n    graph_pass2 = (\n        pass2\n        @ graph.T\n    )\n    graph_consensus = (\n        consensus\n        @ graph.T\n    )\n\n    return _rad_np.concatenate(\n        [\n            core,\n            consensus,\n            disagreement,\n            spread,\n            pair_product,\n            graph_base,\n            graph_public,\n            graph_pass2,\n            graph_consensus,\n        ],\n        axis=1,\n    )\n\n\ndef _v11_fit_hgb(\n    x,\n    y,\n    sample_weight,\n    seed,\n):\n    from sklearn.ensemble import (\n        HistGradientBoostingRegressor\n    )\n\n    model = HistGradientBoostingRegressor(\n        loss=\"squared_error\",\n        learning_rate=0.035,\n        max_iter=140,\n        max_leaf_nodes=7,\n        max_depth=3,\n        min_samples_leaf=42,\n        l2_regularization=9.0,\n        early_stopping=False,\n        random_state=int(seed),\n    )\n    model.fit(\n        _rad_np.asarray(\n            x,\n            _rad_np.float64,\n        ),\n        _rad_np.asarray(\n            y,\n            _rad_np.float64,\n        ),\n        sample_weight=_rad_np.asarray(\n            sample_weight,\n            _rad_np.float64,\n        ),\n    )\n    return model\n\n\ndef _v11_fold_consistency(\n    truth,\n    baseline,\n    candidate,\n    folds,\n):\n    gains = []\n\n    for fold_id in sorted(\n        int(value)\n        for value in _rad_np.unique(\n            folds\n        )\n    ):\n        mask = (\n            folds == int(fold_id)\n        )\n\n        if mask.sum() < 4:\n            continue\n\n        base_auc = _v10_target_auc(\n            truth[mask],\n            baseline[mask],\n        )\n        candidate_auc = (\n            _v10_target_auc(\n                truth[mask],\n                candidate[mask],\n            )\n        )\n\n        if (\n            _rad_np.isfinite(\n                base_auc\n            )\n            and _rad_np.isfinite(\n                candidate_auc\n            )\n        ):\n            gains.append(\n                candidate_auc\n                - base_auc\n            )\n\n    if not gains:\n        return (\n            0,\n            0.0,\n            0.0,\n        )\n\n    gains = _rad_np.asarray(\n        gains,\n        _rad_np.float64,\n    )\n\n    return (\n        int(len(gains)),\n        float(\n            (gains > 0).mean()\n        ),\n        float(\n            _rad_np.median(gains)\n        ),\n    )\n\n\ndef _v11_meta_challenger(\n    test_base,\n    test_public,\n    test_pass2,\n    test_ids,\n):\n    \"\"\"\n    Nonlinear challenger above V10.\n\n    It combines:\n      - the original linear Ridge stack;\n      - a small HGB regressor that can learn conditional family reliability;\n      - label-correlation graph features;\n      - explicit disagreement / spread / pairwise family interactions.\n\n    Deployment is target-specific and accepted only when the candidate\n    beats the already cross-fitted V10 gold prediction.\n    \"\"\"\n    context = globals().get(\n        \"V11_V10_GOLD_CONTEXT\"\n    )\n    data = _v10_load_oof()\n\n    if (\n        context is None\n        or data is None\n    ):\n        return (\n            None,\n            _rad_np.zeros(\n                len(_RAD_LABELS),\n                _rad_np.float64,\n            ),\n            [\"none\"] * len(_RAD_LABELS),\n        )\n\n    y = data[\"y\"]\n    gold = data[\"gold\"]\n    fold = data[\"fold\"]\n\n    gold_index = _rad_np.asarray(\n        context[\"gold_index\"],\n        dtype=_rad_np.int64,\n    )\n    gold_y = _rad_np.asarray(\n        context[\"gold_y\"],\n        dtype=_rad_np.float64,\n    )\n    gold_fold = _rad_np.asarray(\n        context[\"gold_fold\"],\n        dtype=_rad_np.int64,\n    )\n    v10_gold = _rad_np.asarray(\n        context[\"v10_gold\"],\n        dtype=_rad_np.float64,\n    )\n\n    expected_gold = _rad_np.flatnonzero(\n        gold\n    )\n    if not _rad_np.array_equal(\n        gold_index,\n        expected_gold,\n    ):\n        return (\n            None,\n            _rad_np.zeros(\n                len(_RAD_LABELS),\n                _rad_np.float64,\n            ),\n            [\"none\"] * len(_RAD_LABELS),\n        )\n\n    train_series = _rad_pd.read_csv(\n        ROOT / \"train_series.csv\",\n        dtype={\n            \"StudyInstanceUID\": str,\n            \"SeriesInstanceUID\": str,\n        },\n    )\n    test_series = _rad_pd.read_csv(\n        ROOT / \"test_series.csv\",\n        dtype={\n            \"StudyInstanceUID\": str,\n            \"SeriesInstanceUID\": str,\n        },\n    )\n    test_frame = _rad_pd.read_csv(\n        ROOT / \"test.csv\",\n        dtype={\n            \"StudyInstanceUID\": str\n        },\n    )\n\n    train_protocol = (\n        _v10_protocol_features(\n            train_series,\n            data[\"ids\"],\n        )\n    )\n    test_protocol = (\n        _v10_protocol_features(\n            test_series,\n            test_ids,\n        )\n    )\n    train_demographics = (\n        _v10_demographic_features(\n            data[\"train\"],\n            data[\"ids\"],\n        )\n    )\n    test_demographics = (\n        _v10_demographic_features(\n            test_frame,\n            test_ids,\n        )\n    )\n\n    weak_conf = (\n        0.35\n        + 1.65\n        * _rad_np.abs(\n            y - 0.5\n        )\n        * 2.0\n    )\n    weak_conf = _rad_np.clip(\n        weak_conf,\n        0.35,\n        2.0,\n    )\n\n    unique_folds = sorted(\n        int(value)\n        for value in _rad_np.unique(\n            fold[gold]\n        )\n        if int(value) >= 0\n    )\n\n    if len(unique_folds) < 3:\n        return (\n            None,\n            _rad_np.zeros(\n                len(_RAD_LABELS),\n                _rad_np.float64,\n            ),\n            [\"none\"] * len(_RAD_LABELS),\n        )\n\n    ridge_cross = _rad_np.full(\n        y.shape,\n        _rad_np.nan,\n        _rad_np.float64,\n    )\n    hgb_cross = _rad_np.full(\n        y.shape,\n        _rad_np.nan,\n        _rad_np.float64,\n    )\n\n    for outer in unique_folds:\n        train_mask = (\n            fold != int(outer)\n        )\n        valid_mask = (\n            gold\n            & (fold == int(outer))\n        )\n\n        if not valid_mask.any():\n            continue\n\n        # Strictly fold-safe label graph.\n        graph = _v11_label_graph(\n            y[train_mask]\n        )\n\n        x_fold = _v11_design(\n            data[\"base\"],\n            data[\"public\"],\n            data[\"pass2\"],\n            train_protocol,\n            train_demographics,\n            graph,\n        )\n\n        for target in range(\n            len(_RAD_LABELS)\n        ):\n            target_y = y[\n                :, target\n            ]\n            weight = weak_conf[\n                :, target\n            ].copy()\n\n            # V11 trusts official labels slightly more than V10, while\n            # regularization and cross-fit gates prevent memorization.\n            weight[gold] = 18.0\n\n            ridge = _v10_fit_ridge(\n                x_fold[train_mask],\n                target_y[train_mask],\n                weight[train_mask],\n                alpha=20.0,\n            )\n            ridge_cross[\n                valid_mask,\n                target,\n            ] = _v10_predict_ridge(\n                ridge,\n                x_fold[valid_mask],\n            )\n\n            try:\n                hgb = _v11_fit_hgb(\n                    x_fold[train_mask],\n                    target_y[train_mask],\n                    weight[train_mask],\n                    seed=1147\n                    + 31 * int(outer)\n                    + target,\n                )\n                hgb_cross[\n                    valid_mask,\n                    target,\n                ] = hgb.predict(\n                    x_fold[\n                        valid_mask\n                    ]\n                )\n            except Exception:\n                # Ridge remains a complete fallback candidate.\n                hgb_cross[\n                    valid_mask,\n                    target,\n                ] = ridge_cross[\n                    valid_mask,\n                    target,\n                ]\n\n    if not (\n        _rad_np.isfinite(\n            ridge_cross[\n                gold_index\n            ]\n        ).all()\n        and _rad_np.isfinite(\n            hgb_cross[\n                gold_index\n            ]\n        ).all()\n    ):\n        return (\n            None,\n            _rad_np.zeros(\n                len(_RAD_LABELS),\n                _rad_np.float64,\n            ),\n            [\"none\"] * len(_RAD_LABELS),\n        )\n\n    ridge_gold = _v10_rank(\n        ridge_cross[\n            gold_index\n        ]\n    )\n    hgb_gold = _v10_rank(\n        hgb_cross[\n            gold_index\n        ]\n    )\n    blend_gold = _v10_rank(\n        0.68 * ridge_gold\n        + 0.32 * hgb_gold\n    )\n\n    candidate_gold = {\n        \"ridge\": ridge_gold,\n        \"hgb\": hgb_gold,\n        \"blend\": blend_gold,\n    }\n\n    deployment = _rad_np.zeros(\n        len(_RAD_LABELS),\n        _rad_np.float64,\n    )\n    chosen_model = [\n        \"none\"\n        for _ in _RAD_LABELS\n    ]\n\n    grid = _rad_np.asarray(\n        [\n            0.05,\n            0.10,\n            0.15,\n            0.20,\n            0.25,\n            0.30,\n            0.35,\n        ],\n        _rad_np.float64,\n    )\n\n    for target in range(\n        len(_RAD_LABELS)\n    ):\n        truth = gold_y[\n            :, target\n        ]\n        base = v10_gold[\n            :, target\n        ]\n\n        base_auc = _v10_target_auc(\n            truth,\n            base,\n        )\n        if not _rad_np.isfinite(\n            base_auc\n        ):\n            continue\n\n        best = None\n\n        for model_name, matrix in (\n            candidate_gold.items()\n        ):\n            for mix in grid:\n                candidate = (\n                    (1.0 - mix)\n                    * base\n                    + mix\n                    * matrix[\n                        :, target\n                    ]\n                )\n\n                auc = _v10_target_auc(\n                    truth,\n                    candidate,\n                )\n                if not _rad_np.isfinite(\n                    auc\n                ):\n                    continue\n\n                support = (\n                    _v10_bootstrap_positive_fraction(\n                        truth,\n                        base,\n                        candidate,\n                        seed=2111\n                        + 97 * target\n                        + int(\n                            100 * mix\n                        ),\n                        repeats=280,\n                    )\n                )\n\n                (\n                    valid_folds,\n                    positive_fraction,\n                    median_fold_gain,\n                ) = _v11_fold_consistency(\n                    truth,\n                    base,\n                    candidate,\n                    gold_fold,\n                )\n\n                # Penalize nonlinear complexity and large deployment votes.\n                complexity = (\n                    0.0008\n                    if model_name == \"hgb\"\n                    else (\n                        0.0004\n                        if model_name == \"blend\"\n                        else 0.0\n                    )\n                )\n                objective = (\n                    auc\n                    - 0.0022\n                    * float(mix)\n                    - complexity\n                )\n\n                record = {\n                    \"model\": model_name,\n                    \"mix\": float(mix),\n                    \"auc\": float(auc),\n                    \"gain\": float(\n                        auc - base_auc\n                    ),\n                    \"support\": float(\n                        support\n                    ),\n                    \"valid_folds\": int(\n                        valid_folds\n                    ),\n                    \"fold_positive\": float(\n                        positive_fraction\n                    ),\n                    \"fold_median\": float(\n                        median_fold_gain\n                    ),\n                    \"objective\": float(\n                        objective\n                    ),\n                }\n\n                if (\n                    best is None\n                    or record[\"objective\"]\n                    > best[\"objective\"]\n                ):\n                    best = record\n\n        if best is None:\n            continue\n\n        # Strong gate against 58-study overfitting.\n        fold_ok = (\n            best[\"valid_folds\"] < 2\n            or best[\"fold_positive\"]\n            >= 0.60\n        )\n\n        strong = (\n            best[\"gain\"] >= 0.005\n            and best[\"support\"] >= 0.62\n            and fold_ok\n        )\n        moderate = (\n            best[\"gain\"] >= 0.0025\n            and best[\"support\"] >= 0.59\n            and fold_ok\n        )\n\n        if strong:\n            deployment[target] = min(\n                best[\"mix\"],\n                0.30,\n            )\n            chosen_model[target] = (\n                best[\"model\"]\n            )\n        elif moderate:\n            deployment[target] = min(\n                best[\"mix\"],\n                0.12,\n            )\n            chosen_model[target] = (\n                best[\"model\"]\n            )\n\n    if not (\n        deployment > 0\n    ).any():\n        return (\n            None,\n            deployment,\n            chosen_model,\n        )\n\n    full_graph = _v11_label_graph(\n        y\n    )\n    x_train = _v11_design(\n        data[\"base\"],\n        data[\"public\"],\n        data[\"pass2\"],\n        train_protocol,\n        train_demographics,\n        full_graph,\n    )\n    x_test = _v11_design(\n        test_base,\n        test_public,\n        test_pass2,\n        test_protocol,\n        test_demographics,\n        full_graph,\n    )\n\n    challenger = _rad_np.zeros(\n        (\n            len(test_ids),\n            len(_RAD_LABELS),\n        ),\n        _rad_np.float64,\n    )\n\n    for target in range(\n        len(_RAD_LABELS)\n    ):\n        model_name = chosen_model[\n            target\n        ]\n\n        if model_name == \"none\":\n            # Value is irrelevant because deployment is zero.\n            challenger[\n                :, target\n            ] = test_base[\n                :, target\n            ]\n            continue\n\n        target_y = y[\n            :, target\n        ]\n        weight = weak_conf[\n            :, target\n        ].copy()\n        weight[gold] = 18.0\n\n        ridge = _v10_fit_ridge(\n            x_train,\n            target_y,\n            weight,\n            alpha=20.0,\n        )\n        ridge_test = _v10_predict_ridge(\n            ridge,\n            x_test,\n        )\n\n        if model_name == \"ridge\":\n            challenger[\n                :, target\n            ] = ridge_test\n            continue\n\n        try:\n            hgb = _v11_fit_hgb(\n                x_train,\n                target_y,\n                weight,\n                seed=4171 + target,\n            )\n            hgb_test = hgb.predict(\n                x_test\n            )\n        except Exception:\n            hgb_test = ridge_test\n\n        if model_name == \"hgb\":\n            challenger[\n                :, target\n            ] = hgb_test\n        else:\n            # Same fixed mixture used for cross-fitted validation.\n            challenger[\n                :, target\n            ] = (\n                0.68 * ridge_test\n                + 0.32 * hgb_test\n            )\n\n    return (\n        _v10_rank(\n            challenger\n        ),\n        deployment,\n        chosen_model,\n    )\n","metadata":{"execution":{"iopub.status.busy":"2026-08-22T08:48:02.612883Z","iopub.execute_input":"2026-08-22T08:48:02.613166Z","iopub.status.idle":"2026-08-22T08:48:02.651093Z","shell.execute_reply.started":"2026-08-22T08:48:02.613147Z","shell.execute_reply":"2026-08-22T08:48:02.650405Z"},"papermill":{"duration":0.075538,"end_time":"2026-08-20T11:31:54.963913+00:00","exception":false,"start_time":"2026-08-20T11:31:54.888375+00:00","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"df54511e","cell_type":"markdown","source":"## Stage 3D — V14 inference and final blend\n\nV14 performs the test-series header scan and laterality analysis **once**, then reuses the result for the public, E13, and pass-2 RadImageNet cache builds.\n","metadata":{"papermill":{"duration":0.030021,"end_time":"2026-08-20T11:31:55.02517+00:00","exception":false,"start_time":"2026-08-20T11:31:54.995149+00:00","status":"completed"},"tags":[]}},{"id":"47227cab","cell_type":"code","source":"def _rad_main_v14():\n    work = _RadPath(\"/kaggle/working\")\n    primary = work / \"submission.csv\"\n\n    test = _rad_pd.read_csv(\n        ROOT / \"test.csv\",\n        dtype={\"StudyInstanceUID\": str},\n    )\n    expected_ids = test.StudyInstanceUID.astype(str).tolist()\n\n    baseline = _rad_pd.read_csv(\n        primary,\n        dtype={\"StudyInstanceUID\": str},\n    )\n    _rad_validate(baseline, expected_ids)\n\n    device = _rad_torch.device(\"cuda:0\")\n\n    test_series = _rad_pd.read_csv(\n        ROOT / \"test_series.csv\",\n        dtype={\n            \"StudyInstanceUID\": str,\n            \"SeriesInstanceUID\": str,\n        },\n    )\n    plane = dict(\n        zip(\n            test_series.SeriesInstanceUID,\n            test_series.Anatomical_Plane,\n        )\n    )\n\n    # V14: the series header walk does not depend on slot layout/crop.\n    # Perform it once and reuse it for public, E13, and pass-2 branches.\n    _header_t0 = _rad_time.time()\n    globals().update(RULES=dict(RULES_LEGACY))\n    headers = annotate(walk(\"test_series\"))\n    laterality = lat_of(headers, \"test-v14 \")\n    if V14_LOG_STAGE_TIMES:\n        print(\n            f\"[V14] test header scan + annotation: \"\n            f\"{_rad_time.time() - _header_t0:.1f}s, \"\n            f\"{len(headers)} series\"\n        )\n\n    def cache(slots, crop, tag, threshold):\n        globals().update(\n            SLOTS=list(slots),\n            N_SLOT=len(slots),\n            CACHE_SLICES=8,\n            IMG=224,\n            CACHE_IMG=224,\n            CROP_MM=float(crop),\n            RULES=dict(RULES_LEGACY),\n        )\n\n        _cache_t0 = _rad_time.time()\n        studies, pixels, masks = build_cache(\n            pick_slots(headers, plane),\n            plane,\n            laterality,\n            tag,\n        )\n        if V14_LOG_STAGE_TIMES:\n            print(\n                f\"[V14] {tag} cache: \"\n                f\"{_rad_time.time() - _cache_t0:.1f}s\"\n            )\n\n        positions = {\n            str(uid): index\n            for index, uid in enumerate(studies)\n        }\n        missing = [\n            uid\n            for uid in expected_ids\n            if uid not in positions\n        ]\n        if missing:\n            raise RuntimeError(\n                f\"{len(missing)} studies absent from {tag}\"\n            )\n\n        order = _rad_np.asarray(\n            [positions[uid] for uid in expected_ids],\n            dtype=_rad_np.int64,\n        )\n        pixels = pixels[order]\n        masks = masks[order]\n\n        tokens = int(\n            _rad_np.repeat(\n                masks[:, :, None],\n                CACHE_SLICES,\n                axis=2,\n            ).sum()\n        )\n\n        if tokens < int(\n            threshold\n            * len(test)\n            * N_SLOT\n            * CACHE_SLICES\n        ):\n            raise RuntimeError(\n                f\"insufficient slices for {tag}: {tokens}\"\n            )\n\n        return pixels, masks\n\n    encoder_path = _rad_find_file(\n        \"ResNet50.pt\",\n        _RAD_ENCODER_SHA256,\n    )\n    encoder = _RadEncoder()\n    encoder.load_state_dict(\n        _rad_torch.load(\n            encoder_path,\n            map_location=\"cpu\",\n            weights_only=True,\n        ),\n        strict=True,\n    )\n    encoder.eval().to(device)\n\n    for parameter in encoder.parameters():\n        parameter.requires_grad_(False)\n\n    if _rad_torch.cuda.device_count() > 1:\n        encoder = _rad_nn.DataParallel(\n            encoder,\n            device_ids=list(range(_rad_torch.cuda.device_count())),\n        )\n\n    public_slots = [\n        (\"SAG_FS\", \"Sagittal\", None, True),\n        (\"COR_FS\", \"Coronal\", None, True),\n        (\"AX_FS\", \"Axial\", None, True),\n    ]\n\n    pixels, masks = cache(\n        public_slots,\n        10000.0,\n        \"test-v11-public\",\n        0.85,\n    )\n\n    public_heads, public_path = _rad_load_public_heads(\n        device,\n        _RAD_REFERENCE_HEADS_SHA256,\n    )\n\n    features, token_mask = _rad_encode(\n        encoder,\n        pixels,\n        masks,\n        device,\n    )\n\n    public_predictions = [\n        _rad_predict_head(\n            head,\n            features,\n            token_mask,\n            device,\n        )\n        for head in public_heads\n    ]\n\n    (\n        public_probability_rank,\n        public_consensus,\n        public_stability,\n    ) = _v8_consensus(public_predictions)\n\n    del public_heads, features, token_mask, pixels, masks\n    _rad_gc.collect()\n    _rad_torch.cuda.empty_cache()\n\n    globals().update(\n        SLOTS=list(_RAD_E13_SLOTS),\n        N_SLOT=len(_RAD_E13_SLOTS),\n        CACHE_SLICES=_RAD_E13_CACHE_SLICES,\n        IMG=_RAD_E13_IMG,\n        CACHE_IMG=_RAD_E13_IMG,\n        CROP_MM=_RAD_E13_CROP_MM,\n        RULES=dict(RULES_LEGACY),\n    )\n\n    e13_heads, e13_path = _rad_load_e13_heads(device)\n\n    pixels, masks = cache(\n        _RAD_E13_SLOTS,\n        _RAD_E13_CROP_MM,\n        \"test-v11-e13\",\n        0.85,\n    )\n\n    features, token_mask = _rad_encode(\n        encoder,\n        pixels,\n        masks,\n        device,\n    )\n\n    e13_predictions = [\n        _rad_predict_head(\n            head,\n            features,\n            token_mask,\n            device,\n        )\n        for head in e13_heads\n    ]\n\n    (\n        e13_probability_rank,\n        e13_consensus,\n        e13_stability,\n    ) = _v8_consensus(e13_predictions)\n\n    del features, token_mask, pixels, masks\n    _rad_gc.collect()\n    _rad_torch.cuda.empty_cache()\n\n    public_metric = _v8_bundle_metrics(_RadPath(public_path))\n    e13_metric = _v8_bundle_metrics(_RadPath(e13_path))\n\n    public_oof = _v8_discover_oof_auc(\"public\")\n    e13_oof = _v8_discover_oof_auc(\"e13\")\n\n    if public_oof is not None and e13_oof is not None:\n        diff = _rad_np.nan_to_num(\n            e13_oof - public_oof,\n            nan=0.0,\n        )\n        e13_weight = _rad_np.clip(\n            0.50 + 0.55 * diff,\n            0.42,\n            0.58,\n        )\n    elif public_metric is not None and e13_metric is not None:\n        diff = _rad_np.nan_to_num(\n            e13_metric - public_metric,\n            nan=0.0,\n        )\n        e13_weight = _rad_np.clip(\n            0.50 + 0.45 * diff,\n            0.43,\n            0.57,\n        )\n    else:\n        relative = (\n            _v8_robust_z(e13_stability, floor=0.02)\n            - _v8_robust_z(public_stability, floor=0.02)\n        )\n        e13_weight = _rad_np.clip(\n            0.50 + 0.025 * _rad_np.tanh(relative),\n            0.465,\n            0.535,\n        )\n\n    reference_adaptive = _rad_rank_columns(\n        (1.0 - e13_weight)[None, :] * public_consensus\n        + e13_weight[None, :] * e13_consensus\n    )\n\n    reference_exact = _rad_rank_columns(\n        (1.0 - _RAD_E13_MEMBER_WEIGHT) * public_probability_rank\n        + _RAD_E13_MEMBER_WEIGHT * e13_probability_rank\n    )\n\n    baseline_rank = _rad_rank_columns(\n        baseline[_RAD_LABELS].to_numpy()\n    )\n    parent_specialist = _v8_parent_specialist(baseline_rank)\n\n    exact_e10 = baseline_rank.copy()\n    for index, target in enumerate(_RAD_LABELS):\n        if target not in _RAD_EXCLUDE:\n            exact_e10[:, index] = (\n                (1.0 - _RAD_ALPHA) * baseline_rank[:, index]\n                + _RAD_ALPHA * reference_exact[:, index]\n            )\n    exact_e10_rank = _rad_rank_columns(exact_e10)\n\n    adaptive_e10 = parent_specialist.copy()\n\n    ref_quality = _rad_np.maximum(\n        public_stability,\n        e13_stability,\n    )\n    ref_z = _v8_robust_z(ref_quality, floor=0.02)\n    e10_alpha = _rad_np.clip(\n        0.50 + 0.025 * _rad_np.tanh(ref_z),\n        0.47,\n        0.53,\n    )\n\n    for index, target in enumerate(_RAD_LABELS):\n        if target not in _RAD_EXCLUDE:\n            adaptive_e10[:, index] = (\n                (1.0 - e10_alpha[index]) * parent_specialist[:, index]\n                + e10_alpha[index] * reference_adaptive[:, index]\n            )\n\n    adaptive_e10_rank = _rad_rank_columns(adaptive_e10)\n\n    pixels, masks = cache(\n        _RAD_E11_SLOTS,\n        _RAD_E11_CROP_MM,\n        \"test-v11-pass2\",\n        0.55,\n    )\n\n    features, token_mask = _rad_encode(\n        encoder,\n        pixels,\n        masks,\n        device,\n    )\n\n    pass2_predictions = [\n        _rad_predict_head(\n            head,\n            features,\n            token_mask,\n            device,\n        )\n        for head in e13_heads\n    ]\n\n    (\n        pass2_probability_rank,\n        pass2_consensus,\n        pass2_stability,\n    ) = _v8_consensus(pass2_predictions)\n\n    pass2_z = _v8_robust_z(pass2_stability, floor=0.02)\n\n    diversity = _rad_np.zeros(\n        len(_RAD_LABELS),\n        _rad_np.float64,\n    )\n\n    for j in range(len(_RAD_LABELS)):\n        x = pass2_consensus[:, j]\n        y = adaptive_e10_rank[:, j]\n        corr = (\n            float(_rad_np.corrcoef(x, y)[0, 1])\n            if _rad_np.std(x) > 0 and _rad_np.std(y) > 0\n            else 1.0\n        )\n        diversity[j] = 1.0 - abs(corr)\n\n    diversity_z = _v8_robust_z(diversity, floor=0.01)\n\n    pass2_alpha = _rad_np.clip(\n        _RAD_V48_SECOND_ALPHA\n        + 0.022 * _rad_np.tanh(pass2_z)\n        + 0.010 * _rad_np.tanh(diversity_z),\n        0.105,\n        0.205,\n    )\n\n    # V14: legacy hand-tuned priors are isolated behind a switch.\n    # Keep True for score-parity experiments; set False when validating\n    # a fully OOF-driven blend.\n    priors = {\n        \"ACL\": 0.020,\n        \"MCL\": -0.010,\n        \"Medial Meniscus\": 0.005,\n        \"Lateral Meniscus\": 0.005,\n        \"Medial OA\": 0.020,\n        \"Lateral OA\": 0.020,\n        \"PF OA\": 0.010,\n        \"Effusion\": -0.020,\n        \"Synovitis\": -0.015,\n        \"Baker's\": 0.000,\n        \"Contusion\": -0.010,\n        \"Fracture\": 0.020,\n    }\n\n    if V14_USE_PASS2_PRIORS:\n        for j, target in enumerate(_RAD_LABELS):\n            pass2_alpha[j] = float(\n                _rad_np.clip(\n                    pass2_alpha[j] + priors.get(target, 0.0),\n                    0.095,\n                    0.215,\n                )\n            )\n\n    exact_final = _rad_rank_columns(\n        (1.0 - _RAD_V48_SECOND_ALPHA) * exact_e10_rank\n        + _RAD_V48_SECOND_ALPHA * pass2_probability_rank\n    )\n\n    adaptive_final = _rad_rank_columns(\n        (1.0 - pass2_alpha)[None, :] * adaptive_e10_rank\n        + pass2_alpha[None, :] * pass2_consensus\n    )\n\n    # V8 is the measured high-performing anchor.\n    v8_anchor = _rad_rank_columns(\n        0.65 * exact_final\n        + 0.35 * adaptive_final\n    )\n\n    # New trained ensemble layer. It uses only genuine OOF train\n    # predictions for fitting and cross-fitted official labels for\n    # deciding whether each target is allowed to change at all.\n    meta_rank, meta_weight = _v10_meta_stack(\n        test_base=baseline_rank,\n        test_public=public_probability_rank,\n        test_pass2=pass2_probability_rank,\n        test_ids=expected_ids,\n    )\n\n    if meta_rank is None:\n        v10_anchor = v8_anchor\n    else:\n        v10_anchor = _rad_rank_columns(\n            (\n                1.0\n                - meta_weight\n            )[None, :]\n            * v8_anchor\n            + meta_weight[None, :]\n            * meta_rank\n        )\n\n    # V14 keeps the V11 nonlinear challenger behind an explicit switch.\n    # If its evidence is not strong enough, final_rank remains V10 exactly.\n    if V14_ENABLE_HGB_CHALLENGER:\n        (\n            v11_rank,\n            v11_weight,\n            v11_model,\n        ) = _v11_meta_challenger(\n            test_base=baseline_rank,\n            test_public=public_probability_rank,\n            test_pass2=pass2_probability_rank,\n            test_ids=expected_ids,\n        )\n    else:\n        v11_rank = None\n        v11_weight = _rad_np.zeros(len(_RAD_LABELS), dtype=_rad_np.float64)\n        v11_model = [\"disabled\"] * len(_RAD_LABELS)\n\n    if v11_rank is None:\n        final_rank = v10_anchor\n    else:\n        final_rank = _rad_rank_columns(\n            (\n                1.0\n                - v11_weight\n            )[None, :]\n            * v10_anchor\n            + v11_weight[None, :]\n            * v11_rank\n        )\n\n    print(\"[V14] HGB challenger:\", bool(V14_ENABLE_HGB_CHALLENGER))\n    print(\"[V14] legacy pass2 priors:\", bool(V14_USE_PASS2_PRIORS))\n    print(\n        \"[V14] pass2 alpha:\",\n        dict(zip(_RAD_LABELS, _rad_np.round(pass2_alpha, 4))),\n    )\n\n    final = baseline.copy()\n    final[_RAD_LABELS] = final_rank\n\n    _rad_validate(final, expected_ids)\n    final.to_csv(primary, index=False)\n\n    for candidate in work.glob(\"submission*.csv\"):\n        if candidate.name != \"submission.csv\":\n            try:\n                candidate.unlink()\n            except OSError:\n                pass\n\n    for candidate in work.glob(\"*diagnostics*.csv\"):\n        try:\n            candidate.unlink()\n        except OSError:\n            pass\n\n    del (\n        encoder,\n        e13_heads,\n        features,\n        token_mask,\n        pixels,\n        masks,\n        public_predictions,\n        e13_predictions,\n        pass2_predictions,\n    )\n    _rad_gc.collect()\n    _rad_torch.cuda.empty_cache()\n\n\n_rad_main_v14()\n","metadata":{"execution":{"iopub.status.busy":"2026-08-22T08:48:02.652045Z","iopub.execute_input":"2026-08-22T08:48:02.652304Z","iopub.status.idle":"2026-08-22T08:52:30.478527Z","shell.execute_reply.started":"2026-08-22T08:48:02.652285Z","shell.execute_reply":"2026-08-22T08:52:30.47789Z"},"papermill":{"duration":285.38713,"end_time":"2026-08-20T11:36:40.441756+00:00","exception":false,"start_time":"2026-08-20T11:31:55.054626+00:00","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"eb57afe9","cell_type":"markdown","source":"## Stage 4 — V15 OOF-first toolkit (guarded; off at submission time)\n\nEverything below is **development tooling**: grouped-fold construction, the severity soft\nlabeler, statistical comparison, constrained ensemble-weight fitting, and the MIL module for\nthe retrain. All entry points are behind `RUN_V15_*` flags (default off) so the submission\nrun is unaffected. Run them in an internet-off CPU session against the train split.\n","metadata":{"papermill":{"duration":0.032072,"end_time":"2026-08-20T11:36:40.506093+00:00","exception":false,"start_time":"2026-08-20T11:36:40.474021+00:00","status":"completed"},"tags":[]}},{"id":"68a6bc19","cell_type":"code","source":"# =========================================================\n# V15 STAGE 4 — GROUPED FOLDS + SEVERITY LABELS + OOF TOOLS\n# =========================================================\nimport hashlib as _v15_hashlib\nimport os as _v15_os\nimport re as _v15_re\nimport unicodedata as _v15_unicodedata\nfrom pathlib import Path as _V15Path\nimport numpy as _v15_np\nimport pandas as _v15_pd\n\nRUN_V15_BUILD_FOLDS = _v15_os.environ.get('RUN_V15_BUILD_FOLDS', '0') == '1'\nRUN_V15_LABELER_EVAL = _v15_os.environ.get('RUN_V15_LABELER_EVAL', '0') == '1'\nRUN_V15_FIT_WEIGHTS = _v15_os.environ.get('RUN_V15_FIT_WEIGHTS', '0') == '1'\n\n_V15_ROOT = _V15Path('/kaggle/input/competitions/rsna-knee-abnormality-detection')\n_V15_TARGETS = ['ACL', 'MCL', 'Medial Meniscus', 'Lateral Meniscus', 'Medial OA',\n                'Lateral OA', 'PF OA', 'Effusion', 'Synovitis', \"Baker's\",\n                'Contusion', 'Fracture']\n_V15_FP_TAGS = ['Manufacturer', 'ManufacturerModelName', 'SoftwareVersions',\n                'MagneticFieldStrength', 'ImagingFrequency', 'ReceiveCoilName']\n\n\n# ---------------------------------------------------------\n# 4.1  Scanner + patient + report-hash grouped folds\n# ---------------------------------------------------------\ndef _v15_study_fingerprint(study_dir):\n    import pydicom as _v15_pydicom\n    for sdir in sorted(p for p in study_dir.iterdir() if p.is_dir()):\n        for f in sorted(sdir.glob('*.dcm'))[:1]:\n            try:\n                ds = _v15_pydicom.dcmread(f, stop_before_pixels=True, force=True)\n            except Exception:\n                continue\n            fp = '|'.join(str(getattr(ds, t, '')) for t in _V15_FP_TAGS)\n            return fp, str(getattr(ds, 'PatientID', ''))\n    return '', ''\n\n\ndef v15_build_folds(n_splits=5, seed=2026, out='folds_v15.csv'):\n    \"\"\"Leakage-safe folds: any two studies sharing a scanner fingerprint, a PatientID,\n    or an identical normalized report land in the same fold. Stratified so the 58 gold\n    studies and coarse weak-positive burden spread evenly.\"\"\"\n    from sklearn.model_selection import StratifiedGroupKFold\n    train = _v15_pd.read_csv(_V15_ROOT / 'train.csv', dtype={'StudyInstanceUID': str})\n    rows = []\n    for uid in train.StudyInstanceUID:\n        fp, pid = _v15_study_fingerprint(_V15_ROOT / 'train_series' / uid)\n        rows.append({'StudyInstanceUID': uid, 'scanner_fp': fp, 'PatientID': pid})\n    meta = _v15_pd.DataFrame(rows)\n\n    report_col = next((c for c in train.columns\n                       if c.lower() in ('report', 'report_text', 'reports')), None)\n    rep = train[report_col] if report_col else _v15_pd.Series([''] * len(train))\n    meta['report_hash'] = rep.fillna('').map(\n        lambda s: _v15_hashlib.sha1(\n            _v15_re.sub(r'\\s+', ' ', str(s)).strip().lower().encode()\n        ).hexdigest()[:12])\n\n    parent = {}\n\n    def find(a):\n        while parent.setdefault(a, a) != a:\n            parent[a] = parent[parent[a]]\n            a = parent[a]\n        return a\n\n    def union(a, b):\n        parent[find(a)] = find(b)\n\n    for r in meta.itertuples(index=False):\n        keys = [f'S:{r.scanner_fp}']\n        if r.PatientID:\n            keys.append(f'P:{r.PatientID}')\n        if r.report_hash:\n            keys.append(f'R:{r.report_hash}')\n        for k in keys[1:]:\n            union(keys[0], k)\n        union(f'U:{r.StudyInstanceUID}', keys[0])\n    meta['group'] = [find(f'U:{u}') for u in meta.StudyInstanceUID]\n\n    n_pat = meta.PatientID.replace('', _v15_np.nan).dropna().duplicated().sum()\n    print(f'[V15 folds] {meta.group.nunique()} groups over {len(meta)} studies; '\n          f'{n_pat} repeated PatientIDs merged')\n\n    gold = train[_V15_TARGETS].notna().all(1).to_numpy()\n    y_w = train[_V15_TARGETS].fillna(0.5).to_numpy()\n    strat = gold.astype(int) * 8 + _v15_np.clip((y_w > 0.5).sum(1) // 3, 0, 7)\n\n    folds = _v15_np.full(len(train), -1)\n    sgkf = StratifiedGroupKFold(n_splits=n_splits, shuffle=True, random_state=seed)\n    for k, (_, va) in enumerate(sgkf.split(meta, strat, groups=meta.group)):\n        folds[va] = k\n    assert (folds >= 0).all()\n    frame = train[['StudyInstanceUID']].assign(fold=folds, group=meta.group, gold=gold)\n    for k in range(n_splits):\n        print(f'  fold {k}: {(folds == k).sum():4d} studies, '\n              f'{int(gold[folds == k].sum()):2d} gold')\n    frame.to_csv(out, index=False)\n    print(f'[V15 folds] wrote {out}')\n    return frame\n\n\n# ---------------------------------------------------------\n# 4.2  Severity-ordinal soft labeler (skeleton — extend lexicons per language)\n# ---------------------------------------------------------\ndef _v15_norm(t):\n    t = _v15_unicodedata.normalize('NFKD', str(t).lower())\n    return _v15_re.sub(r'\\s+', ' ', t)\n\n_V15_SEV_HIGH = [r'complete', r'full.?thickness', r'high.?grade', r'grade\\s*[34]',\n                 r'grad[oe]\\s*[34]', r'ruptur', r'displaced', r'bucket.?handle',\n                 r'large', r'severe', r'masive|massive', r'y\\u0131rt\\u0131[k\\u011f]',\n                 r'tam kat', r'\\u03c1\\u03ae\\u03be\\u03b7', r'komplett', r'totale?',\n                 r'\\u0440\\u0430\\u0437\\u0440\\u044b\\u0432', r'volledige?']\n_V15_SEV_MID = [r'partial', r'moderate', r'grade\\s*2', r'grad[oe]\\s*2', r'tear(?!\\w)',\n                r'parsiyel', r'parcial', r'moderada?', r'\\u03bc\\u03b5\\u03c1\\u03b9\\u03ba',\n                r'teilweise', r'partiel', r'possible', r'cannot exclude', r'suspicious',\n                r'\\u015f\\u00fcpheli', r'sospech', r'verdacht']\n_V15_SEV_LOW = [r'mild', r'minimal', r'small', r'trace', r'low.?grade', r'grade\\s*1',\n                r'degenerat', r'intrasubstance', r'sprain', r'strain', r'chondropathy',\n                r'thickening', r'signal (change|alteration)', r'hafif', r'leve',\n                r'm\\u00ednim', r'\\u03b5\\u03bb\\u03ac\\u03c7\\u03b9\\u03c3\\u03c4', r'gering',\n                r'discret', r'klein', r'minimaal']\n_V15_NEG = [r'no (evidence of|sign of)?', r'without', r'intact', r'normal',\n            r'unremarkable', r'sin (evidencia|signos)', r'no se (observa|identifica)',\n            r'izlenmedi', r'yoktur', r'saptanmad\\u0131', r'do\\u011fal', r'keine?',\n            r'ohne', r'unauff\\u00e4llig', r'\\u03c7\\u03c9\\u03c1\\u03af\\u03c2',\n            r'\\u03c6\\u03c5\\u03c3\\u03b9\\u03bf\\u03bb\\u03bf\\u03b3\\u03b9\\u03ba', r'geen',\n            r'gaaf', r'pas de', r'sans', r'\\u0431\\u0435\\u0437', r'bez', r'uredan']\n_V15_CHRONIC = [r'chronic', r'old', r'remote', r'sequel', r'kronik', r'cr\\u00f3nic',\n                r'chronisch', r'\\u03c7\\u03c1\\u03cc\\u03bd\\u03b9']\n_V15_POSTOP = [r'graft', r'reconstruct', r'post.?op', r'repair', r'greft', r'plasti']\n\n_V15_ANCHOR = {\n    'ACL': [r'\\bacl\\b', r'anterior cruciate', r'\\u00f6n \\u00e7apraz',\n            r'ligamento cruzado anterior', r'vorderes? kreuzband',\n            r'\\u03c0\\u03c1\\u03cc\\u03c3\\u03b8\\u03b9\\u03bf? \\u03c7\\u03b9\\u03b1\\u03c3\\u03c4',\n            r'voorste kruisband', r'\\blca\\b'],\n    'MCL': [r'\\bmcl\\b', r'medial collateral', r'i\\u00e7 yan ba\\u011f',\n            r'colateral (medial|interno)', r'innenband',\n            r'\\u03ad\\u03c3\\u03c9 \\u03c0\\u03bb\\u03ac\\u03b3\\u03b9'],\n    'Medial Meniscus': [r'medial menisc', r'i\\u00e7 menisk', r'menisco (medial|interno)',\n                        r'innenmeniskus', r'\\u03ad\\u03c3\\u03c9 \\u03bc\\u03b7\\u03bd\\u03af\\u03c3\\u03ba',\n                        r'mediale meniscus'],\n    'Lateral Meniscus': [r'lateral menisc', r'd\\u0131\\u015f menisk',\n                         r'menisco (lateral|externo)', r'au\\u00dfenmeniskus',\n                         r'\\u03ad\\u03be\\u03c9 \\u03bc\\u03b7\\u03bd\\u03af\\u03c3\\u03ba',\n                         r'laterale meniscus'],\n    'Medial OA': [r'medial (compartment|femorotibial)[^.]*(cartilage|chondral|osteo)',\n                  r'medial[^.]*(k\\u0131k\\u0131rdak|kondral)', r'cart\\u00edlago[^.]*medial'],\n    'Lateral OA': [r'lateral (compartment|femorotibial)[^.]*(cartilage|chondral|osteo)',\n                   r'lateral[^.]*(k\\u0131k\\u0131rdak|kondral)'],\n    'PF OA': [r'patell(o|a).?femoral', r'retropatellar', r'troclear|trochle'],\n    'Effusion': [r'effusion', r'joint fluid', r'ef\\u00fczyon', r's\\u0131v\\u0131 art\\u0131\\u015f\\u0131',\n                 r'derrame', r'erguss', r'\\u03c5\\u03b3\\u03c1\\u03cc', r'\\u00e9panchement',\n                 r'vocht'],\n    'Synovitis': [r'synovit', r'sinovit', r'\\u03c5\\u03bc\\u03b5\\u03bd\\u03af\\u03c4',\n                  r'synovial (thickening|proliferation)'],\n    \"Baker's\": [r'baker', r'popliteal cyst', r'quiste popl\\u00edteo',\n                r'\\u03ba\\u03cd\\u03c3\\u03c4\\u03b7', r'popliteal kist'],\n    'Contusion': [r'contusion', r'bone (marrow )?(edema|oedema)',\n                  r'kemik ili\\u011fi \\u00f6demi', r'edema \\u00f3seo',\n                  r'knochenmark\\u00f6dem', r'\\u03bf\\u03af\\u03b4\\u03b7\\u03bc\\u03b1',\n                  r'bot(oedeem|contusie)'],\n    'Fracture': [r'fracture', r'frakt\\u00fcr', r'k\\u0131r\\u0131k', r'fractura',\n                 r'fraktur', r'\\u03ba\\u03ac\\u03c4\\u03b1\\u03b3\\u03bc\\u03b1', r'fractuur'],\n}\n\n_V15_SOFT = {0: 0.03, 1: 0.10, 2: 0.45, 3: 0.93}\n_V15_CONF = {0: 0.80, 1: 0.85, 2: 0.45, 3: 0.95}\n\n\ndef _v15_any(pats, s):\n    return any(_v15_re.search(p, s) for p in pats)\n\n\ndef v15_label_report(text):\n    \"\"\"Report text -> {target: (soft_y, confidence, severity, mentioned)}.\n    Severity thresholds mirror the host rubric: mild / low-grade / intrasubstance /\n    small / chronic-MCL findings are near-negative; only high-grade unambiguous\n    findings map near 1. AUC is rank-based, so ordering matters, calibration does not.\"\"\"\n    t = _v15_norm(text)\n    clauses = _v15_re.split(r'[.;\\n\\u2022]', t)\n    out = {}\n    for tgt, anchors in _V15_ANCHOR.items():\n        sev, seen = 0, False\n        for c in clauses:\n            if not _v15_any(anchors, c):\n                continue\n            seen = True\n            if tgt == 'ACL' and _v15_any(_V15_POSTOP, c):\n                continue\n            if _v15_any(_V15_NEG, c) and not _v15_any(_V15_SEV_HIGH, c):\n                continue\n            if _v15_any(_V15_SEV_HIGH, c):\n                sev = max(sev, 3)\n            elif _v15_any(_V15_SEV_MID, c):\n                if tgt in ('Effusion', \"Baker's\") and _v15_re.search(\n                        r'moderate|moderada?|orta|m\\u00e4\\u00dfig|mod\\u00e9r', c):\n                    sev = max(sev, 3)  # rubric: moderate-or-large fluid = positive\n                elif tgt == 'MCL' and _v15_any(_V15_CHRONIC, c):\n                    sev = max(sev, 1)  # rubric: chronic MCL changes = negative\n                else:\n                    sev = max(sev, 2)\n            elif _v15_any(_V15_SEV_LOW, c):\n                sev = max(sev, 1)\n            else:\n                sev = max(sev, 2)\n        y, w = (_V15_SOFT[sev], _V15_CONF[sev]) if seen else (0.03, 0.70)\n        out[tgt] = (y, w, sev, seen)\n    return out\n\n\n# ---------------------------------------------------------\n# 4.3  Paired bootstrap: is an AUC delta real?\n# ---------------------------------------------------------\ndef paired_bootstrap_auc(y, p_a, p_b, n=2000, seed=7):\n    \"\"\"Per-target paired bootstrap of AUC(b) - AUC(a).\n    Returns (mean delta, (lo, hi) 95% CI, P(delta > 0)).\n    On 58 gold rows the CI spans roughly +-0.03: only large directional wins count.\"\"\"\n    from sklearn.metrics import roc_auc_score\n    rng = _v15_np.random.default_rng(seed)\n    y = _v15_np.asarray(y)\n    p_a = _v15_np.asarray(p_a)\n    p_b = _v15_np.asarray(p_b)\n    d = []\n    for _ in range(int(n)):\n        i = rng.integers(0, len(y), len(y))\n        if len(_v15_np.unique(y[i])) < 2:\n            continue\n        d.append(roc_auc_score(y[i], p_b[i]) - roc_auc_score(y[i], p_a[i]))\n    d = _v15_np.asarray(d)\n    return float(d.mean()), tuple(_v15_np.percentile(d, [2.5, 97.5])), float((d > 0).mean())\n\n\n# ---------------------------------------------------------\n# 4.4  Constrained per-target OOF ensemble weights + family correlation\n# ---------------------------------------------------------\ndef _v15_rank_cols(m):\n    return _v15_pd.DataFrame(m).rank(method='average', pct=True).to_numpy(_v15_np.float64)\n\n\ndef fit_target_weights(oof_ranks, y, gold, l2=0.05, gold_share=0.6):\n    \"\"\"oof_ranks: {family: (N,12) genuine grouped-fold OOF rank matrix}.\n    Optimizes simplex weights per target on gold hard-label AUC plus weak soft-rank\n    agreement (the stabilizer that keeps 58-row noise from steering). Fit ONCE on OOF;\n    ship the returned weights as constants. Never touch the leaderboard with this.\"\"\"\n    from scipy.optimize import minimize\n    from sklearn.metrics import roc_auc_score\n    names = sorted(oof_ranks)\n    K = len(names)\n    P = _v15_np.stack([_v15_np.asarray(oof_ranks[n], _v15_np.float64) for n in names], -1)\n    y = _v15_np.asarray(y, _v15_np.float64)\n    gold = _v15_np.asarray(gold, bool)\n    W = _v15_np.full((len(_V15_TARGETS), K), 1.0 / K)\n    for t in range(len(_V15_TARGETS)):\n        def neg_score(w, t=t):\n            w = _v15_np.clip(w, 0, None)\n            w = w / max(w.sum(), 1e-9)\n            blend = P[:, t] @ w\n            yy = y[gold, t] > 0.5\n            g = roc_auc_score(yy, blend[gold]) if len(_v15_np.unique(yy)) == 2 else 0.5\n            weak = ~gold\n            soft = _v15_np.corrcoef(_v15_rank_cols(y[weak, t:t + 1])[:, 0],\n                                    blend[weak])[0, 1]\n            score = gold_share * g + (1 - gold_share) * 0.5 * (soft + 1)\n            return -score + l2 * float(_v15_np.sum((w - 1.0 / K) ** 2))\n        res = minimize(neg_score, W[t], method='Nelder-Mead',\n                       options={'maxiter': 400, 'xatol': 1e-3})\n        w = _v15_np.clip(res.x, 0, None)\n        W[t] = w / max(w.sum(), 1e-9)\n    for t, tgt in enumerate(_V15_TARGETS):\n        print(f'  {tgt:<17}', dict(zip(names, _v15_np.round(W[t], 3))))\n    return names, W\n\n\ndef prediction_correlation(oof_ranks):\n    names = sorted(oof_ranks)\n    for i, a in enumerate(names):\n        for b in names[i + 1:]:\n            r = float(_v15_np.mean([\n                _v15_np.corrcoef(oof_ranks[a][:, t], oof_ranks[b][:, t])[0, 1]\n                for t in range(len(_V15_TARGETS))]))\n            flag = '   << redundant, consider pruning' if r > 0.97 else ''\n            print(f'{a:>16} vs {b:<16} mean rank-corr {r:.3f}{flag}')\n\n\n# ---------------------------------------------------------\n# 4.5  GatedSliceMIL — module for the V15 retrain (Ilse et al., ICML 2018)\n# ---------------------------------------------------------\ndef v15_gated_slice_mil():\n    import torch as _t\n    import torch.nn as _tnn\n\n    class GatedSliceMIL(_tnn.Module):\n        \"\"\"(B, S_slot, n_slice, D) + slice_mask (B, S, n) -> (B, S_slot, D).\n        Learned replacement for the inference-time max/top2/softpool window tables:\n        insert between the backbone features and SlotHead, cache 8-12 slices/slot.\"\"\"\n\n        def __init__(self, d, hidden=128):\n            super().__init__()\n            self.V = _tnn.Linear(d, hidden)\n            self.U = _tnn.Linear(d, hidden)\n            self.w = _tnn.Linear(hidden, 1)\n\n        def forward(self, x, slice_mask):\n            a = self.w(_t.tanh(self.V(x)) * _t.sigmoid(self.U(x))).squeeze(-1)\n            a = a.masked_fill(slice_mask < 0.5, -1e4).softmax(-1)\n            return _t.einsum('bsn,bsnd->bsd', a, x)\n\n    return GatedSliceMIL\n\n\n# ---------------------------------------------------------\n# 4.6  Guarded entry points\n# ---------------------------------------------------------\nif RUN_V15_BUILD_FOLDS:\n    v15_build_folds()\n\nif RUN_V15_LABELER_EVAL:\n    from sklearn.metrics import roc_auc_score as _v15_auc\n    _train = _v15_pd.read_csv(_V15_ROOT / 'train.csv', dtype={'StudyInstanceUID': str})\n    _rcol = next((c for c in _train.columns\n                  if c.lower() in ('report', 'report_text', 'reports')), None)\n    if _rcol is None:\n        print('[V15 labeler] no report column in train.csv -- point this at your report file')\n    else:\n        _gold = _train[_V15_TARGETS].notna().all(1)\n        _sev = _v15_np.array([[v15_label_report(r)[t][0] for t in _V15_TARGETS]\n                              for r in _train[_rcol].fillna('')])\n        print('[V15 labeler] severity-labeler AUC on the', int(_gold.sum()), 'gold rows:')\n        for j, t in enumerate(_V15_TARGETS):\n            yj = _train.loc[_gold, t].to_numpy(float)\n            if len(_v15_np.unique(yj)) == 2:\n                print(f'  {t:<17} {_v15_auc(yj, _sev[_gold.to_numpy(), j]):.3f}')\n        print('Compare against your current y_derived with paired_bootstrap_auc; '\n              'commit to the retrain only on a clear directional win.')\n\nif RUN_V15_FIT_WEIGHTS:\n    print('[V15 weights] load your three grouped-fold OOF rank matrices into a dict '\n          \"{'dino': ..., 'sixteen': ..., 'radimagenet': ...} aligned to train.csv order, \"\n          'then call fit_target_weights(oof_ranks, y, gold) and prediction_correlation.')\n\nprint('[V15] toolkit loaded | build_folds:', RUN_V15_BUILD_FOLDS,\n      '| labeler_eval:', RUN_V15_LABELER_EVAL,\n      '| fit_weights:', RUN_V15_FIT_WEIGHTS)\n","metadata":{"execution":{"iopub.status.busy":"2026-08-22T08:52:30.479893Z","iopub.execute_input":"2026-08-22T08:52:30.48028Z","iopub.status.idle":"2026-08-22T08:52:30.522243Z","shell.execute_reply.started":"2026-08-22T08:52:30.480256Z","shell.execute_reply":"2026-08-22T08:52:30.521622Z"},"papermill":{"duration":0.084648,"end_time":"2026-08-20T11:36:40.622689+00:00","exception":false,"start_time":"2026-08-20T11:36:40.538041+00:00","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"e0a32150","cell_type":"markdown","source":"## Final submission contract check\n","metadata":{"papermill":{"duration":0.032563,"end_time":"2026-08-20T11:36:40.688055+00:00","exception":false,"start_time":"2026-08-20T11:36:40.655492+00:00","status":"completed"},"tags":[]}},{"id":"00384f31","cell_type":"code","source":"from pathlib import Path\nimport pandas as pd\nimport numpy as np\n\n_v14_submission = Path(\"/kaggle/working/submission.csv\")\nassert _v14_submission.is_file(), \"submission.csv was not created\"\n\n_v14_df = pd.read_csv(_v14_submission, dtype={\"StudyInstanceUID\": str})\n_v14_expected = [\"StudyInstanceUID\"] + TARGETS\nassert list(_v14_df.columns) == _v14_expected, (\n    f\"Unexpected submission columns: {_v14_df.columns.tolist()}\"\n)\nassert len(_v14_df) > 0\n_v14_p = _v14_df[TARGETS].to_numpy(dtype=float)\nassert np.isfinite(_v14_p).all(), \"Non-finite prediction found\"\nassert ((_v14_p >= 0.0) & (_v14_p <= 1.0)).all(), \"Prediction outside [0, 1]\"\n\nprint(f\"[V14] submission ready: {_v14_submission}\")\nprint(f\"[V14] shape: {_v14_df.shape}\")\nprint(_v14_df.head(3))","metadata":{"execution":{"iopub.status.busy":"2026-08-22T08:52:30.523226Z","iopub.execute_input":"2026-08-22T08:52:30.523551Z","iopub.status.idle":"2026-08-22T08:52:30.551295Z","shell.execute_reply.started":"2026-08-22T08:52:30.52353Z","shell.execute_reply":"2026-08-22T08:52:30.550471Z"},"papermill":{"duration":0.054879,"end_time":"2026-08-20T11:36:40.776055+00:00","exception":false,"start_time":"2026-08-20T11:36:40.721176+00:00","status":"completed"},"tags":[],"trusted":true},"outputs":[],"execution_count":null},{"id":"444ea089-3905-4078-8f03-c910397d5ad3","cell_type":"code","source":"from pathlib import Path\nimport numpy as np\nimport pandas as pd\n\nTARGETS = [\n    \"ACL\",\n    \"MCL\",\n    \"Medial Meniscus\",\n    \"Lateral Meniscus\",\n    \"Medial OA\",\n    \"Lateral OA\",\n    \"PF OA\",\n    \"Effusion\",\n    \"Synovitis\",\n    \"Baker's\",\n    \"Contusion\",\n    \"Fracture\",\n]\n\ncompetition_candidates = [\n    Path(\"/kaggle/input/competitions/rsna-knee-abnormality-detection\"),\n    Path(\"/kaggle/input/rsna-knee-abnormality-detection\"),\n]\n\nCOMP = next(\n    (path for path in competition_candidates if (path / \"test.csv\").is_file()),\n    None,\n)\n\nassert COMP is not None, \"Competition input was not found\"\n\nsubmission_path = Path(\"/kaggle/working/submission.csv\")\nassert submission_path.is_file(), \"submission.csv was not created\"\n\ntest = pd.read_csv(\n    COMP / \"test.csv\",\n    dtype={\"StudyInstanceUID\": str},\n)\n\nsubmission = pd.read_csv(\n    submission_path,\n    dtype={\"StudyInstanceUID\": str},\n)\n\nexpected_columns = [\"StudyInstanceUID\"] + TARGETS\n\nassert submission.columns.tolist() == expected_columns, (\n    f\"Wrong columns: {submission.columns.tolist()}\"\n)\n\nassert len(submission) == len(test), (\n    f\"Row mismatch: submission={len(submission)}, test={len(test)}\"\n)\n\nassert submission[\"StudyInstanceUID\"].is_unique, (\n    \"Duplicate StudyInstanceUID found\"\n)\n\nassert set(submission[\"StudyInstanceUID\"]) == set(test[\"StudyInstanceUID\"]), (\n    \"StudyInstanceUID values do not match test.csv\"\n)\n\nvalues = submission[TARGETS].to_numpy(dtype=np.float64)\n\nassert np.isfinite(values).all(), \"NaN or infinity found\"\nassert (values >= 0).all(), \"Prediction below zero found\"\nassert (values <= 1).all(), \"Prediction above one found\"\n\n# Reorder exactly like test.csv\nsubmission = test[[\"StudyInstanceUID\"]].merge(\n    submission,\n    on=\"StudyInstanceUID\",\n    how=\"left\",\n    validate=\"one_to_one\",\n)\n\nassert submission[TARGETS].notna().all().all()\n\nsubmission.to_csv(submission_path, index=False)\n\nprint(\"Submission validation passed\")\nprint(\"Path:\", submission_path)\nprint(\"Shape:\", submission.shape)\nprint(\"Minimum prediction:\", values.min())\nprint(\"Maximum prediction:\", values.max())\ndisplay(submission.head())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-22T08:52:30.552254Z","iopub.execute_input":"2026-08-22T08:52:30.552763Z","iopub.status.idle":"2026-08-22T08:52:30.590101Z","shell.execute_reply.started":"2026-08-22T08:52:30.552742Z","shell.execute_reply":"2026-08-22T08:52:30.589433Z"}},"outputs":[],"execution_count":null}]}