{"docstore/metadata": {"/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/docs/source/conf.py__Configuration_file_for__exclude_patterns._": {"doc_hash": "64179295c7e4b1688b2a1ab1b5acf0626dc8f2cf7bcdd96b43d6389d17e56743"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/docs/source/conf.py_generate_apidocs_generate_apidocs.subprocess_check_call_": {"doc_hash": "10a8ce9e198196367aa18a06320178578357ac476ce8abc0631470afa091b5d6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/docs/source/conf.py_setup_": {"doc_hash": "96d7c1a913c5e5b19f801f57244bfabf4a1b6fb98c4828c027a7e809c7899399"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_evaluation_array.py_sys_main.model_eval_": {"doc_hash": "87dc834845ee9e193c43460c3a818528c43be8b4ceb042005fa07991b1c3ba11"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_evaluation_array.py_main.with_torch_no_grad__": {"doc_hash": "17374bb00036c93b0537dbb21cdb26b355ed1475a63206f5fb184ad7dfbc34f0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_evaluation_dict.py_sys_main.model_eval_": {"doc_hash": "b40120110e1a8fd11a8b84a64c6bcebcf97dbbed4e8ed22ab29ddf1c4acd6f68"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_evaluation_dict.py_main.with_torch_no_grad__": {"doc_hash": "9e44d2aa28bf0113c813a8ede712db36791c2be5725bed8a010364eb3f49707a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_array.py_sys_main.images._": {"doc_hash": "2d272b7229cefa75c8a2e9f2323f18c28efddb634ee8ac4900297304a9d15782"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_array.py_main._2_binary_labels_for_gen_main.writer.SummaryWriter_": {"doc_hash": "5e81cf2d97f510b2707e8edfff95038150bf0608a98a6801e2395cff57a613a7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_array.py_main.for_epoch_in_range_5__": {"doc_hash": "658e26e6529d21c919718229c3daa07a7a9049226848bd2bae4677571780567f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_dict.py_sys_main.images._": {"doc_hash": "de6583d720cd2ee3055928ee468303c2618a6c774b10a56a1d54bb7540500760"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_dict.py_main._2_binary_labels_for_gen_main.writer.SummaryWriter_": {"doc_hash": "8d25692de8be69a7ba4cfa582ab504d6a106aca64c9334b04eb530700a7d18c3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_dict.py_main.for_epoch_in_range_5__": {"doc_hash": "9fa59fe12eecc9cbac0b84b0ed8154cab2a4cc9a6654570935667065c313caf1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_evaluation_array.py_sys_main.val_stats_handler_attach_": {"doc_hash": "c86a45886955eb05ea08e301a94202a84c57fa91a3a182368e6647353b87f877"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_evaluation_array.py_main._for_the_array_data_form_": {"doc_hash": "ffc917ef169b4b368076401546c83e5248eb630dae7e79dc49f28ec1ae3e1ded"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_evaluation_dict.py_from_ignite_metrics_impor_main._add_stats_event_handler": {"doc_hash": "24769f75b59fe3244571ca3b3e1f60fb5611acadf73737c1221bc007d2d90069"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_evaluation_dict.py_main.val_stats_handler_": {"doc_hash": "d49b1c4a982703ca3cf3f946be401a841d26cb3549e8a1a6263bdc81c05cdd1d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_array.py_sys_from_monai_handlers_impor": {"doc_hash": "f46f3759558051889f5d1e9ba776d7dae79667ea0d2d67a241de9128afdd4f53"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_array.py_main_main.images._": {"doc_hash": "7638963c6d63ffd558e6c722e3441a12cd44aa319da36d93d885c652bd06ded6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_array.py_main._2_binary_labels_for_gen_main._add_handler_to_record_m": {"doc_hash": "c2e0253e6d973f62881c538067125762ce85b81b8d6a88c60faa1b010edfd63d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_array.py_main.val_tensorboard_stats_handler_": {"doc_hash": "4ed2981b68ca385bc4fdaf122aaaa865d43aa68745e2113eb827bc05a2418aa4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_dict.py_sys_from_monai_handlers_impor": {"doc_hash": "e2f2d01e708732eeb43b99177783bb82036d913f7164a1e53fad0e47c49422ea"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_dict.py_main_main.images._": {"doc_hash": "dfd86ffe223c5b80f033c6bbaad37b78e4e4cdfc18ad24aa70342e1949faa548"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_dict.py_main._2_binary_labels_for_gen_main._add_evaluation_metric_t": {"doc_hash": "f5462599f95a93397a2c2c5d7fa4016b84fe86bda9c114a17fb475918fbd7739"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_dict.py_main.val_metrics_": {"doc_hash": "29fd32f20862887ebec6b0bae6d752e8bddfd68f0962426f6b88c317d8aed939"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_ddp.py_os_from_monai_metrics_import": {"doc_hash": "9270f6a6c1e0fd5ad82e626638c26088bec144c9937b0a73ddc154260645ad5f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_ddp.py_evaluate_evaluate.with_torch_no_grad_.dist_destroy_process_grou": {"doc_hash": "c846d4add0b0cd81947aabd4f87da6039759cd4b55146cd1b1185d0289ea1083"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_ddp.py_main_": {"doc_hash": "cb3d4d088f7de2c7b75caface71dd5cf4e7ddb1e90e923c2e4b471df3fa77e60"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_ddp.py_os_from_monai_data_import_cr": {"doc_hash": "f205d05594f2e9937f304e0b5cc5147fba061100511cf15ee0260bb36ad890c8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_ddp.py_train_train.epoch_loss_values.list_": {"doc_hash": "5c4378792bb8a42e456c8381c9843c4fbded6711effc0293872aa0a2b96d3a62"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_ddp.py_train.for_epoch_in_range_5__train.dist_destroy_process_grou": {"doc_hash": "6e1fb73594d50b9cfee74ed6b3b98b68c4eca0d2b58e6dad28fd3c9786bbeb2c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_ddp.py_main_": {"doc_hash": "29013157a7ff85ecf972cafd0536f84adb85b251a3234da1b85bcd6eb826337f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_evaluation_array.py_os_from_monai_metrics_import": {"doc_hash": "d12788e683a24b353a1e5c11439981adc31c265544243b756fe57219270b0a6d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_evaluation_array.py_main_": {"doc_hash": "d9896e1730dcf70dadd1e7ed470d4ea1922f1582e574bfdf5bb672ad65dee6b1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_evaluation_dict.py_os_from_monai_engines_import": {"doc_hash": "da213c3d99faa16eea3d89fab9fd6f8e8fe48d4267d3948cebd9222652fc7cc8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_evaluation_dict.py_main_": {"doc_hash": "b2470e7147ef96be88269cc35525e304363496541cb4479f36bc26d8fc00c488"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_array.py_os_from_monai_visualize_impo": {"doc_hash": "ee64b8818a3db636871eed5871711e64d1a5f88333d21f494f506fcc473505ee"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_array.py_main_main.writer.SummaryWriter_": {"doc_hash": "e8416381b053e242ff7edb8fe52b8870eafda11bfe5744e9cec48b177347d8d1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_array.py_main.for_epoch_in_range_5__": {"doc_hash": "fde690662b30c17566beda0de131af026312f018ba6407767a6ddd15a7e2d538"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_dict.py_os_from_monai_visualize_impo": {"doc_hash": "11aa318f0841d6d7b651d992411bf170a4c3d91b1ab59088db0920eef1b0e33a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_dict.py_main_main.dice_metric.DiceMetric_include_backgr": {"doc_hash": "e6d7f3050796394baaf2b3721a56b04342996c38a18fff58e7147cc946e203bc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_dict.py_main._create_UNet_DiceLoss_a_": {"doc_hash": "e6366cf4b81a3f93b2bd802ff9bccff2fffb065d1a8ce356027b41c6ad8062c5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_evaluation_array.py_os_from_monai_networks_impor": {"doc_hash": "3e4762ee69d597404d15dfc2a7a948cb4ca8451441328b85d088e3c84ddcc062"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_evaluation_array.py_main_": {"doc_hash": "41e74ef49f7aca382fa51015af83a7633a7b7af23a37401e7555562cd51df97d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_evaluation_dict.py_os_from_monai_handlers_impor": {"doc_hash": "e0ae2439273ca375fb9a751ab7b458af459d241a3ef7443335865482e0b9e7df"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_evaluation_dict.py_main_": {"doc_hash": "95ab4566bd9ce7db6683c9c0c4506132c38079b23518b74f2e909326c09fe119"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_array.py_os_from_monai_networks_impor": {"doc_hash": "ebc0054bb3b3cfc4f24f5d3bba06276c882021443fd160416920212890678d93"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_array.py_main_main.checkpoint_handler.ModelCheckpoint_runs_": {"doc_hash": "c5f19762e2817568f9c844e9d97e5259f673501a951051e4bfee82d9da3554df"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_array.py_main.trainer_add_event_handler_": {"doc_hash": "c3798e84a2ff0c25b786987a9f32d128c962377e4bcbe298f618def2fa6b4396"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_dict.py_os_from_monai_networks_impor": {"doc_hash": "be92e30df2838b483b9492fb2472bad9d087fb070bf6718be1fb5a69dad4a17b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_dict.py_main_main.val_loader.DataLoader_": {"doc_hash": "96de3917f1b78da084cb0bee20d21a38a36fe7ac135a5146354091002b243509"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_dict.py_main._create_UNet_DiceLoss_a_main._add_handler_to_draw_the": {"doc_hash": "c6bf187186d75b72d97b71ed71c1953ee748efc87338c56603b52b42f47f380a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_dict.py_main._here_we_draw_the_3D_out_": {"doc_hash": "642be43ada70b5c094e8f1300452c097ecb9157a4d5eaf44fc3a66e50f20104a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_evaluation_dict.py_os_from_monai_inferers_impor": {"doc_hash": "e1be462549c88ac3421fc4135d1bad29d1df35e9de5a1ef09f60d48e6719bf58"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_evaluation_dict.py_main_": {"doc_hash": "d1ae9020eb2fcc34d6aecb4cfd331cc6574c4c40deacdad47ad19f3468359f0e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_training_dict.py_os_from_monai_inferers_impor": {"doc_hash": "3a942c1e2d5ba43ac8d9ac202ab4697f6520814c14ae4a4449dffb84b793a24c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_training_dict.py_main_main.lr_scheduler.torch_optim_lr_scheduler_": {"doc_hash": "383276e87bc9b69fe079c4d4bb30b1d86c41ce913ddadb169f157945798a351e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_training_dict.py_main.val_post_transforms_": {"doc_hash": "ab77422adf2a45b67cb832c75028285bd707643bc5d61d4c7d40b54741ee431b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/__init__.py_os_": {"doc_hash": "d24823b9161201d370eb42942624f37539a0196f61ed3a678f5a48ddba7a8e8d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py__This_file_helps_to_comp_sys": {"doc_hash": "680f5a8f985043363959b370b107e91996a8355031aebb99d8e8e0ea4e3a620a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_get_keywords_get_keywords.return.keywords": {"doc_hash": "87b91a61467dec11a0f5dbd405a26ea6e941be28cf983d33435a27de60840d7f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_VersioneerConfig_register_vcs_handler.return.decorate": {"doc_hash": "0d93bb584852ed73cd24d622e1af7df94222a5e65d9cb011941cbb41a8aecda7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_run_command_run_command.return.stdout_p_returncode": {"doc_hash": "1e69a35f56dc4e68c57033a00af6c44354b1250bee2ad6bdacc000d8583e928a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_versions_from_parentdir_versions_from_parentdir.raise_NotThisMethod_root": {"doc_hash": "e47e525037bc2ce6193b5076ff665e346e55f7c0c9f068cb139e329946e70db1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_git_get_keywords_git_get_keywords.return.keywords": {"doc_hash": "bb13ca9fef81c111de6c05b5abcafb2fb4e1c6f8d44fc541af7762d7ad8dabd3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_git_versions_from_keywords_git_versions_from_keywords.return._version_0_unknown_": {"doc_hash": "5323127d7bb16cc0bb393ff48d24d9853f8f6b62c87516cfd4f609e0d5823aa1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_git_pieces_from_vcs_git_pieces_from_vcs.return.pieces": {"doc_hash": "47ba8dfb1221441f58ab7dbc8ebdb96c0bad0312a8e96f87cfb39c02da5ec7b7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_plus_or_dot_render_pep440.return.rendered": {"doc_hash": "179e54ddc2f68ab800a32ab8a3aa4824128450a9304cf1ff5cf0633b10b38146"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_render_pep440_pre_render_pep440_post.return.rendered": {"doc_hash": "380ee116dc41d70ef258364ce78ead5c5fa3657a35105e3945d847948eec894a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_render_pep440_old_render_pep440_old.return.rendered": {"doc_hash": "842e375e39745e7489a13633cac168542114a64242c56a8d10d440d430fe1a2a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_render_git_describe_render_git_describe.return.rendered": {"doc_hash": "ca541fbf5be193f49c52a416bac7e1d201efd978e8208ed40a48b29431f0b56e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_render_git_describe_long_render_git_describe_long.return.rendered": {"doc_hash": "b4ee82712caa15ee150826c967776c9a320b1219fe2c0a210345babe4ec42a0d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_render_render.return._version_rendered_fu": {"doc_hash": "0f4687c560f37254bb87c5c3a17afa33761af6a46c8e77a09c24b698b000c7fd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_get_versions_": {"doc_hash": "7ca3c74c3d0e7d8f2b665f5860ed24765bd558fc33789fb9d615a39447784d0b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/__init__.py_from_utils_import__": {"doc_hash": "72dba0d51e9a2fe1e35f51c234443703e7a261159d220e591ce57a1ff010233e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_from_typing_import_Callab_MedNISTDataset.__init__.super___init___data_tr": {"doc_hash": "792006757762c83169055764e28424388569cbef9eb24f2b5ce84c0fcb8ee817"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_MedNISTDataset.randomize_MedNISTDataset._generate_data_list.return.data": {"doc_hash": "404cd4ab9bf8773fcfff13bc4dc64b5076e5a823aca5e3357146bab51999e4b8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_DecathlonDataset_DecathlonDataset._": {"doc_hash": "59ac316b3eaf4339cb294cf37166d122c1e6ffc33b6435ef1bed1ab100f33c81"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_DecathlonDataset.resource_DecathlonDataset.md5._": {"doc_hash": "5b3d1a3cbcbacdfc15bf53782c7e24bb1ee8283aeb53e58805ce3a0416c72de5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_DecathlonDataset.__init___DecathlonDataset.randomize.self.rann.self_R_random_": {"doc_hash": "c614d8fd18b3c4765d1fcc08cb019a9f190572bbf05b83474fa810f0e6b9339c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_DecathlonDataset._generate_data_list_": {"doc_hash": "816ffe5097c2541d5230f40a114a100ca07f325f0c018864bfd913df795a6985"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/utils.py_from_typing_import_Option_check_md5.return.True": {"doc_hash": "7ac9d37a3abc35f33d3ffbf479fa0893e0ac1b81a32714095f5e45c795f04d0f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/utils.py_download_url_download_url.if_not_check_md5_filepath.raise_RuntimeError_": {"doc_hash": "c5c39e9413a6e1f2be23f578fe70013d069c81f785fb018c74bb515874602344"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/utils.py_extractall_extractall.if_filepath_endswith_zip.else_.raise_TypeError_unsuppor": {"doc_hash": "8330061f303832695499a2609796c1db9c6a75a26712494fe44c46b8cbecef60"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/utils.py_download_and_extract_": {"doc_hash": "9e26e9dc600906275040b834833708502a9d294e0735ab3ef71057741c348f79"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/config/__init__.py_from_deviceconfig_import_": {"doc_hash": "b89ce585999367ddf7be9866b3b3d72c4d2430c372daa9e47be1dd422f151dfe"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/config/deviceconfig.py_os_get_optional_config_values.return.output": {"doc_hash": "f278f56898cacb316cf1221e82e51b513e37d571d34127ca62709584999100ad"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/config/deviceconfig.py_print_config_": {"doc_hash": "0142cde893e985d2db98465d9f0fa5c1a3a95d99c4c140186ff973d1800273a1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/config/type_definitions.py_from_typing_import_Hashab_": {"doc_hash": "e871e578768ff6131d4dbb4644b98a18332d3fcb47f7b7717e26dad8aa04980d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/__init__.py_CSVSaver_": {"doc_hash": "28c24ff1aead5a8ae014b1286758954427d5da04592778325a84902bb593ea2c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/csv_saver.py_from_typing_import_Option_CSVSaver.__init__.self._data_index.0": {"doc_hash": "82826312bf6609642ec3c1ab07bc23581009c832ad2f5f0f78f1c7941204deaa"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/csv_saver.py_CSVSaver.finalize_CSVSaver.finalize.with_open_self__filepath_.for_k_v_in_self__cache_d.f_write_n_": {"doc_hash": "141e90b4ed726d49e0316638fe2972b4dc873663a0acbdfd941e1cc6424b3192"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/csv_saver.py_CSVSaver.save_CSVSaver.save.self__cache_dict_save_key": {"doc_hash": "8f154f659fe1d74e40e0b0605db342ece5c3d29ad28fedfdfe1ef57ab4279889"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/csv_saver.py_CSVSaver.save_batch_": {"doc_hash": "4765a3093ecf1c6a388f0f00c58eddc8b6b8ade09544a711df9c6a89df3c2326"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataloader.py_from_typing_import_Callab_": {"doc_hash": "5307b832fc98e22332da431d850af2c1db4c1d8748b9c8e1d35c6f0af6ad5d82"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_from_typing_import_Callab_Dataset.__getitem__.return.data": {"doc_hash": "fb63b787ca55c5558db142e7dc11a632d7e17b3a79c24b890e9cf156b0cb2a30"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_PersistentDataset_PersistentDataset.__init__.self.cache_dir.Path_cache_dir_if_cache_": {"doc_hash": "5783e2355e7d208f462c889e7d62454b96525b3893e8e0d4c9d224cd58a6dc30"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_PersistentDataset._pre_first_random_transform_PersistentDataset._pre_first_random_transform.return.item_transformed": {"doc_hash": "1233ae6051c656f3aa0154a7e55b48e56b076a89c232d18c197c4735e3f38d22"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_PersistentDataset._first_random_and_beyond_transform_PersistentDataset._first_random_and_beyond_transform.return.item_transformed": {"doc_hash": "7bf49a9af6ea69f713b23534eae3834d3b11a97ff1e541afcbf5d6c10d2c7961"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_PersistentDataset._pre_first_random_cachecheck_PersistentDataset.__getitem__.return.post_random_item": {"doc_hash": "50171b9e48c31b4855f7d8d983abeef5e4effde45d02219e5d85b78e7cbb4b5a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_CacheDataset_CacheDataset.__init__.if_self_cache_num_0_.if_num_workers_0_.else_.for_i_in_range_self_cache.progress_bar_i_1_self_": {"doc_hash": "c2a67c1daf31f8451a3c2ec59426728fe28a480335b7d3bde5902ec97b28b807"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_CacheDataset._load_cache_item_CacheDataset._load_cache_item_thread.with_self__thread_lock_.progress_bar_self__item_p": {"doc_hash": "197dfbc0e68fb41ce21d836220598dd9601582268c5187e79b6903ae3fde28c7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_CacheDataset.__getitem___CacheDataset.__getitem__.return.data": {"doc_hash": "679ecfd4ce49201a2aad450791de89e20934ea22aa7a3c2101c0bd47ebfa2473"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_ZipDataset_ZipDataset.__getitem__.return.data": {"doc_hash": "97f3cda1b269df0d868e500e82456f4da24eb635dc7a3bbf24231f74332ea2c6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_ArrayDataset_": {"doc_hash": "d7289b0e9a127b5cc52b88df598b9a2a24152e5cbd560a4a6e5feab1e5968c5a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/decathalon_datalist.py_from_typing_import_List___append_paths.return.items": {"doc_hash": "e395d84ccd5b2ab2e60295e5f1e44eaf084c13888f57c009407fe9d9e987c9a2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/decathalon_datalist.py_load_decathalon_datalist_": {"doc_hash": "f998624e9001c483a020c8c75146fbf8234e323faf5d6a030dac7b90313df03e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/grid_dataset.py_from_typing_import_Sequen_GridPatchDataset.__init__.self.pad_opts.pad_opts": {"doc_hash": "b0e7fef53b59606a4ef03eacc77931374adad3caba64fa5a97317af46653df5a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/grid_dataset.py_GridPatchDataset.__iter___": {"doc_hash": "92e2cdb8e3d8a4f0269d01f55aa06902f1e5c4771c1c69901018ee79dfac9d99"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_reader.py_from_typing_import_Callab_NiftiDataset.randomize.self._seed.self_R_randint_np_iinfo_n": {"doc_hash": "6b8d979a4e21f54fd63ffac5a6470b54fee0564c220b818de52c0324897c1e03"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_reader.py_NiftiDataset.__getitem___": {"doc_hash": "241fd29c883c8789237ea1ee90fbeea9a0408d29a8ca9f64ffdbc63f92878c4c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_saver.py_from_typing_import_Option_NiftiSaver.__init__.self._data_index.0": {"doc_hash": "47fb71f6ff208355b1444d3a0e20f4b44ba55217c2a3f87d6a35e9519b9f810e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_saver.py_NiftiSaver.save_NiftiSaver.save.write_nifti_": {"doc_hash": "199177bef02c48a101bbec9f23c506f8169b6cc32bf305d9d74dc3b3457ebe19"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_saver.py_NiftiSaver.save_batch_": {"doc_hash": "181506e4dc55ce269224224db23b7ec8f3e36bb94e61d7f204725e6665cb204b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_writer.py_from_typing_import_Option_write_nifti._": {"doc_hash": "d6c62155e832490d45842fc780ba125075005575ba966d688c77c1d163731bca"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_writer.py_write_nifti.assert_isinstance_data_n_write_nifti.output_spatial_shape_.list_output_spatial_shape": {"doc_hash": "f32e20c367ac18321f9c40b42842129873667ba3c3923b9a023bdb162365a2e5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_writer.py_write_nifti.if_data_ndim_3_mult_": {"doc_hash": "4567455e47cbff8f67633860d535bf9c6cb661c95f01035159343a259b5dfab5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/png_saver.py_from_typing_import_Option_PNGSaver.__init__.self._data_index.0": {"doc_hash": "a468e30d76cc20eacdaaed7ffbddee4c9ccd4d149d2ed6c3dcfd925d98bdcf91"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/png_saver.py_PNGSaver.save_PNGSaver.save.write_png_": {"doc_hash": "a4c9ed965d0c7afbb898445f29fd23443babeb258cea2dc341f4dc278c476c62"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/png_saver.py_PNGSaver.save_batch_": {"doc_hash": "aed28e578960c49187e7c2b59b0c2c5e2d666d6eab1eb16266a15792560a742c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/png_writer.py_from_typing_import_Option_": {"doc_hash": "deff9fefc583d6f14fe2e6661eec62c0b7a50a6676105331d5187f720f705c5d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/synthetic.py_from_typing_import_Option_create_test_image_2d.return.noisyimage_labels": {"doc_hash": "60f22b79ca787d14bdbf012b6b203ab941dd93f2af624774fe7de826f7ffeda2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/synthetic.py_create_test_image_3d_": {"doc_hash": "58cf4f16f6a7d0299cfcbe8b220614b66e7f65b7e753c07028645fb461953bca"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_from_typing_import_List__get_random_patch.return.tuple_slice_mc_mc_ps_": {"doc_hash": "7d59d5d4b4359630ad7db73fbbc91e9a1f238245c4f633dc0c0e4ebaa98afbda"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_iter_patch_slices_iter_patch_slices.for_position_in_product_.yield_tuple_slice_s_s_": {"doc_hash": "60d52dc326813e84445428fb2c55c4bd6c5226d8c1e4cd48b064de9920cb85c6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_dense_patch_slices_dense_patch_slices.return.slices": {"doc_hash": "f6246002f799891bcae17d3914ba706be5db8a00fbcf45d87745d43762324d60"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_iter_patch_iter_patch.if_copy_back_.arr_arrpad_slices_": {"doc_hash": "ab34cc2c105529094bfca33c90e7ad42d32e4f4f84a8c1c7ac12fbe7bb0c9b2b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_get_valid_patch_size_get_valid_patch_size.return.tuple_min_ms_ps_or_ms_f": {"doc_hash": "1e9bd4d4d00153e64ed5db302f61dc9dfcc9f3d9969ef668cb1c406c9fae2ccb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_list_data_collate_worker_init_fn.if_hasattr_worker_info_da.worker_info_dataset_trans": {"doc_hash": "3fffc5147739163e636d87a2806c5f9d75df0accc55b3dc9707236216a7474db"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_correct_nifti_header_if_necessary_correct_nifti_header_if_necessary.return.img_nii": {"doc_hash": "bf1ea5d7d321b63243e2b4659531e93b9835af4bf029f60220bffc9d519b3bdc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_rectify_header_sform_qform_rectify_header_sform_qform.return.img_nii": {"doc_hash": "ecf757727213d05f7b21b09a9ad31d258bf301b1e9816943425eb2c2edae9bd8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_zoom_affine_zoom_affine.return.new_affine": {"doc_hash": "83b0a58528450e7d51e9a4ae3268e28f14d9e50193c0d6b1eb445f6a81d2611e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_compute_shape_offset_compute_shape_offset.return.out_shape_astype_int_of": {"doc_hash": "f7f4075138646b8f5e6e41068e608a8285c2623f9c6cc79487f87993ccf05164"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_to_affine_nd_to_affine_nd.return.new_affine": {"doc_hash": "511795d88920bd8d652b954663da5386da68a8d2df982ff6613a20df18e3b792"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_create_file_basename_create_file_basename.return.os_path_join_subfolder_pa": {"doc_hash": "eec5e80b3b9e0e4622089df6dfd1974a52ba5d72c29a336dbef13577d64900bb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_compute_importance_map_": {"doc_hash": "aa167d4e14fd209269c08629b118dff575e14afcb5dfc3583619b44ed4d62854"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/__init__.py_from_multi_gpu_supervise_": {"doc_hash": "182cd2aa0af8b8e53802270bb3c24be3786f4ae65407432c867b5d1cf6314b2a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_from_typing_import_Callab_if_TYPE_CHECKING_.else_.Metric___optional_impo": {"doc_hash": "6dcd62c81f76df45bc05c079b2b92442056e7239ea7ef440e425a53186d888b7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_Evaluator_Evaluator.get_validation_stats.return._best_validation_metric_": {"doc_hash": "a3396cbf5be5a4f13170dc068896e05d32864119d3641e1cfef6b6654ec86f51"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_SupervisedEvaluator_SupervisedEvaluator.__init__.self.inferer.inferer": {"doc_hash": "56519f684382d589fec54a89cf7558e4f45ef38fccdd4e5ebf649418e0ee1451"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_SupervisedEvaluator._iteration_SupervisedEvaluator._iteration.return._Keys_IMAGE_inputs_Keys": {"doc_hash": "17fd0ed04c4700bd161f0b2d06f3d0f44d279cb906c56b0bb62502e94261f4ad"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_EnsembleEvaluator_EnsembleEvaluator.__init__.self.inferer.inferer": {"doc_hash": "a0b6c7cbf2bee7eb2d219b484db7bd34a11baf9ff51159c6496c18be89a50227"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_EnsembleEvaluator._iteration_": {"doc_hash": "64e124f9d5d313f0a4d066b7029cfc4ca4cc31796e0bf99fd84a7c2878441c14"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/multi_gpu_supervised_trainer.py_from_typing_import_Callab__default_eval_transform.return.y_pred_y": {"doc_hash": "4201ad9d9111f17e945df972550344a2648d1a5036c6d57f600063311fd07b75"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/multi_gpu_supervised_trainer.py_create_multigpu_supervised_trainer_create_multigpu_supervised_trainer.return.create_supervised_trainer": {"doc_hash": "bcc8772e1330eff22928ef5e99259eb9dd73f61a53fa14961e05db7632450630"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/multi_gpu_supervised_trainer.py_create_multigpu_supervised_evaluator_": {"doc_hash": "7b6e99dabe560397ecd425a7a9e458f3b109d120b375873e1c5c1a42decf42ee"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_from_typing_import_Callab_if_TYPE_CHECKING_.else_.Metric___optional_impo": {"doc_hash": "38ddad9bb6112cd541d98c418a95cb53ba6ef2b198c506e46a8cc801542a264e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_Trainer_Trainer.get_train_stats.return._total_epochs_self_sta": {"doc_hash": "632315db3a9ef20a6f1b85d189a7cd21c8357ab99b2058cd1236d1a873a8772f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_SupervisedTrainer_SupervisedTrainer.__init__.self.inferer.inferer": {"doc_hash": "d82aecb86d950e55b795d7b34ffc2f3132c1e46d3f3f9d1700db2cff9cce78c3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_SupervisedTrainer._iteration_": {"doc_hash": "18022efb61cde5455772b46028714b9448fb40c49987889c25ce7d51157c47ea"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/utils.py_from_typing_import_Sequen_CommonKeys.LOSS._loss_": {"doc_hash": "00652a81c4b9583d531a4e08b393e0c6bf33517fda4d456b1e13ded4fbe65e88"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/utils.py_get_devices_spec_": {"doc_hash": "125b96038184225f416433d581c8a8f6354317cd45152bb849638bc9c7b3182e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/workflow.py_from_typing_import_Callab_if_TYPE_CHECKING_.else_.Metric___optional_impo": {"doc_hash": "44dad9953ee05cdcf61789df5d9fbb8a02e0ce1621f24874933baea077ac7d44"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/workflow.py_Workflow_Workflow._": {"doc_hash": "380eec7d26d15640b2dafb01fa77a69572f5161832d3f7e355d5126b75260cae"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/workflow.py_Workflow.__init___Workflow.run.super_run_data_self_dat": {"doc_hash": "b78e453b28822333987f76722ec9eed8fdf5196fc389ceaab69492b07f147808"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/workflow.py_Workflow._iteration_": {"doc_hash": "7c4f84d9e7c0c396cfb592025564a086a588533e61f4cb4d84113b36b1190e87"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/__init__.py_CheckpointLoader_": {"doc_hash": "7ca50c4f9a3c745988516b6763fa69173c4907bb93a5ccc5a49217f5ba8149b9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_loader.py_from_typing_import_Option_if_TYPE_CHECKING_.else_.Engine___optional_impo": {"doc_hash": "467d9c2b00f0251af91c69e2a77ebf82049e47791339668f7c1333d9eb1a153c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_loader.py_CheckpointLoader_": {"doc_hash": "fd994c881f036f7ba3a04fc6db0260332bd7308c7d09d8b1ee1919bd9513c171"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_from_typing_import_Any_D_if_TYPE_CHECKING_.else_.Engine___optional_impo": {"doc_hash": "852dc15d53f70372325f9c84942223bedec9c868dd5919654f93fc6a23b0835e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver_CheckpointSaver._": {"doc_hash": "f06300bad36c5138d24212bb757d40757a91db151e62c30ccb4350d72a5ba180"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver.__init___CheckpointSaver.__init__.if_save_interval_0_.self._interval_checkpoint.ModelCheckpoint_": {"doc_hash": "c2fe09637824bf3a5182610f120657e6ebdcb4c0cadf19cd1c8bc4476a0a4804"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver.attach_CheckpointSaver.attach.if_self__interval_checkpo.if_self_epoch_level_.else_.engine_add_event_handler_": {"doc_hash": "654257cb707139572b5c92f4b52fb9b89fa8bf17cc484919975abbd26370ecf5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver.completed_CheckpointSaver.completed.self_logger_info_f_Train_": {"doc_hash": "097c1c5e6abe67efe7caff7cccfff77bde5ee2e5b7a49c2311e2365cc45cc9fd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver.exception_raised_CheckpointSaver.metrics_completed.self__key_metric_checkpoi": {"doc_hash": "c08eae4415913dec12af3c47bcc4ead0f052fe0a79f6741227f8ea1f90fe998d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver.interval_completed_": {"doc_hash": "4dd0679d18a39fb51c59e85a521760e865657cea3249b98979c68d197d56f78b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/classification_saver.py_from_typing_import_Callab_": {"doc_hash": "8f0a7c8e21df49da7c579adaecb9c345492339220dc16347ed40f5ea89bc2999"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/lr_schedule_handler.py_from_typing_import_Callab_if_TYPE_CHECKING_.else_.Engine___optional_impo": {"doc_hash": "b08ef2a4ddc9a1f1c599cd39ed65bf89a700456cbef286dcaef7bd5762fe33ab"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/lr_schedule_handler.py_LrScheduleHandler_": {"doc_hash": "7d3b9722d5ff9c1f40c4bda8cc3f5aecb94f61c1e7a2d603a446e2d2f99d00d6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/mean_dice.py_from_typing_import_Callab_sync_all_reduce___opti": {"doc_hash": "a5f799ed2b74b41b6f5ed59c99e00449b330a4eb6d1cd444ed51b07a18c7901c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/mean_dice.py_MeanDice_MeanDice.reset.self._num_examples.0": {"doc_hash": "bc049fa867cc20e3e7a5078e89eeb590ba608d7dd96eac8c5bb35a9580c7b30c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/mean_dice.py_MeanDice.update_": {"doc_hash": "8a0fca3f513414d7104873cee858daec2e5dc9ef0e94d17c0625b824b836365c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/metric_logger.py_from_typing_import_Callab_": {"doc_hash": "f297f0b28230ca4ad060ea15756000ef33c76e2d4490398a1acbda9b71d6d950"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/roc_auc.py_from_typing_import_Callab_ROCAUC.reset.self._targets._": {"doc_hash": "8ad402a575047c1e109e85dfe6183fa89f6397d2c618c466722524f24524cc94"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/roc_auc.py_ROCAUC.update_": {"doc_hash": "4b4856c79d44f9b42a62679960dc3da9eb73fd8bab6aad86a6bda76045f628b6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/segmentation_saver.py_from_typing_import_Callab_if_TYPE_CHECKING_.else_.Engine___optional_impo": {"doc_hash": "19ebcb389df54a037cbf88f92c71acba3e658048844afd7c2c0cd3ae23d227f9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/segmentation_saver.py_SegmentationSaver_SegmentationSaver.__init__.self._name.name": {"doc_hash": "fd1b5471e8a00555897eb959a3a9c2aa548b3e0129feb7e68d1305e4e884d867"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/segmentation_saver.py_SegmentationSaver.attach_": {"doc_hash": "f79c5904794c2aaacd0af7b80e82897315ae54751fd9de05eafb5d7d13c6b538"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_from_typing_import_Callab_DEFAULT_TAG._Loss_": {"doc_hash": "cc44b18f8c1688dda25b3c9e4d684b5a50377a90e43825a1931766dfbffa36e8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler_StatsHandler.__init__.if_logger_handler_is_not_.self_logger_addHandler_lo": {"doc_hash": "6c68af9128258a0ed9ee341162af1114034a640b6182cbaaf84c2aa28771b607"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler.attach_StatsHandler.attach.None_3.engine_add_event_handler_": {"doc_hash": "0ea9060a03ac8937eccce3e730c6dbb26776b70f05c301b866b0756bc23ef12c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler.epoch_completed_StatsHandler.exception_raised._traceback_print_exc_": {"doc_hash": "e846a12e3ed608410afbc9dc17d6f136b62659f5f7bdb6e2886e94dea2328a61"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler._default_epoch_print_StatsHandler._default_epoch_print.None_1": {"doc_hash": "b14c1a1bac0b0e862b6c29d70d0080e48b195d5e4d8b20d7fb85c15649130abe"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler._default_iteration_print_": {"doc_hash": "a7aa06a892cd1f9ea08c708134dca0488e27a51a85dd908f80f814f79e42cb61"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_from_typing_import_Callab_DEFAULT_TAG._Loss_": {"doc_hash": "0474cb60d0ce9ba3adfc205648342769393346fb6aecaa74a84ccc9370216587"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardStatsHandler_TensorBoardStatsHandler.__init__.self.tag_name.tag_name": {"doc_hash": "45f5dd320fd955f64df00883f3a5f667380b608025815fb688caf45fb1be4dbb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardStatsHandler.attach_TensorBoardStatsHandler.attach.None_1.engine_add_event_handler_": {"doc_hash": "bb9fd9f803a9d8016dcb4db4eedda635df3761ed2f47c528d9a20202b22171b1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardStatsHandler.epoch_completed_TensorBoardStatsHandler.iteration_completed.if_self_iteration_event_w.else_.self__default_iteration_w": {"doc_hash": "27da4a60de3445985caa077de3ee6fd51508ad0aeb0713c28de9a14cd5e435f6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardStatsHandler._default_epoch_writer_TensorBoardStatsHandler._default_epoch_writer.writer_flush_": {"doc_hash": "6650cc52f9066b7e29da862832cce8da852c520cc362d3510443bdde244177a2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardStatsHandler._default_iteration_writer_TensorBoardStatsHandler._default_iteration_writer.writer_flush_": {"doc_hash": "1a36f34b2d88e76d94aa3bb4bb1ba0169738281e99b915529a20dabee1eadcb0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardImageHandler_TensorBoardImageHandler.__init__.self.max_channels.max_channels": {"doc_hash": "62215d184a6d60ac35665e6a2a005d4c0ecd84b8edd99bd9b9bbe8504f534612"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardImageHandler.attach_": {"doc_hash": "7cd39e6cf725df675db0e107df95351e8714ce9b5a8c4c38ed7808c7356d025b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/utils.py_from_typing_import_Callab_": {"doc_hash": "ad82c0ffcd5a2c50c04e7accde77964d54ea6eb58b964b7daea4b4de9079696b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/validation_handler.py_from_typing_import_TYPE_C_": {"doc_hash": "f26a2f62ab3646ff72d7b7a03c41bf42bf0ec54e6574d2eb2ccc4fb4698d4e99"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/__init__.py_sliding_window_inference_": {"doc_hash": "aafb53fd23fd9466f56866912035ebdaa8572011cf7086946df21a239b911214"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/inferer.py_from_typing_import_Sequen_SimpleInferer.__call__.return.network_inputs_": {"doc_hash": "172cdd3351a569812f6632989234c2c8641eb59566cf4fa43db8d29da0485b69"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/inferer.py_SlidingWindowInferer_": {"doc_hash": "851cf4db57cfcd7fbd9a1e58035bebd23ffa3c93df0825dbb94ecf6b4d499c40"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/utils.py_from_typing_import_Callab_sliding_window_inference.pad_size._": {"doc_hash": "75adc6d07602042a927170429c8da615cce8decc83e8a0354cd59f40e31bd172"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/utils.py_sliding_window_inference.for_k_in_range_len_inputs_sliding_window_inference.output_image_count_map": {"doc_hash": "4f306c1004f524da5a2160d317c407607d27ad201fc42d1c16de769ac68e0722"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/utils.py_sliding_window_inference.if_num_spatial_dims_3__sliding_window_inference._2D": {"doc_hash": "1b7271131c86114d54ddfa7daa383cd333dbb63acb537688095aac8183a18bc4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/utils.py__get_scan_interval_": {"doc_hash": "e6ab07c68b812d5d437b4ea77b1cff010d420136ee60a848f4912a99f603e38e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/__init__.py_Dice_": {"doc_hash": "59fc15170e5b5f866df2d0e2207dbe297fc4aa01d248e539694c66452470a963"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_from_typing_import_Callab_DiceLoss.__init__.self.jaccard.jaccard": {"doc_hash": "8a18c0f679b68c124a11b050ac2e772ef4413fd1bdc50f9697b51b867bb53141"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_DiceLoss.forward_DiceLoss.forward.return.f": {"doc_hash": "aee3db3b91cf7c1394a1aa0a1d3c6d530df5f34a4a463268009eb8b162437a81"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_MaskedDiceLoss_MaskedDiceLoss.forward.return.super_forward_input_inp": {"doc_hash": "d85c28d32d6758c78793e5dffa13baa521fcc003177f720713a01f521b211d46"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedDiceLoss_GeneralizedDiceLoss.__init__.if_w_type_Weight_SIMPL.elif_w_type_Weight_SQU.self.w_func.lambda_x_torch_reciproca": {"doc_hash": "297885f23a371ecbe3a7028c149750893c7539411624231249639a3550886c9e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedDiceLoss.forward_": {"doc_hash": "63185aefa4c4b9f763f6879b15444919b30dabceee2467b980288ab5f6342fac"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/focal_loss.py_from_typing_import_Option_FocalLoss.__init__.self.weight": {"doc_hash": "9d0e2e625f009e5c54ff0ecba0746efe1eecc84ecfbf6ffeda49262a83590f9b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/focal_loss.py_FocalLoss.forward_FocalLoss.forward._N_H_W_or_N_C_H_W": {"doc_hash": "bc2bd21c3133ec62875d5ea3fbaee43c42a8e9f21fef95cea2c8dc8067122883"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/focal_loss.py_FocalLoss.forward.if_self_weight_is_not_Non_": {"doc_hash": "1d7c0fb9ba726fee37829020c3d398a88c94017da6a82468528417a799bdad71"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/tversky.py_from_typing_import_Union_TverskyLoss.__init__.self.beta.beta": {"doc_hash": "10731a2e6ceff1362e1e84011532a2b284792af217ea333779c29ee218a7dd5b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/tversky.py_TverskyLoss.forward_": {"doc_hash": "b8a3b11b8accb84c1881ec0c2923b02a4906c232e104990c75c4176bc209a28b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/__init__.py_compute_meandice_": {"doc_hash": "bd534d65f1566824774bfb9e3ffc1c7683b71426040854694cea030674214568"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/meandice.py_from_typing_import_Option_DiceMetric.__init__._keep_track_for_valid_el": {"doc_hash": "d48d83fe968008cc42c40e5528a299ff3c1dc49c5da78250fcbef7683c0d0a8f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/meandice.py_DiceMetric.__call___DiceMetric.__call__.return.f": {"doc_hash": "6f3cdfe1894a026a48418acb23c75e1779a2682a4b1ddd61f0407f964d64a594"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/meandice.py_compute_meandice_compute_meandice.if_not_include_background.y_pred.y_pred_1_if_y_pred_s": {"doc_hash": "b2cab2f058d06a463a2a989b98b138a1d49540fe3b2c00e36ae6e11eb29a9305"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/meandice.py_compute_meandice.assert_y_shape_y_pred__": {"doc_hash": "c8a0c90a25f01f60dd04c5cb88c88cb431baf3f3698814587425af9291204394"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/rocauc.py_from_typing_import_cast___calculate.return.auc_nneg_n_nneg_": {"doc_hash": "578484cb18be1d45b2699168cd539b29abc5ec8829bdd252a04c716731451e7f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/rocauc.py_compute_roc_auc_compute_roc_auc.if_y_ndim_2_and_y_shap.y.y_squeeze_dim_1_": {"doc_hash": "dd3003207c5745c840c720ec62e6df6938d212747431adee28890bff165ecf49"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/rocauc.py_compute_roc_auc.if_y_pred_ndim_1__": {"doc_hash": "641604c44acaacdc20f3db96080ea3186aa9f5f23b1f9a1ea6d07e006189cdac"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/__init__.py_from_utils_import__": {"doc_hash": "514302e911631aa2e6e7c82e847711baac71058625d9828e2c36dce9aabcf9df"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/__init__.py_SimpleASPP_": {"doc_hash": "617cf9d5c6382799440cabac524d9eb4a9e076eba7d1cbd1906db80154cb702e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/aspp.py_torch_": {"doc_hash": "177ca14e2d8751158d00579a20386170528a087a85fbf1080e9af12c0a034aae"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/convolutions.py_np_Convolution.__init__.if_not_conv_only_.if_act_is_not_None_.self_add_module_act_ac": {"doc_hash": "c0b73f36412da9de4d2b6889fcd378e8b8d749e17c9126ef2bbf0db3781edaf2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/convolutions.py_ResidualUnit_": {"doc_hash": "a22a0f7397ca133b8350210e2bcedf404a1a331e00cb8137ed5c7302251a3647"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/downsample.py_from_typing_import_Option_": {"doc_hash": "d4d49a9a8bcc64c5b87bf6f7089e66586f111c4c30c8ef727e6ce06bc28f28ea"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/squeeze_and_excitation.py_from_typing_import_Dict__ChannelSELayer.forward.return.x_y": {"doc_hash": "590a7d4d2e4f66e8f5a8fa3dc6002a4737717681b0625863848659976baf350e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/squeeze_and_excitation.py_ResidualSELayer_ResidualSELayer.forward.return.x_super_forward_x_": {"doc_hash": "c1dbc64ba7cc670e81fa876064aee5144428ab331babbab534f3e54fe40ee124"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/squeeze_and_excitation.py_SEBlock_": {"doc_hash": "212df1cd5d5f5d610f012e8aa7aab818896aad87797a6b40b1b7e6c054f4c018"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/upsample.py_from_typing_import_Option_": {"doc_hash": "24dc67272ff4c0e122cbb3e345f84440e5c28405c5d4203cfce3c2ad824d19cc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/__init__.py_from_convutils_import__": {"doc_hash": "a2bb4dbfc311d28ec949eb527f3cba1a26c53a54e78254ac3fab4f3c7b968c86"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/convutils.py_np_same_padding.return.tuple_padding_if_len_pad": {"doc_hash": "9e5991348db6d50505db1ca1ae0a2a9051c3484d189157f599793b9fa7d7516e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/convutils.py_calculate_out_shape_calculate_out_shape.return.tuple_out_shape_if_len_o": {"doc_hash": "0a6ce0c9a22e0ff952589796208f95ee03f07563aeac87676091c6fb36a59961"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/convutils.py_gaussian_1d_": {"doc_hash": "2729b078104291f5892cb18fb6c8fc8cd8a104dda86e42565bdb2a8f01665850"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py_from_typing_import_Any_C_LayerFactory.add_factory_callable.self.__doc__._": {"doc_hash": "57f0e05022ab09722ed517f21323c708ad4627bcd2e63b84e4535f9a94f76e98"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py_LayerFactory.factory_function_LayerFactory.get_constructor.return.fact_args_": {"doc_hash": "49b70ab5167272600a56207dfc9c289b9d53ec7214812f4e112bf1d34e1ec1b0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py_LayerFactory.__getitem___LayerFactory.__getattr__.return.super___getattribute___": {"doc_hash": "7f669f5b46fbdfa4fcdd5e7e7ec960fe524d60cca6f84bf2deb47ae2596abbd9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py_split_args_split_args.if_isinstance_args_str_.else_.return.name_obj_name_args": {"doc_hash": "606bae0a77f9b2914e7c6e92f59d109bc4c115ea54bfd809bd2975710e71de79"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py__Define_factories_for_th_": {"doc_hash": "4da303977614be02889e5ed44abd95d360d6e7123484b78d035f15afd5d7917d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_from_typing_import_Sequen_Flatten.forward.return.x_view_x_size_0_1_": {"doc_hash": "6af5499acce1566510752a2d3b72dffba40d8368f8694f7cb3b09f3ef31418ac"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_Reshape_Reshape.forward.return.x_reshape_shape_": {"doc_hash": "6b4784f9c8aae0df9e3d269f13007a713ec7985efe194529b272eaa8bf57d4f4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_GaussianFilter_GaussianFilter.__init__.for_idx_param_in_enumera.self_register_parameter_f": {"doc_hash": "74d22e6d1cc24faf10151bbe2a1671fa168506bcc791a483e8145cbf690ef04a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_GaussianFilter.forward_": {"doc_hash": "11e01fa923ad8ed55b071910bd6f8bef6457938d8e0b651d4d234f38454e0fe6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/spatial_transforms.py_from_typing_import_Option_AffineTransform.__init__.self.reverse_indexing.reverse_indexing": {"doc_hash": "c4ac70130a5900dc5e0fdbefdbae10aea69bd6d118ecb684bb0b8cc0c882d9ce"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/spatial_transforms.py_AffineTransform.forward_AffineTransform.forward.if_self_spatial_size_is_n.dst_size.src_size_2_self_spati": {"doc_hash": "620c5241a0186a0a6c4ad65231bbcd2af3d3e80dfb8601dafc66a6b06bd367c9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/spatial_transforms.py_AffineTransform.forward.if_spatial_size_is_not_No_": {"doc_hash": "24dce032691e683ed33d321e716bfa2ed582ca2fed140b5746c91c3b3e6b20b0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/__init__.py_DenseNet_": {"doc_hash": "b90cea2f0b40a9e1d231e373e6142095d3a7dc797dbb3cd604a34a043fd2acf9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/classifier.py_from_typing_import_Option_Classifier.__init__.if_last_act_is_not_None_.self_final_add_module_la": {"doc_hash": "1c3b97336fec25412267071237aa05c870bc13f3b72f26f569b730fe2a3a061f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/classifier.py_Discriminator_Discriminator.__init__.super___init___in_shape": {"doc_hash": "8900dd25be55f6113d392d918a1e456dd37253335c69cbb9a5fe45dfce2ea9ad"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/classifier.py_Critic_": {"doc_hash": "c513bc3eca298db6aa672b324a805c7500941d008d3ed523f4c79125e9e66304"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py_from_collections_import_O__DenseLayer.forward.return.torch_cat_x_new_feature": {"doc_hash": "c6f25d26ee7f4cd19c905c6ba2630e1c21d8cceb5a83972785501f5229971e4b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py__DenseBlock__DenseBlock.__init__.for_i_in_range_layers_.self_add_module_denselay": {"doc_hash": "c45e10684b008c092ec76bf3cad9a30d6b81c6c4b85abf79f5ce13861d6be1eb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py__Transition__Transition.__init__.self_add_module_pool_p": {"doc_hash": "c1c43c6f26b574ed0b14511293bba711af7b0e125c97b5c5cdabe635c6385cf9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py_DenseNet_DenseNet._": {"doc_hash": "7d54ecd86e42d4a3699ee2bb8b3122bb67939d5986230dc71ca687b3ac08d960"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py_DenseNet.__init___DenseNet.forward.return.x": {"doc_hash": "8d71535a9ac7060e2b5a4a5b3c5503ae6c18e3a79792915ddf51fb86ec98a5fc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py_densenet121_": {"doc_hash": "c654d4ec4dcb7f307e54b2b89a6d5537ba3eaa384e4e6a71fa92d8b82685e5b5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/generator.py_from_typing_import_Option_Generator._": {"doc_hash": "ebfce1675fd572ba12c6159be913cff6da7c2269307853494f29acd6f16835b5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/generator.py_Generator.__init___Generator.__init__.for_i_c_s_in_enumerat.echannel.c": {"doc_hash": "9271c691733d8e723f52c7b4ad59fa479d383c6aa2988e0683af71765ea1e1d2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/generator.py_Generator._get_layer_": {"doc_hash": "f47b4da4273003b84832574f5306b087b3408b815c46e1ea9690102b550a0c09"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/highresnet.py_from_typing_import_Option_DEFAULT_LAYER_PARAMS_3D._": {"doc_hash": "007fcda46274b37fc3f97f4590bf69a804fc225a6f7cc36343719ceec7f55627"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/highresnet.py_ConvNormActi_ConvNormActi.forward.return.self_layers_x_": {"doc_hash": "b18760ba98df6930ee2c8d0f3126612da689db78f2cefe39af9dd2616c0a3129"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/highresnet.py_HighResBlock_HighResBlock.forward.return.x_conv_x": {"doc_hash": "30e84ec6aeb39301203b1ea4672678ae9a59f5306031bb8f973b90a5c351ec83"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/highresnet.py_HighResNet_HighResNet._": {"doc_hash": "7f66d5920e5e45bbeca5400bb549fa27e5b7f2526649a5ef2e320b02be0af82d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/highresnet.py_HighResNet.__init___": {"doc_hash": "4b17e48b0110bcc43ae7ad6668b1925db81755ef3c9e7fec7bb8b98202c8991f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/regressor.py_from_typing_import_Option_Regressor.__init__.self.final.self__get_final_layer_ec": {"doc_hash": "386c9d4220e7dcac33768ac77078d25117c8903a786cb6bece89cabe307b5a2b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/regressor.py_Regressor._get_layer_": {"doc_hash": "cd358f42b442b3b65672ae361e99474a866d6506abfe35e2a58c56c0dff04162"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/unet.py_nn_UNet.__init__.self.model._create_block_in_channels": {"doc_hash": "7d812439bd6c88a785deb22c85ed29dd6bfd9e1f9f528f59c800a3c5553b1f4a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/unet.py_UNet._get_down_layer_UNet._get_bottom_layer.return.self__get_down_layer_in_c": {"doc_hash": "95ed4942618921c3bb70417d4dea6c166cc5d2118263ddb2918c70f73c332d86"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/unet.py_UNet._get_up_layer_": {"doc_hash": "0331c79853c5a5a05a42cf2450c36caa835556c46d7259638a2e62baac19e110"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_warnings_one_hot.return.labels": {"doc_hash": "67702b2f29dee22525fea49cf69840053c1a185d100b589b5eeba2c8f0d9c8d5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_slice_channels_predict_segmentation.if_not_mutually_exclusive.else_.return.logits_argmax_1_keepdim_": {"doc_hash": "cb5d1a4d3d0588ecfec36d87a0127a01e6b8ebe209469bd206dbbe786fd6199b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_normalize_transform_normalize_transform.return.norm": {"doc_hash": "768d10af11b1d9ec75adb563730c98ee3f25ce884724b9eabb3c49520ef96059"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_to_norm_affine_to_norm_affine.return.new_affine": {"doc_hash": "d141b7d9c1ed9ae1311bb9fdabcb3afd83bd1b4a57f6845ddaad9d5f42f209fc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_normal_init_": {"doc_hash": "2de2d17ad0cbda43b3da93065ad60f166db9431b4f271b08af4bd1ad9bf7aceb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/__init__.py_from_croppad_array_impor_": {"doc_hash": "08fe979d2c92427ba7c1d80aea24ef64e2480a2ad18ba6f4f66a76aad118e37e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/adaptors.py_from_monai_utils_import_e_adaptor.map_only_names.return._v_ditems_k_for_k_v_in": {"doc_hash": "28a6009c5660bf1f1c143369628b99834943390414ba1af24e5d6a6b3407c0a6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/adaptors.py_adaptor._inner_adaptor.return._inner": {"doc_hash": "98f1c39523a4f7bee83b6cb6f35651655d78f7313d89688e953c9c34b7cf77b1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/adaptors.py_apply_alias_to_kwargs.return._inner": {"doc_hash": "119b24a527ed62673608fd476b7c77e359e81d0902e36fe6dc721916ae135ee6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/adaptors.py_FunctionSignature_": {"doc_hash": "1f02b07f469e8f2746599f5b45ddc64e9e439ae5505e0d3479c8b8ba6ac638cd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_from_typing_import_Any_H_Transform._": {"doc_hash": "8e9f2bb802666706388c0b4581eb2c337c6c025ba832d065d0d016198376e1ae"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_Transform.__call___Transform.__call__.raise_NotImplementedError": {"doc_hash": "d4467a7b78ca6e9ff0cbaf8bf2e4b6af440fe06024f8d6639b131d55ed19294f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_Randomizable_Randomizable.R.np_random_RandomState_": {"doc_hash": "41ac343cd92355b92754918af057aa869418de2f942cb975c179514202982c05"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_Randomizable.set_random_state_Randomizable.set_random_state.return.self": {"doc_hash": "ad5d2e98b5a331cc0bd5f2f48e8bea249a854ac3a29e7741b667b194d1c5e695"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_Randomizable.randomize_Randomizable.randomize.raise_NotImplementedError": {"doc_hash": "0e442a13e1b7b4fb0abcb896b8148078700824a8772ee6cf30e02fa67c4bee04"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_Compose_Compose.__init__.self_set_random_state_see": {"doc_hash": "213aa4153c816013c03d3f8a721c72c966f5812c3b773b3496a0961a31acda35"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_Compose.set_random_state_Compose.__call__.return.input_": {"doc_hash": "302c401843b4e7e848ed0455c66c6ea4898ffcfbbc618acadf38c17bbd4fd1d7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_MapTransform_MapTransform.__init__.for_key_in_self_keys_.if_not_isinstance_key_Ha.raise_ValueError_f_keys_s": {"doc_hash": "3f5ce130384a6bb306604646fc7478c1807f2f888364c7a4382e19c3655fceb8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_MapTransform.__call___": {"doc_hash": "2d022f9f0adf144444daff174bf002d1214f5fdebcb880849ed46a27cde8a213"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/__init__.py__": {"doc_hash": "c23c3b22e4a81f73f6cb3229b775eae033de918fd6d04619cce6fa6ee87e622a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_from_typing_import_Callab_SpatialPad.__init__.self.mode.NumpyPadMode_mode_": {"doc_hash": "600528c10e04af882c7d3d0b9d8ad9214e8759ba9bbe6259ff5a3d058b556207"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_SpatialPad._determine_data_pad_width_SpatialPad._determine_data_pad_width.if_self_method_Method_.else_.return._0_max_self_spatial_siz": {"doc_hash": "f21d5db1bcaa2d6d5971ac5d2f45ff1b9717b49dc13e69b28fa5723ae531e491"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_SpatialPad.__call___SpatialPad.__call__.if_not_np_asarray_all_pad.else_.return.img": {"doc_hash": "dd4f24bb30f60894b8507d15d7eaf9f88cc9e21f4bb753395804fe012f1ec5be"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_BorderPad_BorderPad.__init__.self.mode.NumpyPadMode_mode_": {"doc_hash": "ffbcdcceb9b4302df3b0fc5aa9a9cc2130bcd67838021b72a97447490af3a49d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_BorderPad.__call___BorderPad.__call__.return.np_pad_": {"doc_hash": "6b92ec19a5cc1c8ed7ea12fa3da497f732a0239d62b4f9dd17d265db37e15bae"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_DivisiblePad_DivisiblePad.__init__.self.mode.NumpyPadMode_mode_": {"doc_hash": "b0020f7b88be28c5a281d6452b73bf07f08b08fb23b860c1fe87796937fe4a99"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_DivisiblePad.__call___DivisiblePad.__call__.return.spatial_pad_img_": {"doc_hash": "3465230dac7e99a6437ee59cada7f44770fc295079b1926145ee36b94103ad7a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_SpatialCrop_SpatialCrop.__init__.None_2": {"doc_hash": "c796fe9be431ec95e628ebe7f5042d6ee64d322374bc2cc475387fde3358848a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_SpatialCrop.__call___SpatialCrop.__call__.return.img_tuple_slices_": {"doc_hash": "737518a19ece0d06e47f7d7fac955132200f858122396de92b8c40bd55f367f1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_CenterSpatialCrop_CenterSpatialCrop.__call__.return.cropper_img_": {"doc_hash": "303f4ce6998d3960a780a1d74e9a378e758ee9ccb32c35c60c676c018be2a2b2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandSpatialCrop_RandSpatialCrop.__init__.self._slices.None": {"doc_hash": "f81e250008890e40c9c3760d3561ba3c8ea6af6de9f51008a6063ac4bfd55ecf"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandSpatialCrop.randomize_RandSpatialCrop.__call__.if_self_random_center_.else_.return.cropper_img_": {"doc_hash": "4137714eec57a8b92e75adab54c462466f8ace67abbaa775eacc4cf2f1632bd0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandSpatialCropSamples_RandSpatialCropSamples.__call__.return._self_cropper_img_for___": {"doc_hash": "81c7296462ad1923c5e8139388ad5870dddfe6862111d7a9362f2d02954d2cae"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_CropForeground_CropForeground.__call__.return.cropper_img_": {"doc_hash": "27a5c6f649a304e9fbda38ff5c69dde973e9c2bf32b6bcc9522213af0cf098ac"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandCropByPosNegLabel_RandCropByPosNegLabel.randomize.self.centers.generate_pos_neg_label_cr": {"doc_hash": "6f4da855a724dc5826c520b96214bb88fbc8ee13d5cc9a6db37f61d0deac1ea8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandCropByPosNegLabel.__call___": {"doc_hash": "3742fd782dae325a433815a30eb98392695323133821096b44606c65c9292659"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_from_typing_import_Callab_NumpyPadModeSequence.Union_Sequence_Union_Nump": {"doc_hash": "d5095fc5f6713e75ec453ecc54f4c14e7ff805b1e8f42d8f1275a086f04eacbd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_SpatialPadd_SpatialPadd.__call__.return.d": {"doc_hash": "45ff2655b589114944255424ee789b6f4bcb182714a97af2d698665b7e667bb8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_BorderPadd_BorderPadd.__call__.return.d": {"doc_hash": "02d91d3c5968bac41b701d057efc169937c50cc8ed115f2af69fdf82b8d80bb7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_DivisiblePadd_DivisiblePadd.__call__.return.d": {"doc_hash": "9296fbea4d38aedd4b1d3f2ab82f5ca43ba2ab5cf89d4d71ec438923dd7c5f29"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_SpatialCropd_SpatialCropd.__call__.return.d": {"doc_hash": "1273ba69b67fde48c87ee89233e84fd1bd6dba1e004870888e07edca11980fb0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_CenterSpatialCropd_CenterSpatialCropd.__call__.return.d": {"doc_hash": "21cde419add40f4a63e03da935cbf402ccf305ddf7ba292c1e5239a9818a13fc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandSpatialCropd_RandSpatialCropd.__init__.self._size.None": {"doc_hash": "6f6721880b0318e50600ad55bf3e4222e72b4dc167f711412e91e56de2eb4a6d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandSpatialCropd.randomize_RandSpatialCropd.__call__.return.d": {"doc_hash": "0e5c4af1b1e7e59c60b94432c37173f3f5da83209f1ee206cb33b57643705993"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandSpatialCropSamplesd_RandSpatialCropSamplesd.__call__.return._self_cropper_data_for__": {"doc_hash": "410eaf0feafa10e331d6b7271dc106ddb7a7f4fb30266649815f760108d02ef8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_CropForegroundd_CropForegroundd.__call__.return.d": {"doc_hash": "d5d630cfd7c7d88c9238bba15776bf5c5b5c5d3410351b687e86b359660c9f08"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandCropByPosNegLabeld_RandCropByPosNegLabeld.randomize.self.centers.generate_pos_neg_label_cr": {"doc_hash": "9f89f4059a30d563fb9523ccdbdd84a88dc93b9a581bca4db5ab547236295cde"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandCropByPosNegLabeld.__call___RandCropByPosNegLabeld.__call__.return.results": {"doc_hash": "aa914678420419c0f7de9384b8427b26b91eb51ba52694a919f4ea2dfdbe10dd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_SpatialPadD_": {"doc_hash": "d7ffc845cf156b9f09fd742701da21e993d508be5cb55764287c10d2383b28d5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/__init__.py__": {"doc_hash": "bff2377319ba4065211f7fda928cea2b03eb3bd5ba0890e9b2401f81cf62030b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_from_typing_import_Option_ShiftIntensity.__call__.return._img_self_offset_astyp": {"doc_hash": "4f9e43925c7e8c9a10b97aaf3c38b528860cc82980a51a8432e2ec2765f61ec2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_RandShiftIntensity_RandShiftIntensity.__call__.return.shifter_img_": {"doc_hash": "f8d3715465a0d2e639bf20248f09d564497ecd4c0cc7f59eb84470cc4ce1e97a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensity_ScaleIntensity.__call__.if_self_minv_is_not_None_.else_.return._img_1_self_factor_": {"doc_hash": "90033340af387918b41e37b9f7f7a432e4e509dd6aef4f62b61d53704ab81c67"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_RandScaleIntensity_RandScaleIntensity.__call__.return.scaler_img_": {"doc_hash": "2999b6ce62d1809c7b57d1b071b341da213105c09ddbbd67aaee0986c161de23"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_NormalizeIntensity_NormalizeIntensity.__init__.self.channel_wise.channel_wise": {"doc_hash": "0d3120ec6ad277007aa0eb34f3374eddf086870927a90b7aa7f7b234b7cf3fcb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_NormalizeIntensity._normalize_NormalizeIntensity.__call__.return.img": {"doc_hash": "3befaa654a7966450e079c87f77a5ca37de4606972efa8eaac63b53b92dcd762"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ThresholdIntensity_ThresholdIntensity.__call__.return.np_where_img_self_thres": {"doc_hash": "02d35eebf23778093000da3731635a00392d017deb9e4be58f91c6e44c164b04"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensityRange_ScaleIntensityRange.__init__.self.clip.clip": {"doc_hash": "a9c00efe8eeb4dea56284f89cd4b33114e40f6927e4fe6289b9aa7ba5e82b158"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensityRange.__call___ScaleIntensityRange.__call__.return.img": {"doc_hash": "efee53bc39f3552421196919a3603bd3f679f9c21926d1c36d13c20c2b097f77"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_AdjustContrast_AdjustContrast.__call__.return.np_power_img_img_min_": {"doc_hash": "c20f3fd705013530bceded53ea9d11a222668e6f74fb40b3053df4346042ce82"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_RandAdjustContrast_RandAdjustContrast.__call__.return.adjuster_img_": {"doc_hash": "1923f86a5bda7cb49526c2623e7d9559cb098bed21fdade1cc4d31d175a826dc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensityRangePercentiles_ScaleIntensityRangePercentiles._": {"doc_hash": "138d214c4d4ed40bbdedf475a9334379536f7ec93c0a76cda2764908289fa09b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensityRangePercentiles.__init___ScaleIntensityRangePercentiles.__init__.self.relative.relative": {"doc_hash": "abfb82f2b318c033a4025e02aeed14d90c3357c6ee18c7547c03b9ecdab59084"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensityRangePercentiles.__call___ScaleIntensityRangePercentiles.__call__.return.img": {"doc_hash": "ebbba7d465b63259c3a4a678326ee7cf0dfaffb82ce3772929f517da1458f0be"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_MaskIntensity_": {"doc_hash": "c94dd7c26fbf6aac6dab8302d41c26753723d22fa0391dee6682cb2f60218831"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_from_typing_import_Option_RandGaussianNoised.__call__.return.d": {"doc_hash": "7a768ac48ca6fa8f892d40a85a93e9670507989c0ee81dfd1114b035a91c5b2f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_ShiftIntensityd_ShiftIntensityd.__call__.return.d": {"doc_hash": "10895752a8cef50a4af9fc5f44ce8c838d5010687701227639e9e55fbfed54a8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandShiftIntensityd_RandShiftIntensityd.__call__.return.d": {"doc_hash": "6f6f0eda261cc6a5a9e742411c34c142dd0ef16d90bc106ada2707e25b062486"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_ScaleIntensityd_ScaleIntensityd.__call__.return.d": {"doc_hash": "27501857466a084aa9b3b17a79e2618031a0a008e43d8cbaa55e16d83f3e25c4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandScaleIntensityd_RandScaleIntensityd.__call__.return.d": {"doc_hash": "c51479d4d41282dc349dade4a7fa39e5d2d47a448cab259a59f7d194566cfe86"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_NormalizeIntensityd_NormalizeIntensityd.__call__.return.d": {"doc_hash": "235194f36d58a6904cd6db4d0c9e1d20312011c59fd8bb4ca7b2ce72b379228b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_ThresholdIntensityd_ThresholdIntensityd.__call__.return.d": {"doc_hash": "205d1380952e8736577985a43ee43767edfb7932828d444e7878a69c77f2578a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_ScaleIntensityRanged_ScaleIntensityRanged.__call__.return.d": {"doc_hash": "18b7cfd71b2dd5cbc7aa12fa2816c1ff3501532d32885a37993fed3aa4509cea"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_AdjustContrastd_AdjustContrastd.__call__.return.d": {"doc_hash": "914cc39d45db57a5e743a5339ccf00c6c865d98bdd274c4fec4c45ea9c3bb469"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandAdjustContrastd_RandAdjustContrastd.__call__.return.d": {"doc_hash": "cb594223f23472624d65ba0d0ca915c90c67ed6f6463ca74f1623a2531a028b8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_ScaleIntensityRangePercentilesd_ScaleIntensityRangePercentilesd.__call__.return.d": {"doc_hash": "c0ae73c48424b7d7961888b0cd5d0d8b64b7bef254309deb237df374782ef507"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_MaskIntensityd_MaskIntensityd.__call__.return.d": {"doc_hash": "bf82014de7fe2cc1f57c68827bf12ac9acd1485df334bbb7c7c36e67d47fbbd7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandGaussianNoiseD_": {"doc_hash": "21f15236b67826bae124dd5b568a45b5aa539a458fc104fecb3544ada987cc9d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/__init__.py__": {"doc_hash": "c7ecd1fe880f43eda25bfb18254cee43f6a4517366d3dae055caf0f318c3164e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_from_typing_import_Option_LoadNifti.__init__.self.dtype.dtype": {"doc_hash": "ac1fa35fd95c8cda99207e9809008cbfd7a2553ab8d07fc7e603b5f69030bfaa"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadNifti.__call___LoadNifti.__call__.return.img_array_compatible_met": {"doc_hash": "9d7bf192af8af4962082a069fb51333126f3795132cc7a44bab1703a11b0a3ea"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadPNG_LoadPNG.__init__.self.dtype.dtype": {"doc_hash": "f784f7f0d912b67672b4b9a028c3f9180ff6caa2c2d7938cefa0b35720230796"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadPNG.__call___LoadPNG.__call__.return.img_array_if_self_image_o": {"doc_hash": "f3d97ccd4c300c624884320759cef877aa680ad876c9af868680f46ce7d23c85"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadNumpy_LoadNumpy.__init__.self.npz_keys.npz_keys": {"doc_hash": "128b2fd8c7c05e919ae204e6f21b919eec80ebd7f58ffccda1660bef8e303fdf"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadNumpy.__call___LoadNumpy.__call__._save_data_meta.return.compatible_meta": {"doc_hash": "0f50d0b3195bb3314d42435361f3842c6f586d3bcb62a0299927adaf2df14897"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadNumpy.__call__.for_name_in_filename__": {"doc_hash": "b8405e8b75bc8742ec57ecb0b193d7e437525e3594212e7439574b7931a6d5c4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_from_typing_import_Option_LoadDatad.__init__.self.overwriting.overwriting": {"doc_hash": "6afd1be269f5b5e0f692ae94697203db13d8e227cd97e1510ce0aefdf9496da8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_LoadDatad.__call___LoadDatad.__call__.return.d": {"doc_hash": "49cc22d5b0e99a602f67918771f8f842cc5a72c840b922b10c42a89d135568cf"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_LoadNiftid_LoadNiftid.__init__.super___init___keys_lo": {"doc_hash": "35712b61dcab57ab599f98e04068b192af28e9fe92098385d87c3e4e3486745b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_LoadPNGd_LoadPNGd.__init__.super___init___keys_lo": {"doc_hash": "b7e4fbf1bbac29316aa53e053b9aee2ff774ba67169a59389167c5c44c239283"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_LoadNumpyd_": {"doc_hash": "00c9c490e3b46e9bea93c683db4de0fad6f85c8cf57caf763c4b999727727ce7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/__init__.py__": {"doc_hash": "2aa1cc63a079d41dac679a652f4c5730dde4f0a58beb7aafeff87a474f74429e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_from_typing_import_Callab_SplitChannel.__init__.self.num_classes.num_classes": {"doc_hash": "9848dcd74955879dd268b4056566e81c9419b53d60d8cc779133d3cb61ba04c1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_SplitChannel.__call___SplitChannel.__call__.return.outputs": {"doc_hash": "f721fbae35d6e6879d93c147cfd133b7ce7855fa73835911a3fa9e2b7adfba37"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_Activations_Activations.__init__.self.other.other": {"doc_hash": "a03b38f2dfd4015ed96ef485568eeaa4239edeeeb4bb2bb63ce450414d91aebe"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_Activations.__call___Activations.__call__.return.img": {"doc_hash": "12765211722b5ed64574020ff568c201a612c707251312f213514beb8e7abda4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_AsDiscrete_AsDiscrete.__init__.self.logit_thresh.logit_thresh": {"doc_hash": "1e17d5d7d7235745ee5fbc5d8c38e3050a16a5cccd4352cdb139651c2724d7e4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_AsDiscrete.__call___AsDiscrete.__call__.return.img_float_": {"doc_hash": "45fa3055b23e90a901399f09dd54402a81ce16743f83966a7defd8fcb9debf62"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_KeepLargestConnectedComponent_KeepLargestConnectedComponent._": {"doc_hash": "37e85d7c3a997e9f9cb9cefed5a97d05cb084a1c301aa50b3f5329f5d262f276"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_KeepLargestConnectedComponent.__init___KeepLargestConnectedComponent.__init__.self.connectivity.connectivity": {"doc_hash": "b8295cbf9ff9312bc3afc3b43ed5ae633a07afbbe23432fc03d447990eebc35a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_KeepLargestConnectedComponent.__call___KeepLargestConnectedComponent.__call__.return.output": {"doc_hash": "f970bfcc5ccdb9908cd6be0b69e1c09d1c3ce5b894a0804df3c0e3bcb822562a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_LabelToContour_LabelToContour.__init__.self.kernel_type.kernel_type": {"doc_hash": "c3ab697220b2fe81a980c724f361bc9ad997dd19b1c631cbe19a1c9c6db6a896"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_LabelToContour.__call___LabelToContour.__call__.return.contour_img": {"doc_hash": "bc30802c8005dd6f2fe5cc2e1dfb2902a27e423a4989cfc968e63bbf3bb3c394"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_MeanEnsemble_MeanEnsemble.__init__.self.weights.torch_as_tensor_weights_": {"doc_hash": "64009bb749aab9a236c34073072ab43bbfc9cf8e1c78d9e75672e48a60440b04"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_MeanEnsemble.__call___": {"doc_hash": "50719f88ef5b35ce9bf6e884833c1ada6f11376336e57e7e0235935c241cc9ff"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_from_typing_import_Option_SplitChanneld.__call__.return.d": {"doc_hash": "bafd5cd1b0e288254ce4ad0b2196be890828d813ec00713133f9466833bd67bf"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_Activationsd_Activationsd.__call__.return.d": {"doc_hash": "789b4203f49ebc94c4246666ff86d4c9f29c5d3f6a0b675c0c980de8d5d3b38f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_AsDiscreted_AsDiscreted.__call__.return.d": {"doc_hash": "819985050b8714347ce8f4221cdaa7aca4ab19d68f773ac5dbe690314992da6a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_KeepLargestConnectedComponentd_KeepLargestConnectedComponentd.__call__.return.d": {"doc_hash": "91eb172bacfb603181c51c4885acfb693c2e71cd436ea95c67141f71ae57aa99"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_LabelToContourd_LabelToContourd.__call__.return.d": {"doc_hash": "477f20f2df44b026f8b0c94c2616f9f62c993e0872f4caf5af7567bbe0a91661"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_MeanEnsembled_": {"doc_hash": "36a738c6ecd406e771ba66099b5e06a8a87860a9c8c2acbe95db7e394fb0e62e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/__init__.py__": {"doc_hash": "d0d3ad5174a0e484e778a51a7be7261e800006dcbf11cc0d8b40ca762ab4c65e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_from_typing_import_Callab_if_get_torch_version_tupl.else_._torch_interp.torch_nn_functional_inter": {"doc_hash": "84c4f1b6d6900fe2e1d13456d5a08825c24a8d631cfc02d216d118b1b432d2f1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Spacing_Spacing.__init__.self.dtype.dtype": {"doc_hash": "6cdc25953517b4d51b5437bd75ecc3ce4be678d3ffbc089f8cfacb11ee008ec0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Spacing.__call___Spacing.__call__.return.output_data_affine_new_": {"doc_hash": "6cc582b9739813ea9f965ed1f6d647bfe67d977971b4c2fb54e99fa55eeb0843"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Orientation_Orientation.__init__.self.labels.labels": {"doc_hash": "457e6f490359528a3be692eb99b93a4ecb2d89340fc9158158962f54d286fe6b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Orientation.__call___Orientation.__call__.return.data_array_affine_new_a": {"doc_hash": "e38aaeb8864b203788729dbec9d0bfaf1a4d648e28930f2a70f30a3f8d93c6f0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Flip_Flip.__call__.return.np_stack_flipped_astype_": {"doc_hash": "4114d6d9d3cc341cc4301e57badb483f4f6650b259564d88f0942c16ba121f0e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Resize_Resize.__init__.self.align_corners.align_corners": {"doc_hash": "86bf48673284ccccd9c64d97584d20c9fe49c4486f20bd44872813a0ea10431a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Resize.__call___Resize.__call__.return.resized": {"doc_hash": "ea34a77d075657e35c5ef39afde8ea0555a727f894c666565ef567a1e09d1cd4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rotate_Rotate.__init__.self.align_corners.align_corners": {"doc_hash": "1b944617e805cfa2856aaefe1ffec4cbf8f4ada1e1c6f970dc157c289fde0e5d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rotate.__call___Rotate.__call__.return.output": {"doc_hash": "087725190b8632a1303949f01af2d571ceba8dcdf760c9150fea3bd738247d21"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Zoom_Zoom.__init__.self.keep_size.keep_size": {"doc_hash": "397c4e1ccc9bd5c91e77313071871c086b94d1b1eb203a7f9d23fea91ea4b63b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Zoom.__call___Zoom.__call__.return.zoomed_tuple_slice_vec_": {"doc_hash": "bc99f02c53d9b513359ebcd3869d6d1b23a9c048015ec52d5bffcbc6a45c9489"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rotate90_Rotate90.__call__.return.np_stack_rotated_astype_": {"doc_hash": "b39c032142d91d8c86c0a00745fd377c1faddf47bb919726ae6c15b992a7851c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandRotate90_RandRotate90.__call__.return.rotator_img_": {"doc_hash": "5962c1ea62a39a8a3c6aa2cd06c7eb59b0b769b38af89d4eacf32bbc2303dff4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandRotate_RandRotate.randomize.self.z.self_R_uniform_low_self_r": {"doc_hash": "12e6473155227473e8a77f10f1610bb025c5f0badd822e05e5f087dcb2259f0b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandRotate.__call___RandRotate.__call__.return.rotator_img_": {"doc_hash": "d47dad39ed69299efc75e2b9e0b830285b56353d38651b543ff57e0540cbb008"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandFlip_RandFlip.__call__.return.self_flipper_img_": {"doc_hash": "a5cec355bf4bc64461c648cc42a0da52f012584d5301e4db5c354d9b47cf8005"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandZoom_RandZoom.randomize.if_len_self__zoom_1_.self._zoom.self__zoom_0_": {"doc_hash": "2396f20b378110bb38f8dea05d3b9387149284bdd6e8630d4a4b4f1cfd64afd0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandZoom.__call___RandZoom.__call__.return.zoomer_": {"doc_hash": "44393ed21179fb8c6ae406fa060d5070ca78b84e0aca5626b1469019f7e654e8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_AffineGrid_AffineGrid.__init__.self.device.device": {"doc_hash": "2bb9b06e33da15c306d6188776d5a97ad7d87db5595df5bc38fb2fdff64c5eec"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_AffineGrid.__call___AffineGrid.__call__.return.grid_cpu_numpy_": {"doc_hash": "32f9d4bd70ba90b98255b438f97d0b42549a10f96365dad3eb36b6ba3c3d08bf"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandAffineGrid_RandAffineGrid.__init__.self.device.device": {"doc_hash": "8743a098a3344bc84e08656e6de234f9b2f3f8767f6c86f02428af2e7a417671"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandAffineGrid.randomize_RandAffineGrid.randomize.if_self_scale_range_.self.scale_params._self_R_uniform_f_f_": {"doc_hash": "7cb4c1ec259aa1584abf547f811b86843b0e438cd4b97e81ceff5291f1b21c20"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandAffineGrid.__call___RandAffineGrid.__call__.return.affine_grid_spatial_size_": {"doc_hash": "ebec8e8bcd4ac158342f0e2d3de55589832d0f7177acd9d0d3e671752628d8b8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandDeformGrid_RandDeformGrid.randomize.self.rand_mag.self_R_uniform_self_magni": {"doc_hash": "e3796d1d3e8b7b9ef699f91b5a049bf55407b5debf3bda5cf8f9c33950d327b9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandDeformGrid.__call___RandDeformGrid.__call__.return.control_grid": {"doc_hash": "e64cbf582d24868cdcb6b9c1eefbe4380c6121ce956a7a7ac692a0d78bf5d170"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Resample_Resample.__init__.self.device.device": {"doc_hash": "fb4154af16cd0e96fb20fd79c8ae9c1f2666ee506818b4fa2e803f3851c9230a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Resample.__call___Resample.__call__.return.out_cpu_numpy_": {"doc_hash": "846365f93cb3122716b810445fc8fb2cc0e6aed143812db6d3d4791935bca540"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Affine_Affine.__init__.self.padding_mode.GridSamplePadMode_padding": {"doc_hash": "68b2a429a7178600d37e560e72cc95fafcdb744630a3e1ad24aed9a88bda062b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Affine.__call___Affine.__call__.return.self_resampler_": {"doc_hash": "ea680c2b375437024155a55af571e92ea72d6f10ecdc6488b84b046232a9d6b7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandAffine_RandAffine.__init__.self.prob.prob": {"doc_hash": "cc2b52e98096df90473f103939f6602c4dc92a659df908549e78e8a09e9924b2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandAffine.set_random_state_RandAffine.__call__.return.self_resampler_": {"doc_hash": "743dca03845987271c1130884f11277cc9afa2bb55e0b9395fe36cbc3b7d3417"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand2DElastic_Rand2DElastic.__init__.self.do_transform.False": {"doc_hash": "c54ee48fa1cd17e6aa812be49f5b43ea45124158aece36dce72b10e64de983f3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand2DElastic.set_random_state_Rand2DElastic.randomize.self_rand_affine_grid_ran": {"doc_hash": "5d04a2121f3a1b830284f0ef50e6467f788c9e1a04ee76be97de6992257a4219"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand2DElastic.__call___Rand2DElastic.__call__.return.self_resampler_img_grid_": {"doc_hash": "5410032f7ffb7151683741977978a4031b0f3f2e9208fb4098f08d7207120618"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand3DElastic_Rand3DElastic.__init__.self.sigma.1_0": {"doc_hash": "7e3f5c0bcd32071348a96c206f54e25b94c02a4786a584294d2bcfe2f0dc56b4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand3DElastic.set_random_state_Rand3DElastic.randomize.self_rand_affine_grid_ran": {"doc_hash": "123dcec418438425caf26c7330b5d2926edac95c791c03436d8ce2a87c0f7ebf"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand3DElastic.__call___": {"doc_hash": "45d840fb319f5cc78b5cfca8ca964f99b5e2ecaa038168b5de54462809b61d57"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_from_typing_import_Option_InterpolateModeSequence.Union_Sequence_Union_Inte": {"doc_hash": "9b0fe74866dcd71feb240378cd00d19ec585bfc0160f6a0162c19563a4d26204"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Spacingd_Spacingd.__init__.self.meta_key_postfix.meta_key_postfix": {"doc_hash": "338a882d0bb535cbfc7a15e1382b1647199792039099fd899f6b3b7de76e343b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Spacingd.__call___Spacingd.__call__.return.d": {"doc_hash": "6900f98f92ad9702b9e6e1d32f644ee37e585302ef42f4f51575c66f774070e6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Orientationd_Orientationd.__call__.return.d": {"doc_hash": "95c9ad0cc5f5887eead228f7f766b39493502f68b0a504b678edc70a3917ff8a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rotate90d_Rotate90d.__call__.return.d": {"doc_hash": "675b7fc41f6822b9af2813e408075518ded5c1fafdb8f04d76a3a5cfe6d137b0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandRotate90d_RandRotate90d.__call__.return.d": {"doc_hash": "acaa6f3430f614c5b5612c0056f0bec4e487806ec216f7c523c1a8dc1d39af4a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Resized_Resized.__call__.return.d": {"doc_hash": "031a3ea55a2761f19e4667ccc69b95d967a341dcfe0b4b0ddc767d22f6a7a6f6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandAffined_RandAffined.__init__.self.padding_mode.ensure_tuple_rep_padding_": {"doc_hash": "64ccb5d98ca2008098b6f0dda54056c9c130c619e55840599b416102ef947caf"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandAffined.set_random_state_RandAffined.__call__.return.d": {"doc_hash": "cb31999b056b20e27d99af8bbef680a612ae2909822a9ddaba39e12f6c998308"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rand2DElasticd_Rand2DElasticd.__init__.self.padding_mode.ensure_tuple_rep_padding_": {"doc_hash": "d8d066e2a3be7a28f3df84ffb6e9d17c388a57305fe0e758adb7f03dcdf8e292"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rand2DElasticd.set_random_state_Rand2DElasticd.__call__.return.d": {"doc_hash": "b3a6cef2b2f1136bf98120ca94354102b809566a6888893633d49a9e08963f10"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rand3DElasticd_Rand3DElasticd.__init__.self.padding_mode.ensure_tuple_rep_padding_": {"doc_hash": "26c932238dd24f63c641decdf214814ca4574eb60391e804e5e26dbf6d7fb2c6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rand3DElasticd.set_random_state_Rand3DElasticd.__call__.return.d": {"doc_hash": "d003be2ac47a417a330e7d0b1213fd7fd9046b77ca2a35f53c104f0806ed5998"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Flipd_Flipd.__call__.return.d": {"doc_hash": "e6300dc0b52ab2bc14e8ee30debec75d3e61cd5a2481db94ae492843685ae0b0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandFlipd_RandFlipd.__call__.return.d": {"doc_hash": "3cf0bb2c66855683362b074270c9e3d957597263d36e96984d9face1656b7727"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rotated_Rotated.__call__.return.d": {"doc_hash": "fb6427df93d04feb145929e1580d5b5f1fae10c8bec7fe5a175105a9b30cc49d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandRotated_RandRotated._": {"doc_hash": "3718c14049bf95446c3c4551a9fd0eb50b754abf43b78230312a027560eb3c29"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandRotated.__init___RandRotated.randomize.self.z.self_R_uniform_low_self_r": {"doc_hash": "c6dea69545ac5589ad9a25e5a8b40571fb974a43597e95ce88f16410a3802878"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandRotated.__call___RandRotated.__call__.return.d": {"doc_hash": "9813690012a3319a0a66a737ca3de0efad58c7269e306937f0a898a7839d18d7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Zoomd_Zoomd.__call__.return.d": {"doc_hash": "7b0bf6e2b7e026ceec4507ae8ad11068d9316566ef511a42f82bfb5157f26432"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandZoomd_RandZoomd.__call__.return.d": {"doc_hash": "7bd282d72b8fe76d1af48a123e19705bda86c63d628cb11476e74fd335453651"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_SpacingD_": {"doc_hash": "738f48459a1c6a1df78b33b3559eaaaad8a574bad5bc87e5ffc70b64edbf8529"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/__init__.py__": {"doc_hash": "cd2a264a38cdcbe3032b67d2af4c4c91d246a1a09f44c26ab577c069fc11f107"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_from_typing_import_Callab_Identity.__call__.return.np_asanyarray_img_": {"doc_hash": "99b9762a1ca033e2ca892c3e54e21766a182a9f07824fb3cc566920c4a164e2e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_AsChannelFirst_AsChannelFirst.__call__.return.np_moveaxis_img_self_cha": {"doc_hash": "00d124f523362eede64a553c819171fbc0e7746e2e116087123d7f07d894c2e3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_AsChannelLast_AsChannelLast.__call__.return.np_moveaxis_img_self_cha": {"doc_hash": "8ca29e810f75981ae239d5e9989fa16cdaa3c4695a5bd64f1dbba1a3ee3816d5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_AddChannel_AddChannel.__call__.return.img_None_": {"doc_hash": "36aca50c5d6176dcdb0bc968b0c94b41eae6db4f66f1d52cb76d09283caaff07"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_RepeatChannel_RepeatChannel.__call__.return.np_repeat_img_self_repea": {"doc_hash": "5a7256dd1dc15eeafe0917485b00eac37af6f227378ef706245557fd83e8d2ea"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_CastToType_CastToType.__call__.return.img_astype_self_dtype_if_": {"doc_hash": "73fb94db13440d8809ae55c7febbf2ae304a5b2f284ebf1bbbe74568f83670ae"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_ToTensor_Transpose.__call__.return.img_transpose_self_indice": {"doc_hash": "b40cee4d21675aef5acbb4e194d840637f7462e68ac458778ee48246ba8eb02e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_SqueezeDim_SqueezeDim.__call__.return.img_squeeze_self_dim_": {"doc_hash": "d3704264412556e97e39e0a70a0bfce11d2003c6c134227a3dc7aa6c333a4067"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_DataStats_DataStats.__init__.if_logger_handler_is_not_.self__logger_addHandler_l": {"doc_hash": "629c893ecd414f959821c011fa6f72ef6c9ea8b394eb899a70b55de607bda3bb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_DataStats.__call___DataStats.__call__.return.img": {"doc_hash": "6f1d30226512e16898937fa0d0b4faecbb6208cf9d37eced1c97426ce5d73dad"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_SimulateDelay_SimulateDelay.__call__.return.img": {"doc_hash": "158be57c9fe97ab9007d1843c6993272680cc3af40224f0f989fa78a3652be04"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_Lambda_Lambda.__call__.if_self_func_is_not_None_.else_.raise_RuntimeError_neith": {"doc_hash": "f99dcb03cd55d9869855c86f60432e4dc3b5c255aa1ad628e71239b10f6b9aab"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_LabelToMask_LabelToMask.__init__.self.merge_channels.merge_channels": {"doc_hash": "e6e8b12e52951d0f4e7b98f6ef269820d3e7e97af06387ee044a9fc0e2f2b0de"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_LabelToMask.__call___": {"doc_hash": "4860683d6f85775646b85b9a7a3945919b9cc5a06fcde39b9f52a3a9478b9006"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_from_typing_import_Option_from_monai_transforms_uti": {"doc_hash": "572a05ce8d6b73469d829c1f8d4676e0f4efb9bbbd731f6e97506c6dd6353da5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_Identityd_Identityd.__call__.return.d": {"doc_hash": "2ae36d092f3da6493c846054ec6cceff4c7aabb6f5ace2978b55479e98e34942"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_AsChannelFirstd_AsChannelFirstd.__call__.return.d": {"doc_hash": "708ecaa0641b5b045ae774c435feecb2db8b2191c7e66bee51cb1c7db724ce9f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_AsChannelLastd_AsChannelLastd.__call__.return.d": {"doc_hash": "1e9656e89dbdef2ba135a285f868b67431fb59960a0f1f31e9ed28634fb257b3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_AddChanneld_AddChanneld.__call__.return.d": {"doc_hash": "bb02cdb26283c590fb8fcf57a9ec9661dff0cb2b44b59ab4e860b245f83abe31"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_RepeatChanneld_RepeatChanneld.__call__.return.d": {"doc_hash": "fb68b453dc776c551ac58435336bb2ee206b621b6c32ee648ba560529275578a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_CastToTyped_CastToTyped.__call__.return.d": {"doc_hash": "93b136aebeb60b73e50ec3f534b6082d684902144080a8a85199dacaa6e6ff99"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_ToTensord_ToTensord.__call__.return.d": {"doc_hash": "f382e6080f8dd40d24620ba647abba5195f9900ca09aa7b4628427b55af4a688"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_ToNumpyd_ToNumpyd.__call__.return.d": {"doc_hash": "076532a6c728ddbbb80bb9f5f296dfacad187e949a6cf89be87c7e004d7fef66"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_DeleteItemsd_DeleteItemsd.__call__.return._key_val_for_key_val_in": {"doc_hash": "548a23d5711147494862754d91bd8e23b8212c4b54d248d819896a67106e18b8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_SqueezeDimd_SqueezeDimd.__call__.return.d": {"doc_hash": "dd6d356cc52c9d97fdee5bafe841fd34e4aa2b02636004a4437ad43e090d67e7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_DataStatsd_DataStatsd.__call__.return.d": {"doc_hash": "6d4383e581f29560584c2d4efb7814db55a7c062aef3b17cc6269f6368d26eb6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_SimulateDelayd_SimulateDelayd.__call__.return.d": {"doc_hash": "a589c11d03b752d4a9d229ed3a9223d9a6b33f6a072e2ec4ac275708786cca2f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_CopyItemsd_CopyItemsd.__call__.return.d": {"doc_hash": "10e5b84dcf660c02054eeffdcaa3d9b574fd0b60907be1ff984880e0fe9c8f5c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_ConcatItemsd_ConcatItemsd.__init__.self.dim.dim": {"doc_hash": "1659d6520461fa73df7d18c2f88f2d44a8a3507269b2e16abfd7e9b1337f4374"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_ConcatItemsd.__call___ConcatItemsd.__call__.return.d": {"doc_hash": "ab758ccaf1238baa62f98467d1b50f0bc936d28f0de3a64d3de46891038a779b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_Lambdad_Lambdad.__call__.return.d": {"doc_hash": "810c03150cfa85668aaf9a17569fcfe348bed8c137b076a53a2f6025baf71891"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_LabelToMaskd_LabelToMaskd.__call__.return.d": {"doc_hash": "3d31164f27db8cea7c53fe0660237fd9769e267b99b5e76db95084412597ad68"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_IdentityD_": {"doc_hash": "8714654c2c4e4858c736258c2e6772e015b501bd8e2138478f7503d94b98f9c2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_from_typing_import_Callab_zero_margins.return.True": {"doc_hash": "5102bbc64fb6ea6996783755e7867881d307a23537fc98be906d396797269a64"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_rescale_array_rescale_array._rescale_by_minv_and_max": {"doc_hash": "a14cd7269db0b6bf20669982f4aeb052902d734b362327c6459ab61024ade4ea"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_rescale_instance_array_rescale_array_int_max.return.rescale_array_arr_info_m": {"doc_hash": "e23d503529b64e629e221d9b6399cbe4b95d6f2b6f656abb0a0fa856a1ba456a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_copypaste_arrays_copypaste_arrays.return.tuple_srcslices_tuple_d": {"doc_hash": "f92ce71379f4b95e0b211fa52ad64abbca9b8da40fa8a719efad23fc988612b2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_resize_center_resize_center.return.dest": {"doc_hash": "12e527d9367b97c28f86efb538313df128c18d7f5ca58c24480a032e18f233cb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_generate_pos_neg_label_crop_centers_generate_pos_neg_label_crop_centers.return.centers": {"doc_hash": "c4eceafd45a75f6d4a38e303b98d7fa7c228aa29a0bf01b5499a56a944d54850"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_apply_transform_apply_transform.try_.except_Exception_as_e_.raise_type_e_f_applying_": {"doc_hash": "94d8868e0fa960340365b77c344062ff4bf08b5c84392b970458eda6b6a40357"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_create_grid_create_grid.return.np_concatenate_coords_n": {"doc_hash": "944d9bea0f341eace830857b95ff4720c745e70a0a439efe0fcda4997787504c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_create_control_grid_create_control_grid.return.create_grid_grid_shape_s": {"doc_hash": "26b3ba9c2444e02a6293587771b87f2968f5e5e605b919ff25cf83536a8cbf3b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_create_rotate_create_rotate.raise_ValueError_f_create": {"doc_hash": "1ca1a49722870db6a1dfca3ce55118fe7a1001f588260eb2bf5459a5c2a7f1cd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_create_shear_create_shear.raise_NotImplementedError": {"doc_hash": "fdb1a8343b6d634c85b4e2a026d1666e403ea3207e8a0cc6c40d6281ae893e6e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_create_scale_create_translate.return.affine": {"doc_hash": "5438941e9e8b5f430aa6d4de67d910b5893b0638ce944384c379e6a2a25751cc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_generate_spatial_bounding_box_generate_spatial_bounding_box.return.box_start_box_end": {"doc_hash": "5ddb0fd58e708bb749491ce0ca34ddaff758d188f665acf3a8a5bbbb81f6322c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_get_largest_connected_component_mask_": {"doc_hash": "6f6f86bb9579aa3c688722a7100038bf963917d7d3de49d1f72182c0af2a56dd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/__init__.py_from_aliases_import__": {"doc_hash": "d85f735e9a81ea7827e21dd5b88ce6b7c254534bb8a89ee7c4f3c3c31d9c4f34"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/aliases.py_threading_alias.return._outer": {"doc_hash": "c24d00bea48079556b15abdcd1593f6d274ca6997b1967c63f7b8a1c2d3da14d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/aliases.py_resolve_name_": {"doc_hash": "b51aaba30cdf80d313a1963dd0a4f03f2bb4ec4ed6014e002be7ca60c6436f4e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/decorators.py_time_RestartGenerator.__iter__.return.self_create_gen_": {"doc_hash": "afbe625ddddd70bc428ed89c681748df798ff8dd8da5a1a364fb01d7f1407ca7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/decorators.py_MethodReplacer_": {"doc_hash": "2120a9aaa3492dc5c59c7cc7d0cb081d5bfe3681b8df24caef87ee34df39d337"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/enums.py_from_enum_import_Enum_NumpyPadMode.EMPTY._empty_": {"doc_hash": "6c5d4cf4b9078f06377881ee79362ce31ef0c51eb94a76efdb1ab4efb1f3ea78"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/enums.py_GridSampleMode_": {"doc_hash": "13f9620a2e38c414777164146ac5a2ca01fef821c3522160059ef66aee9ce5aa"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_from_typing_import_Any_C_ensure_tuple_size.return.tuple_tup_dim_": {"doc_hash": "2b319144c078e41e55a52b714316342b5f79803fd40e764dc4516c8b17ce1da3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_ensure_tuple_rep_ensure_tuple_rep.raise_ValueError_f_sequen": {"doc_hash": "05c1122731547f32e79d4f918fd58404df6361043f0683d00a32fe71af13c10c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_fall_back_tuple_fall_back_tuple.return.tuple_use_the_default": {"doc_hash": "99881149ebf1f865281de29e7d73d490bddb33da6a9faba05c5da1ff38165077"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_is_scalar_tensor_get_seed.return._seed": {"doc_hash": "1e8d342aad3dfc8e687c545f57ac59f0677635be2df9b94781376c438d2aa8cb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_set_determinism_": {"doc_hash": "86538e68a6b7cd816d4656279b3081a0e9d9e6d3d27db07e7b610bfe9fe97c61"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/module.py_from_importlib_import_imp_export.return._inner": {"doc_hash": "2cf66c8073193869db86e323b9b8cc45de5835ea7c92b2f249506f7868847ce3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/module.py_load_submodules_load_submodules.return.submodules": {"doc_hash": "75c898d4b08ced4e33eabeaa19360b04f7c2966ecc4ba21ea78c933c7bd5abfa"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/module.py_get_full_type_name_exact_version.return.bool_the_module___version": {"doc_hash": "50ec8b52160d19e4f20adb2946e94541481cbd19c4addcc985387d44a0e6e258"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/module.py_optional_import_optional_import.msg.descriptor_format_actual_": {"doc_hash": "bb59b48dbb1890841ca07c3609d6dd8f30eafe167ac65126de1685f0489f24ae"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/module.py_optional_import.if_version_and_tb_is_None_": {"doc_hash": "2f842b2c05a4ee25abeee50aacf647e813761d6d5c6019344acb3a0a611c20e2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/__init__.py_from_img2tensorboard_imp_": {"doc_hash": "b00603b4911256f4206cb3d0a156f218ea15dffb5d96af9043387ba42d1880b8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py_from_typing_import_Option_if_TYPE_CHECKING_.else_.SummaryWriter___option": {"doc_hash": "8bdadad4ad69d3994fbea0ac1ca450c93fa9bd209065f57eda5b6d7ec4c1932b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py__image3_animated_gif__image3_animated_gif.return.summary_pb2_Summary_value": {"doc_hash": "69f4d7aec995c8afa7ef6c6e8538f68115696b129ad9422263451bde97f1ffef"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py_make_animated_gif_summary_make_animated_gif_summary.return.summary_op": {"doc_hash": "197682eb32495920bebdd42056a6fed2b19cde16ba99fc0b68b98d553a3f4a5f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py_add_animated_gif_add_animated_gif.writer__get_file_writer_": {"doc_hash": "4ffb703c2c5878b671111fd5da6dc7c6651d6990afe32132d4edf0eead8d3ce6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py_add_animated_gif_no_channels_add_animated_gif_no_channels.writer__get_file_writer_": {"doc_hash": "642422e93e99cc0911e407f9908ef978df8f60514cfd4075593b1a8a8a4cc14f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py_plot_2d_or_3d_image_": {"doc_hash": "46139a43b9b9e241e29e042c71a055110d64136029c0c3f36f9ec62d1052515b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/__init__.py__": {"doc_hash": "12e65a29cdc21a03823c6800b0272b125b03953276107cdf027ef19f78119a8c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/coplenet.py_torch_ConvBNActBlock.forward.return.self_conv_conv_se_x_": {"doc_hash": "d588515ec08af19499fd01ea475543f95b91499280888a18ff1cfabba1d13e0a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/coplenet.py_DownBlock_DownBlock.forward.return.self_conv_x_pool_x_poo": {"doc_hash": "600b9be72ae9a3fe229cea8140ebae882432d143d7e277375d7107b1eefd712a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/coplenet.py_UpBlock_UpBlock.forward.return.self_conv_x_cat_x_cat": {"doc_hash": "4128892ee4d06f3cee632c4dbb0e11aa8e9ecabd1a552624cc383453a2aa1caa"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/coplenet.py_CopleNet_CopleNet.__init__.self.out_conv.Convolution_spatial_dims_": {"doc_hash": "d7e9322196d2b1539e419166c8615354a9968b6816731d66e6af85b3a24cb479"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/coplenet.py_CopleNet.forward_": {"doc_hash": "b9b75016e4afdd301e0a63b663d940dfdbc897bb23d815d184c29745fdaddc80"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/run_inference.py_os_OUTPUT_FOLDER.os_path_join_output": {"doc_hash": "fec0d443bec004e87e7f253b60af741813ce9c2bcda6a28418909326c9f2c17f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/run_inference.py__writer_will_create_this_": {"doc_hash": "6d9c155a9348d74f49acc3e24ae9b6fa9ffe63e4125ab492fc9f2727d4ab67c0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/test_coplenet.py_unittest_": {"doc_hash": "9bb7d1024e02c57ffae9b9b35ef3a160c1d6d20f6683a02c1e758cf948bb306e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/__init__.py__": {"doc_hash": "3d2a982be50deb464245734e34f221a3deb1c71942a9327aef8caec40963ae2d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/data_utils.py_os_get_filenames.return.os_path_join_path_img_c": {"doc_hash": "913c4c0875da44eb7ea0993beb96329e6610a4e8539a12811c90dc528006cd7f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/data_utils.py_load_data_and_mask_": {"doc_hash": "5ba08140a367a9325e2da5cd90c3a4549a7d333090a38ab086d83cfc87497439"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/test_unet_pipe.py_unittest_": {"doc_hash": "6bcc12c5bf5025e82a3d54d9eef034f9c6e9d693e40fdfc6b489a312d0c38ad5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_time_torch.backends.cudnn.enabled.True": {"doc_hash": "b59fde0bea021a2619ef136402473d3c18e0386f20bf5bfd80142f088932d040"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_ImageLabelDataset_ImageLabelDataset.__len__.return.len_self_data_": {"doc_hash": "f50f65409e6f919f90ca275f816f6efcf218d394eaa8f7b42a1acd0a85cf8dab"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_train_train.val_dataset.Dataset_ImageLabelDataset": {"doc_hash": "345ca6bc2a9ea62ec9e7a11948ede66af57fbb82e2b1829a9ae766907634e119"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_train.val_dataloader_train._foreground": {"doc_hash": "0891f467c98a1292f89563b6faf0b413adef3ab4c312ceabdb332fd365e15509"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_train.for_epoch_in_range_ep__train.print_total_time_time_": {"doc_hash": "dabcd060aab87f4738be2f4eb98729c750eaf2a404aee3c895c654e2ff259f36"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_if___name_____main____": {"doc_hash": "c3ee9ae850a4f25ea5fd1e195aff9a4041692a93cb722c4ef29f550a6d63fa72"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/unet_pipe.py_from_collections_import_O_PopCat.forward.return.input": {"doc_hash": "066fb3ce6066846fde7aaa951932247ec3f32eb7e8a9963ee530fce4a9178a19"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/unet_pipe.py_flatten_sequential_flatten_sequential.return.nn_Sequential_OrderedDict": {"doc_hash": "31f9924d2ec08e4458d821f727b9564b53f72207b1fa42fabe3705cc58b93f4d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/unet_pipe.py_DoubleConv_DoubleConv.forward.return.self_conv_x_": {"doc_hash": "4688a2c1b0e1449b2513e872d722b21aa19c9d45470e035d87341e46043922cd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/unet_pipe.py_UNetPipe_": {"doc_hash": "74a51f8c57ceccf8a784d7e95b77313ea57c8abdb6f1b8f6b066852e32b3d21c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/setup.py_from_setuptools_import_fi_": {"doc_hash": "37200e06b33043eee718b7622b52929b62558eb8952158a6dce6c05490983fb2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/__init__.py_sys_": {"doc_hash": "b37e807e6619a0b2f7a1a6c198cb34607f180a2a1e1eff536484320d1aeb1c7e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/min_tests.py_glob_": {"doc_hash": "0f7ded25954283c7378a6350768e50943e43b291a871ad351675bfdf4b1fc18b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_activations.py_unittest_": {"doc_hash": "06cdf04e4cbe566684434a4b62296e69e967def044f64ef3cfd5f54dfa29273d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_activationsd.py_unittest_TEST_CASE_3._": {"doc_hash": "d284d4b1632f97b0fa346a5e8e8f5c883f28f909cbb8a89baf78a42b4edc9166"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_activationsd.py_TestActivationsd_": {"doc_hash": "67f6691b77885e4a4a65492867810315cc1719295169b1e21d877c53f7f0e911"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adaptors.py_unittest_TestAdaptors.test_single_in_single_out.None_4": {"doc_hash": "35379b83db1bba8309496a96b2be8844a608722870aa42dd91f4775f3d68a088"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adaptors.py_TestAdaptors.test_multi_in_single_out_TestAdaptors.test_multi_in_single_out.None_2.self_assertEqual_dres_lb": {"doc_hash": "26d9b3b8be0daebadcf5424eac739a9ea8adbd7f6688d5578fae19455c0f020a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adaptors.py_TestAdaptors.test_default_arg_single_out_TestAdaptors.test_dict_out.self_assertEqual_dres_b_": {"doc_hash": "a7c80dc0ab29bee80025d720f5933e32498f91a2c43c75a795393efc9c108ce7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adaptors.py_TestApplyAlias_": {"doc_hash": "fe6ddfa1c4a52a69452f45cc189680caf8d9500502b2a34a5878b3dadf1be28c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_add_channeld.py_unittest_": {"doc_hash": "75374a4b757ca50e2644ed2871990fedd3a5e8275b743357c9fdb41a308fa272"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adjust_contrast.py_unittest_": {"doc_hash": "03facf74c106d07be88cc4c5bd4444c3b5b82f09f5f52c68fd47e8ccce0aca6c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adjust_contrastd.py_unittest_": {"doc_hash": "5b3d827393456618a9dc269a580baefa0d8ab8d9d355f3aadd0b1a44e6701d16"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine.py_unittest_TEST_CASES._": {"doc_hash": "572005c2d477f31d63231dbecd6384a335cf574610f3f539cac8ddcf52c01189"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine.py_TestAffine_": {"doc_hash": "4914d17ea46d2c883cc205eeebd53fd5304c83877c71845d3259ddc6c1439f56"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_grid.py_unittest_TEST_CASES._": {"doc_hash": "926fda71ae58d810dc1e04aff32c0b845c9fbb712d563fb2787d918bc7742a1b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_grid.py_TestAffineGrid_": {"doc_hash": "c7d681b5f0120ed684e5bae6a8bd6c6a585b5dbaa9aaccf8fb471b7f4c2bcb26"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_unittest_TEST_NORM_CASES._": {"doc_hash": "8a85b9732bc70d66518a8d10a7c6a443cf02e34896c30fc3987cc308c203d9c3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TEST_TO_NORM_AFFINE_CASES_TEST_ILL_TO_NORM_AFFINE_CASES._": {"doc_hash": "d2072f01c545fe04b826e7add2f571a82f0416f0b4f40eb0ecfd175ec009b121"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestNormTransform_TestNormTransform.test_norm_xform.if_torch_cuda_is_availabl.np_testing_assert_allclos": {"doc_hash": "a98f83ec098f4478992746b00185f13b1f17fa78a31a29b1b76f51afc66f2c24"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestToNormAffine_TestToNormAffine.test_to_norm_affine.if_torch_cuda_is_availabl.np_testing_assert_allclos": {"doc_hash": "18f1da9302c7fb91a0579b12380816103c9c407e93b76c4385c0ddf548466786"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestToNormAffine.test_to_norm_affine_ill_TestToNormAffine.test_to_norm_affine_ill.None_1.to_norm_affine_affine_sr": {"doc_hash": "69490462f204900de9b9d6a7db7f1db955dae6b136e9384f5acf67238ad07349"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform_TestAffineTransform.test_affine_shift.np_testing_assert_allclos": {"doc_hash": "0d13680d8b1963bb5bc445a9f58f2cd608fe1023be26daa44253f643f702c03d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_shift_1_TestAffineTransform.test_affine_shift_1.np_testing_assert_allclos": {"doc_hash": "9fd7e5f09bb8175cf7dc6277e6a8b859985250d35ff5162ad1e5aa2d151c6e37"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_shift_2_TestAffineTransform.test_affine_shift_2.np_testing_assert_allclos": {"doc_hash": "26928cfa9b219e220b25e44c5041f40e35569cc210ea9997ccbf34582bf85224"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_zoom_TestAffineTransform.test_zoom.np_testing_assert_allclos": {"doc_hash": "df6289faedb5b48725e734f93866586c19aa1182733b6bce27d36ce9c08735ab"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_zoom_1_TestAffineTransform.test_zoom_1.np_testing_assert_allclos": {"doc_hash": "6d4a36371f4558b530c1c47b7a841869a65251f9f49a25babaf8d4cddfa4e392"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_zoom_2_TestAffineTransform.test_zoom_2.np_testing_assert_allclos": {"doc_hash": "ed8ba16e6d72cb7c4c1cc8502d541fff0a0515c4f8c48a709dacdd19a17e8378"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_transform_minimum_TestAffineTransform.test_affine_transform_minimum.np_testing_assert_allclos": {"doc_hash": "7dd10709bd2be20fd48863b8d3e1c1e019d5ab0c7b7e6c461d42b6fbde8dc73c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_transform_2d_TestAffineTransform.test_affine_transform_2d.if_torch_cuda_is_availabl.np_testing_assert_allclos": {"doc_hash": "80946492e237689743519042f79e4a6f507693a9116f37683c3d2f68bed1ebf4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_transform_3d_TestAffineTransform.test_affine_transform_3d.np_testing_assert_allclos": {"doc_hash": "16f06eed852264cb5622ee2ec8510813c52c69ddccaa54be638ffcbf060672bb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_transform_3d.if_torch_cuda_is_availabl_TestAffineTransform.test_affine_transform_3d.if_torch_cuda_is_availabl.np_testing_assert_allclos": {"doc_hash": "ebf9515b1856a7e103b39450878cca2c01d0e625148e91d059803cf3434ea975"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_ill_affine_transform_TestAffineTransform.test_ill_affine_transform.None_3.xform_image_affine_": {"doc_hash": "ecd12f0dea315af2aa6ec18b7973d9041a48525fb8ba07bc36d11b8d13939e53"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_ill_affine_transform.with_self_assertRaises_Ru_TestAffineTransform.test_ill_affine_transform.None_6.out.AffineTransform_1_2_i": {"doc_hash": "043551c328cddd108fa5afe0c3db7742ef664e59652e15103c38f1ae5100e406"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_forward_2d_TestAffineTransform.test_forward_2d.None_5": {"doc_hash": "8573b6534153052ece55147242c140b0b00fa7e8bc03bf1c4673244b82170eac"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_forward_3d_": {"doc_hash": "b85c8b4b8709076acf578f156a94a57f25d70882c98e650ad6d8250793672093"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_arraydataset.py_os_TEST_CASE_4._Compose_LoadNifti_image": {"doc_hash": "6aa3d03b940e65344914529279115c3b8f829aeed4d4c0f842f997c764f8108e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_arraydataset.py_TestArrayDataset_TestArrayDataset.test_shape.shutil_rmtree_tempdir_": {"doc_hash": "ce71d4356cff5451bb2bdc8df80e934599e3b10fb3e6b48212eef33c1a370659"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_arraydataset.py_TestArrayDataset.test_default_none_TestArrayDataset.test_default_none.shutil_rmtree_tempdir_": {"doc_hash": "24b43d0d0a5d23fe52254fe4cf9ac9f5f13e199bf39adee075d89d4f85fe4978"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_arraydataset.py_TestArrayDataset.test_dataloading_": {"doc_hash": "7f8199096718c0a3daa68c512268c293dd5b211dd4aed7bf6d7b4fca673a8213"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_first.py_unittest_": {"doc_hash": "cd97d27e832f1bce0c7fd277d12c4bed74168fe7a5ca86212dc832b1000ea02d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_firstd.py_unittest_TEST_CASE_3._keys_image_labe": {"doc_hash": "4e67b29514bc6881d5c1a618978558d6d5141a954b91d495bcd6f035527c6892"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_firstd.py_TestAsChannelFirstd_": {"doc_hash": "2b89d109c1aafa6733ef45fb646787251cb73ca2b10d37ff652f1129817ef71a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_last.py_unittest_": {"doc_hash": "c208ed5f257efac6aaab6bc6c5e220a151a63e621a3bcf1acff54fd3c2fc46f8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_lastd.py_unittest_TEST_CASE_3._keys_image_labe": {"doc_hash": "11dd0c3606761dfedda3432fbade4eb5b8c44453b129fce0ed06bf7d593da6dc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_lastd.py_TestAsChannelLastd_": {"doc_hash": "962451c788fafde0a7bc3e58a57a092f74de02f3398788d37d736fb166960455"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_discrete.py_unittest_": {"doc_hash": "b4632b768b2a2e2e126b0721ccf18921343c7cec9519df8cd2b247b3e0696b88"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_discreted.py_unittest_TEST_CASE_3._": {"doc_hash": "40e9794c6553398556317adedeef41fa9ae8e5d2012fa8387867d7b982a7614c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_discreted.py_TestAsDiscreted_": {"doc_hash": "de2ec18a5d07391757b4b05cc51556a6c364bce8f49e736ebeb223bcad9aae1e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_border_pad.py_unittest_": {"doc_hash": "6bd34d61af54b10748f2bbe87c7dfd1ecfd7888e95b9b529d8aeade28c9b960c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_border_padd.py_unittest_": {"doc_hash": "1f89165981b4bfc99ae4b276b1e3d8b576faa1e4de5ac081e7db6669c8a63d48"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cachedataset.py_unittest_": {"doc_hash": "51d9cccd4eedc8600409bb8ed5af0bd4720149287a8a18c7e74b57524d2200af"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cachedataset_parallel.py_unittest_TEST_CASE_3._4_100_None_": {"doc_hash": "1a383803f7c5856bb7efdf661ebf3b92122e8f88832d4803aed04891b81fcba2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cachedataset_parallel.py_TestCacheDatasetParallel_": {"doc_hash": "7ed8ab032c34d4c846f1b83dbdc61bbb9b010841e6f57259b3f209d074f738c8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cast_to_type.py_unittest_": {"doc_hash": "c5e5fbf5750811e1f5ba6cafaa5ceeef845817ae96bda938ec81ffba5d0e6d10"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cast_to_typed.py_unittest_": {"doc_hash": "ff93ee0d980b106cdf470d50711b6b75e82f2c4a69f879bbd099bc86fa9244fb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_center_spatial_crop.py_unittest_TEST_CASE_2._": {"doc_hash": "736df230138acda00d6d3ce87f0062aa07706b991e6c53071c57b718b18543d8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_center_spatial_crop.py_TestCenterSpatialCrop_": {"doc_hash": "4f52b8267b057f4cea8058486b2c6f9d7e2a25d8936074111ac6a5e02948d9fc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_center_spatial_cropd.py_unittest_TEST_CASE_2._": {"doc_hash": "67e62f8b3f0a4d490853c9989101ae8b58c8a07caff3fde3c14489e1cfca49ed"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_center_spatial_cropd.py_TestCenterSpatialCropd_": {"doc_hash": "a101ec3afb45d5d85417ee12a8e999e0fcc132ad494fbfe6c1373dec33820f30"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_check_md5.py_unittest_": {"doc_hash": "82b1deafb9039626752c6e19bb10a3f617bddbebe1a54880a3bfce336896801b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compose.py_unittest_TestCompose.test_dict_compose.self_assertDictEqual_c_": {"doc_hash": "a6d505a9280bb6a204c4e149e5a3056abaefb2d44b255d7395ef2619499bacd4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compose.py_TestCompose.test_list_dict_compose_TestCompose.test_list_dict_compose.for_item_in_value_.self_assertDictEqual_item": {"doc_hash": "8cdc84a619cf2134542693c7da7be654537901a01d4a59a667174c4f8339c137"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compose.py_TestCompose.test_random_compose_": {"doc_hash": "907c6229c9042ba68a047ba20c54c842997f163e0ebf580fa3f6113775dbfa33"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_meandice.py_unittest_TEST_CASE_3._": {"doc_hash": "072c70ff02674defb6a7e56f8c1c61e3ea1b52af9031d594412c6e671bb43cee"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_meandice.py_TEST_CASE_4_TEST_CASE_6._": {"doc_hash": "244ba5bb969c12f1b6ddaab3bf9e5a3d291bb51d8733de7c107855c08806e1a3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_meandice.py_TEST_CASE_7_TEST_CASE_9._": {"doc_hash": "ccc1f1cbe924eabf286152e4f95a918226998a569d7d38c5387c120095649af6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_meandice.py_TestComputeMeanDice_TestComputeMeanDice._DiceMetric_class_tests": {"doc_hash": "89b709a41303fa55a4bd23c248f0a4a78d388223ec597e3ac835132a39690e10"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_meandice.py_TestComputeMeanDice.test_value_class_": {"doc_hash": "83a9f58dda958e75a63c75bfb930daea1b28d574b0c5387f5fcd4e6817c7c341"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_roc_auc.py_unittest_": {"doc_hash": "1347751f7556c61d86d1f18aecb49dad7ef9f27329de582019f5277ea2e5eb38"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_concat_itemsd.py_unittest_TestConcatItemsd.test_tensor_values.None_2": {"doc_hash": "43b6a2c67ca701ac5fc396fe1cfd03e8afa40fe59c888b8100ad3208e1d980de"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_concat_itemsd.py_TestConcatItemsd.test_numpy_values_": {"doc_hash": "5a2525c11379947e6591203e24bde7f4dea372a8f059e3647acd226e0b3e4362"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_convolutions.py_from_tests_utils_import_T_TestConvolution2D.test_transpose2.self_assertEqual_out_shap": {"doc_hash": "373ccec2ff1115d88481700ff73fe1b51fb2d219fb1bc8fb8a546000ad7e52af"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_convolutions.py_TestResidualUnit2D_": {"doc_hash": "3ee88a1da5887ee5d8d285c33072310af9f69e59da5ddab1a7d90384b49fbf04"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_copy_itemsd.py_unittest_TEST_CASE_4._img_seg_2_img": {"doc_hash": "f2112056d8da697490970029233ef31cedaaac5944ffc55e82567d5153397c3d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_copy_itemsd.py_TestCopyItemsd_TestCopyItemsd.test_numpy_values.np_testing_assert_allclos": {"doc_hash": "98ac23f1c3bf3edb9a7c9dfa56216e4cd6853abcbe31e8f31a6819a206ad6125"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_copy_itemsd.py_TestCopyItemsd.test_tensor_values_TestCopyItemsd.test_tensor_values.None_2": {"doc_hash": "0bcf889c029cf3ca3a1cde9f1e34bcccc00802356dfe59fdc09a187227a5714c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_copy_itemsd.py_TestCopyItemsd.test_array_values_": {"doc_hash": "e3134a57c135adb0371a43b098d17df64fdf92faca7dcf7d9cb6d35eb0181a69"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_unittest_TestCreateGrid.test_create_grid.g_13.create_grid_2_2_2_sp": {"doc_hash": "ac06c6470e643ebf94887df1d7d1e92248157ba75663cfd1611f78f0ea22cd7d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateGrid.test_create_grid.expected_14_TestCreateGrid.test_create_grid.None_7": {"doc_hash": "ea0cf37951d799c88b511d843711b4fdfd9d925b43c22f8f278ff07855525048"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateGrid.test_create_control_grid_TestCreateGrid.test_create_control_grid.g_6.create_control_grid_2_0_": {"doc_hash": "3353897fdbce19ee7ce4cdea3442b970465c8b388da6580878a68bc556c393f6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateGrid.test_create_control_grid.expected_7_TestCreateGrid.test_create_control_grid.g_8.create_control_grid_1_0_": {"doc_hash": "19d8fc6fa8f2fc207a37e551845b9569a73028b4dd26ed064276c08a3273bf7f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateGrid.test_create_control_grid.expected_9_test_assert.np_testing_assert_allclos": {"doc_hash": "f1feb896d9162bf61ab9a1e63d28925d79e2883956aca351e6e3cca4ed2ed624"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateAffine_TestCreateAffine.test_create_rotate.None_4": {"doc_hash": "6f971b4c7f60022496d6b65ef4b860ff8bc2999dbc46781090cca0ad9fb2c047"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateAffine.test_create_shear_TestCreateAffine.test_create_shear.test_assert_": {"doc_hash": "a9800b20bd42f70e6d35e87b20f5691f2dec77e176c0ed06b06346523e07ad63"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateAffine.test_create_scale_TestCreateAffine.test_create_scale.None_4": {"doc_hash": "69f6e71beb32818100b2f0415fa5e225d0f38117628fcb2cbc1088c1fde52e26"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateAffine.test_create_translate_": {"doc_hash": "c87d2eeb72911fda802f3dae80f61cdea1a37c3552d910d2e11602f5435ef889"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_crop_foreground.py_unittest_": {"doc_hash": "a0cf9ff44a133dc4e1096be2439a250be787f71dd7d2130174ad10e4a83ad4c7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_crop_foregroundd.py_unittest_TEST_CASE_3._": {"doc_hash": "6597c09d0c5666feec868fb7ce7316fd7a45c51b9c63c84b498d4200b6d9c530"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_crop_foregroundd.py_TEST_CASE_4_": {"doc_hash": "93a73392f2a03ec0a595d34e82c2f58544770ab0a7f0e9cc47265ac9f7bab770"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_csv_saver.py_os_": {"doc_hash": "d51b26e189fc7460487eb8f85e22d16c5d860de88015b13a08660f7f2d94474b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_stats.py_unittest_TEST_CASE_7._": {"doc_hash": "acaa32552bd91c6650feab94b62f24a88c5c750ba213b3e3bfc0ae8f9b0998aa"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_stats.py_TestDataStats_": {"doc_hash": "3670e154f62b377c89567eab89c2f3b5190a40a619f545baa71ff824e4046f3f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_statsd.py_unittest_TEST_CASE_6._": {"doc_hash": "bf980f17394afed2ee90b4d3ca12fb10ffad313b2c289c2e80b0fed7ca7ca458"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_statsd.py_TEST_CASE_7_TEST_CASE_8._": {"doc_hash": "df15c8962beeeb714759220c303ff48fc56f2f0a0d0cebad322566978bb67450"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_statsd.py_TestDataStatsd_": {"doc_hash": "778b2698a34d260c113fb5abb03cc354e9fb1bc46a91d90e4af5dba689541cbd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dataloader.py_unittest_": {"doc_hash": "e11fa779b818eff75836026e5ecbd1fe2f7909345630b7dd454c7ce27a59423d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dataset.py_unittest_": {"doc_hash": "7c2168b7de88aa38d0f17c9cc0c689e75554df953474d39053940ae54d3a9fa6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_decathlondataset.py_unittest_": {"doc_hash": "3f93760be80e5eb11258339d8adc3208a00fd1bdb24714788fc9df604307a102"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_delete_itemsd.py_unittest_": {"doc_hash": "b037f175a28c626893cc3889723b821fec56defb76952b2ed3aba6d6d51e3d09"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_densenet.py_unittest_TEST_CASE_1._4_channel_3D_batch_": {"doc_hash": "2ee9dc1e6de55a40f0370ffa95e3ff06812c22b56d101ce882c2c3d0b671980d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_densenet.py_TestDENSENET_": {"doc_hash": "e004157384af1f8cc47b67d6d9fc40782c2824b868fa4cad0e35f37ebeee4460"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dice_loss.py_unittest_TEST_CASES": {"doc_hash": "850a1b7308a4901ea41c23c13680640d6f454d6f4f9cb8c555672ec8583424a3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dice_loss.py_TestDiceLoss_TestDiceLoss.test_ill_opts.None_2.DiceLoss_reduction_None_": {"doc_hash": "e070729c0da0b4f75f62a28196fe0a3d3a2b55845e31c5e624bab89e885e03bc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dice_loss.py_TestDiceLoss.test_input_warnings_": {"doc_hash": "380b93334a42aacdcdb255a8bdf4c4b33d689f510a335a062cff75ee1ca7998f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_discriminator.py_unittest_": {"doc_hash": "4b90870c886714ea926c884b4e95d1e8f1eec7e53066138d25c35f54789a775a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_divisible_pad.py_unittest_": {"doc_hash": "4fde7a521a4ecb4d06d0b5c85226ae5ee7d8e792b997626a4aa0776c0d9b6da9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_divisible_padd.py_unittest_": {"doc_hash": "8c324e31a17d47bb71e259700d4c5517e5e78195f687992de0c2a638faa0b181"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_download_and_extract.py_os_": {"doc_hash": "179489cb370bac76f1358a2f9cb59bb21196cfbfda4ed57105c8893c9fdaaeae"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_downsample_block.py_unittest_": {"doc_hash": "6c09cee1c8ed4c7ebe12e39c37f7062b86f75b9d157a5b9590d8cb2e0b354ed2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_ensemble_evaluator.py_torch_": {"doc_hash": "4c6c8cb2b4ca19d5234171d3f7cbbcf37a7f65f7a2fc0fb40028366b65b83cb6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_flip.py_unittest_": {"doc_hash": "33eb0ab64cc974871ccff4942954f39e2ee6c8d919500e4e1fff875fd3a547a9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_flipd.py_unittest_": {"doc_hash": "e0667f6882b379147fe23a175c1e90201afd5ea3f160da12597cf3baae7468b9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_unittest_TestFocalLoss.test_consistency_with_cross_entropy_2d.self_assertAlmostEqual_ma": {"doc_hash": "2c514ee3b2d19b7ba88c5ed8fd309a76c38dd3f545355172ecedaa827d792b73"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_consistency_with_cross_entropy_classification_TestFocalLoss.test_consistency_with_cross_entropy_classification.self_assertAlmostEqual_ma": {"doc_hash": "0ff65fc541107e8acd7bd91537206d7a982d59fa18a96777cc9869a7b8c304e8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_bin_seg_2d_TestFocalLoss.test_bin_seg_2d.self_assertAlmostEqual_fo": {"doc_hash": "4d255310249ba7b235992301528d4588d6a1382ceb50fa474d3a8445bd73d9b5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_empty_class_2d_TestFocalLoss.test_empty_class_2d.self_assertAlmostEqual_fo": {"doc_hash": "05f691dd96e56566e8b3a257df90021e6ae9859acec7741277c0b20bcbcc3ad4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_multi_class_seg_2d_TestFocalLoss.test_multi_class_seg_2d.None_1": {"doc_hash": "a219ba26f9999f1f42f96eb1b4f49d4aa60d170bad59961b46ec70cd8e8c99c6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_bin_seg_3d_TestFocalLoss.test_bin_seg_3d.None_1": {"doc_hash": "444f3b51ba3403dd58b33e171f5af76ee1081ce7d1272ffde8924666c140196a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_ill_opts_": {"doc_hash": "ef5cd91a041a077d4b6853e3c5b1c2c7a470d8da8f55651737c004ebbd5883a8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_filter.py_unittest_GaussianFilterTestCase.test_1d.np_testing_assert_allclos": {"doc_hash": "67182e74c62f2332b2f1282da16147eded63379e407cbb6d60e4ca10ee23c322"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_filter.py_GaussianFilterTestCase.test_2d_GaussianFilterTestCase.test_2d.if_torch_cuda_is_availabl.np_testing_assert_allclos": {"doc_hash": "d453ae133811b517dbbb3b77d158f44969ecfbf9ed5681ed4a1c48dc0b4b4ba7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_filter.py_GaussianFilterTestCase.test_3d_GaussianFilterTestCase.test_3d.np_testing_assert_allclos": {"doc_hash": "6c2631c9fd804cb75d9064c5f604dd3ca9432b2d26bee26856725faee3bdc61b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_filter.py_GaussianFilterTestCase.test_3d_sigmas_": {"doc_hash": "00bc13d39da8f6bcefd3f9b72c971991f759a88c3e84030a30033e0de0292bde"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generalized_dice_loss.py_unittest_TEST_CASES": {"doc_hash": "6566bb2e64f5503f5010f1f7b14bba7f6df0b1656f5191f30c5e774597e8d15a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generalized_dice_loss.py_TestGeneralizedDiceLoss_TestGeneralizedDiceLoss.test_ill_shape.with_self_assertRaisesReg.loss_forward_torch_ones_": {"doc_hash": "9a92420756e9c35982f141d11453e3919b3e75fe4f5eb6d2cfb54ea4a923d7ef"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generalized_dice_loss.py_TestGeneralizedDiceLoss.test_ill_opts_TestGeneralizedDiceLoss.test_ill_opts.None_2.GeneralizedDiceLoss_reduc": {"doc_hash": "8f314f22055cf461cd867706152abf8a774bb5e5fd2edc3b016a1411b66fd35e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generalized_dice_loss.py_TestGeneralizedDiceLoss.test_input_warnings_": {"doc_hash": "b4e3f227ab5d269804fde73419759923dcb547b9c1353dbca836ce0bf8c76148"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generate_pos_neg_label_crop_centers.py_unittest_": {"doc_hash": "99b3288286ccd7bead080333f597add1a7704f506e3e8ea0c7a9bff92c95281a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generate_spatial_bounding_box.py_unittest_": {"doc_hash": "d1a793b53fc3a23f6c53dc3bc24d0f2d9a20b8515e7562d72dd32823f57d8615"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generator.py_unittest_": {"doc_hash": "0f861fc9e93031c7fa6d4b4612f79136e77edbf3645b275df065bfaac9914d5b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_loader.py_tempfile_TestHandlerCheckpointLoader.test_one_save_one_load.shutil_rmtree_tempdir_": {"doc_hash": "a4d802be384156344bfddf6a09e015c7fd110f731b6170164e3fa6cfcc4cac08"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_loader.py_TestHandlerCheckpointLoader.test_two_save_one_load_TestHandlerCheckpointLoader.test_two_save_one_load.shutil_rmtree_tempdir_": {"doc_hash": "bfc99aee1bc87ddf702782a17f799b5ce7061722f6319f49747a995a36acef2d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_loader.py_TestHandlerCheckpointLoader.test_save_single_device_load_multi_devices_": {"doc_hash": "c2b50c8c19e1749e23af6969d1af70b02fc441d80537fe221f0b9db126ad6310"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_saver.py_os_TEST_CASE_5._True_False_None_1_Tr": {"doc_hash": "bc4959de020db90de268be350f3b4a348e4b2d1974cfce5c45fcb4d2891a1a04"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_saver.py_TestHandlerCheckpointSaver_": {"doc_hash": "4294f570d2e0e61572c7682e580bbf8cf7b5bfeac40a814e226f77d96b7c9354"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_classification_saver.py_os_": {"doc_hash": "230b467fd795819cc0105ca4cfe19ddbdd270b05a7798a6c3d1d76015346632d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_lr_scheduler.py_torch_": {"doc_hash": "66dab2a94456291fd20e63c6ad1e62564ee7ba343c16aa12e7ec3d0a9eaf7581"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_mean_dice.py_unittest_TestHandlerMeanDice.test_compute.self_assertAlmostEqual_av": {"doc_hash": "619bbe644c46a55543338d8b9815b968a3c24172bea38c212ff9a81383581df7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_mean_dice.py_TestHandlerMeanDice.test_misconfig_": {"doc_hash": "06b88036abf526cd6b8bd7049c04a33ed3440288e227b84441e0263b9f167428"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_rocauc.py_unittest_": {"doc_hash": "6aba800e976f6127286606de0cafe4dbb39228718f9a95364f17a89c973e990f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_segmentation_saver.py_os_TestHandlerSegmentationSaver.test_saved_content.None_3": {"doc_hash": "94f2e5d8814f91502eece24e31d4489346edddce7762460a03d8b403c9e878af"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_segmentation_saver.py_TestHandlerSegmentationSaver.test_save_resized_content_": {"doc_hash": "c2a4e331bf7bde86faea38eeca20f62da06adafbf6f79878604b64f83913585d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_stats.py_torch_TestHandlerStats.test_metrics_print.for_idx_line_in_enumerat.if_grep_match_line_.if_idx_in_5_10_.self_assertTrue_has_key_w": {"doc_hash": "b572acc4b700cdc85af7a2068dfb2781b90c15275e3c05ee4a4fdfc31fafcac6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_stats.py_TestHandlerStats.test_loss_print_TestHandlerStats.test_loss_print.for_idx_line_in_enumerat.if_grep_match_line_.if_idx_in_1_2_3_6_7_.self_assertTrue_has_key_w": {"doc_hash": "f34caa23b1bcbf8a3e30debbde85d77983b66c56abd00cb629318dc3b8854307"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_stats.py_TestHandlerStats.test_loss_dict_TestHandlerStats.test_loss_dict.for_idx_line_in_enumerat.if_grep_match_line_.if_idx_in_1_2_3_6_7_.self_assertTrue_has_key_w": {"doc_hash": "0b3b0f837d8e0cabbf795ae25c3826a8ceaeaa077d8fb0c17fa8eade3ab71baf"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_stats.py_TestHandlerStats.test_loss_file_": {"doc_hash": "90cfed5212c5d771fabe0824fc1aefd5ffda1593dde8a2f2b7ee7d000db060c4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_tb_image.py_glob_TEST_CASES._20_20_2_20_20_": {"doc_hash": "d93e375cc71381e88a0920e459a3a4b2286bdc1b9f2c98d27de1e5d945555845"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_tb_image.py_TestHandlerTBImage_": {"doc_hash": "5ed68429ca89fe4c07bcf92eaee29fcd870da94f77037cc87ec4cc4a1fc70fbd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_tb_stats.py_os_TestHandlerTBStats.test_metrics_print.shutil_rmtree_tempdir_": {"doc_hash": "88fa1bf541e6a44c5b6383df890f891c84affddf721efc5719ceb10b786e7bc0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_tb_stats.py_TestHandlerTBStats.test_metrics_writer_": {"doc_hash": "8f2bbc83fa63ab28ebf808513a38dce7edfceaed81170551ae3c7ffa9ea9c43d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_validation.py_unittest_": {"doc_hash": "fe2fa8b5dfcae1490143e2c91be84c049e137f18e201bb4287b94ea5d0b3a5d3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_header_correct.py_unittest_TestCorrection.test_correct.np_testing_assert_allclos": {"doc_hash": "93cbe20008aa25c06a1dfbcb094fcdb63a67f15378e3ff27521e2995a172eaa8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_header_correct.py_TestCorrection.test_affine_": {"doc_hash": "be2df905652f61cdf637b4262366af9a9265c10cf48b01a888366a5ff673f3c2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_highresnet.py_unittest_": {"doc_hash": "98136f8a92978cb342e6508b566cd9315b9be3a2f6379456b1e553e68ca3270a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_identity.py_unittest_": {"doc_hash": "19a40849fdb212627b01e4884f3f41b37961bba4e063ee5a58d909197621eb2c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_identityd.py_unittest_": {"doc_hash": "9a876b8a5ef9c94f13d7a9e8a387fd8a017c7a213f6aa01f463dfc3fd80902ae"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_img2tensorboard.py_tempfile_": {"doc_hash": "247cfc9adc68e9fa4e695d2ee5ca45c5e9615c79b8ca9983698b50db2027bc8a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_classification_2d.py_os_MedNISTDataset.__getitem__.return.self_transforms_self_imag": {"doc_hash": "75de80c0b9cac23fdcc2c276698d0865055a8b1e7430b7c8e8e366d6ae025dde"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_classification_2d.py_run_training_test_run_training_test.return.epoch_loss_values_best_m": {"doc_hash": "f649a734555dccd8fa30c4bfca94abb61ccda9f809afe1773082d6b7ebc759aa"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_classification_2d.py_run_inference_test_run_inference_test.return.tps": {"doc_hash": "87e727b816a15a0ed1514d93a031e86905a57f5f9b447873ca5eef4ed37936df"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_classification_2d.py_IntegrationClassification2D_IntegrationClassification2D.setUp.self.device.torch_device_cuda_0_if_": {"doc_hash": "661cccf85f6a746082ad415d6452b737fefe43b833ea1f2993611186045d7e17"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_classification_2d.py_IntegrationClassification2D.tearDown_": {"doc_hash": "702b66fe8e6062cadf6d4b65640b2da5396c1f22a8118846535279131b5f8152"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_determinism.py_unittest_run_test._TestBatch.__len__.return.train_steps": {"doc_hash": "61e07968848d35dc034a6e21490d39748750b478d08d84d80abb5a67aaa18d00"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_determinism.py_run_test.net_run_test.return.epoch_loss_step": {"doc_hash": "e5f54c0be2bf6e09441567f4997155c81239a9d0e5bcc5f9070e904653abb5be"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_determinism.py_TestDeterminism_": {"doc_hash": "7e499d0e8ac3f121e23c9d163937b9ff16ef2eab7bb0e8b4bfc203d71a97d08a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_os_from_tests_utils_import_s": {"doc_hash": "aaad9a7debd0d74f06fc25c941de2468f4a33371cfa61a57f78b4267b7482fac"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_run_training_test_run_training_test.metric_values.list_": {"doc_hash": "1d1b111e68d8ddbe265ad0bb79650050149cbd7f923582737add18dc19f20509"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_run_training_test.writer_run_training_test.return.epoch_loss_values_best_m": {"doc_hash": "d3f271943e05fcf33875ac00cbc716090061e39ccc65fbd9c721a0ca83084679"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_run_inference_test_run_inference_test.return.metric": {"doc_hash": "30a457457d7acea05576f4b1dd3e10073e819c6a5b66c05cf9b68b92f7497e30"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_IntegrationSegmentation3D_IntegrationSegmentation3D.tearDown.shutil_rmtree_self_data_d": {"doc_hash": "74a7c5c500609d8d4d752e5ae426d75e48325e976a9030a9915927764fda5110"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_IntegrationSegmentation3D.test_training_": {"doc_hash": "bfde1427ae353543c8a93c455e1ed39777fe984fe62701409f6ab3a52e9db30c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_sliding_window.py_os_from_tests_utils_import_m": {"doc_hash": "87ea35ba009485531dbd19e988e43055d2b63166610b7c7b2424c524de8402b8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_sliding_window.py_run_test_run_test.return.saved_name": {"doc_hash": "eefbb799dd49b85636aeb35cf0d46431b5de5c9cadfcc7b6ce22071addd59980"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_sliding_window.py_TestIntegrationSlidingWindow_TestIntegrationSlidingWindow.tearDown.if_os_path_exists_self_se.os_remove_self_seg_name_": {"doc_hash": "a9dcb644d57065b7b949076fd3d5b380212f8ab8cd98d2ab3bbcd09e21dcfad9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_sliding_window.py_TestIntegrationSlidingWindow.test_training_": {"doc_hash": "3784a17cc66c219979b13c3573cf0f44cea396e9aaf77c749ef8c47dc74d3d6b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_stn.py_from___future___import_pr_STNBenchmark.forward.return.self_stn_x_": {"doc_hash": "14a015ac4ed8ac674c652e53774b6bb6b7847284e21dd155375dcc4e0eb9ee17"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_stn.py_compare_2d_compare_2d.return.model_img_a_detach_cpu": {"doc_hash": "1e344d42b8989a3de9f8aa2921be275c1a9cbabe8ade1de2607859ae605267d8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_stn.py_TestSpatialTransformerCore_": {"doc_hash": "aea7c798277405b6cef5358762fe096552d947a3f10a8d6802a7953be3538ccf"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_unet_2d.py_unittest_": {"doc_hash": "a8c2bfc29dfdafd6353997f37d17f74f0430f28cbd5c4ca7f97ac386bcaa774e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_os_from_tests_utils_import_s": {"doc_hash": "bfd56127bc91c7f9eeadc0ea73f6ba4396fe05343bc445d9a945fad78415a685"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_run_training_test_run_training_test.val_handlers._": {"doc_hash": "a18c1d8c1ba4e38edfeb4cdf098b547151e37dcb8106f37ac7a30dc55f987ba5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_run_training_test.evaluator_run_training_test.return.evaluator_state_best_metr": {"doc_hash": "fca393b5e60c38791b2f56faa4a45cbce246971eecccd139d3225b93271ecd2c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_run_inference_test_run_inference_test.return.evaluator_state_best_metr": {"doc_hash": "a9d627c6bbff28a81a162d35bfa3804dbe1d92c320df6eba864a71492d3d4b8a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_IntegrationWorkflows_IntegrationWorkflows.tearDown.shutil_rmtree_self_data_d": {"doc_hash": "3a3891b28359829758518feb0c4fc42d7d7fa299a5a608ec2d773c598325a85d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_IntegrationWorkflows.test_training_": {"doc_hash": "2b7a00691182f4dc85e20e53951144dd4bd9ce90826ebb1f16a37aa9cfb4cd82"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_unittest_grid_2.torch_tensor_0_0_0_": {"doc_hash": "00b89435a9a0893ddcf34dddf5050c1cefdc362963e6a1f700c4eae418661b6d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_grid_3_grid_3.torch_tensor_": {"doc_hash": "43a900334a7591ddf106a1dcff07dcb0999ae37a45150234add55123cafcb3a2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_1_TEST_CASE_6._": {"doc_hash": "dd7a7fb0a12daf4f2dff1d6d2d440fea33f199fe5ccc4afb4b21a7b2ea83fe3c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_7_TEST_CASE_10._": {"doc_hash": "579a09659049b28ee2e268c848e7162df7ff7e14c33f626e1ed14af5f6cc4afa"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_11_TEST_CASE_11._": {"doc_hash": "59cfd1af3b18c7e865388a321aa7ecec960cb5f1b0529f71a2f9bcc321228bbb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_12_TEST_CASE_12._": {"doc_hash": "318b0528a7b8406d19f984b82dccbc44c8e397c5babb756cc1e3c1ca979ed5f3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_13_TEST_CASE_13._": {"doc_hash": "41538a0ddb7f8515f6d4feb743ace6b8b0712058f056262fe818f771a670f802"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_14_TEST_CASE_14._": {"doc_hash": "9513d43143f430bb9a759b2f378f16e4c2fbff49541441dabace61ca9c9f6590"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_15_TEST_CASE_15._": {"doc_hash": "445e34b006220312acb9edfa8b111184cd09f8993aa69193e888d0b7cd0c2cb5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_VALID_CASES_INVALID_CASES._ITEST_CASE_1_ITEST_CASE": {"doc_hash": "0519f5ad54c2ea2d5ece0b70381d033f66dd72aaffa21299b6b5f51d580fab0f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TestKeepLargestConnectedComponent_": {"doc_hash": "9e6c86a0aa7ffcd46f7746d95651d7461db5c4ddd60470bfb3087e95e17516b9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_unittest_grid_2._": {"doc_hash": "a0faba58eb022c0b0605b92e4678c665d9729add21dd7e2c89331d9b89daf921"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_grid_3_grid_3._": {"doc_hash": "8be83d6d11b2fecfbd1f97df5deb682c957972cb3c1ecd98a13cc7d06accf761"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_1_TEST_CASE_6._": {"doc_hash": "0dadbf13d6eb2d5d50748951662fd7e4d5e5f0d276ca4e9cd586641e1af29069"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_7_TEST_CASE_10._": {"doc_hash": "c83925bddfd029418437d3e8e245fe809566fc13bafcda5eab58542743b6a981"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_11_TEST_CASE_11._": {"doc_hash": "3987923c9f58ad831e491757e4e6c773f8cf88b2221107f5eaecb5e2c33aa513"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_12_TEST_CASE_12._": {"doc_hash": "b5caaaecc4a8bdeef4cdb7477863d4c024f6c62d97ae060646932e749cc12498"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_13_TEST_CASE_13._": {"doc_hash": "b396745f71c868fda0f4fa32a45d1aa6a4a7703d4d5872ff48fca16bc6cb30ff"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_14_TEST_CASE_14._": {"doc_hash": "ef1e3541a6359e083ff7b8da42da43c858c2879e49851956e1764f3475b79930"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_15_TEST_CASE_15._": {"doc_hash": "8c0944548fd0b745300ddf4b0a2bedad009914c4093d2685ed99f1b07e6d884b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_VALID_CASES_INVALID_CASES._ITEST_CASE_1_ITEST_CASE": {"doc_hash": "a234bdb65f56c5b9b714c7d68d6b05cb0e552878960669a8dd2746dc148b6c3a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TestKeepLargestConnectedComponentd_": {"doc_hash": "27d81f14f7dafd5c3677602c878b4c36a140d41bfd58e1160d9886d340fb3ccd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contour.py_unittest_expected_output_for_cube": {"doc_hash": "0b849f1976cbf3ac75a82838eb1dbc3e1f63156b4bccaafbcacbabe43e85cb9a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contour.py_gen_fixed_cube_gen_fixed_cube.return.cube_expected_output_for": {"doc_hash": "7b629ffee4dea9214e5bb21e592ea2c80ce5f74ad1cbf4ae403793a35f273d67"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contour.py_gen_fixed_img_gen_fixed_img.return.img_expected_output_for_": {"doc_hash": "42bba26a5877e4380e0c4479c27d03f35595b2650150fe87e0199b853d2cedda"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contour.py_TestContour_": {"doc_hash": "7ea8961f4af10e48915ca5fb630bc36065b9e8adfb033c9d44e696e136e44ccc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contourd.py_unittest_expected_output_for_cube": {"doc_hash": "16db708f9adbecfef6c8d9c8846b9c166034fa5e1da75cc6e9c09285c3e4fa3d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contourd.py_gen_fixed_cube_gen_fixed_cube.return.cube_expected_output_for": {"doc_hash": "2fe8f8caab5a687da08db9474e398a2342806436299be8329f3779d8371d7777"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contourd.py_gen_fixed_img_gen_fixed_img.return.img_expected_output_for_": {"doc_hash": "13023f92ad319442886deb243730bdea8f650d04d49b690c0ed741ec2dea2ad2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contourd.py_TestContourd_": {"doc_hash": "c6d8c79cd2ef08c29f94510fbde804c300accdc78f5f17085ab1cf50055967f6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_mask.py_unittest_": {"doc_hash": "fd131d83eafa70a23b3c2608cf1e8746043e2a20750e55718685e6dcf7dfbedd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_maskd.py_unittest_": {"doc_hash": "66cf32c5dbcc321d8c8a66cbbf28bbb642c5865048776257b630357014da5c8e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_lambda.py_unittest_": {"doc_hash": "c079e68f62501b6f8350f9129fb4fc610dfa9e9ae5d57b2241d3aa02d6e84c32"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_lambdad.py_unittest_": {"doc_hash": "77a825bfb73857571dc98abe9586d67384eb63f93db5103ee3ca120de653e3a0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_list_data_collate.py_unittest_": {"doc_hash": "f13b4fa1557863d596ec0739825afbee693cdbcd47ff95f6ed11e703a7812351"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_decathalon_datalist.py_unittest_TestLoadDecathalonDatalist.test_seg_values.shutil_rmtree_tempdir_": {"doc_hash": "941e6128338572560a286ee95096bb62740bf4261ab9bcd1192a0457df43bbe8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_decathalon_datalist.py_TestLoadDecathalonDatalist.test_cls_values_TestLoadDecathalonDatalist.test_cls_values.shutil_rmtree_tempdir_": {"doc_hash": "f3eba94383eff683ea052c232161315c97719717b5ae405a9b1b2de36f079711"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_decathalon_datalist.py_TestLoadDecathalonDatalist.test_seg_no_basedir_TestLoadDecathalonDatalist.test_seg_no_basedir.None_1": {"doc_hash": "1cf38558fe0b29503277456e6fc18a8a511778fb77121628cfd08ffd69146a03"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_decathalon_datalist.py_TestLoadDecathalonDatalist.test_seg_no_labels_": {"doc_hash": "2f5dcc64b8b1dcb01061f748814933b947dd5b2ef7f1e12ac9f01f73b6365608"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_nifti.py_unittest_TEST_CASE_4._": {"doc_hash": "3338614c0519f907def4b91ac38a4a4473671c469df4c0862c7dad7a30f4fa3c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_nifti.py_TestLoadNifti_": {"doc_hash": "1cc208f29bae3cd4bb2bbbfeb0751aeac25d5cb74b678c4a329d92f78a62e687"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_niftid.py_unittest_": {"doc_hash": "b19da2fa895b52c42b2ca3b06ebb5bfb1457a476e332ec9cb910aed4f5cc1275"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpy.py_unittest_TestLoadNumpy.test_npy.shutil_rmtree_tempdir_": {"doc_hash": "f3d554017b827fe68dc8fd38aa92b1d131ec6b46093f9151567d4a4391e50969"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpy.py_TestLoadNumpy.test_npz1_TestLoadNumpy.test_npz1.shutil_rmtree_tempdir_": {"doc_hash": "ce7c5de19143d558e720c8763a1b05740e3d1f212d55f4428ad4676de852bde1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpy.py_TestLoadNumpy.test_npz2_TestLoadNumpy.test_npz2.shutil_rmtree_tempdir_": {"doc_hash": "5a246ba736127688a90585e7a4cc24dccfeb8f418f35a4bbd8b3097164efaadc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpy.py_TestLoadNumpy.test_npz3_TestLoadNumpy.test_npz3.shutil_rmtree_tempdir_": {"doc_hash": "296b5bfde257a9808f9f0e3bfd953c223a83561fe136f46f3801386235d5490b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpy.py_TestLoadNumpy.test_npy_pickle_": {"doc_hash": "7c1f76611b358fdf472dcfffff8651d93465461d980afce435c28c052936e8fe"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpyd.py_unittest_TestLoadNumpyd.test_npy.shutil_rmtree_tempdir_": {"doc_hash": "3e1d35af9e837acfc59ae6a8aa49772fa48630882f4dc82967bf5d0b4e4b7576"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpyd.py_TestLoadNumpyd.test_npz1_TestLoadNumpyd.test_npz1.shutil_rmtree_tempdir_": {"doc_hash": "3187d218f6970b603238df9c8b3bc9618bfbcbd19c238ca7fa21468a1204357c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpyd.py_TestLoadNumpyd.test_npz2_TestLoadNumpyd.test_npz2.shutil_rmtree_tempdir_": {"doc_hash": "6ec9cf67a1c4460eeb57430c04897186b24c4cc1dbcde747dc82906b0e02b74d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpyd.py_TestLoadNumpyd.test_npz3_TestLoadNumpyd.test_npz3.shutil_rmtree_tempdir_": {"doc_hash": "617b679776b4fac11c5ff0d0d3f59a01cdc7dd00cb64e122ec77ec6980aea431"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpyd.py_TestLoadNumpyd.test_npy_pickle_": {"doc_hash": "343621f27d6711fa1dc0e613184237dff8f6942537d52d82469bd79aa4a52128"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_png.py_unittest_TEST_CASE_3._128_128_test_image": {"doc_hash": "70323bfb402a36b9edd244503e185b6a2144f38956d220effe55c3af61cbfebf"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_png.py_TestLoadPNG_": {"doc_hash": "4edfa32f754b1d15e1e874bad6230826f3b73039b7f672b00285a8e96820c6cc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_pngd.py_unittest_": {"doc_hash": "ce59f85a8880d193fc69352ce98016d7740f29a0a93fde0d37ded004b684dc82"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_os_TestLoadSpacingOrientation.test_load_spacingd.None_5": {"doc_hash": "a07714512250da7f0bb943d4fe7a2ac5493b983316060f5fde414ae09639a454"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_TestLoadSpacingOrientation.test_load_spacingd_rotate_TestLoadSpacingOrientation.test_load_spacingd_rotate.if_anatomical_not_in_fi.else_.np_testing_assert_allclos": {"doc_hash": "56005d239ad96c8a746770551bb2ccaace7f98f70a029b7937b4fa74b8acbde0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_TestLoadSpacingOrientation.test_load_spacingd_non_diag_TestLoadSpacingOrientation.test_load_spacingd_non_diag.np_testing_assert_allclos": {"doc_hash": "82dae05cad6cf31f63369bfe1a72292f842a2b480e85dd6fdd4f848a6dc2755b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_TestLoadSpacingOrientation.test_load_spacingd_rotate_non_diag_TestLoadSpacingOrientation.test_load_spacingd_rotate_non_diag.np_testing_assert_allclos": {"doc_hash": "e492972057e2d51e718a3a359d5cdda26cbea56da1682b049b5b0312d15ea446"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_TestLoadSpacingOrientation.test_load_spacingd_rotate_non_diag_ornt_TestLoadSpacingOrientation.test_load_spacingd_rotate_non_diag_ornt.np_testing_assert_allclos": {"doc_hash": "d981b1a78412be83e442cf2afaa8204a307c1f46bfb5dc82098bff3b5b2c175a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_TestLoadSpacingOrientation.test_load_spacingd_non_diag_ornt_": {"doc_hash": "49c862c25b2c8d34b627424e06c229fb315951707338869c3837fbcbfe943c45"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_map_transform.py_unittest_": {"doc_hash": "81a3009014d681224d0c9cc23091d4feb72ee02f6439ad6582f9b98fb9f7d694"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mask_intensity.py_unittest_": {"doc_hash": "6cf5d6d160b76894538e7f6c7fc9b33f209b2e5096cb6ed2d0319ac430386438"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mask_intensityd.py_unittest_": {"doc_hash": "46dff86d238b768b9e80abe002b32c162ec1e281c6606bda88c701ecd03b4058"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_masked_dice_loss.py_unittest_TEST_CASES": {"doc_hash": "2e80b64a9e6a9c669eb5bb8627616809fa26ef5e806c43513769d296f1517190"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_masked_dice_loss.py_TestDiceLoss_TestDiceLoss.test_ill_shape.with_self_assertRaisesReg.loss_forward_torch_ones_": {"doc_hash": "9a10dacd3c87ff66d71108cacce51c2b4550e0f9d993e2d0984cc193addc92f2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_masked_dice_loss.py_TestDiceLoss.test_ill_opts_TestDiceLoss.test_ill_opts.None_2.MaskedDiceLoss_reduction_": {"doc_hash": "f6aae6ee3ce63654ce04fad035ef739434267de0272a457a66dc444f24a913f2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_masked_dice_loss.py_TestDiceLoss.test_input_warnings_": {"doc_hash": "500897acc35cdf3c18f7c7a0a451e063d11614efc63e068c32a5ab617ab58057"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mean_ensemble.py_unittest_TEST_CASE_6._": {"doc_hash": "3f7c11778a87b8a046402d77ba958e33e7a8d0e6861b5ba4d6a1fa2f8d7bd092"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mean_ensemble.py_TestMeanEnsemble_": {"doc_hash": "69731292576158a1c9597444dd2a9ba713218715791b79b0fbd74b80e6f25966"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mean_ensembled.py_unittest_TEST_CASE_6._": {"doc_hash": "63adf0591fa3728a4a5602acc243c3a0aadf8114d1c5ac8187a6036d3b23c531"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mean_ensembled.py_TestMeanEnsembled_": {"doc_hash": "b4fc3e366b4f3848105850b93143ed2c58e9d37520c45138add67b108f8aaa8a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mednistdataset.py_unittest_": {"doc_hash": "6ab34ecbc4da7c655792bce08ed68db6dec18cc6828b613333a86d6136d58311"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_dataset.py_os_RandTest.__call__.return.data_self__a": {"doc_hash": "1de68f2df792a7b681a04da9684b2d2fd04aacf4cd799c11e54f412727590c28"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_dataset.py_TestNiftiDataset_TestNiftiDataset.test_dataset.dataset_7.NiftiDataset_": {"doc_hash": "91098d3e370207158f7c8456a6aeb7c1d431c91e3501c2551e5595f31f35640f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_dataset.py_TestNiftiDataset.test_dataset.for_idx_d_tuple_ref_i_": {"doc_hash": "3933c35748ded0cf5ecf35cf3a8a46e91d305cc1e59482fbfd30932c0d45cb00"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_header_revise.py_unittest_": {"doc_hash": "7d16357fb8e2242dd483701a2c2a34715a2c062edc6bef73a1a40787a4a40512"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_os_TEST_CASES._": {"doc_hash": "841cbf6324003dedee8dca8b796a677edea0d28cbfe3a2d78b681a9c7ec49756"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead_TestNiftiLoadRead.test_orientation.np_testing_assert_allclos": {"doc_hash": "9e0475ea2ee481bd46de9625acf5497a0011b9bb24bd486a2f33d957a2696b70"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead.test_consistency_TestNiftiLoadRead.test_consistency.None_2.os_remove_test_image_": {"doc_hash": "6a9d8046bbd7c65647dcb521ad527a699a243915ce4dee2f259520aed6a88ab6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead.test_write_2d_TestNiftiLoadRead.test_write_2d.shutil_rmtree_out_dir_": {"doc_hash": "2435396293f2a1d049ac383f4df6c2d40ad03e84c21d72234ac12912219bb002"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead.test_write_3d_TestNiftiLoadRead.test_write_3d.shutil_rmtree_out_dir_": {"doc_hash": "9023b6b2edd4f1e30cb3e31ad6bf2dba4ccf7e7754c8d03edea5a282ff2e0db8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead.test_write_4d_TestNiftiLoadRead.test_write_4d.shutil_rmtree_out_dir_": {"doc_hash": "6be113e6084b0f3749fb63223a9cc3617340b1026c8e2fe77dae0166b99b261c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead.test_write_5d_": {"doc_hash": "8336abd62c9e05029810c345e51e6967fbd12065fdb9a50d0d9ae81e1673a1ae"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_saver.py_os_TestNiftiSaver.test_saved_content.None_2": {"doc_hash": "6a8f255e95bc2fc2f3886cb287dc0c36f51ae30e8ac866072e36158e2195c9a9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_saver.py_TestNiftiSaver.test_saved_resize_content_TestNiftiSaver.test_saved_resize_content.None_2": {"doc_hash": "6a0f2481f94c0770a8293e7cd64984664987c03baf1167a1e7dc300893cbade4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_saver.py_TestNiftiSaver.test_saved_3d_resize_content_": {"doc_hash": "5c68fdc8df74e438d6724617815dead144ade57017d8ee9108fdaf5e66af0601"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensity.py_unittest_TEST_CASE_3._nonzero_True_np_ar": {"doc_hash": "9f8dedc0636038259c51b3434f15ee70b24696486d6c4ef19a2c1c9eb7f8a2a0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensity.py_TestNormalizeIntensity_TestNormalizeIntensity.test_nonzero.np_testing_assert_allclos": {"doc_hash": "2843dc3cae03224d688243a96f89295c357fca31f86226436108be1d8a150f01"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensity.py_TestNormalizeIntensity.test_channel_wise_": {"doc_hash": "6e51a979488724cced99a0c1624d373b4deae52badecd661128c05f528e6ede6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensityd.py_unittest_TEST_CASE_3._": {"doc_hash": "e6714521619659f867756675e9fb5115787be15a357129b27278b05ed5830cb0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensityd.py_TestNormalizeIntensityd_TestNormalizeIntensityd.test_nonzero.np_testing_assert_allclos": {"doc_hash": "52f4da2d29c74ffd260e0728e2d8ef1cea176deec7539cd88cdd79dd4012c95f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensityd.py_TestNormalizeIntensityd.test_channel_wise_": {"doc_hash": "9d765f853ceaae45ddfc396ef6c6594b003bf648e128753a58185adf34f11654"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_optional_import.py_unittest_TestOptionalImport.test_import_wrong_number.None_2.print_my_module_randint_1": {"doc_hash": "806bde5740d1e5f8f53c40f54e5fa7d36f98324b8ab3241304fe4a33d90f72af"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_optional_import.py_TestOptionalImport.test_import_good_number_TestOptionalImport.test_import_good_number.None_5": {"doc_hash": "494cfd606891dafef2826956fdd356353733fd17772cf76086e2dbd3cea6de70"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_optional_import.py_TestOptionalImport.test_import_exact_": {"doc_hash": "4593f4a6b074321a5d0629b578e23c2bce524662d1513579e2996ab07bf95a67"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientation.py_unittest_TEST_CASES._": {"doc_hash": "02b35793b4eb42358560f6925c758b07aaf2449514403a2c0f0c927e6427af81"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientation.py_ILL_CASES_": {"doc_hash": "c159930d350c92b014f3025488a10cd3b6ee349b43ed658461f7087c3d843038"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientationd.py_unittest_TestOrientationdCase.test_orntd.self_assertEqual_code_": {"doc_hash": "948e8a4fdded8c51b27a00bb10efb2602fd0245cb9eb8b59a499188df2ba01e9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientationd.py_TestOrientationdCase.test_orntd_3d_TestOrientationdCase.test_orntd_3d.None_3": {"doc_hash": "2dc638abd86325ec7716c6c769e1e0b873881955b51a06223a6707a24041e0e7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientationd.py_TestOrientationdCase.test_orntd_2d_TestOrientationdCase.test_orntd_2d.None_2": {"doc_hash": "1f1607a521975acca7ad39c517072ee7b3bd748cb61fc5f36ad602d5192f5bdc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientationd.py_TestOrientationdCase.test_orntd_1d_TestOrientationdCase.test_orntd_1d.None_2": {"doc_hash": "9d9747d6879423925012b82fc555ca3abdd7e90d2ef3eeca8001055598e9cc74"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientationd.py_TestOrientationdCase.test_orntd_canonical_": {"doc_hash": "e52a617e3c2212622f6e70d1747e023d0b65841490385f7793dbe634e4a51931"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_parallel_execution.py_unittest_": {"doc_hash": "cc4783b328af39ac7d81a5a6c495515946fa5ea0ef39aa06f2a9f27a91f415bb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_persistentdataset.py_unittest_TEST_CASE_3._None_128_128_128_": {"doc_hash": "9886f1f6ed80fd82c002513b605be7a2a2fe34d057fb699ca63929274aa13076"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_persistentdataset.py_TestDataset_": {"doc_hash": "5e66a163a5dfecb2604c770ae59ee74fcd907d5e3d815e9852dda71825c813e8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_plot_2d_or_3d_image.py_glob_TEST_CASE_5._1_3_10_10_10_": {"doc_hash": "bd95cd15fc13f01e67dd463fa6d8a05243d8b19e9bcb489853709aecfcccfcbb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_plot_2d_or_3d_image.py_TestPlot2dOr3dImage_": {"doc_hash": "491fafa8420776d332b2a68e36f17196c9a89994cc8f0cdab9f85793fbc47b2d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_png_rw.py_os_": {"doc_hash": "dae4d6b111c69ec63ea274ae71d9f1a0ab38d0e5b7cd19213a45da9d7dd9d634"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_png_saver.py_os_TestPNGSaver.test_saved_content.None_2": {"doc_hash": "06058a4bc982cd632683c00f2ee908400f0da2a053b95d5657ecc6b0229d90ce"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_png_saver.py_TestPNGSaver.test_saved_content_three_channel_TestPNGSaver.test_saved_content_three_channel.None_2": {"doc_hash": "a51472e19030dae358de711f1478fcb02f8e21b599d2b4a4197ff0ccc5a4966f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_png_saver.py_TestPNGSaver.test_saved_content_spatial_size_": {"doc_hash": "82034067bc2416fce3bbae85954dd6aaba2812de4dfb95b02bfcd8fb9a9fdd45"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_query_memory.py_unittest_": {"doc_hash": "08736eea0c19ab7279062412adc289aa4988081efbfe7db26ff2ad461b88543a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_adjust_contrast.py_unittest_": {"doc_hash": "a93374874279b8aa1ea047ab1a13db6383506670898fce70e9eb35965278a82b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_adjust_contrastd.py_unittest_": {"doc_hash": "1f86f8b3c1166a46b5ef9fbd13b88846e2e53486752973ec9ed67afb3c773c71"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affine.py_unittest_TEST_CASES._": {"doc_hash": "09f948405d827a7367cb360c46e539f33f78e9aba6c5e1b746e3e7b316b5f9a1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affine.py_TestRandAffine_": {"doc_hash": "8ac041ee78ac67db6adb5ce30380cad2b82860ff7146d21f66f288fb0445b926"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affine_grid.py_unittest_TEST_CASES": {"doc_hash": "fd73fb129123450edb1c817c266a334db20e54369a845996972c9eeb4fc40d70"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affine_grid.py_TestRandAffineGrid_": {"doc_hash": "a4efaca54ad9d7123cadae53e31d222ff62e75f05938a8608bfde2a76d480428"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affined.py_unittest_TEST_CASES._": {"doc_hash": "a6ea0e8b9aca435b631ea227a959522cc29336f6ee5d8db64fb073ed0bee9d4f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affined.py_TestRandAffined_": {"doc_hash": "21016494d0e797ca6ed9c0d7882703c994c4f1fca557c916f1b13b1d31ed4efa"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_crop_by_pos_neg_label.py_unittest_": {"doc_hash": "62cc950cca89c54cf65929729504a5dc8409c69b56ec1f90e8f62f8e2e694011"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_crop_by_pos_neg_labeld.py_unittest_TEST_CASE_2._": {"doc_hash": "a17fdf6d2275ecd6f64624917c2306b311455fb4c9a196a691297a65190f47f9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_crop_by_pos_neg_labeld.py_TestRandCropByPosNegLabeld_": {"doc_hash": "bb788fb8211848cb0b143df640c07071d9625fccba63aea6ed586b30aee9797b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_deform_grid.py_unittest_TEST_CASES": {"doc_hash": "9dc91ec1f4c8a87410de372907480b7c056cd80a4ac3e4ac577bf335c55f4736"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_deform_grid.py_TestRandDeformGrid_": {"doc_hash": "27c5a74115fa2cc4089db8f7487d3c99ad20a6babce8742deba53689774791f2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elastic_2d.py_unittest_TEST_CASES._": {"doc_hash": "9bcdb53cc0fed03ef78e2f2c26032e8348b21d4c4f911d37dbe9ee775f2b3930"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elastic_2d.py_TestRand2DElastic_": {"doc_hash": "4c7b326b87dae484ccad71a3514d3d606e520362d1b09b12f3bb3f58fa232a51"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elastic_3d.py_unittest_TEST_CASES._": {"doc_hash": "a2d331cbe1c59dc76bb835a87cdc86a9174b70da2f8db58dbb872700278fc559"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elastic_3d.py_TestRand3DElastic_": {"doc_hash": "999b19b28b029a498b11894d5b7af4147e008b923d2ae8bbdbeea79900556d68"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elasticd_2d.py_unittest_TEST_CASES._": {"doc_hash": "247b4bc4c5dbdda4105173a8e04df6e77e1190fee843fee8dc09030d8173ceb5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elasticd_2d.py_TestRand2DElasticd_": {"doc_hash": "126c37cd1310e9244d2cf6c7b68e09228bf40dfeae8d2fa5f5ccb459f30e4ecd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elasticd_3d.py_unittest_TEST_CASES._": {"doc_hash": "e640691b66fb30773d314821f9230a0e1b394aed01066544b2e106c71d06d3e8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elasticd_3d.py_TestRand3DElasticd_": {"doc_hash": "e66c288893d5f7d34e67ccc2854cf193fedf4474b81483f437915b212cf01f67"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_flip.py_unittest_": {"doc_hash": "c40b2468e2c288c2ee4d2afa8b63ca724b459940feab6c39b4d99ddc94cb3ca7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_flipd.py_unittest_": {"doc_hash": "23c658d4fe4af3cb90e5625b618bc919f54f3210882e1bdb893513c5679531a7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_gaussian_noise.py_unittest_": {"doc_hash": "71d7cf3eeefa9a1cbea2156c8fe6da8a4fa8e229871309805aef0e20d6fcac08"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_gaussian_noised.py_unittest_": {"doc_hash": "d59e0bd0d44d30282140f653e887ba791ba539f32bf8147add6702a3e447ccd2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotate.py_unittest_TestRandRotate2D.test_correct_results.np_testing_assert_allclos": {"doc_hash": "13f25f12a1c117f3500f1db09604a485b2c56699ca2932ef77ce8e1a5acc6c25"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotate.py_TestRandRotate3D_": {"doc_hash": "c8a373bc72b8f90b05971e00bd82a30a4fd5c793fbfc9bd543933468eb5f2655"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotate90.py_unittest_": {"doc_hash": "3d2fec7f9e9e3c40c4db9e4fb1681c0c3d3e7893988ab88b562b78dc217959fa"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotate90d.py_unittest_TestRandRotate90d.test_spatial_axes.self_assertTrue_np_allclo": {"doc_hash": "0ef55967b76d3c5113c51eb644d6f246c3de9e8dbd9d12d10476a93ea120e623"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotate90d.py_TestRandRotate90d.test_prob_k_spatial_axes_": {"doc_hash": "026c119c9002bc99d2a84c8abffca0712f5eedae2fd6d3ba069eaf242daeab2f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotated.py_unittest_TestRandRotated2D.test_correct_results.self_assertTrue_np_allclo": {"doc_hash": "64d58c9bdac58da9b512138e76a51c67584e6c4626097523e3594d92719d0ea6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotated.py_TestRandRotated3D_": {"doc_hash": "931075573322080080b48e26b8cec55978e5834539ac4d24d01d9154c015dbcc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_scale_intensity.py_unittest_": {"doc_hash": "9bd29b84eed525ca1f5bb4aa0b2c42789414baa8addbafcf8eaf1c5be48339cb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_scale_intensityd.py_unittest_": {"doc_hash": "1a4a984811c47cbfc6fe82ca5bb71a55a1c0399f700c42be576b4a26b366e901"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_shift_intensity.py_unittest_": {"doc_hash": "4a32563d44049d4d407901579146817b059494f6591d71e58d97f7fe60ed635e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_shift_intensityd.py_unittest_": {"doc_hash": "554c4cbe55a6feae4a12563b80534b50d2a7ba602117268762877dffc7c75bb9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_crop.py_unittest_TEST_CASE_3._": {"doc_hash": "8e9829af58759cf64c6774393f2a6d652d143623ef2bd41290c13e3d83b511cf"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_crop.py_TestRandSpatialCrop_": {"doc_hash": "1595b53f4bd1e222875f4387080fa9bbc1809c1fa0f31646210748fb9907dbb9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_crop_samples.py_unittest_": {"doc_hash": "301489a681fe83532e84c803dacf97c0446af6de2c48f7d04cc90e7ba547e63b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_crop_samplesd.py_unittest_": {"doc_hash": "8671a2d2e86d5caba221f2fcd5b8ad1e2780170519bca0eb1eed4022d611e074"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_cropd.py_unittest_TEST_CASE_3._": {"doc_hash": "b84015f65213fde6a05e0c62702601ff7d1a62d8ae27386c56c8d2899383faf7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_cropd.py_TestRandSpatialCropd_": {"doc_hash": "cf0a51b2676049d8b2c34daf2155b79b4724a018bfd57a2b83ee7fa3dd7a9b30"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_zoom.py_unittest_TestRandZoom.test_correct_results.np_testing_assert_allclos": {"doc_hash": "873febbd590442796cb8c64fa2097b10937e104d469f0d72c903c24c0fab4f54"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_zoom.py_TestRandZoom.test_keep_size_TestRandZoom.test_keep_size.None_2": {"doc_hash": "ef15738a6fd5d102b81d040d60454fee8f531a8385eaae98dd6966baa52688dd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_zoom.py_TestRandZoom.test_invalid_inputs_": {"doc_hash": "347e58d2d09c6e70a48399b1edda6ee715c75cc6cc8ee7418b6da7973c9f6ca0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_zoomd.py_unittest_TestRandZoomd.test_correct_results.np_testing_assert_allclos": {"doc_hash": "b808733c573c1366b3166e11f46fa5d33bc23f120f097a01baf9d53a34c43914"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_zoomd.py_TestRandZoomd.test_keep_size_": {"doc_hash": "b3fa189b0b667744ae62bf6028567657bd995e746d8f38b5b9e6d8fed177e9d9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_randomizable.py_unittest_": {"doc_hash": "37a782dfd164a77815adb0c0a6f925c7d238bb978fbeaaef844e318ce281c7ee"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_repeat_channel.py_unittest_": {"doc_hash": "cd5288f8072187f31bedbd5a3fec62db4965439dd97343c2512e4d715b5698ae"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_repeat_channeld.py_unittest_": {"doc_hash": "65910e935522ccee903544a711dab73881115cd7ce58e1476e5cd76724d70ad9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_resampler.py_unittest_TEST_CASES._": {"doc_hash": "eb7d2e87d39ebd14dcdd54f91345796bd7b0233c0f7a07a08ed09dfeb716227b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_resampler.py_TestResample_": {"doc_hash": "d26ea8a06d7ddc0433cedf68b164846462b0e1f3d4a5ece2be55680f42185659"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_resize.py_unittest_": {"doc_hash": "b6b7775521277179642d837a1b830eaa9db1c2c64cb472f7b9a06d310e95d8c7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_resized.py_unittest_": {"doc_hash": "17606d90d8dc67baa31a1f052661cdbdf40204a7cdd43c40186c087d02c2485a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate.py_unittest_TEST_CASES_SHAPE_3D._": {"doc_hash": "c732b753af6d6ed5a1ea3a0e1d9737d5e03addc47412d5bd7b423ebbf652ba08"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate.py_TestRotate2D_TestRotate2D.test_correct_results.np_testing_assert_allclos": {"doc_hash": "b04fe0690ba6d79897aafe18de425532a755997e067ba5e6010046f038e2234d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate.py_TestRotate3D_TestRotate3D.test_correct_results.np_testing_assert_allclos": {"doc_hash": "b37dded6692628634659266e01caabdb3aad047210f510a209d63ba56bfbea6b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate.py_TestRotate3D.test_correct_shape_": {"doc_hash": "34432312568c81bc903985c590dc4cafa9874c36101664aa7f252ee190ebcafd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate90.py_unittest_": {"doc_hash": "8870a6d5e0f599ae71fb10e92493927cdbdad3fd672a820e8760a369526c9e16"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate90d.py_unittest_": {"doc_hash": "11fc07eeb043397b0c0420312b8cfb075a95828292d045777b255231dbec3126"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotated.py_unittest_TEST_CASES_3D._": {"doc_hash": "28df48ec28685494456c4eaf6fb843414557b21bf0df7c4959fd1365e0a82860"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotated.py_TestRotated2D_TestRotated2D.test_correct_results.self_assertLessEqual_np_c": {"doc_hash": "3fc8a945a5706cfad26b5c00e975ed680e82dd643ad0e855c9a3d6912cf02076"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotated.py_TestRotated3D_TestRotated3D.test_correct_results.self_assertLessEqual_np_c": {"doc_hash": "9ef4352514a849d59f1f86af6b50fce2981cbba205b50a0b902d1c87b2acf731"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotated.py_TestRotated3DXY_": {"doc_hash": "6c91f0623be7a4e97a83f2307ac1df11957a5cd8a6555739578d94ed8985897b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity.py_unittest_": {"doc_hash": "c1de005a860d073bedd16f73f29576de20b77dc77825a0b6657d2762bba0a2ff"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range.py_unittest_": {"doc_hash": "c8f1655ece9b01b24c0d8e66e482057412559d78de298d46faf0252bc7fa1317"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentiles.py_unittest_TestScaleIntensityRangePercentiles.test_scaling.self_assertTrue_np_allclo": {"doc_hash": "a4cd0c3425abdb34e9ea522d1afe3440ee0d338e33f42eda402886ccd70e5125"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentiles.py_TestScaleIntensityRangePercentiles.test_relative_scaling_TestScaleIntensityRangePercentiles.test_relative_scaling.self_assertTrue_np_allclo": {"doc_hash": "a801ad2bd2d33c93938eaca152603f226919971788e17dd1f4b18784f7630f42"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentiles.py_TestScaleIntensityRangePercentiles.test_invalid_instantiation_": {"doc_hash": "f3da79e1032073fd0929835458ebc1ff1cc0df62c54e9d48016aab5a90d12d21"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentilesd.py_unittest_TestScaleIntensityRangePercentilesd.test_scaling.self_assertTrue_np_allclo": {"doc_hash": "73fb1b95fe161279a3e2a4188dbdcc21ee48be5995305d123206ce3c440cb875"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentilesd.py_TestScaleIntensityRangePercentilesd.test_relative_scaling_TestScaleIntensityRangePercentilesd.test_relative_scaling.self_assertTrue_np_allclo": {"doc_hash": "3c25d9828e95eb9d0f535678047f1aa8f711ab30208a596ac5e65a493dee2e88"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentilesd.py_TestScaleIntensityRangePercentilesd.test_invalid_instantiation_": {"doc_hash": "801d0de8b2e7995e895305957a26df5369e8f158526470cf080982ca4820130f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_ranged.py_unittest_": {"doc_hash": "ff970a64f5c8d52d5f179e2ffc154419d989a6845eb137a8a5200567a9a278ed"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensityd.py_unittest_": {"doc_hash": "dfcc1b3f7522d8c84be3c5e119ee2876b86cef4ef87120558e874bd766698cee"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_se_block.py_unittest_for_type_1_in_.for_type_2_in_.TEST_CASES_3D_append_test": {"doc_hash": "e8ef93866f0df5828e202764e7f77007fcd8b43c1537bccceb84783ff5fb4c8a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_se_block.py_TestSEBlockLayer_": {"doc_hash": "e2b6f75b196ec4d22a07fcd70128d3ec42984ab3323263ac79abba5d44006d46"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_se_blocks.py_unittest_": {"doc_hash": "1e5272e762ac2a98807698dfd8e3e80831fefda204b9348086d53866fecbe653"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_seg_loss_integration.py_unittest_TEST_CASES._": {"doc_hash": "ed95f0837fd1b77044396f0a86ae46ae01e8a4100531da40ee2a81f0b02965f2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_seg_loss_integration.py_TestSegLossIntegration_TestSegLossIntegration.test_convergence._define_a_one_layer_mode": {"doc_hash": "ed89baecf130aba060752006361891f7f018493fd39e54708c5c4c0ccc8a6fc7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_seg_loss_integration.py_TestSegLossIntegration.test_convergence.OnelayerNet_TestSegLossIntegration.test_convergence.OnelayerNet.forward.return.x": {"doc_hash": "1a72a77faa759300292ee8cf695d55a639cf177a1b817134c618bcda85c83071"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_seg_loss_integration.py_TestSegLossIntegration.test_convergence._initialise_the_network_": {"doc_hash": "2a001033d18926c47b4f13acb896f045afdb428a202b6b9de53d3483c616ad45"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_set_determinism.py_unittest_": {"doc_hash": "6ba6169ba712c4d74bae42cd526ddf224748f758101e0949970e9d71e5d7e212"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_shift_intensity.py_unittest_": {"doc_hash": "afdbc0c4db8ee00a5137670a8626dcc9b6be0c715e271f046371dd308549a695"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_shift_intensityd.py_unittest_": {"doc_hash": "97182d43d145d6f4b65300c3cdddc8cd4c590e3239aa6a9a182244e3cc687b10"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_simple_aspp.py_unittest_TEST_ILL_CASES._": {"doc_hash": "b747025149141d59bb05397dbc4c5e980c2810e26c72d0147d005e2f605162e1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_simple_aspp.py_TestChannelSELayer_": {"doc_hash": "510e0e689fb7f8a248914cefa75716a4446fc8910e6050e1821a09254dcd022c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_simulatedelay.py_unittest_": {"doc_hash": "638db309cc22aae938a02640aae1b4ea2763c0154813d9de35a0051b6d2f8786"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_simulatedelayd.py_unittest_": {"doc_hash": "95dae5f9c03cb5effb7479e06574bf2f6f84b4cc004c8a7a34e56c906b485569"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_sliding_window_inference.py_unittest_TEST_CASE_7._1_3_16_15_7_4_1": {"doc_hash": "2587841801bc657715b1176c1a6c68a05c3b0cf075e652f4500986fdef13c932"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_sliding_window_inference.py__3D_small_roi_gaussian_": {"doc_hash": "e63edc5ed67183f6459f44fbfaf8437f129719265cfdb2b42d26c706c16d43e0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacing.py_unittest_TEST_CASES": {"doc_hash": "a758e49290a0399571611e27bd97163e1c8a30bb080a579d82b2755302277bfe"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacing.py_TestSpacingCase_": {"doc_hash": "82c24da42e2802c05cf8e55c64c833a5bc905cc363a34061021f869c92f5efe9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacingd.py_unittest_TestSpacingDCase.test_spacingd_3d.None_2": {"doc_hash": "b4c9e5e79905b600f6c0fca5ac12d3001be21264eb89a0ebdcc64b3018a91d00"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacingd.py_TestSpacingDCase.test_spacingd_2d_TestSpacingDCase.test_spacingd_2d.None_2": {"doc_hash": "8aaed058fc07a57596b13343b28e5e78c7b2782098c12c5755fd98335309ed19"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacingd.py_TestSpacingDCase.test_interp_all_TestSpacingDCase.test_interp_all.None_2": {"doc_hash": "ee1ca806996ed6bee2bcff15f9dd0c34edf1264b92e19ce4d8991b55a08d91af"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacingd.py_TestSpacingDCase.test_interp_sep_": {"doc_hash": "ca43811c014a9a46f7236c0fe0f0be02455c92a5bb993a390e32459aef7de747"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spatial_crop.py_unittest_": {"doc_hash": "152dd754877c1475a8e2c0c720cafc3b8179f5807b79c53102815106ed0e49c8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spatial_cropd.py_unittest_": {"doc_hash": "63e0930c7b90b114e6ad85e8784ac82b99b2ea7e8ba43214062ae0610d5b5f12"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spatial_pad.py_unittest_": {"doc_hash": "b5cb6c2ae076b73479e10b825d09ab75d05cb82450b1668d619cef64f013ed39"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spatial_padd.py_unittest_": {"doc_hash": "2a4a1dfb6e05e1a2e5d8a8e8d5e568e054dad8cca161b772910181caf11fe6da"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_split_channel.py_unittest_": {"doc_hash": "b08b9c4fdc9517b8ef9198d7093bed45cd9d24fd23be9e5f571e914f6317a840"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_split_channeld.py_unittest_": {"doc_hash": "9a0a9696c466af421448ad4d884d61381f5afd6e47c7e67aed9ab487308a629d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_squeezedim.py_unittest_TEST_CASE_6._dim_0_5_np_random_": {"doc_hash": "8afda4fa4d6f358f4f54d1dad7c6c57cb26cfd734a4806cc2692642d16f15db4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_squeezedim.py_TestSqueezeDim_": {"doc_hash": "b09b34a5ee04c0141319ea18105fe4ec6dce96832791544289cd24581f7ab212"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_squeezedimd.py_unittest_TEST_CASE_6._": {"doc_hash": "ace8f336e745c95b08f7f00b694485861ae38ade125d4409c9af9ca6f3375e0c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_squeezedimd.py_TestSqueezeDim_": {"doc_hash": "6552ed734a52e0a0255cb42d60e10bcd7816033de58cbbf3f9b1b9241c8f5105"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_threshold_intensity.py_unittest_": {"doc_hash": "e534b03e4bf87b757cc954505f18ccae35747a222613fcc65f3308212d32146f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_threshold_intensityd.py_unittest_TEST_CASE_3._": {"doc_hash": "3f9decf35929679bfd25398935f223c8b3317d6ba0149f130036cda67c778ff8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_threshold_intensityd.py_TestThresholdIntensityd_": {"doc_hash": "4d88f713215646861a00b981f571d1f9e441cd6b9291ea2c0f6ab765fa1c384e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_to_numpy.py_unittest_": {"doc_hash": "6a3975c3b2189b3263f48922f00e9f780834fba81247cc1190f9a5045f35085d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_to_numpyd.py_unittest_": {"doc_hash": "3ffba08c7b32702eac1fe5560d1c9055a36fcf0a22b0d37d5697a0815026d864"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_to_onehot.py_unittest_TEST_CASE_4._no_channel_0D_batch": {"doc_hash": "f39b2da576e3c007e2302a2a9b08246184fc8a6578dd0be7ab14e7147ca683e7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_to_onehot.py_TestToOneHot_": {"doc_hash": "3a657d69562fd4cf3e3b3fbe7e82af9ad68eec651ee575f82ee848154ca1833c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_tversky_loss.py_unittest_TEST_CASES._": {"doc_hash": "87e6a692a6e8e14ef87389682f9d6a3bcd6dd73a13b97334d33e690c54c0a64f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_tversky_loss.py_TestTverskyLoss_TestTverskyLoss.test_ill_shape.None_2.TverskyLoss_reduction_Non": {"doc_hash": "263a13605a29548fa24916068acc28f94996c25c7f1793cb89669e3942e5c47d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_tversky_loss.py_TestTverskyLoss.test_input_warnings_": {"doc_hash": "a7781f4e11007b73626fd25465b973761feb772f84c1157cd26bf86c2a210e50"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_unet.py_unittest_TEST_CASE_5._4_channel_3D_batch_": {"doc_hash": "944179307b5190c4a1ce6643dcfd41622a557764d42cec6850c4c7ba81e261a1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_unet.py_TEST_CASE_6_": {"doc_hash": "a379325aa1113adaae6ce1f5faee34f2f0616ed0c8e9fd02cde80e423eb47b07"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_upsample_block.py_unittest_": {"doc_hash": "ab290f4ce7336bd82f53776ce0c26d3fc2f5456c8d10232f77899717af2d570b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zipdataset.py_unittest_": {"doc_hash": "0e64b268cbdcf8ad477cf56098f0722319624a1b375306afc34a2bd22c9171ac"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom.py_unittest_INVALID_CASES._None_None_bilinear": {"doc_hash": "72abac4945441aa39a6c947ea24454f4975e6da16cb71f433ccf2f0215a37605"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom.py_TestZoom_TestZoom.test_correct_results.np_testing_assert_allclos": {"doc_hash": "95b37a2bf9f8619a7279ffea82daff8dace483b22946a96241d9719cabfdc94b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom.py_TestZoom.test_keep_size_": {"doc_hash": "25aad7c2b17dec508a9637fe75367802ff451dc0ad7c200cff57972a4adceaf4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom_affine.py_unittest_VALID_CASES._": {"doc_hash": "e0b96f6d1ed34b28ec0ecc8125906ca7f9b10c00c9abc59745bd16978337ceca"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom_affine.py_DIAGONAL_CASES_DIAGONAL_CASES._": {"doc_hash": "8a8bd01afc5596687781fded052e0366e694eefe3b112075d2272137934f9b1f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom_affine.py_TestZoomAffine_": {"doc_hash": "bb8fb4f6755eab54647c64234fccbc08a52816da71293d07c72478fb6997c520"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoomd.py_unittest_INVALID_CASES._no_zoom_None_bilin": {"doc_hash": "cb3e20ecaa106a3553375a1720b83818cd97ce52e8da22c31aa7dafdef375027"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoomd.py_TestZoomd_TestZoomd.test_correct_results.np_testing_assert_allclos": {"doc_hash": "9f521bff2d8def8e597da86ee87b8027f0cdf107cd6bd549f4c0bc58e9f3e895"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoomd.py_TestZoomd.test_keep_size_": {"doc_hash": "325c1caf645f717dd6d1ecc078fe56511effc2df291ef04b2e667deb1106338b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/utils.py_os_skip_if_quick.return.unittest_skipIf_is_quick_": {"doc_hash": "b6516cff6f040e344d7238d9d2c615c61b6342258b1a3da5bed541cebf5a5d91"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/utils.py_make_nifti_image_make_nifti_image.return.image_name": {"doc_hash": "9aff81a921d77846bf73c9b99ed694af72e277eb8e585c6fead25386152f3002"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/utils.py_NumpyImageTestCase2D_TorchImageTestCase2D.setUp.self.segn.torch_tensor_self_segn_": {"doc_hash": "588bffb4c26254305253faf110da2b324861d58a0cd1d1d4a3ec83679c9d378f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/utils.py_NumpyImageTestCase3D_expect_failure_if_no_gpu.if_not_torch_cuda_is_avai.else_.return.test": {"doc_hash": "824cb74da0cf6cf4fbd0a570838da5037a0b2f4310c2d590b046b02f900ebb3d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/utils.py_query_memory_": {"doc_hash": "5021b1cda7c55d5ae70ba772d093a262b6ae5a8c040d22bc0309a8e2f8fdb86d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py__Version_0_18_get_root.return.root": {"doc_hash": "52d0a21c83fb1e586b6d23faf372d214a1c3955639456f16be3a0fb8fa0e41c5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_config_from_root_get_config_from_root.return.cfg": {"doc_hash": "f9c2e42c490016a4c20a5a5e196fc69b0abfd07e1b949b0261afc895dd98cb06"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_NotThisMethod_register_vcs_handler.return.decorate": {"doc_hash": "a24c3e79ac684f387193532bbbb6b93bc3338d65f89c8decdfcac70cbd7d4966"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_run_command_run_command.return.stdout_p_returncode": {"doc_hash": "d193078b8f1038085bb4ca451fa3314684e9637d429ca9e8cc419c494972214b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_git_get_keywords_git_get_keywords.return.keywords": {"doc_hash": "24589a0695cc6db686b17707d2ae846bb00b32afb520696f4ba33bdcef540ce7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_git_versions_from_keywords_git_versions_from_keywords.return._": {"doc_hash": "9d97b2169ad3bbbdc77f3e272a3553754ca01147e0050b318be1c848dbf63769"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_git_pieces_from_vcs_git_pieces_from_vcs.return.pieces": {"doc_hash": "819499a9d7bb6bfd837fbbf6ce81003f54ed1ca11c4de7f1b8f447d52dec3753"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_do_vcs_install_do_vcs_install.run_command_GITS_add_": {"doc_hash": "ce6841ff519b17aa2d7473d5ad7ac0e07f12143a79c7f074763a9631c2fc7184"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_versions_from_parentdir_versions_from_parentdir.raise_NotThisMethod_root": {"doc_hash": "eb27147b4dca2b18020791f0e65c0fbf7aec6bd2532f6ea54436911b8190d4b1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_SHORT_VERSION_PY_versions_from_file.return.json_loads_mo_group_1_": {"doc_hash": "f889af4c9f7c0dcc8e197ed134b0c106004a915486f59b74be5deb7d7df9f68c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_write_to_version_file_plus_or_dot.return._": {"doc_hash": "75973a5ef462074580ea01f4ad51787ab7d7bc39ff5eda566ef9f40d05aeda5d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_pep440_render_pep440_pre.return.rendered": {"doc_hash": "b5c7b2d14b2131ebb04a2505311ffdf94f9eb8758b15f82fa2f89a5e6320d643"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_pep440_post_render_pep440_post.return.rendered": {"doc_hash": "118807a5c2a97d74d8fe5f796e9018ac18aadcc9b3182b6181ecd25e8dcbd0d7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_pep440_old_render_pep440_old.return.rendered": {"doc_hash": "6c6b4eb402371d591eeb0abb50ada6698ebe88b10543f867cefca40fd086f508"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_git_describe_render_git_describe.return.rendered": {"doc_hash": "a3d9b39392875e0334af8c64b46fe88c38f8d51c8b168839e4ae228db30b0daf"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_git_describe_long_render_git_describe_long.return.rendered": {"doc_hash": "cf56b90f4c7b7ac99479cdeafeebaf306a0ab42713bb536dffdfe85f0a8b1c00"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_VersioneerBadRootError._The_project_root_direc": {"doc_hash": "8830b95a2390f35b59b15edddd77bdcb0dbc6a910169bd3a9f57b3c382046551"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_versions_get_versions.return._": {"doc_hash": "8c9846352af5fa04f4ae6f00259417363a735b385dc9858b46939a847d6928f6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_version_get_cmdclass.from_distutils_core_impor": {"doc_hash": "b46b8ebb3921cc678793c9ac073ce2ccfa012b4f230b5a81c900c42f0a97cf9a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_cmdclass.cmd_version_get_cmdclass.cmd_version.run.if_vers_error_.print_error_s_vers": {"doc_hash": "e0cb6df2b5995ce185fbe7f4e46b80764040478598a909f72d8a8c80b245b2a6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_cmdclass.cmds_version_cmd_ver_get_cmdclass.if_cx_Freeze_in_sys_mod.del_cmds_build_py_": {"doc_hash": "5f2b9e6ba564b64eb5ad58eb1a20468b892281ded68a6853fd99b5b32009b74e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_cmdclass.if_py2exe_in_sys_module_get_cmdclass.None_4.else_.from_distutils_command_sd": {"doc_hash": "87bdcf2e70de35d43f3ebdfa9e0afe55d1c33f8b64f86ec9323b19d7c46130d6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_cmdclass.cmd_sdist_get_cmdclass.return.cmds": {"doc_hash": "01f7a5da14f46686d5dd5ce377a6e7818f49b0d42afeed64a5b82b5f9f7dfe96"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_CONFIG_ERROR_INIT_PY_SNIPPET._": {"doc_hash": "aadd871f92dd45b60bf6a6dfe7fc15fa89a744ae887e426fcf312b1aa2557082"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_do_setup_do_setup.return.0": {"doc_hash": "c2bcd07b9d53c25471038425396ab5dcb5cd7f9d8cd3c4569068e4849c3b095e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_scan_setup_py_": {"doc_hash": "83c4211be1e0dcbb1815fd41e4ccb28871b1cd8f3dd45fa8ed714ff8f031fbda"}}, "docstore/data": {"/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/docs/source/conf.py__Configuration_file_for__exclude_patterns._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/docs/source/conf.py__Configuration_file_for__exclude_patterns._", "embedding": null, "metadata": {"file_path": "docs/source/conf.py", "file_name": "conf.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1, "end_line": 49, "span_ids": ["docstring"], "tokens": 322}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "# Configuration file for the Sphinx documentation builder.\n#\n# This file only contains a selection of the most common options. For a full\n# list see the documentation:\n# https://www.sphinx-doc.org/en/master/usage/configuration.html\n\n# -- Path setup --------------------------------------------------------------\n\n# If extensions (or modules to document with autodoc) are in another directory,\n# add these directories to sys.path here. If the directory is relative to the\n# documentation root, use os.path.abspath to make it absolute, like shown here.\n#\nimport os\nimport sys\nimport subprocess\n\nsys.path.insert(0, os.path.abspath(\"..\"))\nsys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), \"..\", \"..\")))\nprint(sys.path)\n\nimport monai # noqa: E402\n\n# -- Project information -----------------------------------------------------\nproject = \"MONAI\"\ncopyright = \"2020 MONAI Consortium\"\nauthor = \"MONAI Contributors\"\n\n# The full version, including alpha/beta/rc tags\nshort_version = monai.__version__.split(\"+\")[0]\nrelease = short_version\nversion = short_version\n\n# List of patterns, relative to source directory, that match files and\n# directories to ignore when looking for source files.\n# This pattern also affects html_static_path and html_extra_path.\nexclude_patterns = [\n \"transforms\",\n \"networks\",\n \"metrics\",\n \"engines\",\n \"data\",\n \"apps\",\n \"config\",\n \"handlers\",\n \"losses\",\n \"visualize\",\n \"utils\",\n \"inferers\",\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/docs/source/conf.py_generate_apidocs_generate_apidocs.subprocess_check_call_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/docs/source/conf.py_generate_apidocs_generate_apidocs.subprocess_check_call_", "embedding": null, "metadata": {"file_path": "docs/source/conf.py", "file_name": "conf.py", "file_type": "text/x-python", "category": "implementation", "start_line": 52, "end_line": 67, "span_ids": ["generate_apidocs"], "tokens": 205}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def generate_apidocs(*args):\n \"\"\"Generate API docs automatically by trawling the available modules\"\"\"\n module_path = os.path.abspath(os.path.join(os.path.dirname(__file__), \"..\", \"..\", \"monai\"))\n output_path = os.path.abspath(os.path.join(os.path.dirname(__file__), \"apidocs\"))\n apidoc_command_path = \"sphinx-apidoc\"\n if hasattr(sys, \"real_prefix\"): # called from a virtualenv\n apidoc_command_path = os.path.join(sys.prefix, \"bin\", \"sphinx-apidoc\")\n apidoc_command_path = os.path.abspath(apidoc_command_path)\n print(f\"output_path {output_path}\")\n print(f\"module_path {module_path}\")\n subprocess.check_call(\n [apidoc_command_path, \"-e\"]\n + [\"-o\", output_path]\n + [module_path]\n + [os.path.join(module_path, p) for p in exclude_patterns]\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/docs/source/conf.py_setup_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/docs/source/conf.py_setup_", "embedding": null, "metadata": {"file_path": "docs/source/conf.py", "file_name": "conf.py", "file_type": "text/x-python", "category": "implementation", "start_line": 70, "end_line": 134, "span_ids": ["impl:18", "setup"], "tokens": 530}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def setup(app):\n # Hook to allow for automatic generation of API docs\n # before doc deployment begins.\n app.connect(\"builder-inited\", generate_apidocs)\n\n\n# -- General configuration ---------------------------------------------------\n\n# Add any Sphinx extension module names here, as strings. They can be\n# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom\n# ones.\nsource_suffix = {\".rst\": \"restructuredtext\", \".txt\": \"restructuredtext\", \".md\": \"markdown\"}\n\nextensions = [\n \"recommonmark\",\n \"sphinx.ext.intersphinx\",\n \"sphinx.ext.mathjax\",\n \"sphinx.ext.napoleon\",\n \"sphinx.ext.autodoc\",\n \"sphinx.ext.viewcode\",\n \"sphinx.ext.autosectionlabel\",\n \"sphinx_autodoc_typehints\",\n]\n\nautoclass_content = \"both\"\nadd_module_names = True\nautosectionlabel_prefix_document = True\nnapoleon_use_param = True\nset_type_checking_flag = True\n\n# Add any paths that contain templates here, relative to this directory.\ntemplates_path = [\"_templates\"]\n\n# -- Options for HTML output -------------------------------------------------\n\n# The theme to use for HTML and HTML Help pages. See the documentation for\n# a list of builtin themes.\n#\nhtml_theme = \"sphinx_rtd_theme\"\n# html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]\nhtml_theme_options = {\n \"collapse_navigation\": True,\n \"display_version\": True,\n \"sticky_navigation\": True, # Set to False to disable the sticky nav while scrolling.\n \"logo_only\": True, # if we have a html_logo below, this shows /only/ the logo with no title text\n \"style_nav_header_background\": \"#FBFBFB\",\n}\nhtml_context = {\n \"display_github\": True,\n \"github_user\": \"Project-MONAI\",\n \"github_repo\": \"MONAI\",\n \"github_version\": \"master\",\n \"conf_py_path\": \"/docs/\",\n}\nhtml_scaled_image_link = False\nhtml_show_sourcelink = True\nhtml_favicon = \"../images/favicon.ico\"\nhtml_logo = \"../images/MONAI-logo-color.png\"\n\n# Add any paths that contain custom static files (such as style sheets) here,\n# relative to this directory. They are copied after the builtin static files,\n# so a file named \"default.css\" will overwrite the builtin \"default.css\".\nhtml_static_path = [\"../_static\"]\nhtml_css_files = [\"custom.css\"]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_evaluation_array.py_sys_main.model_eval_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_evaluation_array.py_sys_main.model_eval_", "embedding": null, "metadata": {"file_path": "examples/classification_3d/densenet_evaluation_array.py", "file_name": "densenet_evaluation_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 58, "span_ids": ["main", "docstring"], "tokens": 715}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import sys\nimport logging\nimport numpy as np\nimport os\nimport torch\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.data import NiftiDataset, CSVSaver\nfrom monai.transforms import Compose, AddChannel, ScaleIntensity, Resize, ToTensor\n\n\ndef main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n # IXI dataset as a demo, downloadable from https://brain-development.org/ixi-dataset/\n images = [\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI607-Guys-1097-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI175-HH-1570-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI385-HH-2078-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI344-Guys-0905-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI409-Guys-0960-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI584-Guys-1129-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI253-HH-1694-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI092-HH-1436-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI574-IOP-1156-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI585-Guys-1130-T1.nii.gz\"]),\n ]\n\n # 2 binary labels for gender classification: man and woman\n labels = np.array([0, 0, 1, 0, 1, 0, 1, 0, 1, 0], dtype=np.int64)\n\n # Define transforms for image\n val_transforms = Compose([ScaleIntensity(), AddChannel(), Resize((96, 96, 96)), ToTensor()])\n\n # Define nifti dataset\n val_ds = NiftiDataset(image_files=images, labels=labels, transform=val_transforms, image_only=False)\n # create a validation data loader\n val_loader = DataLoader(val_ds, batch_size=2, num_workers=4, pin_memory=torch.cuda.is_available())\n\n # Create DenseNet121\n device = torch.device(\"cuda:0\")\n model = monai.networks.nets.densenet.densenet121(spatial_dims=3, in_channels=1, out_channels=2).to(device)\n\n model.load_state_dict(torch.load(\"best_metric_model.pth\"))\n model.eval()\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_evaluation_array.py_main.with_torch_no_grad__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_evaluation_array.py_main.with_torch_no_grad__", "embedding": null, "metadata": {"file_path": "examples/classification_3d/densenet_evaluation_array.py", "file_name": "densenet_evaluation_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 59, "end_line": 77, "span_ids": ["impl", "main"], "tokens": 159}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n # ... other code\n with torch.no_grad():\n num_correct = 0.0\n metric_count = 0\n saver = CSVSaver(output_dir=\"./output\")\n for val_data in val_loader:\n val_images, val_labels = val_data[0].to(device), val_data[1].to(device)\n val_outputs = model(val_images).argmax(dim=1)\n value = torch.eq(val_outputs, val_labels)\n metric_count += len(value)\n num_correct += value.sum().item()\n saver.save_batch(val_outputs, val_data[2])\n metric = num_correct / metric_count\n print(\"evaluation metric:\", metric)\n saver.finalize()\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_evaluation_dict.py_sys_main.model_eval_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_evaluation_dict.py_sys_main.model_eval_", "embedding": null, "metadata": {"file_path": "examples/classification_3d/densenet_evaluation_dict.py", "file_name": "densenet_evaluation_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 66, "span_ids": ["main", "docstring"], "tokens": 767}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import sys\nimport logging\nimport numpy as np\nimport os\nimport torch\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.transforms import Compose, LoadNiftid, AddChanneld, ScaleIntensityd, Resized, ToTensord\nfrom monai.data import CSVSaver\n\n\ndef main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n # IXI dataset as a demo, downloadable from https://brain-development.org/ixi-dataset/\n images = [\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI607-Guys-1097-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI175-HH-1570-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI385-HH-2078-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI344-Guys-0905-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI409-Guys-0960-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI584-Guys-1129-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI253-HH-1694-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI092-HH-1436-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI574-IOP-1156-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI585-Guys-1130-T1.nii.gz\"]),\n ]\n\n # 2 binary labels for gender classification: man and woman\n labels = np.array([0, 0, 1, 0, 1, 0, 1, 0, 1, 0], dtype=np.int64)\n val_files = [{\"img\": img, \"label\": label} for img, label in zip(images, labels)]\n\n # Define transforms for image\n val_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\"]),\n AddChanneld(keys=[\"img\"]),\n ScaleIntensityd(keys=[\"img\"]),\n Resized(keys=[\"img\"], spatial_size=(96, 96, 96)),\n ToTensord(keys=[\"img\"]),\n ]\n )\n\n # create a validation data loader\n val_ds = monai.data.Dataset(data=val_files, transform=val_transforms)\n val_loader = DataLoader(val_ds, batch_size=2, num_workers=4, pin_memory=torch.cuda.is_available())\n\n # Create DenseNet121\n device = torch.device(\"cuda:0\")\n model = monai.networks.nets.densenet.densenet121(spatial_dims=3, in_channels=1, out_channels=2).to(device)\n\n model.load_state_dict(torch.load(\"best_metric_model.pth\"))\n model.eval()\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_evaluation_dict.py_main.with_torch_no_grad__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_evaluation_dict.py_main.with_torch_no_grad__", "embedding": null, "metadata": {"file_path": "examples/classification_3d/densenet_evaluation_dict.py", "file_name": "densenet_evaluation_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 67, "end_line": 85, "span_ids": ["impl", "main"], "tokens": 161}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n # ... other code\n with torch.no_grad():\n num_correct = 0.0\n metric_count = 0\n saver = CSVSaver(output_dir=\"./output\")\n for val_data in val_loader:\n val_images, val_labels = val_data[\"img\"].to(device), val_data[\"label\"].to(device)\n val_outputs = model(val_images).argmax(dim=1)\n value = torch.eq(val_outputs, val_labels)\n metric_count += len(value)\n num_correct += value.sum().item()\n saver.save_batch(val_outputs, val_data[\"img_meta_dict\"])\n metric = num_correct / metric_count\n print(\"evaluation metric:\", metric)\n saver.finalize()\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_array.py_sys_main.images._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_array.py_sys_main.images._", "embedding": null, "metadata": {"file_path": "examples/classification_3d/densenet_training_array.py", "file_name": "densenet_training_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 51, "span_ids": ["main", "docstring"], "tokens": 874}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import sys\nimport logging\nimport numpy as np\nimport os\nimport torch\nfrom torch.utils.data import DataLoader\nfrom torch.utils.tensorboard import SummaryWriter\n\nimport monai\nfrom monai.data import NiftiDataset\nfrom monai.transforms import Compose, AddChannel, ScaleIntensity, Resize, RandRotate90, ToTensor\n\n\ndef main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n # IXI dataset as a demo, downloadable from https://brain-development.org/ixi-dataset/\n images = [\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI314-IOP-0889-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI249-Guys-1072-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI609-HH-2600-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI173-HH-1590-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI020-Guys-0700-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI342-Guys-0909-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI134-Guys-0780-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI577-HH-2661-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI066-Guys-0731-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI130-HH-1528-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI607-Guys-1097-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI175-HH-1570-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI385-HH-2078-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI344-Guys-0905-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI409-Guys-0960-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI584-Guys-1129-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI253-HH-1694-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI092-HH-1436-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI574-IOP-1156-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI585-Guys-1130-T1.nii.gz\"]),\n ]\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_array.py_main._2_binary_labels_for_gen_main.writer.SummaryWriter_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_array.py_main._2_binary_labels_for_gen_main.writer.SummaryWriter_", "embedding": null, "metadata": {"file_path": "examples/classification_3d/densenet_training_array.py", "file_name": "densenet_training_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 53, "end_line": 86, "span_ids": ["main"], "tokens": 493}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n\n # 2 binary labels for gender classification: man and woman\n labels = np.array([0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0], dtype=np.int64)\n\n # Define transforms\n train_transforms = Compose([ScaleIntensity(), AddChannel(), Resize((96, 96, 96)), RandRotate90(), ToTensor()])\n val_transforms = Compose([ScaleIntensity(), AddChannel(), Resize((96, 96, 96)), ToTensor()])\n\n # Define nifti dataset, data loader\n check_ds = NiftiDataset(image_files=images, labels=labels, transform=train_transforms)\n check_loader = DataLoader(check_ds, batch_size=2, num_workers=2, pin_memory=torch.cuda.is_available())\n im, label = monai.utils.misc.first(check_loader)\n print(type(im), im.shape, label)\n\n # create a training data loader\n train_ds = NiftiDataset(image_files=images[:10], labels=labels[:10], transform=train_transforms)\n train_loader = DataLoader(train_ds, batch_size=2, shuffle=True, num_workers=2, pin_memory=torch.cuda.is_available())\n\n # create a validation data loader\n val_ds = NiftiDataset(image_files=images[-10:], labels=labels[-10:], transform=val_transforms)\n val_loader = DataLoader(val_ds, batch_size=2, num_workers=2, pin_memory=torch.cuda.is_available())\n\n # Create DenseNet121, CrossEntropyLoss and Adam optimizer\n device = torch.device(\"cuda:0\")\n model = monai.networks.nets.densenet.densenet121(spatial_dims=3, in_channels=1, out_channels=2).to(device)\n loss_function = torch.nn.CrossEntropyLoss()\n optimizer = torch.optim.Adam(model.parameters(), 1e-5)\n\n # start a typical PyTorch training\n val_interval = 2\n best_metric = -1\n best_metric_epoch = -1\n epoch_loss_values = list()\n metric_values = list()\n writer = SummaryWriter()\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_array.py_main.for_epoch_in_range_5__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_array.py_main.for_epoch_in_range_5__", "embedding": null, "metadata": {"file_path": "examples/classification_3d/densenet_training_array.py", "file_name": "densenet_training_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 87, "end_line": 139, "span_ids": ["impl", "main"], "tokens": 485}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n # ... other code\n for epoch in range(5):\n print(\"-\" * 10)\n print(f\"epoch {epoch + 1}/{5}\")\n model.train()\n epoch_loss = 0\n step = 0\n for batch_data in train_loader:\n step += 1\n inputs, labels = batch_data[0].to(device), batch_data[1].to(device)\n optimizer.zero_grad()\n outputs = model(inputs)\n loss = loss_function(outputs, labels)\n loss.backward()\n optimizer.step()\n epoch_loss += loss.item()\n epoch_len = len(train_ds) // train_loader.batch_size\n print(f\"{step}/{epoch_len}, train_loss: {loss.item():.4f}\")\n writer.add_scalar(\"train_loss\", loss.item(), epoch_len * epoch + step)\n epoch_loss /= step\n epoch_loss_values.append(epoch_loss)\n print(f\"epoch {epoch + 1} average loss: {epoch_loss:.4f}\")\n\n if (epoch + 1) % val_interval == 0:\n model.eval()\n with torch.no_grad():\n num_correct = 0.0\n metric_count = 0\n for val_data in val_loader:\n val_images, val_labels = val_data[0].to(device), val_data[1].to(device)\n val_outputs = model(val_images)\n value = torch.eq(val_outputs.argmax(dim=1), val_labels)\n metric_count += len(value)\n num_correct += value.sum().item()\n metric = num_correct / metric_count\n metric_values.append(metric)\n if metric > best_metric:\n best_metric = metric\n best_metric_epoch = epoch + 1\n torch.save(model.state_dict(), \"best_metric_model.pth\")\n print(\"saved new best metric model\")\n print(\n \"current epoch: {} current accuracy: {:.4f} best accuracy: {:.4f} at epoch {}\".format(\n epoch + 1, metric, best_metric, best_metric_epoch\n )\n )\n writer.add_scalar(\"val_accuracy\", metric, epoch + 1)\n print(f\"train completed, best_metric: {best_metric:.4f} at epoch: {best_metric_epoch}\")\n writer.close()\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_dict.py_sys_main.images._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_dict.py_sys_main.images._", "embedding": null, "metadata": {"file_path": "examples/classification_3d/densenet_training_dict.py", "file_name": "densenet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 51, "span_ids": ["main", "docstring"], "tokens": 886}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import sys\nimport logging\nimport numpy as np\nimport os\nimport torch\nfrom torch.utils.data import DataLoader\nfrom torch.utils.tensorboard import SummaryWriter\n\nimport monai\nfrom monai.transforms import Compose, LoadNiftid, AddChanneld, ScaleIntensityd, Resized, RandRotate90d, ToTensord\nfrom monai.metrics import compute_roc_auc\n\n\ndef main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n # IXI dataset as a demo, downloadable from https://brain-development.org/ixi-dataset/\n images = [\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI314-IOP-0889-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI249-Guys-1072-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI609-HH-2600-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI173-HH-1590-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI020-Guys-0700-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI342-Guys-0909-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI134-Guys-0780-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI577-HH-2661-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI066-Guys-0731-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI130-HH-1528-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI607-Guys-1097-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI175-HH-1570-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI385-HH-2078-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI344-Guys-0905-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI409-Guys-0960-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI584-Guys-1129-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI253-HH-1694-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI092-HH-1436-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI574-IOP-1156-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI585-Guys-1130-T1.nii.gz\"]),\n ]\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_dict.py_main._2_binary_labels_for_gen_main.writer.SummaryWriter_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_dict.py_main._2_binary_labels_for_gen_main.writer.SummaryWriter_", "embedding": null, "metadata": {"file_path": "examples/classification_3d/densenet_training_dict.py", "file_name": "densenet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 53, "end_line": 103, "span_ids": ["main"], "tokens": 614}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n\n # 2 binary labels for gender classification: man and woman\n labels = np.array([0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0], dtype=np.int64)\n train_files = [{\"img\": img, \"label\": label} for img, label in zip(images[:10], labels[:10])]\n val_files = [{\"img\": img, \"label\": label} for img, label in zip(images[-10:], labels[-10:])]\n\n # Define transforms for image\n train_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\"]),\n AddChanneld(keys=[\"img\"]),\n ScaleIntensityd(keys=[\"img\"]),\n Resized(keys=[\"img\"], spatial_size=(96, 96, 96)),\n RandRotate90d(keys=[\"img\"], prob=0.8, spatial_axes=[0, 2]),\n ToTensord(keys=[\"img\"]),\n ]\n )\n val_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\"]),\n AddChanneld(keys=[\"img\"]),\n ScaleIntensityd(keys=[\"img\"]),\n Resized(keys=[\"img\"], spatial_size=(96, 96, 96)),\n ToTensord(keys=[\"img\"]),\n ]\n )\n\n # Define dataset, data loader\n check_ds = monai.data.Dataset(data=train_files, transform=train_transforms)\n check_loader = DataLoader(check_ds, batch_size=2, num_workers=4, pin_memory=torch.cuda.is_available())\n check_data = monai.utils.misc.first(check_loader)\n print(check_data[\"img\"].shape, check_data[\"label\"])\n\n # create a training data loader\n train_ds = monai.data.Dataset(data=train_files, transform=train_transforms)\n train_loader = DataLoader(train_ds, batch_size=2, shuffle=True, num_workers=4, pin_memory=torch.cuda.is_available())\n\n # create a validation data loader\n val_ds = monai.data.Dataset(data=val_files, transform=val_transforms)\n val_loader = DataLoader(val_ds, batch_size=2, num_workers=4, pin_memory=torch.cuda.is_available())\n\n # Create DenseNet121, CrossEntropyLoss and Adam optimizer\n device = torch.device(\"cuda:0\")\n model = monai.networks.nets.densenet.densenet121(spatial_dims=3, in_channels=1, out_channels=2).to(device)\n loss_function = torch.nn.CrossEntropyLoss()\n optimizer = torch.optim.Adam(model.parameters(), 1e-5)\n\n # start a typical PyTorch training\n val_interval = 2\n best_metric = -1\n best_metric_epoch = -1\n writer = SummaryWriter()\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_dict.py_main.for_epoch_in_range_5__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_dict.py_main.for_epoch_in_range_5__", "embedding": null, "metadata": {"file_path": "examples/classification_3d/densenet_training_dict.py", "file_name": "densenet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 104, "end_line": 155, "span_ids": ["impl", "main"], "tokens": 535}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n # ... other code\n for epoch in range(5):\n print(\"-\" * 10)\n print(f\"epoch {epoch + 1}/{5}\")\n model.train()\n epoch_loss = 0\n step = 0\n for batch_data in train_loader:\n step += 1\n inputs, labels = batch_data[\"img\"].to(device), batch_data[\"label\"].to(device)\n optimizer.zero_grad()\n outputs = model(inputs)\n loss = loss_function(outputs, labels)\n loss.backward()\n optimizer.step()\n epoch_loss += loss.item()\n epoch_len = len(train_ds) // train_loader.batch_size\n print(f\"{step}/{epoch_len}, train_loss: {loss.item():.4f}\")\n writer.add_scalar(\"train_loss\", loss.item(), epoch_len * epoch + step)\n epoch_loss /= step\n print(f\"epoch {epoch + 1} average loss: {epoch_loss:.4f}\")\n\n if (epoch + 1) % val_interval == 0:\n model.eval()\n with torch.no_grad():\n y_pred = torch.tensor([], dtype=torch.float32, device=device)\n y = torch.tensor([], dtype=torch.long, device=device)\n for val_data in val_loader:\n val_images, val_labels = val_data[\"img\"].to(device), val_data[\"label\"].to(device)\n y_pred = torch.cat([y_pred, model(val_images)], dim=0)\n y = torch.cat([y, val_labels], dim=0)\n\n acc_value = torch.eq(y_pred.argmax(dim=1), y)\n acc_metric = acc_value.sum().item() / len(acc_value)\n auc_metric = compute_roc_auc(y_pred, y, to_onehot_y=True, softmax=True)\n if acc_metric > best_metric:\n best_metric = acc_metric\n best_metric_epoch = epoch + 1\n torch.save(model.state_dict(), \"best_metric_model.pth\")\n print(\"saved new best metric model\")\n print(\n \"current epoch: {} current accuracy: {:.4f} current AUC: {:.4f} best accuracy: {:.4f} at epoch {}\".format(\n epoch + 1, acc_metric, auc_metric, best_metric, best_metric_epoch\n )\n )\n writer.add_scalar(\"val_accuracy\", acc_metric, epoch + 1)\n print(f\"train completed, best_metric: {best_metric:.4f} at epoch: {best_metric_epoch}\")\n writer.close()\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_evaluation_array.py_sys_main.val_stats_handler_attach_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_evaluation_array.py_sys_main.val_stats_handler_attach_", "embedding": null, "metadata": {"file_path": "examples/classification_3d_ignite/densenet_evaluation_array.py", "file_name": "densenet_evaluation_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 72, "span_ids": ["main", "docstring"], "tokens": 873}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import sys\nimport logging\nimport numpy as np\nimport os\nimport torch\nfrom ignite.engine import create_supervised_evaluator, _prepare_batch\nfrom ignite.metrics import Accuracy\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.data import NiftiDataset\nfrom monai.transforms import Compose, AddChannel, ScaleIntensity, Resize, ToTensor\nfrom monai.handlers import StatsHandler, ClassificationSaver, CheckpointLoader\n\n\ndef main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n # IXI dataset as a demo, downloadable from https://brain-development.org/ixi-dataset/\n images = [\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI607-Guys-1097-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI175-HH-1570-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI385-HH-2078-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI344-Guys-0905-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI409-Guys-0960-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI584-Guys-1129-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI253-HH-1694-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI092-HH-1436-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI574-IOP-1156-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI585-Guys-1130-T1.nii.gz\"]),\n ]\n\n # 2 binary labels for gender classification: man and woman\n labels = np.array([0, 0, 1, 0, 1, 0, 1, 0, 1, 0], dtype=np.int64)\n\n # define transforms for image\n val_transforms = Compose([ScaleIntensity(), AddChannel(), Resize((96, 96, 96)), ToTensor()])\n # define nifti dataset\n val_ds = NiftiDataset(image_files=images, labels=labels, transform=val_transforms, image_only=False)\n # create DenseNet121\n net = monai.networks.nets.densenet.densenet121(spatial_dims=3, in_channels=1, out_channels=2)\n device = torch.device(\"cuda:0\")\n\n metric_name = \"Accuracy\"\n # add evaluation metric to the evaluator engine\n val_metrics = {metric_name: Accuracy()}\n\n def prepare_batch(batch, device=None, non_blocking=False):\n return _prepare_batch((batch[0], batch[1]), device, non_blocking)\n\n # Ignite evaluator expects batch=(img, label) and returns output=(y_pred, y) at every iteration,\n # user can add output_transform to return other values\n evaluator = create_supervised_evaluator(net, val_metrics, device, True, prepare_batch=prepare_batch)\n\n # add stats event handler to print validation stats via evaluator\n val_stats_handler = StatsHandler(\n name=\"evaluator\",\n output_transform=lambda x: None, # no need to print loss value, so disable per iteration output\n )\n val_stats_handler.attach(evaluator)\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_evaluation_array.py_main._for_the_array_data_form_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_evaluation_array.py_main._for_the_array_data_form_", "embedding": null, "metadata": {"file_path": "examples/classification_3d_ignite/densenet_evaluation_array.py", "file_name": "densenet_evaluation_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 74, "end_line": 94, "span_ids": ["impl", "main"], "tokens": 173}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n\n # for the array data format, assume the 3rd item of batch data is the meta_data\n prediction_saver = ClassificationSaver(\n output_dir=\"tempdir\",\n batch_transform=lambda batch: batch[2],\n output_transform=lambda output: output[0].argmax(1),\n )\n prediction_saver.attach(evaluator)\n\n # the model was trained by \"densenet_training_array\" example\n CheckpointLoader(load_path=\"./runs/net_checkpoint_20.pth\", load_dict={\"net\": net}).attach(evaluator)\n\n # create a validation data loader\n val_loader = DataLoader(val_ds, batch_size=2, num_workers=4, pin_memory=torch.cuda.is_available())\n\n state = evaluator.run(val_loader)\n print(state)\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_evaluation_dict.py_from_ignite_metrics_impor_main._add_stats_event_handler": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_evaluation_dict.py_from_ignite_metrics_impor_main._add_stats_event_handler", "embedding": null, "metadata": {"file_path": "examples/classification_3d_ignite/densenet_evaluation_dict.py", "file_name": "densenet_evaluation_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 73, "span_ids": ["main", "docstring"], "tokens": 856}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from ignite.metrics import Accuracy\nimport sys\nimport logging\nimport numpy as np\nimport os\nimport torch\nfrom ignite.engine import create_supervised_evaluator, _prepare_batch\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.handlers import StatsHandler, CheckpointLoader, ClassificationSaver\nfrom monai.transforms import Compose, LoadNiftid, AddChanneld, ScaleIntensityd, Resized, ToTensord\n\n\ndef main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n # IXI dataset as a demo, downloadable from https://brain-development.org/ixi-dataset/\n images = [\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI607-Guys-1097-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI175-HH-1570-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI385-HH-2078-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI344-Guys-0905-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI409-Guys-0960-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI584-Guys-1129-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI253-HH-1694-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI092-HH-1436-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI574-IOP-1156-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI585-Guys-1130-T1.nii.gz\"]),\n ]\n\n # 2 binary labels for gender classification: man and woman\n labels = np.array([0, 0, 1, 0, 1, 0, 1, 0, 1, 0], dtype=np.int64)\n val_files = [{\"img\": img, \"label\": label} for img, label in zip(images, labels)]\n\n # define transforms for image\n val_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\"]),\n AddChanneld(keys=[\"img\"]),\n ScaleIntensityd(keys=[\"img\"]),\n Resized(keys=[\"img\"], spatial_size=(96, 96, 96)),\n ToTensord(keys=[\"img\"]),\n ]\n )\n\n # create DenseNet121\n net = monai.networks.nets.densenet.densenet121(spatial_dims=3, in_channels=1, out_channels=2)\n device = torch.device(\"cuda:0\")\n\n def prepare_batch(batch, device=None, non_blocking=False):\n return _prepare_batch((batch[\"img\"], batch[\"label\"]), device, non_blocking)\n\n metric_name = \"Accuracy\"\n # add evaluation metric to the evaluator engine\n val_metrics = {metric_name: Accuracy()}\n # Ignite evaluator expects batch=(img, label) and returns output=(y_pred, y) at every iteration,\n # user can add output_transform to return other values\n evaluator = create_supervised_evaluator(net, val_metrics, device, True, prepare_batch=prepare_batch)\n\n # add stats event handler to print validation stats via evaluator\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_evaluation_dict.py_main.val_stats_handler_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_evaluation_dict.py_main.val_stats_handler_", "embedding": null, "metadata": {"file_path": "examples/classification_3d_ignite/densenet_evaluation_dict.py", "file_name": "densenet_evaluation_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 74, "end_line": 102, "span_ids": ["impl", "main"], "tokens": 251}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n # ... other code\n val_stats_handler = StatsHandler(\n name=\"evaluator\",\n output_transform=lambda x: None, # no need to print loss value, so disable per iteration output\n )\n val_stats_handler.attach(evaluator)\n\n # for the array data format, assume the 3rd item of batch data is the meta_data\n prediction_saver = ClassificationSaver(\n output_dir=\"tempdir\",\n name=\"evaluator\",\n batch_transform=lambda batch: batch[\"img_meta_dict\"],\n output_transform=lambda output: output[0].argmax(1),\n )\n prediction_saver.attach(evaluator)\n\n # the model was trained by \"densenet_training_dict\" example\n CheckpointLoader(load_path=\"./runs/net_checkpoint_20.pth\", load_dict={\"net\": net}).attach(evaluator)\n\n # create a validation data loader\n val_ds = monai.data.Dataset(data=val_files, transform=val_transforms)\n val_loader = DataLoader(val_ds, batch_size=2, num_workers=4, pin_memory=torch.cuda.is_available())\n\n state = evaluator.run(val_loader)\n print(state)\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_array.py_sys_from_monai_handlers_impor": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_array.py_sys_from_monai_handlers_impor", "embedding": null, "metadata": {"file_path": "examples/classification_3d_ignite/densenet_training_array.py", "file_name": "densenet_training_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 25, "span_ids": ["docstring"], "tokens": 112}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import sys\nimport logging\nimport numpy as np\nimport os\nimport torch\nfrom ignite.engine import Events, create_supervised_trainer, create_supervised_evaluator\nfrom ignite.handlers import ModelCheckpoint, EarlyStopping\nfrom ignite.metrics import Accuracy\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.data import NiftiDataset\nfrom monai.transforms import Compose, AddChannel, ScaleIntensity, Resize, RandRotate90, ToTensor\nfrom monai.handlers import StatsHandler, TensorBoardStatsHandler, stopping_fn_from_metric", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_array.py_main_main.images._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_array.py_main_main.images._", "embedding": null, "metadata": {"file_path": "examples/classification_3d_ignite/densenet_training_array.py", "file_name": "densenet_training_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 28, "end_line": 54, "span_ids": ["main"], "tokens": 804}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n # IXI dataset as a demo, downloadable from https://brain-development.org/ixi-dataset/\n images = [\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI314-IOP-0889-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI249-Guys-1072-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI609-HH-2600-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI173-HH-1590-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI020-Guys-0700-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI342-Guys-0909-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI134-Guys-0780-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI577-HH-2661-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI066-Guys-0731-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI130-HH-1528-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI607-Guys-1097-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI175-HH-1570-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI385-HH-2078-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI344-Guys-0905-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI409-Guys-0960-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI584-Guys-1129-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI253-HH-1694-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI092-HH-1436-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI574-IOP-1156-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI585-Guys-1130-T1.nii.gz\"]),\n ]\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_array.py_main._2_binary_labels_for_gen_main._add_handler_to_record_m": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_array.py_main._2_binary_labels_for_gen_main._add_handler_to_record_m", "embedding": null, "metadata": {"file_path": "examples/classification_3d_ignite/densenet_training_array.py", "file_name": "densenet_training_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 56, "end_line": 114, "span_ids": ["main"], "tokens": 768}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n\n # 2 binary labels for gender classification: man and woman\n labels = np.array([0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0], dtype=np.int64)\n\n # define transforms\n train_transforms = Compose([ScaleIntensity(), AddChannel(), Resize((96, 96, 96)), RandRotate90(), ToTensor()])\n val_transforms = Compose([ScaleIntensity(), AddChannel(), Resize((96, 96, 96)), ToTensor()])\n\n # define nifti dataset, data loader\n check_ds = NiftiDataset(image_files=images, labels=labels, transform=train_transforms)\n check_loader = DataLoader(check_ds, batch_size=2, num_workers=2, pin_memory=torch.cuda.is_available())\n im, label = monai.utils.misc.first(check_loader)\n print(type(im), im.shape, label)\n\n # create DenseNet121, CrossEntropyLoss and Adam optimizer\n net = monai.networks.nets.densenet.densenet121(spatial_dims=3, in_channels=1, out_channels=2)\n loss = torch.nn.CrossEntropyLoss()\n lr = 1e-5\n opt = torch.optim.Adam(net.parameters(), lr)\n device = torch.device(\"cuda:0\")\n\n # Ignite trainer expects batch=(img, label) and returns output=loss at every iteration,\n # user can add output_transform to return other values, like: y_pred, y, etc.\n trainer = create_supervised_trainer(net, opt, loss, device, False)\n\n # adding checkpoint handler to save models (network params and optimizer stats) during training\n checkpoint_handler = ModelCheckpoint(\"./runs/\", \"net\", n_saved=10, require_empty=False)\n trainer.add_event_handler(\n event_name=Events.EPOCH_COMPLETED, handler=checkpoint_handler, to_save={\"net\": net, \"opt\": opt}\n )\n\n # StatsHandler prints loss at every iteration and print metrics at every epoch,\n # we don't set metrics for trainer here, so just print loss, user can also customize print functions\n # and can use output_transform to convert engine.state.output if it's not loss value\n train_stats_handler = StatsHandler(name=\"trainer\")\n train_stats_handler.attach(trainer)\n\n # TensorBoardStatsHandler plots loss at every iteration and plots metrics at every epoch, same as StatsHandler\n train_tensorboard_stats_handler = TensorBoardStatsHandler()\n train_tensorboard_stats_handler.attach(trainer)\n\n # set parameters for validation\n validation_every_n_epochs = 1\n\n metric_name = \"Accuracy\"\n # add evaluation metric to the evaluator engine\n val_metrics = {metric_name: Accuracy()}\n # Ignite evaluator expects batch=(img, label) and returns output=(y_pred, y) at every iteration,\n # user can add output_transform to return other values\n evaluator = create_supervised_evaluator(net, val_metrics, device, True)\n\n # add stats event handler to print validation stats via evaluator\n val_stats_handler = StatsHandler(\n name=\"evaluator\",\n output_transform=lambda x: None, # no need to print loss value, so disable per iteration output\n global_epoch_transform=lambda x: trainer.state.epoch,\n ) # fetch global epoch number from trainer\n val_stats_handler.attach(evaluator)\n\n # add handler to record metrics to TensorBoard at every epoch\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_array.py_main.val_tensorboard_stats_handler_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_array.py_main.val_tensorboard_stats_handler_", "embedding": null, "metadata": {"file_path": "examples/classification_3d_ignite/densenet_training_array.py", "file_name": "densenet_training_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 115, "end_line": 144, "span_ids": ["impl", "main"], "tokens": 314}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n # ... other code\n val_tensorboard_stats_handler = TensorBoardStatsHandler(\n output_transform=lambda x: None, # no need to plot loss value, so disable per iteration output\n global_epoch_transform=lambda x: trainer.state.epoch,\n ) # fetch global epoch number from trainer\n val_tensorboard_stats_handler.attach(evaluator)\n\n # add early stopping handler to evaluator\n early_stopper = EarlyStopping(patience=4, score_function=stopping_fn_from_metric(metric_name), trainer=trainer)\n evaluator.add_event_handler(event_name=Events.EPOCH_COMPLETED, handler=early_stopper)\n\n # create a validation data loader\n val_ds = NiftiDataset(image_files=images[-10:], labels=labels[-10:], transform=val_transforms)\n val_loader = DataLoader(val_ds, batch_size=2, num_workers=2, pin_memory=torch.cuda.is_available())\n\n @trainer.on(Events.EPOCH_COMPLETED(every=validation_every_n_epochs))\n def run_validation(engine):\n evaluator.run(val_loader)\n\n # create a training data loader\n train_ds = NiftiDataset(image_files=images[:10], labels=labels[:10], transform=train_transforms)\n train_loader = DataLoader(train_ds, batch_size=2, shuffle=True, num_workers=2, pin_memory=torch.cuda.is_available())\n\n train_epochs = 30\n state = trainer.run(train_loader, train_epochs)\n print(state)\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_dict.py_sys_from_monai_handlers_impor": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_dict.py_sys_from_monai_handlers_impor", "embedding": null, "metadata": {"file_path": "examples/classification_3d_ignite/densenet_training_dict.py", "file_name": "densenet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 24, "span_ids": ["docstring"], "tokens": 122}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import sys\nimport logging\nimport numpy as np\nimport os\nimport torch\nfrom ignite.engine import Events, create_supervised_trainer, create_supervised_evaluator, _prepare_batch\nfrom ignite.handlers import ModelCheckpoint, EarlyStopping\nfrom ignite.metrics import Accuracy\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.transforms import Compose, LoadNiftid, AddChanneld, ScaleIntensityd, Resized, RandRotate90d, ToTensord\nfrom monai.handlers import StatsHandler, TensorBoardStatsHandler, stopping_fn_from_metric, ROCAUC", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_dict.py_main_main.images._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_dict.py_main_main.images._", "embedding": null, "metadata": {"file_path": "examples/classification_3d_ignite/densenet_training_dict.py", "file_name": "densenet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 27, "end_line": 53, "span_ids": ["main"], "tokens": 804}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n # IXI dataset as a demo, downloadable from https://brain-development.org/ixi-dataset/\n images = [\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI314-IOP-0889-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI249-Guys-1072-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI609-HH-2600-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI173-HH-1590-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI020-Guys-0700-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI342-Guys-0909-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI134-Guys-0780-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI577-HH-2661-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI066-Guys-0731-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI130-HH-1528-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI607-Guys-1097-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI175-HH-1570-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI385-HH-2078-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI344-Guys-0905-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI409-Guys-0960-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI584-Guys-1129-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI253-HH-1694-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI092-HH-1436-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI574-IOP-1156-T1.nii.gz\"]),\n os.sep.join([\"workspace\", \"data\", \"medical\", \"ixi\", \"IXI-T1\", \"IXI585-Guys-1130-T1.nii.gz\"]),\n ]\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_dict.py_main._2_binary_labels_for_gen_main._add_evaluation_metric_t": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_dict.py_main._2_binary_labels_for_gen_main._add_evaluation_metric_t", "embedding": null, "metadata": {"file_path": "examples/classification_3d_ignite/densenet_training_dict.py", "file_name": "densenet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 55, "end_line": 122, "span_ids": ["main"], "tokens": 800}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n\n # 2 binary labels for gender classification: man and woman\n labels = np.array([0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0], dtype=np.int64)\n train_files = [{\"img\": img, \"label\": label} for img, label in zip(images[:10], labels[:10])]\n val_files = [{\"img\": img, \"label\": label} for img, label in zip(images[-10:], labels[-10:])]\n\n # define transforms for image\n train_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\"]),\n AddChanneld(keys=[\"img\"]),\n ScaleIntensityd(keys=[\"img\"]),\n Resized(keys=[\"img\"], spatial_size=(96, 96, 96)),\n RandRotate90d(keys=[\"img\"], prob=0.8, spatial_axes=[0, 2]),\n ToTensord(keys=[\"img\"]),\n ]\n )\n val_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\"]),\n AddChanneld(keys=[\"img\"]),\n ScaleIntensityd(keys=[\"img\"]),\n Resized(keys=[\"img\"], spatial_size=(96, 96, 96)),\n ToTensord(keys=[\"img\"]),\n ]\n )\n\n # define dataset, data loader\n check_ds = monai.data.Dataset(data=train_files, transform=train_transforms)\n check_loader = DataLoader(check_ds, batch_size=2, num_workers=4, pin_memory=torch.cuda.is_available())\n check_data = monai.utils.misc.first(check_loader)\n print(check_data[\"img\"].shape, check_data[\"label\"])\n\n # create DenseNet121, CrossEntropyLoss and Adam optimizer\n net = monai.networks.nets.densenet.densenet121(spatial_dims=3, in_channels=1, out_channels=2)\n loss = torch.nn.CrossEntropyLoss()\n lr = 1e-5\n opt = torch.optim.Adam(net.parameters(), lr)\n device = torch.device(\"cuda:0\")\n\n # Ignite trainer expects batch=(img, label) and returns output=loss at every iteration,\n # user can add output_transform to return other values, like: y_pred, y, etc.\n def prepare_batch(batch, device=None, non_blocking=False):\n\n return _prepare_batch((batch[\"img\"], batch[\"label\"]), device, non_blocking)\n\n trainer = create_supervised_trainer(net, opt, loss, device, False, prepare_batch=prepare_batch)\n\n # adding checkpoint handler to save models (network params and optimizer stats) during training\n checkpoint_handler = ModelCheckpoint(\"./runs/\", \"net\", n_saved=10, require_empty=False)\n trainer.add_event_handler(\n event_name=Events.EPOCH_COMPLETED, handler=checkpoint_handler, to_save={\"net\": net, \"opt\": opt}\n )\n\n # StatsHandler prints loss at every iteration and print metrics at every epoch,\n # we don't set metrics for trainer here, so just print loss, user can also customize print functions\n # and can use output_transform to convert engine.state.output if it's not loss value\n train_stats_handler = StatsHandler(name=\"trainer\")\n train_stats_handler.attach(trainer)\n\n # TensorBoardStatsHandler plots loss at every iteration and plots metrics at every epoch, same as StatsHandler\n train_tensorboard_stats_handler = TensorBoardStatsHandler()\n train_tensorboard_stats_handler.attach(trainer)\n\n # set parameters for validation\n validation_every_n_epochs = 1\n\n metric_name = \"Accuracy\"\n # add evaluation metric to the evaluator engine\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_dict.py_main.val_metrics_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_dict.py_main.val_metrics_", "embedding": null, "metadata": {"file_path": "examples/classification_3d_ignite/densenet_training_dict.py", "file_name": "densenet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 123, "end_line": 166, "span_ids": ["impl", "main"], "tokens": 476}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n # ... other code\n val_metrics = {metric_name: Accuracy(), \"AUC\": ROCAUC(to_onehot_y=True, softmax=True)}\n # Ignite evaluator expects batch=(img, label) and returns output=(y_pred, y) at every iteration,\n # user can add output_transform to return other values\n evaluator = create_supervised_evaluator(net, val_metrics, device, True, prepare_batch=prepare_batch)\n\n # add stats event handler to print validation stats via evaluator\n val_stats_handler = StatsHandler(\n name=\"evaluator\",\n output_transform=lambda x: None, # no need to print loss value, so disable per iteration output\n global_epoch_transform=lambda x: trainer.state.epoch,\n ) # fetch global epoch number from trainer\n val_stats_handler.attach(evaluator)\n\n # add handler to record metrics to TensorBoard at every epoch\n val_tensorboard_stats_handler = TensorBoardStatsHandler(\n output_transform=lambda x: None, # no need to plot loss value, so disable per iteration output\n global_epoch_transform=lambda x: trainer.state.epoch,\n ) # fetch global epoch number from trainer\n val_tensorboard_stats_handler.attach(evaluator)\n\n # add early stopping handler to evaluator\n early_stopper = EarlyStopping(patience=4, score_function=stopping_fn_from_metric(metric_name), trainer=trainer)\n evaluator.add_event_handler(event_name=Events.EPOCH_COMPLETED, handler=early_stopper)\n\n # create a validation data loader\n val_ds = monai.data.Dataset(data=val_files, transform=val_transforms)\n val_loader = DataLoader(val_ds, batch_size=2, num_workers=4, pin_memory=torch.cuda.is_available())\n\n @trainer.on(Events.EPOCH_COMPLETED(every=validation_every_n_epochs))\n def run_validation(engine):\n evaluator.run(val_loader)\n\n # create a training data loader\n train_ds = monai.data.Dataset(data=train_files, transform=train_transforms)\n train_loader = DataLoader(train_ds, batch_size=2, shuffle=True, num_workers=4, pin_memory=torch.cuda.is_available())\n\n train_epochs = 30\n state = trainer.run(train_loader, train_epochs)\n print(state)\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_ddp.py_os_from_monai_metrics_import": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_ddp.py_os_from_monai_metrics_import", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_evaluation_ddp.py", "file_name": "unet_evaluation_ddp.py", "file_type": "text/x-python", "category": "implementation", "start_line": 40, "end_line": 61, "span_ids": ["docstring:11", "imports:10"], "tokens": 132}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nfrom glob import glob\nimport nibabel as nib\nimport numpy as np\nimport torch\nimport argparse\nimport torch.multiprocessing as mp\nimport torch.distributed as dist\nfrom torch.nn.parallel import DistributedDataParallel\nfrom torch.utils.data.distributed import DistributedSampler\n\nimport monai\nfrom monai.transforms import (\n Compose,\n LoadNiftid,\n AsChannelFirstd,\n ScaleIntensityd,\n ToTensord,\n)\nfrom monai.data import create_test_image_3d, Dataset, DataLoader\nfrom monai.inferers import sliding_window_inference\nfrom monai.metrics import DiceMetric", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_ddp.py_evaluate_evaluate.with_torch_no_grad_.dist_destroy_process_grou": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_ddp.py_evaluate_evaluate.with_torch_no_grad_.dist_destroy_process_grou", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_evaluation_ddp.py", "file_name": "unet_evaluation_ddp.py", "file_type": "text/x-python", "category": "implementation", "start_line": 64, "end_line": 131, "span_ids": ["evaluate"], "tokens": 774}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def evaluate(gpu, args):\n # initialize the distributed evaluation process, every GPU runs in a process,\n # so the process rank is (node index x GPU count of 1 node + GPU index)\n rank = args.node * args.gpus + gpu\n dist.init_process_group(backend=\"nccl\", init_method=\"env://\", world_size=args.world_size, rank=rank)\n\n images = sorted(glob(os.path.join(args.dir, \"img*.nii.gz\")))\n segs = sorted(glob(os.path.join(args.dir, \"seg*.nii.gz\")))\n val_files = [{\"img\": img, \"seg\": seg} for img, seg in zip(images, segs)]\n\n # define transforms for image and segmentation\n val_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\", \"seg\"]),\n AsChannelFirstd(keys=[\"img\", \"seg\"], channel_dim=-1),\n ScaleIntensityd(keys=[\"img\", \"seg\"]),\n ToTensord(keys=[\"img\", \"seg\"]),\n ]\n )\n\n # create a evaluation data loader\n val_ds = Dataset(data=val_files, transform=val_transforms)\n # create a evaluation data sampler\n val_sampler = DistributedSampler(val_ds, num_replicas=args.world_size, rank=rank)\n # sliding window inference need to input 1 image in every iteration\n val_loader = DataLoader(\n val_ds, batch_size=1, shuffle=False, num_workers=0, pin_memory=torch.cuda.is_available(), sampler=val_sampler,\n )\n dice_metric = DiceMetric(include_background=True, to_onehot_y=False, sigmoid=True, reduction=\"mean\")\n\n # create UNet, DiceLoss and Adam optimizer\n device = torch.device(f\"cuda:{gpu}\")\n model = monai.networks.nets.UNet(\n dimensions=3,\n in_channels=1,\n out_channels=1,\n channels=(16, 32, 64, 128, 256),\n strides=(2, 2, 2, 2),\n num_res_units=2,\n ).to(device)\n # wrap the model with DistributedDataParallel module\n model = DistributedDataParallel(model, device_ids=[gpu])\n # config mapping to expected GPU device\n map_location = {\"cuda:0\": f\"cuda:{gpu}\"}\n # load model parameters to GPU device\n model.load_state_dict(torch.load(\"final_model.pth\", map_location=map_location))\n\n model.eval()\n with torch.no_grad():\n # define PyTorch Tensor to record metrics result at each GPU\n # the first value is `sum` of all dice metric, the second value is `count` of not_nan items\n metric = torch.zeros(2, dtype=torch.float, device=device)\n for val_data in val_loader:\n val_images, val_labels = val_data[\"img\"].to(device), val_data[\"seg\"].to(device)\n # define sliding window size and batch size for windows inference\n roi_size = (96, 96, 96)\n sw_batch_size = 4\n val_outputs = sliding_window_inference(val_images, roi_size, sw_batch_size, model)\n value = dice_metric(y_pred=val_outputs, y=val_labels).squeeze()\n metric[0] += value * dice_metric.not_nans\n metric[1] += dice_metric.not_nans\n # synchronizes all processes and reduce results\n dist.barrier()\n dist.all_reduce(metric, op=torch.distributed.ReduceOp.SUM)\n metric = metric.tolist()\n if rank == 0:\n print(\"evaluation metric:\", metric[0] / metric[1])\n dist.destroy_process_group()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_ddp.py_main_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_ddp.py_main_", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_evaluation_ddp.py", "file_name": "unet_evaluation_ddp.py", "file_type": "text/x-python", "category": "implementation", "start_line": 134, "end_line": 166, "span_ids": ["impl", "main"], "tokens": 472}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n parser = argparse.ArgumentParser()\n parser.add_argument(\"-mi\", \"--master_ip\", default=\"localhost\", type=str, help=\"IP address of the master node\")\n parser.add_argument(\"-mp\", \"--master_port\", default=\"8888\", type=str, help=\"PORT of the master node\")\n parser.add_argument(\"-n\", \"--nodes\", default=1, type=int, help=\"number of nodes in total\")\n parser.add_argument(\"-g\", \"--gpus\", default=1, type=int, help=\"number of gpus per node\")\n parser.add_argument(\"-i\", \"--node\", default=0, type=int, help=\"node index within all the nodes\")\n parser.add_argument(\"-d\", \"--dir\", default=\"./testdata\", type=str, help=\"directory to create random data\")\n args = parser.parse_args()\n\n # create 16 random image, mask paris for evaluation\n if not os.path.exists(args.dir):\n print(f\"generating synthetic data to {args.dir} (this may take a while)\")\n os.makedirs(args.dir)\n # set random seed to generate same random data for every node\n np.random.seed(seed=0)\n for i in range(16):\n im, seg = create_test_image_3d(128, 128, 128, num_seg_classes=1, channel_dim=-1)\n n = nib.Nifti1Image(im, np.eye(4))\n nib.save(n, os.path.join(args.dir, f\"img{i:d}.nii.gz\"))\n n = nib.Nifti1Image(seg, np.eye(4))\n nib.save(n, os.path.join(args.dir, f\"seg{i:d}.nii.gz\"))\n\n args.world_size = args.gpus * args.nodes\n os.environ[\"MASTER_ADDR\"] = args.master_ip\n os.environ[\"MASTER_PORT\"] = args.master_port\n mp.spawn(evaluate, nprocs=args.gpus, args=(args,))\n\n\n# usage: \"python unet_evaluation_ddp.py -mi 10.23.137.29 -mp 8888 -n 2 -g 1 -i \" (i in [0 - (n - 1)])\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_ddp.py_os_from_monai_data_import_cr": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_ddp.py_os_from_monai_data_import_cr", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_training_ddp.py", "file_name": "unet_training_ddp.py", "file_type": "text/x-python", "category": "implementation", "start_line": 39, "end_line": 61, "span_ids": ["imports:13", "docstring:11"], "tokens": 130}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport sys\nfrom glob import glob\nimport nibabel as nib\nimport numpy as np\nimport torch\nimport argparse\nimport torch.multiprocessing as mp\nimport torch.distributed as dist\nfrom torch.nn.parallel import DistributedDataParallel\nfrom torch.utils.data.distributed import DistributedSampler\n\nimport monai\nfrom monai.transforms import (\n Compose,\n LoadNiftid,\n AsChannelFirstd,\n ScaleIntensityd,\n RandCropByPosNegLabeld,\n RandRotate90d,\n ToTensord,\n)\nfrom monai.data import create_test_image_3d, Dataset, DataLoader", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_ddp.py_train_train.epoch_loss_values.list_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_ddp.py_train_train.epoch_loss_values.list_", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_training_ddp.py", "file_name": "unet_training_ddp.py", "file_type": "text/x-python", "category": "implementation", "start_line": 64, "end_line": 122, "span_ids": ["train"], "tokens": 632}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def train(gpu, args):\n # disable logging for processes execpt 0 on every node\n if gpu != 0:\n f = open(os.devnull, \"w\")\n sys.stdout = sys.stderr = f\n # initialize the distributed training process, every GPU runs in a process,\n # so the process rank is (node index x GPU count of 1 node + GPU index)\n rank = args.node * args.gpus + gpu\n dist.init_process_group(backend=\"nccl\", init_method=\"env://\", world_size=args.world_size, rank=rank)\n\n images = sorted(glob(os.path.join(args.dir, \"img*.nii.gz\")))\n segs = sorted(glob(os.path.join(args.dir, \"seg*.nii.gz\")))\n train_files = [{\"img\": img, \"seg\": seg} for img, seg in zip(images, segs)]\n\n # define transforms for image and segmentation\n train_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\", \"seg\"]),\n AsChannelFirstd(keys=[\"img\", \"seg\"], channel_dim=-1),\n ScaleIntensityd(keys=[\"img\", \"seg\"]),\n RandCropByPosNegLabeld(\n keys=[\"img\", \"seg\"], label_key=\"seg\", spatial_size=[96, 96, 96], pos=1, neg=1, num_samples=4\n ),\n RandRotate90d(keys=[\"img\", \"seg\"], prob=0.5, spatial_axes=[0, 2]),\n ToTensord(keys=[\"img\", \"seg\"]),\n ]\n )\n\n # create a training data loader\n train_ds = Dataset(data=train_files, transform=train_transforms)\n # create a training data sampler\n train_sampler = DistributedSampler(train_ds, num_replicas=args.world_size, rank=rank)\n # use batch_size=2 to load images and use RandCropByPosNegLabeld to generate 2 x 4 images for network training\n train_loader = DataLoader(\n train_ds,\n batch_size=2,\n shuffle=False,\n num_workers=0,\n pin_memory=torch.cuda.is_available(),\n sampler=train_sampler,\n )\n\n # create UNet, DiceLoss and Adam optimizer\n device = torch.device(f\"cuda:{gpu}\")\n model = monai.networks.nets.UNet(\n dimensions=3,\n in_channels=1,\n out_channels=1,\n channels=(16, 32, 64, 128, 256),\n strides=(2, 2, 2, 2),\n num_res_units=2,\n ).to(device)\n loss_function = monai.losses.DiceLoss(sigmoid=True).to(device)\n optimizer = torch.optim.Adam(model.parameters(), 1e-3)\n # wrap the model with DistributedDataParallel module\n model = DistributedDataParallel(model, device_ids=[gpu])\n\n # start a typical PyTorch training\n epoch_loss_values = list()\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_ddp.py_train.for_epoch_in_range_5__train.dist_destroy_process_grou": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_ddp.py_train.for_epoch_in_range_5__train.dist_destroy_process_grou", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_training_ddp.py", "file_name": "unet_training_ddp.py", "file_type": "text/x-python", "category": "implementation", "start_line": 123, "end_line": 147, "span_ids": ["train"], "tokens": 245}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def train(gpu, args):\n # ... other code\n for epoch in range(5):\n print(\"-\" * 10)\n print(f\"epoch {epoch + 1}/{5}\")\n model.train()\n epoch_loss = 0\n step = 0\n train_sampler.set_epoch(epoch)\n for batch_data in train_loader:\n step += 1\n inputs, labels = batch_data[\"img\"].to(device), batch_data[\"seg\"].to(device)\n optimizer.zero_grad()\n outputs = model(inputs)\n loss = loss_function(outputs, labels)\n loss.backward()\n optimizer.step()\n epoch_loss += loss.item()\n epoch_len = len(train_ds) // train_loader.batch_size\n print(f\"{step}/{epoch_len}, train_loss: {loss.item():.4f}\")\n epoch_loss /= step\n epoch_loss_values.append(epoch_loss)\n print(f\"epoch {epoch + 1} average loss: {epoch_loss:.4f}\")\n print(f\"train completed, epoch losses: {epoch_loss_values}\")\n if rank == 0:\n torch.save(model.state_dict(), \"final_model.pth\")\n dist.destroy_process_group()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_ddp.py_main_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_ddp.py_main_", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_training_ddp.py", "file_name": "unet_training_ddp.py", "file_type": "text/x-python", "category": "implementation", "start_line": 150, "end_line": 182, "span_ids": ["impl", "main"], "tokens": 471}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n parser = argparse.ArgumentParser()\n parser.add_argument(\"-mi\", \"--master_ip\", default=\"localhost\", type=str, help=\"IP address of the master node\")\n parser.add_argument(\"-mp\", \"--master_port\", default=\"8888\", type=str, help=\"PORT of the master node\")\n parser.add_argument(\"-n\", \"--nodes\", default=1, type=int, help=\"number of nodes in total\")\n parser.add_argument(\"-g\", \"--gpus\", default=1, type=int, help=\"number of gpus per node\")\n parser.add_argument(\"-i\", \"--node\", default=0, type=int, help=\"node index within all the nodes\")\n parser.add_argument(\"-d\", \"--dir\", default=\"./testdata\", type=str, help=\"directory to create random data\")\n args = parser.parse_args()\n\n # create 40 random image, mask paris for training\n if not os.path.exists(args.dir):\n print(f\"generating synthetic data to {args.dir} (this may take a while)\")\n os.makedirs(args.dir)\n # set random seed to generate same random data for every node\n np.random.seed(seed=0)\n for i in range(40):\n im, seg = create_test_image_3d(128, 128, 128, num_seg_classes=1, channel_dim=-1)\n n = nib.Nifti1Image(im, np.eye(4))\n nib.save(n, os.path.join(args.dir, f\"img{i:d}.nii.gz\"))\n n = nib.Nifti1Image(seg, np.eye(4))\n nib.save(n, os.path.join(args.dir, f\"seg{i:d}.nii.gz\"))\n\n args.world_size = args.gpus * args.nodes\n os.environ[\"MASTER_ADDR\"] = args.master_ip\n os.environ[\"MASTER_PORT\"] = args.master_port\n mp.spawn(train, nprocs=args.gpus, args=(args,))\n\n\n# usage: \"python unet_training_ddp.py -mi 10.23.137.29 -mp 8888 -n 2 -g 1 -i \" (i in [0 - (n - 1)])\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_evaluation_array.py_os_from_monai_metrics_import": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_evaluation_array.py_os_from_monai_metrics_import", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d/unet_evaluation_array.py", "file_name": "unet_evaluation_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 28, "span_ids": ["docstring"], "tokens": 117}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport sys\nimport tempfile\nimport shutil\nfrom glob import glob\nimport logging\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom torch.utils.data import DataLoader\n\nfrom monai import config\nfrom monai.transforms import Compose, AddChannel, ScaleIntensity, ToTensor\nfrom monai.networks.nets import UNet\nfrom monai.data import create_test_image_3d, NiftiSaver, NiftiDataset\nfrom monai.inferers import sliding_window_inference\nfrom monai.metrics import DiceMetric", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_evaluation_array.py_main_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_evaluation_array.py_main_", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d/unet_evaluation_array.py", "file_name": "unet_evaluation_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 31, "end_line": 91, "span_ids": ["impl", "main"], "tokens": 630}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n tempdir = tempfile.mkdtemp()\n print(f\"generating synthetic data to {tempdir} (this may take a while)\")\n for i in range(5):\n im, seg = create_test_image_3d(128, 128, 128, num_seg_classes=1)\n\n n = nib.Nifti1Image(im, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"im{i:d}.nii.gz\"))\n\n n = nib.Nifti1Image(seg, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"seg{i:d}.nii.gz\"))\n\n images = sorted(glob(os.path.join(tempdir, \"im*.nii.gz\")))\n segs = sorted(glob(os.path.join(tempdir, \"seg*.nii.gz\")))\n\n # define transforms for image and segmentation\n imtrans = Compose([ScaleIntensity(), AddChannel(), ToTensor()])\n segtrans = Compose([AddChannel(), ToTensor()])\n val_ds = NiftiDataset(images, segs, transform=imtrans, seg_transform=segtrans, image_only=False)\n # sliding window inference for one image at every iteration\n val_loader = DataLoader(val_ds, batch_size=1, num_workers=1, pin_memory=torch.cuda.is_available())\n dice_metric = DiceMetric(include_background=True, to_onehot_y=False, sigmoid=True, reduction=\"mean\")\n\n device = torch.device(\"cuda:0\")\n model = UNet(\n dimensions=3,\n in_channels=1,\n out_channels=1,\n channels=(16, 32, 64, 128, 256),\n strides=(2, 2, 2, 2),\n num_res_units=2,\n ).to(device)\n\n model.load_state_dict(torch.load(\"best_metric_model.pth\"))\n model.eval()\n with torch.no_grad():\n metric_sum = 0.0\n metric_count = 0\n saver = NiftiSaver(output_dir=\"./output\")\n for val_data in val_loader:\n val_images, val_labels = val_data[0].to(device), val_data[1].to(device)\n # define sliding window size and batch size for windows inference\n roi_size = (96, 96, 96)\n sw_batch_size = 4\n val_outputs = sliding_window_inference(val_images, roi_size, sw_batch_size, model)\n value = dice_metric(y_pred=val_outputs, y=val_labels)\n metric_count += len(value)\n metric_sum += value.item() * len(value)\n val_outputs = (val_outputs.sigmoid() >= 0.5).float()\n saver.save_batch(val_outputs, val_data[2])\n metric = metric_sum / metric_count\n print(\"evaluation metric:\", metric)\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_evaluation_dict.py_os_from_monai_engines_import": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_evaluation_dict.py_os_from_monai_engines_import", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d/unet_evaluation_dict.py", "file_name": "unet_evaluation_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 29, "span_ids": ["docstring"], "tokens": 135}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport sys\nimport tempfile\nimport shutil\nfrom glob import glob\nimport logging\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.data import list_data_collate, create_test_image_3d, NiftiSaver\nfrom monai.inferers import sliding_window_inference\nfrom monai.metrics import DiceMetric\nfrom monai.networks.nets import UNet\nfrom monai.transforms import Compose, LoadNiftid, AsChannelFirstd, ScaleIntensityd, ToTensord\nfrom monai.engines import get_devices_spec", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_evaluation_dict.py_main_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_evaluation_dict.py_main_", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d/unet_evaluation_dict.py", "file_name": "unet_evaluation_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 32, "end_line": 105, "span_ids": ["impl", "main"], "tokens": 751}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n tempdir = tempfile.mkdtemp()\n print(f\"generating synthetic data to {tempdir} (this may take a while)\")\n for i in range(5):\n im, seg = create_test_image_3d(128, 128, 128, num_seg_classes=1, channel_dim=-1)\n\n n = nib.Nifti1Image(im, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"im{i:d}.nii.gz\"))\n\n n = nib.Nifti1Image(seg, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"seg{i:d}.nii.gz\"))\n\n images = sorted(glob(os.path.join(tempdir, \"im*.nii.gz\")))\n segs = sorted(glob(os.path.join(tempdir, \"seg*.nii.gz\")))\n val_files = [{\"img\": img, \"seg\": seg} for img, seg in zip(images, segs)]\n\n # define transforms for image and segmentation\n val_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\", \"seg\"]),\n AsChannelFirstd(keys=[\"img\", \"seg\"], channel_dim=-1),\n ScaleIntensityd(keys=[\"img\", \"seg\"]),\n ToTensord(keys=[\"img\", \"seg\"]),\n ]\n )\n val_ds = monai.data.Dataset(data=val_files, transform=val_transforms)\n # sliding window inference need to input 1 image in every iteration\n val_loader = DataLoader(val_ds, batch_size=1, num_workers=4, collate_fn=list_data_collate)\n dice_metric = DiceMetric(include_background=True, to_onehot_y=False, sigmoid=True, reduction=\"mean\")\n\n # try to use all the available GPUs\n devices = get_devices_spec(None)\n model = UNet(\n dimensions=3,\n in_channels=1,\n out_channels=1,\n channels=(16, 32, 64, 128, 256),\n strides=(2, 2, 2, 2),\n num_res_units=2,\n ).to(devices[0])\n\n model.load_state_dict(torch.load(\"best_metric_model.pth\"))\n\n # if we have multiple GPUs, set data parallel to execute sliding window inference\n if len(devices) > 1:\n model = torch.nn.DataParallel(model, device_ids=devices)\n\n model.eval()\n with torch.no_grad():\n metric_sum = 0.0\n metric_count = 0\n saver = NiftiSaver(output_dir=\"./output\")\n for val_data in val_loader:\n val_images, val_labels = val_data[\"img\"].to(devices[0]), val_data[\"seg\"].to(devices[0])\n # define sliding window size and batch size for windows inference\n roi_size = (96, 96, 96)\n sw_batch_size = 4\n val_outputs = sliding_window_inference(val_images, roi_size, sw_batch_size, model)\n value = dice_metric(y_pred=val_outputs, y=val_labels)\n metric_count += len(value)\n metric_sum += value.item() * len(value)\n val_outputs = (val_outputs.sigmoid() >= 0.5).float()\n saver.save_batch(val_outputs, val_data[\"img_meta_dict\"])\n metric = metric_sum / metric_count\n print(\"evaluation metric:\", metric)\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_array.py_os_from_monai_visualize_impo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_array.py_os_from_monai_visualize_impo", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d/unet_training_array.py", "file_name": "unet_training_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 29, "span_ids": ["docstring"], "tokens": 131}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport sys\nimport tempfile\nimport shutil\nfrom glob import glob\nimport logging\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom torch.utils.data import DataLoader\nfrom torch.utils.tensorboard import SummaryWriter\n\nimport monai\nfrom monai.data import NiftiDataset, create_test_image_3d\nfrom monai.inferers import sliding_window_inference\nfrom monai.transforms import Compose, AddChannel, ScaleIntensity, RandSpatialCrop, RandRotate90, ToTensor\nfrom monai.metrics import DiceMetric\nfrom monai.visualize import plot_2d_or_3d_image", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_array.py_main_main.writer.SummaryWriter_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_array.py_main_main.writer.SummaryWriter_", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d/unet_training_array.py", "file_name": "unet_training_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 32, "end_line": 105, "span_ids": ["main"], "tokens": 781}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n # create a temporary directory and 40 random image, mask paris\n tempdir = tempfile.mkdtemp()\n print(f\"generating synthetic data to {tempdir} (this may take a while)\")\n for i in range(40):\n im, seg = create_test_image_3d(128, 128, 128, num_seg_classes=1)\n\n n = nib.Nifti1Image(im, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"im{i:d}.nii.gz\"))\n\n n = nib.Nifti1Image(seg, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"seg{i:d}.nii.gz\"))\n\n images = sorted(glob(os.path.join(tempdir, \"im*.nii.gz\")))\n segs = sorted(glob(os.path.join(tempdir, \"seg*.nii.gz\")))\n\n # define transforms for image and segmentation\n train_imtrans = Compose(\n [\n ScaleIntensity(),\n AddChannel(),\n RandSpatialCrop((96, 96, 96), random_size=False),\n RandRotate90(prob=0.5, spatial_axes=(0, 2)),\n ToTensor(),\n ]\n )\n train_segtrans = Compose(\n [\n AddChannel(),\n RandSpatialCrop((96, 96, 96), random_size=False),\n RandRotate90(prob=0.5, spatial_axes=(0, 2)),\n ToTensor(),\n ]\n )\n val_imtrans = Compose([ScaleIntensity(), AddChannel(), ToTensor()])\n val_segtrans = Compose([AddChannel(), ToTensor()])\n\n # define nifti dataset, data loader\n check_ds = NiftiDataset(images, segs, transform=train_imtrans, seg_transform=train_segtrans)\n check_loader = DataLoader(check_ds, batch_size=10, num_workers=2, pin_memory=torch.cuda.is_available())\n im, seg = monai.utils.misc.first(check_loader)\n print(im.shape, seg.shape)\n\n # create a training data loader\n train_ds = NiftiDataset(images[:20], segs[:20], transform=train_imtrans, seg_transform=train_segtrans)\n train_loader = DataLoader(train_ds, batch_size=4, shuffle=True, num_workers=8, pin_memory=torch.cuda.is_available())\n # create a validation data loader\n val_ds = NiftiDataset(images[-20:], segs[-20:], transform=val_imtrans, seg_transform=val_segtrans)\n val_loader = DataLoader(val_ds, batch_size=1, num_workers=4, pin_memory=torch.cuda.is_available())\n dice_metric = DiceMetric(include_background=True, to_onehot_y=False, sigmoid=True, reduction=\"mean\")\n\n # create UNet, DiceLoss and Adam optimizer\n device = torch.device(\"cuda:0\")\n model = monai.networks.nets.UNet(\n dimensions=3,\n in_channels=1,\n out_channels=1,\n channels=(16, 32, 64, 128, 256),\n strides=(2, 2, 2, 2),\n num_res_units=2,\n ).to(device)\n loss_function = monai.losses.DiceLoss(sigmoid=True)\n optimizer = torch.optim.Adam(model.parameters(), 1e-3)\n\n # start a typical PyTorch training\n val_interval = 2\n best_metric = -1\n best_metric_epoch = -1\n epoch_loss_values = list()\n metric_values = list()\n writer = SummaryWriter()\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_array.py_main.for_epoch_in_range_5__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_array.py_main.for_epoch_in_range_5__", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d/unet_training_array.py", "file_name": "unet_training_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 106, "end_line": 168, "span_ids": ["impl", "main"], "tokens": 650}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n # ... other code\n for epoch in range(5):\n print(\"-\" * 10)\n print(f\"epoch {epoch + 1}/{5}\")\n model.train()\n epoch_loss = 0\n step = 0\n for batch_data in train_loader:\n step += 1\n inputs, labels = batch_data[0].to(device), batch_data[1].to(device)\n optimizer.zero_grad()\n outputs = model(inputs)\n loss = loss_function(outputs, labels)\n loss.backward()\n optimizer.step()\n epoch_loss += loss.item()\n epoch_len = len(train_ds) // train_loader.batch_size\n print(f\"{step}/{epoch_len}, train_loss: {loss.item():.4f}\")\n writer.add_scalar(\"train_loss\", loss.item(), epoch_len * epoch + step)\n epoch_loss /= step\n epoch_loss_values.append(epoch_loss)\n print(f\"epoch {epoch + 1} average loss: {epoch_loss:.4f}\")\n\n if (epoch + 1) % val_interval == 0:\n model.eval()\n with torch.no_grad():\n metric_sum = 0.0\n metric_count = 0\n val_images = None\n val_labels = None\n val_outputs = None\n for val_data in val_loader:\n val_images, val_labels = val_data[0].to(device), val_data[1].to(device)\n roi_size = (96, 96, 96)\n sw_batch_size = 4\n val_outputs = sliding_window_inference(val_images, roi_size, sw_batch_size, model)\n value = dice_metric(y_pred=val_outputs, y=val_labels)\n metric_count += len(value)\n metric_sum += value.item() * len(value)\n metric = metric_sum / metric_count\n metric_values.append(metric)\n if metric > best_metric:\n best_metric = metric\n best_metric_epoch = epoch + 1\n torch.save(model.state_dict(), \"best_metric_model.pth\")\n print(\"saved new best metric model\")\n print(\n \"current epoch: {} current mean dice: {:.4f} best mean dice: {:.4f} at epoch {}\".format(\n epoch + 1, metric, best_metric, best_metric_epoch\n )\n )\n writer.add_scalar(\"val_mean_dice\", metric, epoch + 1)\n # plot the last model output as GIF image in TensorBoard with the corresponding image and label\n plot_2d_or_3d_image(val_images, epoch + 1, writer, index=0, tag=\"image\")\n plot_2d_or_3d_image(val_labels, epoch + 1, writer, index=0, tag=\"label\")\n plot_2d_or_3d_image(val_outputs, epoch + 1, writer, index=0, tag=\"output\")\n shutil.rmtree(tempdir)\n print(f\"train completed, best_metric: {best_metric:.4f} at epoch: {best_metric_epoch}\")\n writer.close()\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_dict.py_os_from_monai_visualize_impo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_dict.py_os_from_monai_visualize_impo", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d/unet_training_dict.py", "file_name": "unet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 37, "span_ids": ["docstring"], "tokens": 155}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport sys\nimport tempfile\nimport shutil\nfrom glob import glob\nimport logging\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom torch.utils.data import DataLoader\nfrom torch.utils.tensorboard import SummaryWriter\n\nimport monai\nfrom monai.transforms import (\n Compose,\n LoadNiftid,\n AsChannelFirstd,\n ScaleIntensityd,\n RandCropByPosNegLabeld,\n RandRotate90d,\n ToTensord,\n)\nfrom monai.data import create_test_image_3d, list_data_collate\nfrom monai.inferers import sliding_window_inference\nfrom monai.metrics import DiceMetric\nfrom monai.visualize import plot_2d_or_3d_image", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_dict.py_main_main.dice_metric.DiceMetric_include_backgr": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_dict.py_main_main.dice_metric.DiceMetric_include_backgr", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d/unet_training_dict.py", "file_name": "unet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 40, "end_line": 104, "span_ids": ["main"], "tokens": 781}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n # create a temporary directory and 40 random image, mask paris\n tempdir = tempfile.mkdtemp()\n print(f\"generating synthetic data to {tempdir} (this may take a while)\")\n for i in range(40):\n im, seg = create_test_image_3d(128, 128, 128, num_seg_classes=1, channel_dim=-1)\n\n n = nib.Nifti1Image(im, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"img{i:d}.nii.gz\"))\n\n n = nib.Nifti1Image(seg, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"seg{i:d}.nii.gz\"))\n\n images = sorted(glob(os.path.join(tempdir, \"img*.nii.gz\")))\n segs = sorted(glob(os.path.join(tempdir, \"seg*.nii.gz\")))\n train_files = [{\"img\": img, \"seg\": seg} for img, seg in zip(images[:20], segs[:20])]\n val_files = [{\"img\": img, \"seg\": seg} for img, seg in zip(images[-20:], segs[-20:])]\n\n # define transforms for image and segmentation\n train_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\", \"seg\"]),\n AsChannelFirstd(keys=[\"img\", \"seg\"], channel_dim=-1),\n ScaleIntensityd(keys=[\"img\", \"seg\"]),\n RandCropByPosNegLabeld(\n keys=[\"img\", \"seg\"], label_key=\"seg\", spatial_size=[96, 96, 96], pos=1, neg=1, num_samples=4\n ),\n RandRotate90d(keys=[\"img\", \"seg\"], prob=0.5, spatial_axes=[0, 2]),\n ToTensord(keys=[\"img\", \"seg\"]),\n ]\n )\n val_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\", \"seg\"]),\n AsChannelFirstd(keys=[\"img\", \"seg\"], channel_dim=-1),\n ScaleIntensityd(keys=[\"img\", \"seg\"]),\n ToTensord(keys=[\"img\", \"seg\"]),\n ]\n )\n\n # define dataset, data loader\n check_ds = monai.data.Dataset(data=train_files, transform=train_transforms)\n # use batch_size=2 to load images and use RandCropByPosNegLabeld to generate 2 x 4 images for network training\n check_loader = DataLoader(check_ds, batch_size=2, num_workers=4, collate_fn=list_data_collate)\n check_data = monai.utils.misc.first(check_loader)\n print(check_data[\"img\"].shape, check_data[\"seg\"].shape)\n\n # create a training data loader\n train_ds = monai.data.Dataset(data=train_files, transform=train_transforms)\n # use batch_size=2 to load images and use RandCropByPosNegLabeld to generate 2 x 4 images for network training\n train_loader = DataLoader(\n train_ds,\n batch_size=2,\n shuffle=True,\n num_workers=4,\n collate_fn=list_data_collate,\n pin_memory=torch.cuda.is_available(),\n )\n # create a validation data loader\n val_ds = monai.data.Dataset(data=val_files, transform=val_transforms)\n val_loader = DataLoader(val_ds, batch_size=1, num_workers=4, collate_fn=list_data_collate)\n dice_metric = DiceMetric(include_background=True, to_onehot_y=False, sigmoid=True, reduction=\"mean\")\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_dict.py_main._create_UNet_DiceLoss_a_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_dict.py_main._create_UNet_DiceLoss_a_", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d/unet_training_dict.py", "file_name": "unet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 106, "end_line": 188, "span_ids": ["impl", "main"], "tokens": 819}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n\n # create UNet, DiceLoss and Adam optimizer\n device = torch.device(\"cuda:0\")\n model = monai.networks.nets.UNet(\n dimensions=3,\n in_channels=1,\n out_channels=1,\n channels=(16, 32, 64, 128, 256),\n strides=(2, 2, 2, 2),\n num_res_units=2,\n ).to(device)\n loss_function = monai.losses.DiceLoss(sigmoid=True)\n optimizer = torch.optim.Adam(model.parameters(), 1e-3)\n\n # start a typical PyTorch training\n val_interval = 2\n best_metric = -1\n best_metric_epoch = -1\n epoch_loss_values = list()\n metric_values = list()\n writer = SummaryWriter()\n for epoch in range(5):\n print(\"-\" * 10)\n print(f\"epoch {epoch + 1}/{5}\")\n model.train()\n epoch_loss = 0\n step = 0\n for batch_data in train_loader:\n step += 1\n inputs, labels = batch_data[\"img\"].to(device), batch_data[\"seg\"].to(device)\n optimizer.zero_grad()\n outputs = model(inputs)\n loss = loss_function(outputs, labels)\n loss.backward()\n optimizer.step()\n epoch_loss += loss.item()\n epoch_len = len(train_ds) // train_loader.batch_size\n print(f\"{step}/{epoch_len}, train_loss: {loss.item():.4f}\")\n writer.add_scalar(\"train_loss\", loss.item(), epoch_len * epoch + step)\n epoch_loss /= step\n epoch_loss_values.append(epoch_loss)\n print(f\"epoch {epoch + 1} average loss: {epoch_loss:.4f}\")\n\n if (epoch + 1) % val_interval == 0:\n model.eval()\n with torch.no_grad():\n metric_sum = 0.0\n metric_count = 0\n val_images = None\n val_labels = None\n val_outputs = None\n for val_data in val_loader:\n val_images, val_labels = val_data[\"img\"].to(device), val_data[\"seg\"].to(device)\n roi_size = (96, 96, 96)\n sw_batch_size = 4\n val_outputs = sliding_window_inference(val_images, roi_size, sw_batch_size, model)\n value = dice_metric(y_pred=val_outputs, y=val_labels)\n metric_count += len(value)\n metric_sum += value.item() * len(value)\n metric = metric_sum / metric_count\n metric_values.append(metric)\n if metric > best_metric:\n best_metric = metric\n best_metric_epoch = epoch + 1\n torch.save(model.state_dict(), \"best_metric_model.pth\")\n print(\"saved new best metric model\")\n print(\n \"current epoch: {} current mean dice: {:.4f} best mean dice: {:.4f} at epoch {}\".format(\n epoch + 1, metric, best_metric, best_metric_epoch\n )\n )\n writer.add_scalar(\"val_mean_dice\", metric, epoch + 1)\n # plot the last model output as GIF image in TensorBoard with the corresponding image and label\n plot_2d_or_3d_image(val_images, epoch + 1, writer, index=0, tag=\"image\")\n plot_2d_or_3d_image(val_labels, epoch + 1, writer, index=0, tag=\"label\")\n plot_2d_or_3d_image(val_outputs, epoch + 1, writer, index=0, tag=\"output\")\n shutil.rmtree(tempdir)\n print(f\"train completed, best_metric: {best_metric:.4f} at epoch: {best_metric_epoch}\")\n writer.close()\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_evaluation_array.py_os_from_monai_networks_impor": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_evaluation_array.py_os_from_monai_networks_impor", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d_ignite/unet_evaluation_array.py", "file_name": "unet_evaluation_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 30, "span_ids": ["docstring"], "tokens": 139}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport sys\nimport tempfile\nimport shutil\nfrom glob import glob\nimport logging\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom ignite.engine import Engine\nfrom torch.utils.data import DataLoader\n\nfrom monai import config\nfrom monai.handlers import CheckpointLoader, SegmentationSaver, StatsHandler, MeanDice\nfrom monai.data import NiftiDataset, create_test_image_3d\nfrom monai.inferers import sliding_window_inference\nfrom monai.transforms import Compose, AddChannel, ScaleIntensity, ToTensor\nfrom monai.networks.nets import UNet\nfrom monai.networks import predict_segmentation", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_evaluation_array.py_main_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_evaluation_array.py_main_", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d_ignite/unet_evaluation_array.py", "file_name": "unet_evaluation_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 33, "end_line": 115, "span_ids": ["impl", "main"], "tokens": 778}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n tempdir = tempfile.mkdtemp()\n print(f\"generating synthetic data to {tempdir} (this may take a while)\")\n for i in range(5):\n im, seg = create_test_image_3d(128, 128, 128, num_seg_classes=1)\n\n n = nib.Nifti1Image(im, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"im{i:d}.nii.gz\"))\n\n n = nib.Nifti1Image(seg, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"seg{i:d}.nii.gz\"))\n\n images = sorted(glob(os.path.join(tempdir, \"im*.nii.gz\")))\n segs = sorted(glob(os.path.join(tempdir, \"seg*.nii.gz\")))\n\n # define transforms for image and segmentation\n imtrans = Compose([ScaleIntensity(), AddChannel(), ToTensor()])\n segtrans = Compose([AddChannel(), ToTensor()])\n ds = NiftiDataset(images, segs, transform=imtrans, seg_transform=segtrans, image_only=False)\n\n device = torch.device(\"cuda:0\")\n net = UNet(\n dimensions=3,\n in_channels=1,\n out_channels=1,\n channels=(16, 32, 64, 128, 256),\n strides=(2, 2, 2, 2),\n num_res_units=2,\n )\n net.to(device)\n\n # define sliding window size and batch size for windows inference\n roi_size = (96, 96, 96)\n sw_batch_size = 4\n\n def _sliding_window_processor(engine, batch):\n net.eval()\n with torch.no_grad():\n val_images, val_labels = batch[0].to(device), batch[1].to(device)\n seg_probs = sliding_window_inference(val_images, roi_size, sw_batch_size, net)\n return seg_probs, val_labels\n\n evaluator = Engine(_sliding_window_processor)\n\n # add evaluation metric to the evaluator engine\n MeanDice(sigmoid=True, to_onehot_y=False).attach(evaluator, \"Mean_Dice\")\n\n # StatsHandler prints loss at every iteration and print metrics at every epoch,\n # we don't need to print loss for evaluator, so just print metrics, user can also customize print functions\n val_stats_handler = StatsHandler(\n name=\"evaluator\",\n output_transform=lambda x: None, # no need to print loss value, so disable per iteration output\n )\n val_stats_handler.attach(evaluator)\n\n # for the array data format, assume the 3rd item of batch data is the meta_data\n file_saver = SegmentationSaver(\n output_dir=\"tempdir\",\n output_ext=\".nii.gz\",\n output_postfix=\"seg\",\n name=\"evaluator\",\n batch_transform=lambda x: x[2],\n output_transform=lambda output: predict_segmentation(output[0]),\n )\n file_saver.attach(evaluator)\n\n # the model was trained by \"unet_training_array\" example\n ckpt_saver = CheckpointLoader(load_path=\"./runs/net_checkpoint_100.pth\", load_dict={\"net\": net})\n ckpt_saver.attach(evaluator)\n\n # sliding window inference for one image at every iteration\n loader = DataLoader(ds, batch_size=1, num_workers=1, pin_memory=torch.cuda.is_available())\n state = evaluator.run(loader)\n print(state)\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_evaluation_dict.py_os_from_monai_handlers_impor": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_evaluation_dict.py_os_from_monai_handlers_impor", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d_ignite/unet_evaluation_dict.py", "file_name": "unet_evaluation_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 30, "span_ids": ["docstring"], "tokens": 147}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport sys\nimport tempfile\nimport shutil\nfrom glob import glob\nimport logging\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom ignite.engine import Engine\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.data import list_data_collate, create_test_image_3d\nfrom monai.inferers import sliding_window_inference\nfrom monai.networks import predict_segmentation\nfrom monai.networks.nets import UNet\nfrom monai.transforms import Compose, LoadNiftid, AsChannelFirstd, ScaleIntensityd, ToTensord\nfrom monai.handlers import SegmentationSaver, CheckpointLoader, StatsHandler, MeanDice", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_evaluation_dict.py_main_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_evaluation_dict.py_main_", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d_ignite/unet_evaluation_dict.py", "file_name": "unet_evaluation_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 33, "end_line": 121, "span_ids": ["impl", "main"], "tokens": 823}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n tempdir = tempfile.mkdtemp()\n print(f\"generating synthetic data to {tempdir} (this may take a while)\")\n for i in range(5):\n im, seg = create_test_image_3d(128, 128, 128, num_seg_classes=1, channel_dim=-1)\n\n n = nib.Nifti1Image(im, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"im{i:d}.nii.gz\"))\n\n n = nib.Nifti1Image(seg, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"seg{i:d}.nii.gz\"))\n\n images = sorted(glob(os.path.join(tempdir, \"im*.nii.gz\")))\n segs = sorted(glob(os.path.join(tempdir, \"seg*.nii.gz\")))\n val_files = [{\"img\": img, \"seg\": seg} for img, seg in zip(images, segs)]\n\n # define transforms for image and segmentation\n val_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\", \"seg\"]),\n AsChannelFirstd(keys=[\"img\", \"seg\"], channel_dim=-1),\n ScaleIntensityd(keys=[\"img\", \"seg\"]),\n ToTensord(keys=[\"img\", \"seg\"]),\n ]\n )\n val_ds = monai.data.Dataset(data=val_files, transform=val_transforms)\n\n device = torch.device(\"cuda:0\")\n net = UNet(\n dimensions=3,\n in_channels=1,\n out_channels=1,\n channels=(16, 32, 64, 128, 256),\n strides=(2, 2, 2, 2),\n num_res_units=2,\n )\n net.to(device)\n\n # define sliding window size and batch size for windows inference\n roi_size = (96, 96, 96)\n sw_batch_size = 4\n\n def _sliding_window_processor(engine, batch):\n net.eval()\n with torch.no_grad():\n val_images, val_labels = batch[\"img\"].to(device), batch[\"seg\"].to(device)\n seg_probs = sliding_window_inference(val_images, roi_size, sw_batch_size, net)\n return seg_probs, val_labels\n\n evaluator = Engine(_sliding_window_processor)\n\n # add evaluation metric to the evaluator engine\n MeanDice(sigmoid=True, to_onehot_y=False).attach(evaluator, \"Mean_Dice\")\n\n # StatsHandler prints loss at every iteration and print metrics at every epoch,\n # we don't need to print loss for evaluator, so just print metrics, user can also customize print functions\n val_stats_handler = StatsHandler(\n name=\"evaluator\",\n output_transform=lambda x: None, # no need to print loss value, so disable per iteration output\n )\n val_stats_handler.attach(evaluator)\n\n # convert the necessary metadata from batch data\n SegmentationSaver(\n output_dir=\"tempdir\",\n output_ext=\".nii.gz\",\n output_postfix=\"seg\",\n name=\"evaluator\",\n batch_transform=lambda batch: batch[\"img_meta_dict\"],\n output_transform=lambda output: predict_segmentation(output[0]),\n ).attach(evaluator)\n # the model was trained by \"unet_training_dict\" example\n CheckpointLoader(load_path=\"./runs/net_checkpoint_50.pth\", load_dict={\"net\": net}).attach(evaluator)\n\n # sliding window inference for one image at every iteration\n val_loader = DataLoader(\n val_ds, batch_size=1, num_workers=4, collate_fn=list_data_collate, pin_memory=torch.cuda.is_available()\n )\n state = evaluator.run(val_loader)\n print(state)\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_array.py_os_from_monai_networks_impor": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_array.py_os_from_monai_networks_impor", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d_ignite/unet_training_array.py", "file_name": "unet_training_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 35, "span_ids": ["docstring"], "tokens": 155}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport sys\nimport tempfile\nimport shutil\nfrom glob import glob\nimport logging\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom ignite.engine import Events, create_supervised_trainer, create_supervised_evaluator\nfrom ignite.handlers import ModelCheckpoint, EarlyStopping\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.data import NiftiDataset, create_test_image_3d\nfrom monai.transforms import Compose, AddChannel, ScaleIntensity, RandSpatialCrop, Resize, ToTensor\nfrom monai.handlers import (\n StatsHandler,\n TensorBoardStatsHandler,\n TensorBoardImageHandler,\n MeanDice,\n stopping_fn_from_metric,\n)\nfrom monai.networks import predict_segmentation", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_array.py_main_main.checkpoint_handler.ModelCheckpoint_runs_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_array.py_main_main.checkpoint_handler.ModelCheckpoint_runs_", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d_ignite/unet_training_array.py", "file_name": "unet_training_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 38, "end_line": 97, "span_ids": ["main"], "tokens": 776}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n # create a temporary directory and 40 random image, mask paris\n tempdir = tempfile.mkdtemp()\n print(f\"generating synthetic data to {tempdir} (this may take a while)\")\n for i in range(40):\n im, seg = create_test_image_3d(128, 128, 128, num_seg_classes=1)\n\n n = nib.Nifti1Image(im, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"im{i:d}.nii.gz\"))\n\n n = nib.Nifti1Image(seg, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"seg{i:d}.nii.gz\"))\n\n images = sorted(glob(os.path.join(tempdir, \"im*.nii.gz\")))\n segs = sorted(glob(os.path.join(tempdir, \"seg*.nii.gz\")))\n\n # define transforms for image and segmentation\n train_imtrans = Compose(\n [ScaleIntensity(), AddChannel(), RandSpatialCrop((96, 96, 96), random_size=False), ToTensor()]\n )\n train_segtrans = Compose([AddChannel(), RandSpatialCrop((96, 96, 96), random_size=False), ToTensor()])\n val_imtrans = Compose([ScaleIntensity(), AddChannel(), Resize((96, 96, 96)), ToTensor()])\n val_segtrans = Compose([AddChannel(), Resize((96, 96, 96)), ToTensor()])\n\n # define nifti dataset, data loader\n check_ds = NiftiDataset(images, segs, transform=train_imtrans, seg_transform=train_segtrans)\n check_loader = DataLoader(check_ds, batch_size=10, num_workers=2, pin_memory=torch.cuda.is_available())\n im, seg = monai.utils.misc.first(check_loader)\n print(im.shape, seg.shape)\n\n # create a training data loader\n train_ds = NiftiDataset(images[:20], segs[:20], transform=train_imtrans, seg_transform=train_segtrans)\n train_loader = DataLoader(train_ds, batch_size=5, shuffle=True, num_workers=8, pin_memory=torch.cuda.is_available())\n # create a validation data loader\n val_ds = NiftiDataset(images[-20:], segs[-20:], transform=val_imtrans, seg_transform=val_segtrans)\n val_loader = DataLoader(val_ds, batch_size=5, num_workers=8, pin_memory=torch.cuda.is_available())\n\n # create UNet, DiceLoss and Adam optimizer\n net = monai.networks.nets.UNet(\n dimensions=3,\n in_channels=1,\n out_channels=1,\n channels=(16, 32, 64, 128, 256),\n strides=(2, 2, 2, 2),\n num_res_units=2,\n )\n loss = monai.losses.DiceLoss(sigmoid=True)\n lr = 1e-3\n opt = torch.optim.Adam(net.parameters(), lr)\n device = torch.device(\"cuda:0\")\n\n # Ignite trainer expects batch=(img, seg) and returns output=loss at every iteration,\n # user can add output_transform to return other values, like: y_pred, y, etc.\n trainer = create_supervised_trainer(net, opt, loss, device, False)\n\n # adding checkpoint handler to save models (network params and optimizer stats) during training\n checkpoint_handler = ModelCheckpoint(\"./runs/\", \"net\", n_saved=10, require_empty=False)\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_array.py_main.trainer_add_event_handler_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_array.py_main.trainer_add_event_handler_", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d_ignite/unet_training_array.py", "file_name": "unet_training_array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 98, "end_line": 162, "span_ids": ["impl", "main"], "tokens": 676}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n # ... other code\n trainer.add_event_handler(\n event_name=Events.EPOCH_COMPLETED, handler=checkpoint_handler, to_save={\"net\": net, \"opt\": opt}\n )\n\n # StatsHandler prints loss at every iteration and print metrics at every epoch,\n # we don't set metrics for trainer here, so just print loss, user can also customize print functions\n # and can use output_transform to convert engine.state.output if it's not a loss value\n train_stats_handler = StatsHandler(name=\"trainer\")\n train_stats_handler.attach(trainer)\n\n # TensorBoardStatsHandler plots loss at every iteration and plots metrics at every epoch, same as StatsHandler\n train_tensorboard_stats_handler = TensorBoardStatsHandler()\n train_tensorboard_stats_handler.attach(trainer)\n\n validation_every_n_epochs = 1\n # Set parameters for validation\n metric_name = \"Mean_Dice\"\n # add evaluation metric to the evaluator engine\n val_metrics = {metric_name: MeanDice(sigmoid=True, to_onehot_y=False)}\n\n # Ignite evaluator expects batch=(img, seg) and returns output=(y_pred, y) at every iteration,\n # user can add output_transform to return other values\n evaluator = create_supervised_evaluator(net, val_metrics, device, True)\n\n @trainer.on(Events.EPOCH_COMPLETED(every=validation_every_n_epochs))\n def run_validation(engine):\n evaluator.run(val_loader)\n\n # add early stopping handler to evaluator\n early_stopper = EarlyStopping(patience=4, score_function=stopping_fn_from_metric(metric_name), trainer=trainer)\n evaluator.add_event_handler(event_name=Events.EPOCH_COMPLETED, handler=early_stopper)\n\n # add stats event handler to print validation stats via evaluator\n val_stats_handler = StatsHandler(\n name=\"evaluator\",\n output_transform=lambda x: None, # no need to print loss value, so disable per iteration output\n global_epoch_transform=lambda x: trainer.state.epoch,\n ) # fetch global epoch number from trainer\n val_stats_handler.attach(evaluator)\n\n # add handler to record metrics to TensorBoard at every validation epoch\n val_tensorboard_stats_handler = TensorBoardStatsHandler(\n output_transform=lambda x: None, # no need to plot loss value, so disable per iteration output\n global_epoch_transform=lambda x: trainer.state.epoch,\n ) # fetch global epoch number from trainer\n val_tensorboard_stats_handler.attach(evaluator)\n\n # add handler to draw the first image and the corresponding label and model output in the last batch\n # here we draw the 3D output as GIF format along Depth axis, at every validation epoch\n val_tensorboard_image_handler = TensorBoardImageHandler(\n batch_transform=lambda batch: (batch[0], batch[1]),\n output_transform=lambda output: predict_segmentation(output[0]),\n global_iter_transform=lambda x: trainer.state.epoch,\n )\n evaluator.add_event_handler(event_name=Events.EPOCH_COMPLETED, handler=val_tensorboard_image_handler)\n\n train_epochs = 30\n state = trainer.run(train_loader, train_epochs)\n print(state)\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_dict.py_os_from_monai_networks_impor": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_dict.py_os_from_monai_networks_impor", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d_ignite/unet_training_dict.py", "file_name": "unet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 43, "span_ids": ["docstring"], "tokens": 185}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport sys\nimport tempfile\nimport shutil\nfrom glob import glob\nimport logging\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom ignite.engine import Events, create_supervised_trainer, create_supervised_evaluator, _prepare_batch\nfrom ignite.handlers import ModelCheckpoint, EarlyStopping\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.transforms import (\n Compose,\n LoadNiftid,\n AsChannelFirstd,\n ScaleIntensityd,\n RandCropByPosNegLabeld,\n RandRotate90d,\n ToTensord,\n)\nfrom monai.handlers import (\n StatsHandler,\n TensorBoardStatsHandler,\n TensorBoardImageHandler,\n MeanDice,\n stopping_fn_from_metric,\n)\nfrom monai.data import create_test_image_3d, list_data_collate\nfrom monai.networks import predict_segmentation", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_dict.py_main_main.val_loader.DataLoader_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_dict.py_main_main.val_loader.DataLoader_", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d_ignite/unet_training_dict.py", "file_name": "unet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 46, "end_line": 113, "span_ids": ["main"], "tokens": 780}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n # create a temporary directory and 40 random image, mask paris\n tempdir = tempfile.mkdtemp()\n print(f\"generating synthetic data to {tempdir} (this may take a while)\")\n for i in range(40):\n im, seg = create_test_image_3d(128, 128, 128, num_seg_classes=1, channel_dim=-1)\n\n n = nib.Nifti1Image(im, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"img{i:d}.nii.gz\"))\n\n n = nib.Nifti1Image(seg, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"seg{i:d}.nii.gz\"))\n\n images = sorted(glob(os.path.join(tempdir, \"img*.nii.gz\")))\n segs = sorted(glob(os.path.join(tempdir, \"seg*.nii.gz\")))\n train_files = [{\"img\": img, \"seg\": seg} for img, seg in zip(images[:20], segs[:20])]\n val_files = [{\"img\": img, \"seg\": seg} for img, seg in zip(images[-20:], segs[-20:])]\n\n # define transforms for image and segmentation\n train_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\", \"seg\"]),\n AsChannelFirstd(keys=[\"img\", \"seg\"], channel_dim=-1),\n ScaleIntensityd(keys=[\"img\", \"seg\"]),\n RandCropByPosNegLabeld(\n keys=[\"img\", \"seg\"], label_key=\"seg\", spatial_size=[96, 96, 96], pos=1, neg=1, num_samples=4\n ),\n RandRotate90d(keys=[\"img\", \"seg\"], prob=0.5, spatial_axes=[0, 2]),\n ToTensord(keys=[\"img\", \"seg\"]),\n ]\n )\n val_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\", \"seg\"]),\n AsChannelFirstd(keys=[\"img\", \"seg\"], channel_dim=-1),\n ScaleIntensityd(keys=[\"img\", \"seg\"]),\n ToTensord(keys=[\"img\", \"seg\"]),\n ]\n )\n\n # define dataset, data loader\n check_ds = monai.data.Dataset(data=train_files, transform=train_transforms)\n # use batch_size=2 to load images and use RandCropByPosNegLabeld to generate 2 x 4 images for network training\n check_loader = DataLoader(\n check_ds, batch_size=2, num_workers=4, collate_fn=list_data_collate, pin_memory=torch.cuda.is_available()\n )\n check_data = monai.utils.misc.first(check_loader)\n print(check_data[\"img\"].shape, check_data[\"seg\"].shape)\n\n # create a training data loader\n train_ds = monai.data.Dataset(data=train_files, transform=train_transforms)\n # use batch_size=2 to load images and use RandCropByPosNegLabeld to generate 2 x 4 images for network training\n train_loader = DataLoader(\n train_ds,\n batch_size=2,\n shuffle=True,\n num_workers=4,\n collate_fn=list_data_collate,\n pin_memory=torch.cuda.is_available(),\n )\n # create a validation data loader\n val_ds = monai.data.Dataset(data=val_files, transform=val_transforms)\n val_loader = DataLoader(\n val_ds, batch_size=5, num_workers=8, collate_fn=list_data_collate, pin_memory=torch.cuda.is_available()\n )\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_dict.py_main._create_UNet_DiceLoss_a_main._add_handler_to_draw_the": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_dict.py_main._create_UNet_DiceLoss_a_main._add_handler_to_draw_the", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d_ignite/unet_training_dict.py", "file_name": "unet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 115, "end_line": 185, "span_ids": ["main"], "tokens": 810}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n\n # create UNet, DiceLoss and Adam optimizer\n net = monai.networks.nets.UNet(\n dimensions=3,\n in_channels=1,\n out_channels=1,\n channels=(16, 32, 64, 128, 256),\n strides=(2, 2, 2, 2),\n num_res_units=2,\n )\n loss = monai.losses.DiceLoss(sigmoid=True)\n lr = 1e-3\n opt = torch.optim.Adam(net.parameters(), lr)\n device = torch.device(\"cuda:0\")\n\n # Ignite trainer expects batch=(img, seg) and returns output=loss at every iteration,\n # user can add output_transform to return other values, like: y_pred, y, etc.\n def prepare_batch(batch, device=None, non_blocking=False):\n return _prepare_batch((batch[\"img\"], batch[\"seg\"]), device, non_blocking)\n\n trainer = create_supervised_trainer(net, opt, loss, device, False, prepare_batch=prepare_batch)\n\n # adding checkpoint handler to save models (network params and optimizer stats) during training\n checkpoint_handler = ModelCheckpoint(\"./runs/\", \"net\", n_saved=10, require_empty=False)\n trainer.add_event_handler(\n event_name=Events.EPOCH_COMPLETED, handler=checkpoint_handler, to_save={\"net\": net, \"opt\": opt}\n )\n\n # StatsHandler prints loss at every iteration and print metrics at every epoch,\n # we don't set metrics for trainer here, so just print loss, user can also customize print functions\n # and can use output_transform to convert engine.state.output if it's not loss value\n train_stats_handler = StatsHandler(name=\"trainer\")\n train_stats_handler.attach(trainer)\n\n # TensorBoardStatsHandler plots loss at every iteration and plots metrics at every epoch, same as StatsHandler\n train_tensorboard_stats_handler = TensorBoardStatsHandler()\n train_tensorboard_stats_handler.attach(trainer)\n\n validation_every_n_iters = 5\n # set parameters for validation\n metric_name = \"Mean_Dice\"\n # add evaluation metric to the evaluator engine\n val_metrics = {metric_name: MeanDice(sigmoid=True, to_onehot_y=False)}\n\n # Ignite evaluator expects batch=(img, seg) and returns output=(y_pred, y) at every iteration,\n # user can add output_transform to return other values\n evaluator = create_supervised_evaluator(net, val_metrics, device, True, prepare_batch=prepare_batch)\n\n @trainer.on(Events.ITERATION_COMPLETED(every=validation_every_n_iters))\n def run_validation(engine):\n evaluator.run(val_loader)\n\n # add early stopping handler to evaluator\n early_stopper = EarlyStopping(patience=4, score_function=stopping_fn_from_metric(metric_name), trainer=trainer)\n evaluator.add_event_handler(event_name=Events.EPOCH_COMPLETED, handler=early_stopper)\n\n # add stats event handler to print validation stats via evaluator\n val_stats_handler = StatsHandler(\n name=\"evaluator\",\n output_transform=lambda x: None, # no need to print loss value, so disable per iteration output\n global_epoch_transform=lambda x: trainer.state.epoch,\n ) # fetch global epoch number from trainer\n val_stats_handler.attach(evaluator)\n\n # add handler to record metrics to TensorBoard at every validation epoch\n val_tensorboard_stats_handler = TensorBoardStatsHandler(\n output_transform=lambda x: None, # no need to plot loss value, so disable per iteration output\n global_epoch_transform=lambda x: trainer.state.iteration,\n ) # fetch global iteration number from trainer\n val_tensorboard_stats_handler.attach(evaluator)\n\n # add handler to draw the first image and the corresponding label and model output in the last batch\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_dict.py_main._here_we_draw_the_3D_out_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_dict.py_main._here_we_draw_the_3D_out_", "embedding": null, "metadata": {"file_path": "examples/segmentation_3d_ignite/unet_training_dict.py", "file_name": "unet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 186, "end_line": 202, "span_ids": ["impl", "main"], "tokens": 144}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n # here we draw the 3D output as GIF format along the depth axis, every 2 validation iterations.\n val_tensorboard_image_handler = TensorBoardImageHandler(\n batch_transform=lambda batch: (batch[\"img\"], batch[\"seg\"]),\n output_transform=lambda output: predict_segmentation(output[0]),\n global_iter_transform=lambda x: trainer.state.epoch,\n )\n evaluator.add_event_handler(event_name=Events.ITERATION_COMPLETED(every=2), handler=val_tensorboard_image_handler)\n\n train_epochs = 5\n state = trainer.run(train_loader, train_epochs)\n print(state)\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_evaluation_dict.py_os_from_monai_inferers_impor": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_evaluation_dict.py_os_from_monai_inferers_impor", "embedding": null, "metadata": {"file_path": "examples/workflows/unet_evaluation_dict.py", "file_name": "unet_evaluation_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 37, "span_ids": ["docstring"], "tokens": 152}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport sys\nimport tempfile\nimport shutil\nfrom glob import glob\nimport logging\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom ignite.metrics import Accuracy\n\nimport monai\nfrom monai.transforms import (\n Compose,\n LoadNiftid,\n AsChannelFirstd,\n ScaleIntensityd,\n ToTensord,\n Activationsd,\n AsDiscreted,\n KeepLargestConnectedComponentd,\n)\nfrom monai.handlers import StatsHandler, CheckpointLoader, SegmentationSaver, MeanDice\nfrom monai.data import create_test_image_3d\nfrom monai.engines import SupervisedEvaluator\nfrom monai.inferers import SlidingWindowInferer", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_evaluation_dict.py_main_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_evaluation_dict.py_main_", "embedding": null, "metadata": {"file_path": "examples/workflows/unet_evaluation_dict.py", "file_name": "unet_evaluation_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 40, "end_line": 118, "span_ids": ["impl", "main"], "tokens": 741}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n # create a temporary directory and 40 random image, mask paris\n tempdir = tempfile.mkdtemp()\n print(f\"generating synthetic data to {tempdir} (this may take a while)\")\n for i in range(5):\n im, seg = create_test_image_3d(128, 128, 128, num_seg_classes=1, channel_dim=-1)\n n = nib.Nifti1Image(im, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"im{i:d}.nii.gz\"))\n n = nib.Nifti1Image(seg, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"seg{i:d}.nii.gz\"))\n\n images = sorted(glob(os.path.join(tempdir, \"im*.nii.gz\")))\n segs = sorted(glob(os.path.join(tempdir, \"seg*.nii.gz\")))\n val_files = [{\"image\": img, \"label\": seg} for img, seg in zip(images, segs)]\n\n # define transforms for image and segmentation\n val_transforms = Compose(\n [\n LoadNiftid(keys=[\"image\", \"label\"]),\n AsChannelFirstd(keys=[\"image\", \"label\"], channel_dim=-1),\n ScaleIntensityd(keys=[\"image\", \"label\"]),\n ToTensord(keys=[\"image\", \"label\"]),\n ]\n )\n\n # create a validation data loader\n val_ds = monai.data.Dataset(data=val_files, transform=val_transforms)\n val_loader = monai.data.DataLoader(val_ds, batch_size=1, num_workers=4)\n\n # create UNet, DiceLoss and Adam optimizer\n device = torch.device(\"cuda:0\")\n net = monai.networks.nets.UNet(\n dimensions=3,\n in_channels=1,\n out_channels=1,\n channels=(16, 32, 64, 128, 256),\n strides=(2, 2, 2, 2),\n num_res_units=2,\n ).to(device)\n\n val_post_transforms = Compose(\n [\n Activationsd(keys=\"pred\", sigmoid=True),\n AsDiscreted(keys=\"pred\", threshold_values=True),\n KeepLargestConnectedComponentd(keys=\"pred\", applied_labels=[1]),\n ]\n )\n val_handlers = [\n StatsHandler(output_transform=lambda x: None),\n CheckpointLoader(load_path=\"./runs/net_key_metric=0.9101.pth\", load_dict={\"net\": net}),\n SegmentationSaver(\n output_dir=\"./runs/\",\n batch_transform=lambda batch: batch[\"image_meta_dict\"],\n output_transform=lambda output: output[\"pred\"],\n ),\n ]\n\n evaluator = SupervisedEvaluator(\n device=device,\n val_data_loader=val_loader,\n network=net,\n inferer=SlidingWindowInferer(roi_size=(96, 96, 96), sw_batch_size=4, overlap=0.5),\n post_transform=val_post_transforms,\n key_val_metric={\n \"val_mean_dice\": MeanDice(include_background=True, output_transform=lambda x: (x[\"pred\"], x[\"label\"]))\n },\n additional_metrics={\"val_acc\": Accuracy(output_transform=lambda x: (x[\"pred\"], x[\"label\"]))},\n val_handlers=val_handlers,\n )\n evaluator.run()\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_training_dict.py_os_from_monai_inferers_impor": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_training_dict.py_os_from_monai_inferers_impor", "embedding": null, "metadata": {"file_path": "examples/workflows/unet_training_dict.py", "file_name": "unet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 47, "span_ids": ["docstring"], "tokens": 200}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport sys\nimport tempfile\nimport shutil\nfrom glob import glob\nimport logging\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom ignite.metrics import Accuracy\n\nimport monai\nfrom monai.transforms import (\n Compose,\n LoadNiftid,\n AsChannelFirstd,\n ScaleIntensityd,\n RandCropByPosNegLabeld,\n RandRotate90d,\n ToTensord,\n Activationsd,\n AsDiscreted,\n KeepLargestConnectedComponentd,\n)\nfrom monai.handlers import (\n StatsHandler,\n TensorBoardStatsHandler,\n TensorBoardImageHandler,\n ValidationHandler,\n LrScheduleHandler,\n CheckpointSaver,\n MeanDice,\n)\nfrom monai.data import create_test_image_3d\nfrom monai.engines import SupervisedTrainer, SupervisedEvaluator\nfrom monai.inferers import SimpleInferer, SlidingWindowInferer", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_training_dict.py_main_main.lr_scheduler.torch_optim_lr_scheduler_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_training_dict.py_main_main.lr_scheduler.torch_optim_lr_scheduler_", "embedding": null, "metadata": {"file_path": "examples/workflows/unet_training_dict.py", "file_name": "unet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 50, "end_line": 111, "span_ids": ["main"], "tokens": 786}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n # create a temporary directory and 40 random image, mask paris\n tempdir = tempfile.mkdtemp()\n print(f\"generating synthetic data to {tempdir} (this may take a while)\")\n for i in range(40):\n im, seg = create_test_image_3d(128, 128, 128, num_seg_classes=1, channel_dim=-1)\n n = nib.Nifti1Image(im, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"img{i:d}.nii.gz\"))\n n = nib.Nifti1Image(seg, np.eye(4))\n nib.save(n, os.path.join(tempdir, f\"seg{i:d}.nii.gz\"))\n\n images = sorted(glob(os.path.join(tempdir, \"img*.nii.gz\")))\n segs = sorted(glob(os.path.join(tempdir, \"seg*.nii.gz\")))\n train_files = [{\"image\": img, \"label\": seg} for img, seg in zip(images[:20], segs[:20])]\n val_files = [{\"image\": img, \"label\": seg} for img, seg in zip(images[-20:], segs[-20:])]\n\n # define transforms for image and segmentation\n train_transforms = Compose(\n [\n LoadNiftid(keys=[\"image\", \"label\"]),\n AsChannelFirstd(keys=[\"image\", \"label\"], channel_dim=-1),\n ScaleIntensityd(keys=[\"image\", \"label\"]),\n RandCropByPosNegLabeld(\n keys=[\"image\", \"label\"], label_key=\"label\", spatial_size=[96, 96, 96], pos=1, neg=1, num_samples=4\n ),\n RandRotate90d(keys=[\"image\", \"label\"], prob=0.5, spatial_axes=[0, 2]),\n ToTensord(keys=[\"image\", \"label\"]),\n ]\n )\n val_transforms = Compose(\n [\n LoadNiftid(keys=[\"image\", \"label\"]),\n AsChannelFirstd(keys=[\"image\", \"label\"], channel_dim=-1),\n ScaleIntensityd(keys=[\"image\", \"label\"]),\n ToTensord(keys=[\"image\", \"label\"]),\n ]\n )\n\n # create a training data loader\n train_ds = monai.data.CacheDataset(data=train_files, transform=train_transforms, cache_rate=0.5)\n # use batch_size=2 to load images and use RandCropByPosNegLabeld to generate 2 x 4 images for network training\n train_loader = monai.data.DataLoader(train_ds, batch_size=2, shuffle=True, num_workers=4)\n # create a validation data loader\n val_ds = monai.data.CacheDataset(data=val_files, transform=val_transforms, cache_rate=1.0)\n val_loader = monai.data.DataLoader(val_ds, batch_size=1, num_workers=4)\n\n # create UNet, DiceLoss and Adam optimizer\n device = torch.device(\"cuda:0\")\n net = monai.networks.nets.UNet(\n dimensions=3,\n in_channels=1,\n out_channels=1,\n channels=(16, 32, 64, 128, 256),\n strides=(2, 2, 2, 2),\n num_res_units=2,\n ).to(device)\n loss = monai.losses.DiceLoss(sigmoid=True)\n opt = torch.optim.Adam(net.parameters(), 1e-3)\n lr_scheduler = torch.optim.lr_scheduler.StepLR(opt, step_size=2, gamma=0.1)\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_training_dict.py_main.val_post_transforms_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_training_dict.py_main.val_post_transforms_", "embedding": null, "metadata": {"file_path": "examples/workflows/unet_training_dict.py", "file_name": "unet_training_dict.py", "file_type": "text/x-python", "category": "implementation", "start_line": 113, "end_line": 177, "span_ids": ["impl", "main"], "tokens": 569}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def main():\n # ... other code\n\n val_post_transforms = Compose(\n [\n Activationsd(keys=\"pred\", sigmoid=True),\n AsDiscreted(keys=\"pred\", threshold_values=True),\n KeepLargestConnectedComponentd(keys=\"pred\", applied_labels=[1]),\n ]\n )\n val_handlers = [\n StatsHandler(output_transform=lambda x: None),\n TensorBoardStatsHandler(log_dir=\"./runs/\", output_transform=lambda x: None),\n TensorBoardImageHandler(\n log_dir=\"./runs/\", batch_transform=lambda x: (x[\"image\"], x[\"label\"]), output_transform=lambda x: x[\"pred\"]\n ),\n CheckpointSaver(save_dir=\"./runs/\", save_dict={\"net\": net}, save_key_metric=True),\n ]\n\n evaluator = SupervisedEvaluator(\n device=device,\n val_data_loader=val_loader,\n network=net,\n inferer=SlidingWindowInferer(roi_size=(96, 96, 96), sw_batch_size=4, overlap=0.5),\n post_transform=val_post_transforms,\n key_val_metric={\n \"val_mean_dice\": MeanDice(include_background=True, output_transform=lambda x: (x[\"pred\"], x[\"label\"]))\n },\n additional_metrics={\"val_acc\": Accuracy(output_transform=lambda x: (x[\"pred\"], x[\"label\"]))},\n val_handlers=val_handlers,\n )\n\n train_post_transforms = Compose(\n [\n Activationsd(keys=\"pred\", sigmoid=True),\n AsDiscreted(keys=\"pred\", threshold_values=True),\n KeepLargestConnectedComponentd(keys=\"pred\", applied_labels=[1]),\n ]\n )\n train_handlers = [\n LrScheduleHandler(lr_scheduler=lr_scheduler, print_lr=True),\n ValidationHandler(validator=evaluator, interval=2, epoch_level=True),\n StatsHandler(tag_name=\"train_loss\", output_transform=lambda x: x[\"loss\"]),\n TensorBoardStatsHandler(log_dir=\"./runs/\", tag_name=\"train_loss\", output_transform=lambda x: x[\"loss\"]),\n CheckpointSaver(save_dir=\"./runs/\", save_dict={\"net\": net, \"opt\": opt}, save_interval=2, epoch_level=True),\n ]\n\n trainer = SupervisedTrainer(\n device=device,\n max_epochs=5,\n train_data_loader=train_loader,\n network=net,\n optimizer=opt,\n loss_function=loss,\n inferer=SimpleInferer(),\n amp=False,\n post_transform=train_post_transforms,\n key_train_metric={\"train_acc\": Accuracy(output_transform=lambda x: (x[\"pred\"], x[\"label\"]))},\n train_handlers=train_handlers,\n )\n trainer.run()\n\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/__init__.py_os_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/__init__.py_os_", "embedding": null, "metadata": {"file_path": "monai/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 32, "span_ids": ["docstring"], "tokens": 139}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport sys\n\nfrom ._version import get_versions\nfrom .utils.module import load_submodules\n\n__version__ = get_versions()[\"version\"]\ndel get_versions\n\n__copyright__ = \"(c) 2020 MONAI Consortium\"\n\n__basedir__ = os.path.dirname(__file__)\n\nexcludes = \"^(handlers)\" # the handlers have some external decorators the users may not have installed\n\n# load directory modules only, skip loading individual files\nload_submodules(sys.modules[__name__], False, exclude_pattern=excludes)\n\n# load all modules, this will trigger all export decorations\nload_submodules(sys.modules[__name__], True, exclude_pattern=excludes)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py__This_file_helps_to_comp_sys": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py__This_file_helps_to_comp_sys", "embedding": null, "metadata": {"file_path": "monai/_version.py", "file_name": "_version.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1, "end_line": 16, "span_ids": ["docstring"], "tokens": 129}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "# This file helps to compute a version number in source trees obtained from\n# git-archive tarball (such as those provided by githubs download-from-tag\n# feature). Distribution tarballs (built by setup.py sdist) and build\n# directories (produced by setup.py build) will contain a much shorter file\n# that just contains the computed version number.\n\n# This file is released into the public domain. Generated by\n# versioneer-0.18 (https://github.com/warner/python-versioneer)\n\n\"\"\"Git implementation of _version.py.\"\"\"\n\nimport errno\nimport os\nimport re\nimport subprocess\nimport sys", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_get_keywords_get_keywords.return.keywords": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_get_keywords_get_keywords.return.keywords", "embedding": null, "metadata": {"file_path": "monai/_version.py", "file_name": "_version.py", "file_type": "text/x-python", "category": "implementation", "start_line": 19, "end_line": 29, "span_ids": ["get_keywords"], "tokens": 129}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def get_keywords():\n \"\"\"Get the keywords needed to look up the version information.\"\"\"\n # these strings will be replaced by git during git-archive.\n # setup.py/versioneer.py will grep for the variable names, so they must\n # each be defined on a line of their own. _version.py will just call\n # get_keywords().\n git_refnames = \"$Format:%d$\"\n git_full = \"$Format:%H$\"\n git_date = \"$Format:%ci$\"\n keywords = {\"refnames\": git_refnames, \"full\": git_full, \"date\": git_date}\n return keywords", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_VersioneerConfig_register_vcs_handler.return.decorate": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_VersioneerConfig_register_vcs_handler.return.decorate", "embedding": null, "metadata": {"file_path": "monai/_version.py", "file_name": "_version.py", "file_type": "text/x-python", "category": "implementation", "start_line": 32, "end_line": 66, "span_ids": ["VersioneerConfig", "impl", "NotThisMethod", "register_vcs_handler", "get_config"], "tokens": 234}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class VersioneerConfig:\n \"\"\"Container for Versioneer configuration parameters.\"\"\"\n\n\ndef get_config():\n \"\"\"Create, populate and return the VersioneerConfig() object.\"\"\"\n # these strings are filled in when 'setup.py versioneer' creates\n # _version.py\n cfg = VersioneerConfig()\n cfg.VCS = \"git\"\n cfg.style = \"pep440\"\n cfg.tag_prefix = \"\"\n cfg.parentdir_prefix = \"\"\n cfg.versionfile_source = \"monai/_version.py\"\n cfg.verbose = False\n return cfg\n\n\nclass NotThisMethod(Exception):\n \"\"\"Exception raised if a method is not valid for the current scenario.\"\"\"\n\n\nLONG_VERSION_PY = {}\nHANDLERS = {}\n\n\ndef register_vcs_handler(vcs, method): # decorator\n \"\"\"Decorator to mark a method as the handler for a particular VCS.\"\"\"\n def decorate(f):\n \"\"\"Store f in HANDLERS[vcs][method].\"\"\"\n if vcs not in HANDLERS:\n HANDLERS[vcs] = {}\n HANDLERS[vcs][method] = f\n return f\n return decorate", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_run_command_run_command.return.stdout_p_returncode": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_run_command_run_command.return.stdout_p_returncode", "embedding": null, "metadata": {"file_path": "monai/_version.py", "file_name": "_version.py", "file_type": "text/x-python", "category": "implementation", "start_line": 69, "end_line": 103, "span_ids": ["run_command"], "tokens": 290}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,\n env=None):\n \"\"\"Call the given command(s).\"\"\"\n assert isinstance(commands, list)\n p = None\n for c in commands:\n try:\n dispcmd = str([c] + args)\n # remember shell=False, so use git.cmd on windows, not just git\n p = subprocess.Popen([c] + args, cwd=cwd, env=env,\n stdout=subprocess.PIPE,\n stderr=(subprocess.PIPE if hide_stderr\n else None))\n break\n except EnvironmentError:\n e = sys.exc_info()[1]\n if e.errno == errno.ENOENT:\n continue\n if verbose:\n print(\"unable to run %s\" % dispcmd)\n print(e)\n return None, None\n else:\n if verbose:\n print(\"unable to find command, tried %s\" % (commands,))\n return None, None\n stdout = p.communicate()[0].strip()\n if sys.version_info[0] >= 3:\n stdout = stdout.decode()\n if p.returncode != 0:\n if verbose:\n print(\"unable to run %s (error)\" % dispcmd)\n print(\"stdout was %s\" % stdout)\n return None, p.returncode\n return stdout, p.returncode", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_versions_from_parentdir_versions_from_parentdir.raise_NotThisMethod_root": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_versions_from_parentdir_versions_from_parentdir.raise_NotThisMethod_root", "embedding": null, "metadata": {"file_path": "monai/_version.py", "file_name": "_version.py", "file_type": "text/x-python", "category": "implementation", "start_line": 106, "end_line": 128, "span_ids": ["versions_from_parentdir"], "tokens": 205}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def versions_from_parentdir(parentdir_prefix, root, verbose):\n \"\"\"Try to determine the version from the parent directory name.\n\n Source tarballs conventionally unpack into a directory that includes both\n the project name and a version string. We will also support searching up\n two directory levels for an appropriately named parent directory\n \"\"\"\n rootdirs = []\n\n for i in range(3):\n dirname = os.path.basename(root)\n if dirname.startswith(parentdir_prefix):\n return {\"version\": dirname[len(parentdir_prefix):],\n \"full-revisionid\": None,\n \"dirty\": False, \"error\": None, \"date\": None}\n else:\n rootdirs.append(root)\n root = os.path.dirname(root) # up a level\n\n if verbose:\n print(\"Tried directories %s but none started with prefix %s\" %\n (str(rootdirs), parentdir_prefix))\n raise NotThisMethod(\"rootdir doesn't start with parentdir_prefix\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_git_get_keywords_git_get_keywords.return.keywords": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_git_get_keywords_git_get_keywords.return.keywords", "embedding": null, "metadata": {"file_path": "monai/_version.py", "file_name": "_version.py", "file_type": "text/x-python", "category": "implementation", "start_line": 131, "end_line": 157, "span_ids": ["git_get_keywords"], "tokens": 255}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "@register_vcs_handler(\"git\", \"get_keywords\")\ndef git_get_keywords(versionfile_abs):\n \"\"\"Extract version information from the given file.\"\"\"\n # the code embedded in _version.py can just fetch the value of these\n # keywords. When used from setup.py, we don't want to import _version.py,\n # so we do it with a regexp instead. This function is not used from\n # _version.py.\n keywords = {}\n try:\n f = open(versionfile_abs, \"r\")\n for line in f.readlines():\n if line.strip().startswith(\"git_refnames =\"):\n mo = re.search(r'=\\s*\"(.*)\"', line)\n if mo:\n keywords[\"refnames\"] = mo.group(1)\n if line.strip().startswith(\"git_full =\"):\n mo = re.search(r'=\\s*\"(.*)\"', line)\n if mo:\n keywords[\"full\"] = mo.group(1)\n if line.strip().startswith(\"git_date =\"):\n mo = re.search(r'=\\s*\"(.*)\"', line)\n if mo:\n keywords[\"date\"] = mo.group(1)\n f.close()\n except EnvironmentError:\n pass\n return keywords", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_git_versions_from_keywords_git_versions_from_keywords.return._version_0_unknown_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_git_versions_from_keywords_git_versions_from_keywords.return._version_0_unknown_", "embedding": null, "metadata": {"file_path": "monai/_version.py", "file_name": "_version.py", "file_type": "text/x-python", "category": "implementation", "start_line": 160, "end_line": 212, "span_ids": ["git_versions_from_keywords"], "tokens": 714}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "@register_vcs_handler(\"git\", \"keywords\")\ndef git_versions_from_keywords(keywords, tag_prefix, verbose):\n \"\"\"Get version information from git keywords.\"\"\"\n if not keywords:\n raise NotThisMethod(\"no keywords at all, weird\")\n date = keywords.get(\"date\")\n if date is not None:\n # git-2.2.0 added \"%cI\", which expands to an ISO-8601 -compliant\n # datestamp. However we prefer \"%ci\" (which expands to an \"ISO-8601\n # -like\" string, which we must then edit to make compliant), because\n # it's been around since git-1.5.3, and it's too difficult to\n # discover which version we're using, or to work around using an\n # older one.\n date = date.strip().replace(\" \", \"T\", 1).replace(\" \", \"\", 1)\n refnames = keywords[\"refnames\"].strip()\n if refnames.startswith(\"$Format\"):\n if verbose:\n print(\"keywords are unexpanded, not using\")\n raise NotThisMethod(\"unexpanded keywords, not a git-archive tarball\")\n refs = set([r.strip() for r in refnames.strip(\"()\").split(\",\")])\n # starting in git-1.8.3, tags are listed as \"tag: foo-1.0\" instead of\n # just \"foo-1.0\". If we see a \"tag: \" prefix, prefer those.\n TAG = \"tag: \"\n tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])\n if not tags:\n # Either we're using git < 1.8.3, or there really are no tags. We use\n # a heuristic: assume all version tags have a digit. The old git %d\n # expansion behaves like git log --decorate=short and strips out the\n # refs/heads/ and refs/tags/ prefixes that would let us distinguish\n # between branches and tags. By ignoring refnames without digits, we\n # filter out many common branch names like \"release\" and\n # \"stabilization\", as well as \"HEAD\" and \"master\".\n tags = set([r for r in refs if re.search(r'\\d', r)])\n if verbose:\n print(\"discarding '%s', no digits\" % \",\".join(refs - tags))\n if verbose:\n print(\"likely tags: %s\" % \",\".join(sorted(tags)))\n for ref in sorted(tags):\n # sorting will prefer e.g. \"2.0\" over \"2.0rc1\"\n if ref.startswith(tag_prefix):\n r = ref[len(tag_prefix):]\n if verbose:\n print(\"picking %s\" % r)\n return {\"version\": r,\n \"full-revisionid\": keywords[\"full\"].strip(),\n \"dirty\": False, \"error\": None,\n \"date\": date}\n # no suitable tags, so version is \"0+unknown\", but full hex is still there\n if verbose:\n print(\"no suitable tags, using unknown + full revision id\")\n return {\"version\": \"0+unknown\",\n \"full-revisionid\": keywords[\"full\"].strip(),\n \"dirty\": False, \"error\": \"no suitable tags\", \"date\": None}", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_git_pieces_from_vcs_git_pieces_from_vcs.return.pieces": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_git_pieces_from_vcs_git_pieces_from_vcs.return.pieces", "embedding": null, "metadata": {"file_path": "monai/_version.py", "file_name": "_version.py", "file_type": "text/x-python", "category": "implementation", "start_line": 215, "end_line": 304, "span_ids": ["git_pieces_from_vcs"], "tokens": 874}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "@register_vcs_handler(\"git\", \"pieces_from_vcs\")\ndef git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):\n \"\"\"Get version from 'git describe' in the root of the source tree.\n\n This only gets called if the git-archive 'subst' keywords were *not*\n expanded, and _version.py hasn't already been rewritten with a short\n version string, meaning we're inside a checked out source tree.\n \"\"\"\n GITS = [\"git\"]\n if sys.platform == \"win32\":\n GITS = [\"git.cmd\", \"git.exe\"]\n\n out, rc = run_command(GITS, [\"rev-parse\", \"--git-dir\"], cwd=root,\n hide_stderr=True)\n if rc != 0:\n if verbose:\n print(\"Directory %s not under git control\" % root)\n raise NotThisMethod(\"'git rev-parse --git-dir' returned error\")\n\n # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]\n # if there isn't one, this yields HEX[-dirty] (no NUM)\n describe_out, rc = run_command(GITS, [\"describe\", \"--tags\", \"--dirty\",\n \"--always\", \"--long\",\n \"--match\", \"%s*\" % tag_prefix],\n cwd=root)\n # --long was added in git-1.5.5\n if describe_out is None:\n raise NotThisMethod(\"'git describe' failed\")\n describe_out = describe_out.strip()\n full_out, rc = run_command(GITS, [\"rev-parse\", \"HEAD\"], cwd=root)\n if full_out is None:\n raise NotThisMethod(\"'git rev-parse' failed\")\n full_out = full_out.strip()\n\n pieces = {}\n pieces[\"long\"] = full_out\n pieces[\"short\"] = full_out[:7] # maybe improved later\n pieces[\"error\"] = None\n\n # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty]\n # TAG might have hyphens.\n git_describe = describe_out\n\n # look for -dirty suffix\n dirty = git_describe.endswith(\"-dirty\")\n pieces[\"dirty\"] = dirty\n if dirty:\n git_describe = git_describe[:git_describe.rindex(\"-dirty\")]\n\n # now we have TAG-NUM-gHEX or HEX\n\n if \"-\" in git_describe:\n # TAG-NUM-gHEX\n mo = re.search(r'^(.+)-(\\d+)-g([0-9a-f]+)$', git_describe)\n if not mo:\n # unparseable. Maybe git-describe is misbehaving?\n pieces[\"error\"] = (\"unable to parse git-describe output: '%s'\"\n % describe_out)\n return pieces\n\n # tag\n full_tag = mo.group(1)\n if not full_tag.startswith(tag_prefix):\n if verbose:\n fmt = \"tag '%s' doesn't start with prefix '%s'\"\n print(fmt % (full_tag, tag_prefix))\n pieces[\"error\"] = (\"tag '%s' doesn't start with prefix '%s'\"\n % (full_tag, tag_prefix))\n return pieces\n pieces[\"closest-tag\"] = full_tag[len(tag_prefix):]\n\n # distance: number of commits since tag\n pieces[\"distance\"] = int(mo.group(2))\n\n # commit: short hex revision ID\n pieces[\"short\"] = mo.group(3)\n\n else:\n # HEX: no tags\n pieces[\"closest-tag\"] = None\n count_out, rc = run_command(GITS, [\"rev-list\", \"HEAD\", \"--count\"],\n cwd=root)\n pieces[\"distance\"] = int(count_out) # total number of commits\n\n # commit date: see ISO-8601 comment in git_versions_from_keywords()\n date = run_command(GITS, [\"show\", \"-s\", \"--format=%ci\", \"HEAD\"],\n cwd=root)[0].strip()\n pieces[\"date\"] = date.strip().replace(\" \", \"T\", 1).replace(\" \", \"\", 1)\n\n return pieces", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_plus_or_dot_render_pep440.return.rendered": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_plus_or_dot_render_pep440.return.rendered", "embedding": null, "metadata": {"file_path": "monai/_version.py", "file_name": "_version.py", "file_type": "text/x-python", "category": "implementation", "start_line": 307, "end_line": 336, "span_ids": ["plus_or_dot", "render_pep440"], "tokens": 258}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def plus_or_dot(pieces):\n \"\"\"Return a + if we don't already have one, else return a .\"\"\"\n if \"+\" in pieces.get(\"closest-tag\", \"\"):\n return \".\"\n return \"+\"\n\n\ndef render_pep440(pieces):\n \"\"\"Build up version string, with post-release \"local version identifier\".\n\n Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you\n get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty\n\n Exceptions:\n 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty]\n \"\"\"\n if pieces[\"closest-tag\"]:\n rendered = pieces[\"closest-tag\"]\n if pieces[\"distance\"] or pieces[\"dirty\"]:\n rendered += plus_or_dot(pieces)\n rendered += \"%d.g%s\" % (pieces[\"distance\"], pieces[\"short\"])\n if pieces[\"dirty\"]:\n rendered += \".dirty\"\n else:\n # exception #1\n rendered = \"0+untagged.%d.g%s\" % (pieces[\"distance\"],\n pieces[\"short\"])\n if pieces[\"dirty\"]:\n rendered += \".dirty\"\n return rendered", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_render_pep440_pre_render_pep440_post.return.rendered": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_render_pep440_pre_render_pep440_post.return.rendered", "embedding": null, "metadata": {"file_path": "monai/_version.py", "file_name": "_version.py", "file_type": "text/x-python", "category": "implementation", "start_line": 339, "end_line": 379, "span_ids": ["render_pep440_post", "render_pep440_pre"], "tokens": 321}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def render_pep440_pre(pieces):\n \"\"\"TAG[.post.devDISTANCE] -- No -dirty.\n\n Exceptions:\n 1: no tags. 0.post.devDISTANCE\n \"\"\"\n if pieces[\"closest-tag\"]:\n rendered = pieces[\"closest-tag\"]\n if pieces[\"distance\"]:\n rendered += \".post.dev%d\" % pieces[\"distance\"]\n else:\n # exception #1\n rendered = \"0.post.dev%d\" % pieces[\"distance\"]\n return rendered\n\n\ndef render_pep440_post(pieces):\n \"\"\"TAG[.postDISTANCE[.dev0]+gHEX] .\n\n The \".dev0\" means dirty. Note that .dev0 sorts backwards\n (a dirty tree will appear \"older\" than the corresponding clean one),\n but you shouldn't be releasing software with -dirty anyways.\n\n Exceptions:\n 1: no tags. 0.postDISTANCE[.dev0]\n \"\"\"\n if pieces[\"closest-tag\"]:\n rendered = pieces[\"closest-tag\"]\n if pieces[\"distance\"] or pieces[\"dirty\"]:\n rendered += \".post%d\" % pieces[\"distance\"]\n if pieces[\"dirty\"]:\n rendered += \".dev0\"\n rendered += plus_or_dot(pieces)\n rendered += \"g%s\" % pieces[\"short\"]\n else:\n # exception #1\n rendered = \"0.post%d\" % pieces[\"distance\"]\n if pieces[\"dirty\"]:\n rendered += \".dev0\"\n rendered += \"+g%s\" % pieces[\"short\"]\n return rendered", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_render_pep440_old_render_pep440_old.return.rendered": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_render_pep440_old_render_pep440_old.return.rendered", "embedding": null, "metadata": {"file_path": "monai/_version.py", "file_name": "_version.py", "file_type": "text/x-python", "category": "implementation", "start_line": 382, "end_line": 401, "span_ids": ["render_pep440_old"], "tokens": 143}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def render_pep440_old(pieces):\n \"\"\"TAG[.postDISTANCE[.dev0]] .\n\n The \".dev0\" means dirty.\n\n Exceptions:\n 1: no tags. 0.postDISTANCE[.dev0]\n \"\"\"\n if pieces[\"closest-tag\"]:\n rendered = pieces[\"closest-tag\"]\n if pieces[\"distance\"] or pieces[\"dirty\"]:\n rendered += \".post%d\" % pieces[\"distance\"]\n if pieces[\"dirty\"]:\n rendered += \".dev0\"\n else:\n # exception #1\n rendered = \"0.post%d\" % pieces[\"distance\"]\n if pieces[\"dirty\"]:\n rendered += \".dev0\"\n return rendered", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_render_git_describe_render_git_describe.return.rendered": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_render_git_describe_render_git_describe.return.rendered", "embedding": null, "metadata": {"file_path": "monai/_version.py", "file_name": "_version.py", "file_type": "text/x-python", "category": "implementation", "start_line": 404, "end_line": 421, "span_ids": ["render_git_describe"], "tokens": 129}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def render_git_describe(pieces):\n \"\"\"TAG[-DISTANCE-gHEX][-dirty].\n\n Like 'git describe --tags --dirty --always'.\n\n Exceptions:\n 1: no tags. HEX[-dirty] (note: no 'g' prefix)\n \"\"\"\n if pieces[\"closest-tag\"]:\n rendered = pieces[\"closest-tag\"]\n if pieces[\"distance\"]:\n rendered += \"-%d-g%s\" % (pieces[\"distance\"], pieces[\"short\"])\n else:\n # exception #1\n rendered = pieces[\"short\"]\n if pieces[\"dirty\"]:\n rendered += \"-dirty\"\n return rendered", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_render_git_describe_long_render_git_describe_long.return.rendered": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_render_git_describe_long_render_git_describe_long.return.rendered", "embedding": null, "metadata": {"file_path": "monai/_version.py", "file_name": "_version.py", "file_type": "text/x-python", "category": "implementation", "start_line": 424, "end_line": 441, "span_ids": ["render_git_describe_long"], "tokens": 133}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def render_git_describe_long(pieces):\n \"\"\"TAG-DISTANCE-gHEX[-dirty].\n\n Like 'git describe --tags --dirty --always -long'.\n The distance/hash is unconditional.\n\n Exceptions:\n 1: no tags. HEX[-dirty] (note: no 'g' prefix)\n \"\"\"\n if pieces[\"closest-tag\"]:\n rendered = pieces[\"closest-tag\"]\n rendered += \"-%d-g%s\" % (pieces[\"distance\"], pieces[\"short\"])\n else:\n # exception #1\n rendered = pieces[\"short\"]\n if pieces[\"dirty\"]:\n rendered += \"-dirty\"\n return rendered", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_render_render.return._version_rendered_fu": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_render_render.return._version_rendered_fu", "embedding": null, "metadata": {"file_path": "monai/_version.py", "file_name": "_version.py", "file_type": "text/x-python", "category": "implementation", "start_line": 444, "end_line": 473, "span_ids": ["render"], "tokens": 264}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def render(pieces, style):\n \"\"\"Render the given version pieces into the requested style.\"\"\"\n if pieces[\"error\"]:\n return {\"version\": \"unknown\",\n \"full-revisionid\": pieces.get(\"long\"),\n \"dirty\": None,\n \"error\": pieces[\"error\"],\n \"date\": None}\n\n if not style or style == \"default\":\n style = \"pep440\" # the default\n\n if style == \"pep440\":\n rendered = render_pep440(pieces)\n elif style == \"pep440-pre\":\n rendered = render_pep440_pre(pieces)\n elif style == \"pep440-post\":\n rendered = render_pep440_post(pieces)\n elif style == \"pep440-old\":\n rendered = render_pep440_old(pieces)\n elif style == \"git-describe\":\n rendered = render_git_describe(pieces)\n elif style == \"git-describe-long\":\n rendered = render_git_describe_long(pieces)\n else:\n raise ValueError(\"unknown style '%s'\" % style)\n\n return {\"version\": rendered, \"full-revisionid\": pieces[\"long\"],\n \"dirty\": pieces[\"dirty\"], \"error\": None,\n \"date\": pieces.get(\"date\")}", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_get_versions_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/_version.py_get_versions_", "embedding": null, "metadata": {"file_path": "monai/_version.py", "file_name": "_version.py", "file_type": "text/x-python", "category": "implementation", "start_line": 476, "end_line": 520, "span_ids": ["get_versions"], "tokens": 377}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def get_versions():\n \"\"\"Get version information or return default if unable to do so.\"\"\"\n # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have\n # __file__, we can work backwards from there to the root. Some\n # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which\n # case we can only use expanded keywords.\n\n cfg = get_config()\n verbose = cfg.verbose\n\n try:\n return git_versions_from_keywords(get_keywords(), cfg.tag_prefix,\n verbose)\n except NotThisMethod:\n pass\n\n try:\n root = os.path.realpath(__file__)\n # versionfile_source is the relative path from the top of the source\n # tree (where the .git directory might live) to this file. Invert\n # this to find the root from __file__.\n for i in cfg.versionfile_source.split('/'): # lgtm[py/unused-loop-variable]\n root = os.path.dirname(root)\n except NameError:\n return {\"version\": \"0+unknown\", \"full-revisionid\": None,\n \"dirty\": None,\n \"error\": \"unable to find root of source tree\",\n \"date\": None}\n\n try:\n pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose)\n return render(pieces, cfg.style)\n except NotThisMethod:\n pass\n\n try:\n if cfg.parentdir_prefix:\n return versions_from_parentdir(cfg.parentdir_prefix, root, verbose)\n except NotThisMethod:\n pass\n\n return {\"version\": \"0+unknown\", \"full-revisionid\": None,\n \"dirty\": None,\n \"error\": \"unable to compute version\", \"date\": None}", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/__init__.py_from_utils_import__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/__init__.py_from_utils_import__", "embedding": null, "metadata": {"file_path": "monai/apps/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 14, "span_ids": ["docstring"], "tokens": 10}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from .utils import *\nfrom .datasets import *", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_from_typing_import_Callab_MedNISTDataset.__init__.super___init___data_tr": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_from_typing_import_Callab_MedNISTDataset.__init__.super___init___data_tr", "embedding": null, "metadata": {"file_path": "monai/apps/datasets.py", "file_name": "datasets.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 86, "span_ids": ["MedNISTDataset.__init__", "MedNISTDataset", "docstring"], "tokens": 835}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Union, Sequence, Any, Optional\n\nimport os\nimport sys\n\nfrom monai.data import CacheDataset, load_decathalon_datalist\nfrom monai.transforms import LoadNiftid, LoadPNGd, Randomizable\nfrom monai.apps.utils import download_and_extract\n\n\nclass MedNISTDataset(Randomizable, CacheDataset):\n \"\"\"\n The Dataset to automatically download MedNIST data and generate items for training, validation or test.\n It's based on `CacheDataset` to accelerate the training process.\n\n Args:\n root_dir: target directory to download and load MedNIST dataset.\n section: expected data section, can be: `training`, `validation` or `test`.\n transform: transforms to execute operations on input data. the default transform is `LoadPNGd`,\n which can load data into numpy array with [H, W] shape. for further usage, use `AddChanneld`\n to convert the shape to [C, H, W, D].\n download: whether to download and extract the MedNIST from resource link, default is False.\n if expected file already exists, skip downloading even set it to True.\n user can manually copy `MedNIST.tar.gz` file or `MedNIST` folder to root directory.\n seed: random seed to randomly split training, validation and test datasets, defaut is 0.\n val_frac: percentage of of validation fraction in the whole dataset, default is 0.1.\n test_frac: percentage of of test fraction in the whole dataset, default is 0.1.\n cache_num: number of items to be cached. Default is `sys.maxsize`.\n will take the minimum of (cache_num, data_length x cache_rate, data_length).\n cache_rate: percentage of cached data in total, default is 1.0 (cache all).\n will take the minimum of (cache_num, data_length x cache_rate, data_length).\n num_workers: the number of worker threads to use.\n if 0 a single thread will be used. Default is 0.\n\n Raises:\n ValueError: root_dir must be a directory.\n RuntimeError: can not find dataset directory, please use download=True to download it.\n\n \"\"\"\n\n resource = \"https://www.dropbox.com/s/5wwskxctvcxiuea/MedNIST.tar.gz?dl=1\"\n md5 = \"0bc7306e7427e00ad1c5526a6677552d\"\n compressed_file_name = \"MedNIST.tar.gz\"\n dataset_folder_name = \"MedNIST\"\n\n def __init__(\n self,\n root_dir: str,\n section: str,\n transform: Union[Sequence[Callable], Callable] = LoadPNGd(\"image\"),\n download: bool = False,\n seed: int = 0,\n val_frac: float = 0.1,\n test_frac: float = 0.1,\n cache_num: int = sys.maxsize,\n cache_rate: float = 1.0,\n num_workers: int = 0,\n ) -> None:\n if not os.path.isdir(root_dir):\n raise ValueError(\"root_dir must be a directory.\")\n self.section = section\n self.val_frac = val_frac\n self.test_frac = test_frac\n self.set_random_state(seed=seed)\n tarfile_name = os.path.join(root_dir, self.compressed_file_name)\n dataset_dir = os.path.join(root_dir, self.dataset_folder_name)\n if download:\n download_and_extract(self.resource, tarfile_name, root_dir, self.md5)\n\n if not os.path.exists(dataset_dir):\n raise RuntimeError(\n f\"can not find dataset directory: {dataset_dir}, please use download=True to download it.\"\n )\n data = self._generate_data_list(dataset_dir)\n super().__init__(data, transform, cache_num=cache_num, cache_rate=cache_rate, num_workers=num_workers)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_MedNISTDataset.randomize_MedNISTDataset._generate_data_list.return.data": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_MedNISTDataset.randomize_MedNISTDataset._generate_data_list.return.data", "embedding": null, "metadata": {"file_path": "monai/apps/datasets.py", "file_name": "datasets.py", "file_type": "text/x-python", "category": "implementation", "start_line": 88, "end_line": 125, "span_ids": ["MedNISTDataset.randomize", "MedNISTDataset._generate_data_list"], "tokens": 335}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class MedNISTDataset(Randomizable, CacheDataset):\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self.rann = self.R.random()\n\n def _generate_data_list(self, dataset_dir: str):\n class_names = sorted((x for x in os.listdir(dataset_dir) if os.path.isdir(os.path.join(dataset_dir, x))))\n num_class = len(class_names)\n image_files = [\n [\n os.path.join(dataset_dir, class_names[i], x)\n for x in os.listdir(os.path.join(dataset_dir, class_names[i]))\n ]\n for i in range(num_class)\n ]\n num_each = [len(image_files[i]) for i in range(num_class)]\n image_files_list = []\n image_class = []\n for i in range(num_class):\n image_files_list.extend(image_files[i])\n image_class.extend([i] * num_each[i])\n num_total = len(image_class)\n\n data = list()\n\n for i in range(num_total):\n self.randomize()\n if self.section == \"training\":\n if self.rann < self.val_frac + self.test_frac:\n continue\n elif self.section == \"validation\":\n if self.rann >= self.val_frac:\n continue\n elif self.section == \"test\":\n if self.rann < self.val_frac or self.rann >= self.val_frac + self.test_frac:\n continue\n else:\n raise ValueError(\"section name can only be: training, validation or test.\")\n data.append({\"image\": image_files_list[i], \"label\": image_class[i]})\n return data", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_DecathlonDataset_DecathlonDataset._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_DecathlonDataset_DecathlonDataset._", "embedding": null, "metadata": {"file_path": "monai/apps/datasets.py", "file_name": "datasets.py", "file_type": "text/x-python", "category": "implementation", "start_line": 128, "end_line": 179, "span_ids": ["DecathlonDataset"], "tokens": 664}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DecathlonDataset(Randomizable, CacheDataset):\n \"\"\"\n The Dataset to automatically download the data of Medical Segmentation Decathlon challenge\n (http://medicaldecathlon.com/) and generate items for training, validation or test.\n It's based on :py:class:`monai.data.CacheDataset` to accelerate the training process.\n\n Args:\n root_dir: user's local directory for caching and loading the MSD datasets.\n task: which task to download and execute: one of list (\"Task01_BrainTumour\", \"Task02_Heart\",\n \"Task03_Liver\", \"Task04_Hippocampus\", \"Task05_Prostate\", \"Task06_Lung\", \"Task07_Pancreas\",\n \"Task08_HepaticVessel\", \"Task09_Spleen\", \"Task10_Colon\").\n section: expected data section, can be: `training`, `validation` or `test`.\n transform: transforms to execute operations on input data. the default transform is `LoadNiftid`,\n which can load Nifit format data into numpy array with [H, W, D] or [H, W, D, C] shape.\n for further usage, use `AddChanneld` or `AsChannelFirstd` to convert the shape to [C, H, W, D].\n download: whether to download and extract the Decathlon from resource link, default is False.\n if expected file already exists, skip downloading even set it to True.\n user can manually copy tar file or dataset folder to the root directory.\n seed: random seed to randomly split `training`, `validation` and `test` datasets, defaut is 0.\n val_frac: percentage of of validation fraction from the `training` section, default is 0.2.\n Decathlon data only contains `training` section with labels and `test` section without labels,\n so randomly select fraction from the `training` section as the `validation` section.\n cache_num: number of items to be cached. Default is `sys.maxsize`.\n will take the minimum of (cache_num, data_length x cache_rate, data_length).\n cache_rate: percentage of cached data in total, default is 1.0 (cache all).\n will take the minimum of (cache_num, data_length x cache_rate, data_length).\n num_workers: the number of worker threads to use.\n if 0 a single thread will be used. Default is 0.\n\n Example::\n\n transform = Compose(\n [\n LoadNiftid(keys=[\"image\", \"label\"]),\n AddChanneld(keys=[\"image\", \"label\"]),\n ScaleIntensityd(keys=\"image\"),\n ToTensord(keys=[\"image\", \"label\"]),\n ]\n )\n\n data = DecathlonDataset(\n root_dir=\"./\", task=\"Task09_Spleen\", transform=transform, section=\"validation\", download=True\n )\n\n print(data[0][\"image\"], data[0][\"label\"])\n\n Raises:\n ValueError: root_dir must be a directory.\n ValueError: unsupported task.\n RuntimeError: can not find dataset directory, please use download=True to download it.\n\n \"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_DecathlonDataset.resource_DecathlonDataset.md5._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_DecathlonDataset.resource_DecathlonDataset.md5._", "embedding": null, "metadata": {"file_path": "monai/apps/datasets.py", "file_name": "datasets.py", "file_type": "text/x-python", "category": "implementation", "start_line": 181, "end_line": 204, "span_ids": ["DecathlonDataset"], "tokens": 736}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DecathlonDataset(Randomizable, CacheDataset):\n\n resource = {\n \"Task01_BrainTumour\": \"https://drive.google.com/uc?id=1A2IU8Sgea1h3fYLpYtFb2v7NYdMjvEhU\",\n \"Task02_Heart\": \"https://drive.google.com/uc?id=1wEB2I6S6tQBVEPxir8cA5kFB8gTQadYY\",\n \"Task03_Liver\": \"https://drive.google.com/uc?id=1jyVGUGyxKBXV6_9ivuZapQS8eUJXCIpu\",\n \"Task04_Hippocampus\": \"https://www.dropbox.com/s/j9s3le3ogwztevr/Task04_Hippocampus.tar?dl=1\",\n \"Task05_Prostate\": \"https://www.dropbox.com/s/y3xg3e2giz5f5s9/Task05_Prostate.tar?dl=1\",\n \"Task06_Lung\": \"https://drive.google.com/uc?id=1I1LR7XjyEZ-VBQ-Xruh31V7xExMjlVvi\",\n \"Task07_Pancreas\": \"https://drive.google.com/uc?id=1YZQFSonulXuagMIfbJkZeTFJ6qEUuUxL\",\n \"Task08_HepaticVessel\": \"https://drive.google.com/uc?id=1qVrpV7vmhIsUxFiH189LmAn0ALbAPrgS\",\n \"Task09_Spleen\": \"https://drive.google.com/uc?id=1jzeNU1EKnK81PyTsrx0ujfNl-t0Jo8uE\",\n \"Task10_Colon\": \"https://drive.google.com/uc?id=1m7tMpE9qEcQGQjL_BdMD-Mvgmc44hG1Y\",\n }\n md5 = {\n \"Task01_BrainTumour\": \"240a19d752f0d9e9101544901065d872\",\n \"Task02_Heart\": \"06ee59366e1e5124267b774dbd654057\",\n \"Task03_Liver\": \"a90ec6c4aa7f6a3d087205e23d4e6397\",\n \"Task04_Hippocampus\": \"9d24dba78a72977dbd1d2e110310f31b\",\n \"Task05_Prostate\": \"35138f08b1efaef89d7424d2bcc928db\",\n \"Task06_Lung\": \"8afd997733c7fc0432f71255ba4e52dc\",\n \"Task07_Pancreas\": \"4f7080cfca169fa8066d17ce6eb061e4\",\n \"Task08_HepaticVessel\": \"641d79e80ec66453921d997fbf12a29c\",\n \"Task09_Spleen\": \"410d4a301da4e5b2f6f86ec3ddba524e\",\n \"Task10_Colon\": \"bad7a188931dc2f6acf72b08eb6202d0\",\n }", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_DecathlonDataset.__init___DecathlonDataset.randomize.self.rann.self_R_random_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_DecathlonDataset.__init___DecathlonDataset.randomize.self.rann.self_R_random_", "embedding": null, "metadata": {"file_path": "monai/apps/datasets.py", "file_name": "datasets.py", "file_type": "text/x-python", "category": "implementation", "start_line": 206, "end_line": 239, "span_ids": ["DecathlonDataset.__init__", "DecathlonDataset.randomize"], "tokens": 338}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DecathlonDataset(Randomizable, CacheDataset):\n\n def __init__(\n self,\n root_dir: str,\n task: str,\n section: str,\n transform: Union[Sequence[Callable], Callable] = LoadNiftid([\"image\", \"label\"]),\n download: bool = False,\n seed: int = 0,\n val_frac: float = 0.2,\n cache_num: int = sys.maxsize,\n cache_rate: float = 1.0,\n num_workers: int = 0,\n ) -> None:\n if not os.path.isdir(root_dir):\n raise ValueError(\"root_dir must be a directory.\")\n self.section = section\n self.val_frac = val_frac\n self.set_random_state(seed=seed)\n if task not in self.resource:\n raise ValueError(f\"unsupported task: {task}, available options are: {list(self.resource)}.\")\n dataset_dir = os.path.join(root_dir, task)\n tarfile_name = f\"{dataset_dir}.tar\"\n if download:\n download_and_extract(self.resource[task], tarfile_name, root_dir, self.md5[task])\n\n if not os.path.exists(dataset_dir):\n raise RuntimeError(\n f\"can not find dataset directory: {dataset_dir}, please use download=True to download it.\"\n )\n data = self._generate_data_list(dataset_dir)\n super().__init__(data, transform, cache_num=cache_num, cache_rate=cache_rate, num_workers=num_workers)\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self.rann = self.R.random()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_DecathlonDataset._generate_data_list_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_DecathlonDataset._generate_data_list_", "embedding": null, "metadata": {"file_path": "monai/apps/datasets.py", "file_name": "datasets.py", "file_type": "text/x-python", "category": "implementation", "start_line": 241, "end_line": 258, "span_ids": ["DecathlonDataset._generate_data_list"], "tokens": 145}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DecathlonDataset(Randomizable, CacheDataset):\n\n def _generate_data_list(self, dataset_dir: str):\n section = \"training\" if self.section in [\"training\", \"validation\"] else \"test\"\n datalist = load_decathalon_datalist(os.path.join(dataset_dir, \"dataset.json\"), True, section)\n if section == \"test\":\n return datalist\n else:\n data = list()\n for i in datalist:\n self.randomize()\n if self.section == \"training\":\n if self.rann < self.val_frac:\n continue\n else:\n if self.rann >= self.val_frac:\n continue\n data.append(i)\n return data", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/utils.py_from_typing_import_Option_check_md5.return.True": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/utils.py_from_typing_import_Option_check_md5.return.True", "embedding": null, "metadata": {"file_path": "monai/apps/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 49, "span_ids": ["check_md5", "docstring"], "tokens": 252}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional\n\nimport os\nfrom urllib.request import urlretrieve\nfrom urllib.error import URLError, ContentTooShortError, HTTPError\nimport hashlib\nimport tarfile\nimport zipfile\n\nfrom monai.utils import progress_bar, optional_import\n\ngdown, has_gdown = optional_import(\"gdown\", \"3.6\")\n\n\ndef check_md5(filepath: str, md5_value: Optional[str] = None) -> bool:\n \"\"\"\n check MD5 signature of specified file.\n\n Args:\n filepath: path of source file to verify MD5.\n md5_value: expected MD5 value of the file.\n\n \"\"\"\n if md5_value is not None:\n md5 = hashlib.md5()\n try:\n with open(filepath, \"rb\") as f:\n for chunk in iter(lambda: f.read(1024 * 1024), b\"\"):\n md5.update(chunk)\n except Exception as e:\n print(f\"Exception in check_md5: {e}\")\n return False\n if md5_value != md5.hexdigest():\n return False\n else:\n print(f\"expected MD5 is None, skip MD5 check for file {filepath}.\")\n\n return True", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/utils.py_download_url_download_url.if_not_check_md5_filepath.raise_RuntimeError_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/utils.py_download_url_download_url.if_not_check_md5_filepath.raise_RuntimeError_", "embedding": null, "metadata": {"file_path": "monai/apps/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 52, "end_line": 98, "span_ids": ["download_url"], "tokens": 451}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def download_url(url: str, filepath: str, md5_value: Optional[str] = None) -> None:\n \"\"\"\n Download file from specified URL link, support process bar and MD5 check.\n\n Args:\n url: source URL link to download file.\n filepath: target filepath to save the downloaded file.\n md5_value: expected MD5 value to validate the downloaded file.\n if None, skip MD5 validation.\n\n Raises:\n RuntimeError: MD5 check of existing file {filepath} failed, please delete it and try again.\n URLError: See urllib.request.urlopen\n HTTPError: See urllib.request.urlopen\n ContentTooShortError: See urllib.request.urlopen\n IOError: See urllib.request.urlopen\n RuntimeError: MD5 check of downloaded file failed, URL={url}, filepath={filepath}, expected MD5={md5_value}.\n\n \"\"\"\n if os.path.exists(filepath):\n if not check_md5(filepath, md5_value):\n raise RuntimeError(f\"MD5 check of existing file {filepath} failed, please delete it and try again.\")\n print(f\"file {filepath} exists, skip downloading.\")\n return\n os.makedirs(os.path.dirname(filepath), exist_ok=True)\n\n if url.startswith(\"https://drive.google.com\"):\n gdown.download(url, filepath, quiet=False)\n if not os.path.exists(filepath):\n raise RuntimeError(\"download failed due to network issue or permission denied.\")\n else:\n\n def _process_hook(blocknum, blocksize, totalsize):\n progress_bar(blocknum * blocksize, totalsize, f\"Downloading {filepath.split('/')[-1]}:\")\n\n try:\n urlretrieve(url, filepath, reporthook=_process_hook)\n print(f\"\\ndownloaded file: {filepath}.\")\n except (URLError, HTTPError, ContentTooShortError, IOError) as e:\n print(f\"download failed from {url} to {filepath}.\")\n raise e\n\n if not check_md5(filepath, md5_value):\n raise RuntimeError(\n f\"MD5 check of downloaded file failed, \\\n URL={url}, filepath={filepath}, expected MD5={md5_value}.\"\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/utils.py_extractall_extractall.if_filepath_endswith_zip.else_.raise_TypeError_unsuppor": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/utils.py_extractall_extractall.if_filepath_endswith_zip.else_.raise_TypeError_unsuppor", "embedding": null, "metadata": {"file_path": "monai/apps/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 101, "end_line": 133, "span_ids": ["extractall"], "tokens": 279}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def extractall(filepath: str, output_dir: str, md5_value: Optional[str] = None) -> None:\n \"\"\"\n Extract file to the output directory.\n Expected file types are: `zip`, `tar.gz` and `tar`.\n\n Args:\n filepath: the file path of compressed file.\n output_dir: target directory to save extracted files.\n md5_value: expected MD5 value to validate the compressed file.\n if None, skip MD5 validation.\n\n Raises:\n RuntimeError: MD5 check of compressed file {filepath} failed.\n TypeError: unsupported compressed file type.\n\n \"\"\"\n target_file = os.path.join(output_dir, os.path.basename(filepath).split(\".\")[0])\n if os.path.exists(target_file):\n print(f\"extracted file {target_file} exists, skip extracting.\")\n return\n if not check_md5(filepath, md5_value):\n raise RuntimeError(f\"MD5 check of compressed file {filepath} failed.\")\n\n if filepath.endswith(\"zip\"):\n zip_file = zipfile.ZipFile(filepath)\n zip_file.extractall(output_dir)\n zip_file.close()\n elif filepath.endswith(\"tar\") or filepath.endswith(\"tar.gz\"):\n tar_file = tarfile.open(filepath)\n tar_file.extractall(output_dir)\n tar_file.close()\n else:\n raise TypeError(\"unsupported compressed file type.\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/utils.py_download_and_extract_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/utils.py_download_and_extract_", "embedding": null, "metadata": {"file_path": "monai/apps/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 136, "end_line": 151, "span_ids": ["download_and_extract"], "tokens": 154}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def download_and_extract(url: str, filepath: str, output_dir: str, md5_value: Optional[str] = None) -> None:\n \"\"\"\n Download file from URL and extract it to the output directory.\n\n Args:\n url: source URL link to download file.\n filepath: the file path of compressed file.\n output_dir: target directory to save extracted files.\n defaut is None to save in current directory.\n md5_value: expected MD5 value to validate the downloaded file.\n if None, skip MD5 validation.\n\n \"\"\"\n download_url(url=url, filepath=filepath, md5_value=md5_value)\n extractall(filepath=filepath, output_dir=output_dir, md5_value=md5_value)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/config/__init__.py_from_deviceconfig_import_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/config/__init__.py_from_deviceconfig_import_", "embedding": null, "metadata": {"file_path": "monai/config/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 14, "span_ids": ["docstring"], "tokens": 12}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from .deviceconfig import *\nfrom .type_definitions import *", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/config/deviceconfig.py_os_get_optional_config_values.return.output": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/config/deviceconfig.py_os_get_optional_config_values.return.output", "embedding": null, "metadata": {"file_path": "monai/config/deviceconfig.py", "file_name": "deviceconfig.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 88, "span_ids": ["get_config_values", "get_optional_config_values", "docstring"], "tokens": 377}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport sys\nfrom collections import OrderedDict\n\nimport monai\nimport numpy as np\nimport torch\n\n\ntry:\n import ignite\n\n ignite_version = ignite.__version__\n del ignite\nexcept (ImportError, AttributeError):\n ignite_version = \"NOT INSTALLED or UNKNOWN VERSION.\"\n\ntry:\n import nibabel\n\n nibabel_version = nibabel.__version__\n del nibabel\nexcept (ImportError, AttributeError):\n nibabel_version = \"NOT INSTALLED or UNKNOWN VERSION.\"\n\ntry:\n import skimage\n\n skimage_version = skimage.__version__\n del skimage\nexcept (ImportError, AttributeError):\n skimage_version = \"NOT INSTALLED or UNKNOWN VERSION.\"\n\ntry:\n import PIL\n\n PIL_version = PIL.__version__\n del PIL\nexcept (ImportError, AttributeError):\n PIL_version = \"NOT INSTALLED or UNKNOWN VERSION.\"\n\ntry:\n import tensorboard\n\n tensorboard_version = tensorboard.__version__\n del tensorboard\nexcept (ImportError, AttributeError):\n tensorboard_version = \"NOT INSTALLED or UNKNOWN VERSION.\"\n\n\ndef get_config_values():\n \"\"\"\n Read the package versions into a dictionary.\n \"\"\"\n output = OrderedDict()\n\n output[\"MONAI\"] = monai.__version__\n output[\"Python\"] = sys.version.replace(\"\\n\", \" \")\n output[\"Numpy\"] = np.version.full_version\n output[\"Pytorch\"] = torch.__version__\n\n return output\n\n\ndef get_optional_config_values():\n \"\"\"\n Read the optional package versions into a dictionary.\n \"\"\"\n output = OrderedDict()\n\n output[\"Pytorch Ignite\"] = ignite_version\n output[\"Nibabel\"] = nibabel_version\n output[\"scikit-image\"] = skimage_version\n output[\"Pillow\"] = PIL_version\n output[\"Tensorboard\"] = tensorboard_version\n\n return output", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/config/deviceconfig.py_print_config_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/config/deviceconfig.py_print_config_", "embedding": null, "metadata": {"file_path": "monai/config/deviceconfig.py", "file_name": "deviceconfig.py", "file_type": "text/x-python", "category": "implementation", "start_line": 91, "end_line": 120, "span_ids": ["print_config", "set_visible_devices", "get_torch_version_tuple"], "tokens": 229}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def print_config(file=sys.stdout):\n \"\"\"\n Print the package versions to `file`.\n Defaults to `sys.stdout`.\n \"\"\"\n for k, v in get_config_values().items():\n print(f\"{k} version: {v}\", file=file, flush=True)\n\n print(\"\\nOptional dependencies:\", file=file, flush=True)\n for k, v in get_optional_config_values().items():\n print(f\"{k} version: {v}\", file=file, flush=True)\n print(\"\\nFor details about installing the optional dependencies, please visit:\", file=file, flush=True)\n print(\n \" https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\\n\",\n file=file,\n flush=True,\n )\n\n\ndef set_visible_devices(*dev_inds):\n os.environ[\"CUDA_VISIBLE_DEVICES\"] = \",\".join(map(str, dev_inds))\n\n\ndef get_torch_version_tuple():\n \"\"\"\n Returns:\n tuple of ints represents the pytorch major/minor version.\n \"\"\"\n return tuple((int(x) for x in torch.__version__.split(\".\")[:2]))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/config/type_definitions.py_from_typing_import_Hashab_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/config/type_definitions.py_from_typing_import_Hashab_", "embedding": null, "metadata": {"file_path": "monai/config/type_definitions.py", "file_name": "type_definitions.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 53, "span_ids": ["docstring"], "tokens": 347}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Hashable, Iterable, Union, Collection\n\n\n\"\"\"Commonly used concepts\nThis module provides naming and type specifications for commonly used concepts\nwithin the MONAI package. The intent is to explicitly identify information\nthat should be used consistently throughout the entire MONAI package.\n\nA type would be named as type_definitions.KeysCollection\nwhich includes a meaningful name for the concent in the name itself. The\ndefinitions in this file map context meaningful names to the underlying\nobject properties that define the expected API.\n\nA conceptual type is represented by a new type name but is also one which\ncan be different depending on an environment (i.e. differences for python 3.6 vs 3.9\nmay be implemented). Consistent use of the concept and recorded documentation of\nthe rationale and convention behind it lowers the learning curve for new\ndevelopers. For readability, short names are preferred.\n\"\"\"\n\nKeysCollection = Union[Collection[Hashable], Hashable]\n\"\"\"KeysCollection\n\nThe KeyCollection type is used to for defining variables\nthat store a subset of keys to select items from a dictionary.\nThe container of keys must contain hashable elements.\nNOTE: `Hashable` is not a collection, but is provided as a\n convenience to end-users. All supplied values will be\n internally converted to a tuple of `Hashable`'s before\n use\n\"\"\"\n\n\nIndexSelection = Union[Iterable[int], int]\n\"\"\"IndexSelection\n\nThe IndexSelection type is used to for defining variables\nthat store a subset of indexes to select items from a List or Array like objects.\nThe indexes must be integers, and if a container of indexes is specified, the\ncontainer must be iterable.\n\"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/__init__.py_CSVSaver_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/__init__.py_CSVSaver_", "embedding": null, "metadata": {"file_path": "monai/data/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 24, "span_ids": ["docstring"], "tokens": 128}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from .csv_saver import CSVSaver\nfrom .dataloader import DataLoader\nfrom .dataset import Dataset, PersistentDataset, CacheDataset, ZipDataset, ArrayDataset\nfrom .decathalon_datalist import load_decathalon_datalist\nfrom .grid_dataset import GridPatchDataset\nfrom .nifti_reader import NiftiDataset\nfrom .nifti_saver import NiftiSaver\nfrom .nifti_writer import write_nifti\nfrom .png_saver import PNGSaver\nfrom .png_writer import write_png\nfrom .synthetic import *\nfrom .utils import *", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/csv_saver.py_from_typing_import_Option_CSVSaver.__init__.self._data_index.0": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/csv_saver.py_from_typing_import_Option_CSVSaver.__init__.self._data_index.0", "embedding": null, "metadata": {"file_path": "monai/data/csv_saver.py", "file_name": "csv_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 44, "span_ids": ["CSVSaver.__init__", "CSVSaver", "docstring"], "tokens": 288}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Union, Dict\n\nfrom collections import OrderedDict\nimport os\nimport csv\n\nimport numpy as np\nimport torch\n\n\nclass CSVSaver:\n \"\"\"\n Save the data in a dictionary format cache, and write to a CSV file finally.\n Typically, the data can be classification predictions, call `save` for single data\n or call `save_batch` to save a batch of data together, and call `finalize` to write\n the cached data into CSV file. If no meta data provided, use index from 0 to save data.\n \"\"\"\n\n def __init__(self, output_dir: str = \"./\", filename: str = \"predictions.csv\", overwrite: bool = True) -> None:\n \"\"\"\n Args:\n output_dir: output CSV file directory.\n filename: name of the saved CSV file name.\n overwrite: whether to overwriting existing CSV file content. If we are not overwriting,\n then we check if the results have been previously saved, and load them to the prediction_dict.\n\n \"\"\"\n self.output_dir = output_dir\n self._cache_dict: OrderedDict = OrderedDict()\n assert isinstance(filename, str) and filename[-4:] == \".csv\", \"filename must be a string with CSV format.\"\n self._filepath = os.path.join(output_dir, filename)\n self.overwrite = overwrite\n self._data_index = 0", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/csv_saver.py_CSVSaver.finalize_CSVSaver.finalize.with_open_self__filepath_.for_k_v_in_self__cache_d.f_write_n_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/csv_saver.py_CSVSaver.finalize_CSVSaver.finalize.with_open_self__filepath_.for_k_v_in_self__cache_d.f_write_n_", "embedding": null, "metadata": {"file_path": "monai/data/csv_saver.py", "file_name": "csv_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 46, "end_line": 64, "span_ids": ["CSVSaver.finalize"], "tokens": 156}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CSVSaver:\n\n def finalize(self) -> None:\n \"\"\"\n Writes the cached dict to a csv\n\n \"\"\"\n if not self.overwrite and os.path.exists(self._filepath):\n with open(self._filepath, \"r\") as f:\n reader = csv.reader(f)\n for row in reader:\n self._cache_dict[row[0]] = np.array(row[1:]).astype(np.float32)\n\n if not os.path.exists(self.output_dir):\n os.makedirs(self.output_dir)\n with open(self._filepath, \"w\") as f:\n for k, v in self._cache_dict.items():\n f.write(k)\n for result in v.flatten():\n f.write(\",\" + str(result))\n f.write(\"\\n\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/csv_saver.py_CSVSaver.save_CSVSaver.save.self__cache_dict_save_key": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/csv_saver.py_CSVSaver.save_CSVSaver.save.self__cache_dict_save_key", "embedding": null, "metadata": {"file_path": "monai/data/csv_saver.py", "file_name": "csv_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 66, "end_line": 81, "span_ids": ["CSVSaver.save"], "tokens": 189}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CSVSaver:\n\n def save(self, data: Union[torch.Tensor, np.ndarray], meta_data: Optional[Dict] = None) -> None:\n \"\"\"Save data into the cache dictionary. The metadata should have the following key:\n - ``'filename_or_obj'`` -- save the data corresponding to file name or object.\n If meta_data is None, use the default index from 0 to save data instead.\n\n Args:\n data: target data content that save into cache.\n meta_data: the meta data information corresponding to the data.\n\n \"\"\"\n save_key = meta_data[\"filename_or_obj\"] if meta_data else str(self._data_index)\n self._data_index += 1\n if torch.is_tensor(data):\n data = data.detach().cpu().numpy()\n assert isinstance(data, np.ndarray)\n self._cache_dict[save_key] = data.astype(np.float32)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/csv_saver.py_CSVSaver.save_batch_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/csv_saver.py_CSVSaver.save_batch_", "embedding": null, "metadata": {"file_path": "monai/data/csv_saver.py", "file_name": "csv_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 83, "end_line": 93, "span_ids": ["CSVSaver.save_batch"], "tokens": 129}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CSVSaver:\n\n def save_batch(self, batch_data: Union[torch.Tensor, np.ndarray], meta_data: Optional[Dict] = None) -> None:\n \"\"\"Save a batch of data into the cache dictionary.\n\n Args:\n batch_data: target batch data content that save into cache.\n meta_data: every key-value in the meta_data is corresponding to 1 batch of data.\n\n \"\"\"\n for i, data in enumerate(batch_data): # save a batch of files\n self.save(data, {k: meta_data[k][i] for k in meta_data} if meta_data else None)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataloader.py_from_typing_import_Callab_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataloader.py_from_typing_import_Callab_", "embedding": null, "metadata": {"file_path": "monai/data/dataloader.py", "file_name": "dataloader.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 80, "span_ids": ["DataLoader.__init__", "DataLoader", "docstring"], "tokens": 642}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Optional\n\nfrom torch.utils.data import Dataset, Sampler, DataLoader as _TorchDataLoader\n\nfrom monai.data.utils import list_data_collate, worker_init_fn\n\n__all__ = [\"DataLoader\"]\n\n\nclass DataLoader(_TorchDataLoader):\n \"\"\"Generates images/labels for train/validation/testing from dataset.\n It inherits from PyTorch DataLoader and adds callbacks for `collate` and `worker_fn`.\n\n Args:\n dataset: dataset from which to load the data.\n batch_size: how many samples per batch to load\n (default: ``1``).\n shuffle: set to ``True`` to have the data reshuffled\n at every epoch (default: ``False``).\n sampler: defines the strategy to draw samples from\n the dataset. If specified, :attr:`shuffle` must be ``False``.\n batch_sampler: like :attr:`sampler`, but returns a batch of\n indices at a time. Mutually exclusive with :attr:`batch_size`,\n :attr:`shuffle`, :attr:`sampler`, and :attr:`drop_last`.\n num_workers: how many subprocesses to use for data\n loading. ``0`` means that the data will be loaded in the main process.\n (default: ``0``)\n pin_memory: If ``True``, the data loader will copy Tensors\n into CUDA pinned memory before returning them. If your data elements\n are a custom type, or your :attr:`collate_fn` returns a batch that is a custom type,\n see the example below.\n drop_last: set to ``True`` to drop the last incomplete batch,\n if the dataset size is not divisible by the batch size. If ``False`` and\n the size of dataset is not divisible by the batch size, then the last batch\n will be smaller. (default: ``False``)\n timeout: if positive, the timeout value for collecting a batch\n from workers. Should always be non-negative. (default: ``0``)\n multiprocessing_context: specify a valid start method for multi-processing.\n\n \"\"\"\n\n def __init__(\n self,\n dataset: Dataset,\n batch_size: int = 1,\n shuffle: bool = False,\n sampler: Optional[Sampler] = None,\n batch_sampler: Optional[Sampler] = None,\n num_workers: int = 0,\n pin_memory: bool = False,\n drop_last: bool = False,\n timeout: float = 0.0,\n multiprocessing_context: Optional[Callable] = None,\n ) -> None:\n super().__init__( # type: ignore # No overload variant matches argument types\n dataset=dataset,\n batch_size=batch_size,\n shuffle=shuffle,\n sampler=sampler,\n batch_sampler=batch_sampler,\n num_workers=num_workers,\n collate_fn=list_data_collate,\n pin_memory=pin_memory,\n drop_last=drop_last,\n timeout=timeout,\n worker_init_fn=worker_init_fn,\n multiprocessing_context=multiprocessing_context,\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_from_typing_import_Callab_Dataset.__getitem__.return.data": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_from_typing_import_Callab_Dataset.__getitem__.return.data", "embedding": null, "metadata": {"file_path": "monai/data/dataset.py", "file_name": "dataset.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 59, "span_ids": ["Dataset", "Dataset.__init__", "Dataset.__getitem__", "docstring", "Dataset.__len__"], "tokens": 346}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Optional, Sequence, Union, Tuple, Any\n\nimport hashlib\nimport json\nimport sys\nimport threading\nfrom multiprocessing.pool import ThreadPool\nfrom pathlib import Path\n\nimport numpy as np\nimport torch\nfrom torch.utils.data import Dataset as _TorchDataset\n\nfrom monai.transforms import apply_transform, Compose, Randomizable, Transform\nfrom monai.utils import get_seed, progress_bar\n\n\nclass Dataset(_TorchDataset):\n \"\"\"\n A generic dataset with a length property and an optional callable data transform\n when fetching a data sample.\n For example, typical input data can be a list of dictionaries::\n\n [{ { {\n 'img': 'image1.nii.gz', 'img': 'image2.nii.gz', 'img': 'image3.nii.gz',\n 'seg': 'label1.nii.gz', 'seg': 'label2.nii.gz', 'seg': 'label3.nii.gz',\n 'extra': 123 'extra': 456 'extra': 789\n }, }, }]\n \"\"\"\n\n def __init__(self, data: Sequence, transform: Optional[Callable] = None) -> None:\n \"\"\"\n Args:\n data: input data to load and transform to generate dataset for model.\n transform: a callable data transform on input data.\n \"\"\"\n self.data = data\n self.transform = transform\n\n def __len__(self) -> int:\n return len(self.data)\n\n def __getitem__(self, index: int):\n data = self.data[index]\n if self.transform is not None:\n data = apply_transform(self.transform, data)\n\n return data", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_PersistentDataset_PersistentDataset.__init__.self.cache_dir.Path_cache_dir_if_cache_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_PersistentDataset_PersistentDataset.__init__.self.cache_dir.Path_cache_dir_if_cache_", "embedding": null, "metadata": {"file_path": "monai/data/dataset.py", "file_name": "dataset.py", "file_type": "text/x-python", "category": "implementation", "start_line": 62, "end_line": 115, "span_ids": ["PersistentDataset", "PersistentDataset.__init__"], "tokens": 617}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class PersistentDataset(Dataset):\n \"\"\"\n Persistent storage of pre-computed values to efficiently manage larger than memory dictionary format data,\n it can operate transforms for specific fields. Results from the non-random transform components are computed\n when first used, and stored in the `cache_dir` for rapid retrieval on subsequent uses.\n\n For example, typical input data can be a list of dictionaries::\n\n [{ { {\n 'img': 'image1.nii.gz', 'img': 'image2.nii.gz', 'img': 'image3.nii.gz',\n 'seg': 'label1.nii.gz', 'seg': 'label2.nii.gz', 'seg': 'label3.nii.gz',\n 'extra': 123 'extra': 456 'extra': 789\n }, }, }]\n\n For a composite transform like\n\n .. code-block:: python\n\n [ LoadNiftid(keys=['image', 'label']),\n Orientationd(keys=['image', 'label'], axcodes='RAS'),\n ScaleIntensityRanged(keys=['image'], a_min=-57, a_max=164, b_min=0.0, b_max=1.0, clip=True),\n RandCropByPosNegLabeld(keys=['image', 'label'], label_key='label', spatial_size=(96, 96, 96),\n pos=1, neg=1, num_samples=4, image_key='image', image_threshold=0),\n ToTensord(keys=['image', 'label'])]\n\n Upon first use a filename based dataset will be processed by the transform for the\n [LoadNiftid, Orientationd, ScaleIntensityRanged] and the resulting tensor written to\n the `cache_dir` before applying the remaining random dependant transforms\n [RandCropByPosNegLabeld, ToTensord] elements for use in the analysis.\n\n Subsequent uses of a dataset directly read pre-processed results from `cache_dir`\n followed by applying the random dependant parts of transform processing.\n \"\"\"\n\n def __init__(\n self,\n data: Sequence,\n transform: Union[Sequence[Callable], Callable],\n cache_dir: Optional[Union[Path, str]] = None,\n ) -> None:\n \"\"\"\n Args:\n data: input data to load and transform to generate dataset for model.\n transform: transforms to execute operations on input data.\n cache_dir: If specified, this is the location for persistent storage\n of pre-computed transformed data tensors. The cache_dir is computed once, and\n persists on disk until explicitly removed. Different runs, programs, experiments\n may share a common cache dir provided that the transforms pre-processing is\n consistent.\n \"\"\"\n if not isinstance(transform, Compose):\n transform = Compose(transform)\n super().__init__(data=data, transform=transform)\n self.cache_dir = Path(cache_dir) if cache_dir is not None else None", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_PersistentDataset._pre_first_random_transform_PersistentDataset._pre_first_random_transform.return.item_transformed": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_PersistentDataset._pre_first_random_transform_PersistentDataset._pre_first_random_transform.return.item_transformed", "embedding": null, "metadata": {"file_path": "monai/data/dataset.py", "file_name": "dataset.py", "file_type": "text/x-python", "category": "implementation", "start_line": 117, "end_line": 133, "span_ids": ["PersistentDataset._pre_first_random_transform"], "tokens": 135}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class PersistentDataset(Dataset):\n\n def _pre_first_random_transform(self, item_transformed):\n \"\"\"\n Process the data from original state up to the first random element.\n\n Args:\n item_transformed: The data to be transformed\n\n Returns:\n the transformed element up to the first identified\n random transform object\n \"\"\"\n for _transform in self.transform.transforms: # pytype: disable=attribute-error\n # execute all the deterministic transforms\n if isinstance(_transform, Randomizable) or not isinstance(_transform, Transform):\n break\n item_transformed = apply_transform(_transform, item_transformed)\n return item_transformed", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_PersistentDataset._first_random_and_beyond_transform_PersistentDataset._first_random_and_beyond_transform.return.item_transformed": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_PersistentDataset._first_random_and_beyond_transform_PersistentDataset._first_random_and_beyond_transform.return.item_transformed", "embedding": null, "metadata": {"file_path": "monai/data/dataset.py", "file_name": "dataset.py", "file_type": "text/x-python", "category": "implementation", "start_line": 135, "end_line": 154, "span_ids": ["PersistentDataset._first_random_and_beyond_transform"], "tokens": 164}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class PersistentDataset(Dataset):\n\n def _first_random_and_beyond_transform(self, item_transformed):\n \"\"\"\n Process the data from before the first random transform to the final state ready for evaluation.\n\n Args:\n item_transformed: The data to be transformed (already processed up to the first random transform)\n\n Returns:\n the transformed element through the random transforms\n \"\"\"\n start_post_randomize_run = False\n for _transform in self.transform.transforms: # pytype: disable=attribute-error\n if (\n start_post_randomize_run\n or isinstance(_transform, Randomizable)\n or not isinstance(_transform, Transform)\n ):\n start_post_randomize_run = True\n item_transformed = apply_transform(_transform, item_transformed)\n return item_transformed", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_PersistentDataset._pre_first_random_cachecheck_PersistentDataset.__getitem__.return.post_random_item": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_PersistentDataset._pre_first_random_cachecheck_PersistentDataset.__getitem__.return.post_random_item", "embedding": null, "metadata": {"file_path": "monai/data/dataset.py", "file_name": "dataset.py", "file_type": "text/x-python", "category": "implementation", "start_line": 156, "end_line": 205, "span_ids": ["PersistentDataset._pre_first_random_cachecheck", "PersistentDataset.__getitem__"], "tokens": 511}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class PersistentDataset(Dataset):\n\n def _pre_first_random_cachecheck(self, item_transformed):\n \"\"\"\n A function to cache the expensive input data transform operations\n so that huge data sets (larger than computer memory) can be processed\n on the fly as needed, and intermediate results written to disk for\n future use.\n\n Args:\n item_transformed: The current data element to be mutated into transformed representation\n\n Returns:\n The transformed data_element, either from cache, or explicitly computing it.\n\n Warning:\n The current implementation does not encode transform information as part of the\n hashing mechanism used for generating cache names. If the transforms applied are\n changed in any way, the objects in the cache dir will be invalid. The hash for the\n cache is ONLY dependant on the input filename paths.\n \"\"\"\n if item_transformed.get(\"cached\", False) is False:\n hashfile: Optional[Path] = None\n if self.cache_dir is not None:\n cache_dir_path: Path = Path(self.cache_dir)\n if cache_dir_path.is_dir():\n # TODO: Find way to hash transforms content as part of the cache\n data_item_md5 = hashlib.md5(\n json.dumps(item_transformed, sort_keys=True).encode(\"utf-8\")\n ).hexdigest()\n hashfile = Path(cache_dir_path) / f\"{data_item_md5}.pt\"\n\n if hashfile is not None and hashfile.is_file():\n item_transformed = torch.load(hashfile)\n else:\n item_transformed = self._pre_first_random_transform(item_transformed)\n if hashfile is not None:\n # add sentinel flag to indicate that the transforms have already been computed.\n item_transformed[\"cache\"] = True\n # NOTE: Writing to \".temp_write_cache\" and then using a nearly atomic rename operation\n # to make the cache more robust to manual killing of parent process\n # which may leave partially written cache files in an incomplete state\n temp_hash_file: Path = hashfile.with_suffix(\".temp_write_cache\")\n torch.save(item_transformed, temp_hash_file)\n temp_hash_file.rename(hashfile)\n\n return item_transformed\n\n def __getitem__(self, index: int):\n pre_random_item = self._pre_first_random_cachecheck(self.data[index])\n post_random_item = self._first_random_and_beyond_transform(pre_random_item)\n return post_random_item", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_CacheDataset_CacheDataset.__init__.if_self_cache_num_0_.if_num_workers_0_.else_.for_i_in_range_self_cache.progress_bar_i_1_self_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_CacheDataset_CacheDataset.__init__.if_self_cache_num_0_.if_num_workers_0_.else_.for_i_in_range_self_cache.progress_bar_i_1_self_", "embedding": null, "metadata": {"file_path": "monai/data/dataset.py", "file_name": "dataset.py", "file_type": "text/x-python", "category": "implementation", "start_line": 208, "end_line": 278, "span_ids": ["CacheDataset.__init__", "CacheDataset"], "tokens": 718}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CacheDataset(Dataset):\n \"\"\"\n Dataset with cache mechanism that can load data and cache deterministic transforms' result during training.\n\n By caching the results of non-random preprocessing transforms, it accelerates the training data pipeline.\n If the requested data is not in the cache, all transforms will run normally\n (see also :py:class:`monai.data.dataset.Dataset`).\n\n Users can set the cache rate or number of items to cache.\n It is recommended to experiment with different `cache_num` or `cache_rate` to identify the best training speed.\n\n To improve the caching efficiency, please always put as many as possible non-random transforms\n before the randomized ones when composing the chain of transforms.\n\n For example, if the transform is a `Compose` of::\n\n transforms = Compose([\n LoadNiftid(),\n AddChanneld(),\n Spacingd(),\n Orientationd(),\n ScaleIntensityRanged(),\n RandCropByPosNegLabeld(),\n ToTensord()\n ])\n\n when `transforms` is used in a multi-epoch training pipeline, before the first training epoch,\n this dataset will cache the results up to ``ScaleIntensityRanged``, as\n all non-random transforms `LoadNiftid`, `AddChanneld`, `Spacingd`, `Orientationd`, `ScaleIntensityRanged`\n can be cached. During training, the dataset will load the cached results and run\n ``RandCropByPosNegLabeld`` and ``ToTensord``, as ``RandCropByPosNegLabeld`` is a randomized transform\n and the outcome not cached.\n \"\"\"\n\n def __init__(\n self,\n data: Sequence,\n transform: Union[Sequence[Callable], Callable],\n cache_num: int = sys.maxsize,\n cache_rate: float = 1.0,\n num_workers: int = 0,\n ) -> None:\n \"\"\"\n Args:\n data: input data to load and transform to generate dataset for model.\n transform: transforms to execute operations on input data.\n cache_num: number of items to be cached. Default is `sys.maxsize`.\n will take the minimum of (cache_num, data_length x cache_rate, data_length).\n cache_rate: percentage of cached data in total, default is 1.0 (cache all).\n will take the minimum of (cache_num, data_length x cache_rate, data_length).\n num_workers: the number of worker threads to use.\n If 0 a single thread will be used. Default is 0.\n \"\"\"\n if not isinstance(transform, Compose):\n transform = Compose(transform)\n super().__init__(data, transform)\n self.cache_num = min(cache_num, int(len(self) * cache_rate), len(self))\n if self.cache_num > 0:\n self._cache = [None] * self.cache_num\n if num_workers > 0:\n self._item_processed = 0\n self._thread_lock = threading.Lock()\n with ThreadPool(num_workers) as p:\n p.map(\n self._load_cache_item_thread,\n [(i, data[i], transform.transforms) for i in range(self.cache_num)],\n )\n else:\n for i in range(self.cache_num):\n self._cache[i] = self._load_cache_item(data[i], transform.transforms)\n progress_bar(i + 1, self.cache_num, \"Load and cache transformed data: \")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_CacheDataset._load_cache_item_CacheDataset._load_cache_item_thread.with_self__thread_lock_.progress_bar_self__item_p": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_CacheDataset._load_cache_item_CacheDataset._load_cache_item_thread.with_self__thread_lock_.progress_bar_self__item_p", "embedding": null, "metadata": {"file_path": "monai/data/dataset.py", "file_name": "dataset.py", "file_type": "text/x-python", "category": "implementation", "start_line": 280, "end_line": 293, "span_ids": ["CacheDataset._load_cache_item", "CacheDataset._load_cache_item_thread"], "tokens": 150}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CacheDataset(Dataset):\n\n def _load_cache_item(self, item: Any, transforms: Sequence[Callable]):\n for _transform in transforms:\n # execute all the deterministic transforms\n if isinstance(_transform, Randomizable) or not isinstance(_transform, Transform):\n break\n item = apply_transform(_transform, item)\n return item\n\n def _load_cache_item_thread(self, args: Tuple) -> None:\n i, item, transforms = args\n self._cache[i] = self._load_cache_item(item, transforms)\n with self._thread_lock:\n self._item_processed += 1\n progress_bar(self._item_processed, self.cache_num, \"Load and cache transformed data: \")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_CacheDataset.__getitem___CacheDataset.__getitem__.return.data": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_CacheDataset.__getitem___CacheDataset.__getitem__.return.data", "embedding": null, "metadata": {"file_path": "monai/data/dataset.py", "file_name": "dataset.py", "file_type": "text/x-python", "category": "implementation", "start_line": 295, "end_line": 309, "span_ids": ["CacheDataset.__getitem__"], "tokens": 147}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CacheDataset(Dataset):\n\n def __getitem__(self, index):\n if index < self.cache_num:\n # load data from cache and execute from the first random transform\n start_run = False\n data = self._cache[index]\n for _transform in self.transform.transforms: # pytype: disable=attribute-error\n if not start_run and not isinstance(_transform, Randomizable) and isinstance(_transform, Transform):\n continue\n else:\n start_run = True\n data = apply_transform(_transform, data)\n else:\n # no cache for this data, execute all the transforms directly\n data = super(CacheDataset, self).__getitem__(index)\n return data", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_ZipDataset_ZipDataset.__getitem__.return.data": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_ZipDataset_ZipDataset.__getitem__.return.data", "embedding": null, "metadata": {"file_path": "monai/data/dataset.py", "file_name": "dataset.py", "file_type": "text/x-python", "category": "implementation", "start_line": 312, "end_line": 353, "span_ids": ["ZipDataset", "ZipDataset.__init__", "ZipDataset.__getitem__", "ZipDataset.__len__"], "tokens": 361}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ZipDataset(Dataset):\n \"\"\"\n Zip several PyTorch datasets and output data(with the same index) together in a tuple.\n If the output of single dataset is already a tuple, flatten it and extend to the result.\n For example: if datasetA returns (img, imgmeta), datasetB returns (seg, segmeta),\n finally return (img, imgmeta, seg, segmeta).\n And if the datasets don't have same length, use the minimum length of them as the length\n of ZipDataset.\n\n Examples::\n\n >>> zip_data = ZipDataset([[1, 2, 3], [4, 5]])\n >>> print(len(zip_data))\n 2\n >>> for item in zip_data:\n >>> print(item)\n [1, 4]\n [2, 5]\n\n \"\"\"\n\n def __init__(self, datasets: Sequence, transform: Optional[Callable] = None) -> None:\n \"\"\"\n Args:\n datasets (list or tuple): list of datasets to zip together.\n transform: a callable data transform operates on the zipped item from `datasets`.\n \"\"\"\n super().__init__(list(datasets), transform=transform)\n\n def __len__(self) -> int:\n return min((len(dataset) for dataset in self.data))\n\n def __getitem__(self, index: int):\n def to_list(x):\n return list(x) if isinstance(x, (tuple, list)) else [x]\n\n data = list()\n for dataset in self.data:\n data.extend(to_list(dataset[index]))\n if self.transform is not None:\n data = apply_transform(self.transform, data, map_items=False) # transform the list data\n return data", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_ArrayDataset_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_ArrayDataset_", "embedding": null, "metadata": {"file_path": "monai/data/dataset.py", "file_name": "dataset.py", "file_type": "text/x-python", "category": "implementation", "start_line": 356, "end_line": 453, "span_ids": ["ArrayDataset.__len__", "ArrayDataset.randomize", "ArrayDataset.__getitem__", "ArrayDataset", "ArrayDataset.__init__"], "tokens": 850}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ArrayDataset(Randomizable, _TorchDataset):\n \"\"\"\n Dataset for segmentation and classification tasks based on array format input data and transforms.\n It ensures the same random seeds in the randomized transforms defined for image, segmentation and label.\n The `transform` can be :py:class:`monai.transforms.Compose` or any other callable object.\n For example:\n If train based on Nifti format images without metadata, all transforms can be composed::\n\n img_transform = Compose(\n [\n LoadNifti(image_only=True),\n AddChannel(),\n RandAdjustContrast()\n ]\n )\n ArrayDataset(img_file_list, img_transform=img_transform)\n\n If training based on images and the metadata, the array transforms can not be composed\n because several transforms receives multiple parameters or return multiple values. Then Users need\n to define their own callable method to parse metadata from `LoadNifti` or set `affine` matrix\n to `Spacing` transform::\n\n class TestCompose(Compose):\n def __call__(self, input_):\n img, metadata = self.transforms[0](input_)\n img = self.transforms[1](img)\n img, _, _ = self.transforms[2](img, metadata[\"affine\"])\n return self.transforms[3](img), metadata\n img_transform = TestCompose(\n [\n LoadNifti(image_only=False),\n AddChannel(),\n Spacing(pixdim=(1.5, 1.5, 3.0)),\n RandAdjustContrast()\n ]\n )\n ArrayDataset(img_file_list, img_transform=img_transform)\n\n Examples::\n\n >>> ds = ArrayDataset([1, 2, 3, 4], lambda x: x + 0.1)\n >>> print(ds[0])\n 1.1\n\n >>> ds = ArrayDataset(img=[1, 2, 3, 4], seg=[5, 6, 7, 8])\n >>> print(ds[0])\n [1, 5]\n\n \"\"\"\n\n def __init__(\n self,\n img: Sequence,\n img_transform: Optional[Callable] = None,\n seg: Optional[Sequence] = None,\n seg_transform: Optional[Callable] = None,\n labels: Optional[Sequence] = None,\n label_transform: Optional[Callable] = None,\n ) -> None:\n \"\"\"\n Initializes the dataset with the filename lists. The transform `img_transform` is applied\n to the images and `seg_transform` to the segmentations.\n\n Args:\n img: sequence of images.\n img_transform: transform to apply to each element in `img`.\n seg: sequence of segmentations.\n seg_transform: transform to apply to each element in `seg`.\n labels: sequence of labels.\n label_transform: transform to apply to each element in `labels`.\n\n \"\"\"\n items = [(img, img_transform), (seg, seg_transform), (labels, label_transform)]\n self.set_random_state(seed=get_seed())\n datasets = [Dataset(x[0], x[1]) for x in items if x[0] is not None]\n self.dataset = datasets[0] if len(datasets) == 1 else ZipDataset(datasets)\n\n self._seed = 0 # transform synchronization seed\n\n def __len__(self) -> int:\n return len(self.dataset)\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self._seed = self.R.randint(np.iinfo(np.int32).max)\n\n def __getitem__(self, index: int):\n self.randomize()\n if isinstance(self.dataset, ZipDataset):\n # set transforms of each zip component\n for dataset in self.dataset.data:\n transform = getattr(dataset, \"transform\", None)\n if isinstance(transform, Randomizable):\n transform.set_random_state(seed=self._seed)\n transform = getattr(self.dataset, \"transform\", None)\n if isinstance(transform, Randomizable):\n transform.set_random_state(seed=self._seed)\n return self.dataset[index]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/decathalon_datalist.py_from_typing_import_List___append_paths.return.items": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/decathalon_datalist.py_from_typing_import_List___append_paths.return.items", "embedding": null, "metadata": {"file_path": "monai/data/decathalon_datalist.py", "file_name": "decathalon_datalist.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 39, "span_ids": ["_compute_path", "_append_paths", "docstring"], "tokens": 228}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import List, Optional, Union, Dict\n\nimport os\nimport json\n\n\ndef _compute_path(base_dir: str, element: Union[List[str], str]):\n if isinstance(element, str):\n return os.path.normpath(os.path.join(base_dir, element))\n elif isinstance(element, list):\n for e in element:\n if not isinstance(e, str):\n raise ValueError(\"file path must be a string.\")\n return [os.path.normpath(os.path.join(base_dir, e)) for e in element]\n else:\n raise ValueError(\"file path must be a string or a list of string.\")\n\n\ndef _append_paths(base_dir: str, is_segmentation: bool, items: List[Dict]):\n for item in items:\n if not isinstance(item, dict):\n raise ValueError(\"data item must be dict.\")\n for k, v in item.items():\n if k == \"image\":\n item[k] = _compute_path(base_dir, v)\n elif is_segmentation and k == \"label\":\n item[k] = _compute_path(base_dir, v)\n return items", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/decathalon_datalist.py_load_decathalon_datalist_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/decathalon_datalist.py_load_decathalon_datalist_", "embedding": null, "metadata": {"file_path": "monai/data/decathalon_datalist.py", "file_name": "decathalon_datalist.py", "file_type": "text/x-python", "category": "implementation", "start_line": 42, "end_line": 87, "span_ids": ["load_decathalon_datalist"], "tokens": 427}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def load_decathalon_datalist(\n data_list_file_path: str,\n is_segmentation: bool = True,\n data_list_key: str = \"training\",\n base_dir: Optional[str] = None,\n):\n \"\"\"Load image/label paths of decathalon challenge from JSON file\n\n Json file is similar to what you get from http://medicaldecathlon.com/\n Those dataset.json files\n\n Args:\n data_list_file_path: the path to the json file of datalist.\n is_segmentation: whether the datalist is for segmentation task, default is True.\n data_list_key: the key to get a list of dictionary to be used, default is \"training\".\n base_dir: the base directory of the dataset, if None, use the datalist directory.\n\n Raises:\n ValueError: data list file {data_list_file_path} does not exist.\n ValueError: data list {data_list_key} not specified in '{data_list_file_path}'.\n\n Returns a list of data items, each of which is a dict keyed by element names, for example:\n\n .. code-block::\n\n [\n {'image': '/workspace/data/chest_19.nii.gz', 'label': 0},\n {'image': '/workspace/data/chest_31.nii.gz', 'label': 1}\n ]\n\n \"\"\"\n if not os.path.isfile(data_list_file_path):\n raise ValueError(f\"data list file {data_list_file_path} does not exist.\")\n with open(data_list_file_path) as json_file:\n json_data = json.load(json_file)\n if data_list_key not in json_data:\n raise ValueError(f\"data list {data_list_key} not specified in '{data_list_file_path}'.\")\n expected_data = json_data[data_list_key]\n if data_list_key == \"test\":\n expected_data = [{\"image\": i} for i in expected_data]\n\n if base_dir is None:\n base_dir = os.path.dirname(data_list_file_path)\n\n return _append_paths(base_dir, is_segmentation, expected_data)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/grid_dataset.py_from_typing_import_Sequen_GridPatchDataset.__init__.self.pad_opts.pad_opts": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/grid_dataset.py_from_typing_import_Sequen_GridPatchDataset.__init__.self.pad_opts.pad_opts", "embedding": null, "metadata": {"file_path": "monai/data/grid_dataset.py", "file_name": "grid_dataset.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 58, "span_ids": ["GridPatchDataset", "GridPatchDataset.__init__", "docstring"], "tokens": 499}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Sequence, Union, Dict\n\nimport math\n\nimport torch\nfrom torch.utils.data import Dataset, IterableDataset\n\nfrom monai.data.utils import iter_patch\nfrom monai.utils import ensure_tuple, NumpyPadMode\n\n\nclass GridPatchDataset(IterableDataset):\n \"\"\"\n Yields patches from arrays read from an input dataset. The patches are chosen in a contiguous grid sampling scheme.\n \"\"\"\n\n def __init__(\n self,\n dataset: Dataset,\n patch_size: Sequence[int],\n start_pos: Sequence[int] = (),\n mode: Union[NumpyPadMode, str] = NumpyPadMode.WRAP,\n **pad_opts: Dict,\n ) -> None:\n \"\"\"\n Initializes this dataset in terms of the input dataset and patch size. The `patch_size` is the size of the\n patch to sample from the input arrays. It is assumed the arrays first dimension is the channel dimension which\n will be yielded in its entirety so this should not be specified in `patch_size`. For example, for an input 3D\n array with 1 channel of size (1, 20, 20, 20) a regular grid sampling of eight patches (1, 10, 10, 10) would be\n specified by a `patch_size` of (10, 10, 10).\n\n Args:\n dataset: the dataset to read array data from\n patch_size: size of patches to generate slices for, 0/None selects whole dimension\n start_pos: starting position in the array, default is 0 for each dimension\n mode: {``\"constant\"``, ``\"edge\"``, ``\"linear_ramp\"``, ``\"maximum\"``, ``\"mean\"``,\n ``\"median\"``, ``\"minimum\"``, ``\"reflect\"``, ``\"symmetric\"``, ``\"wrap\"``, ``\"empty\"``}\n One of the listed string values or a user supplied function. Defaults to ``\"wrap\"``.\n See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html\n pad_opts: padding options, see numpy.pad\n \"\"\"\n\n self.dataset = dataset\n self.patch_size = (None,) + tuple(patch_size)\n self.start_pos = ensure_tuple(start_pos)\n self.mode: NumpyPadMode = NumpyPadMode(mode)\n self.pad_opts = pad_opts", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/grid_dataset.py_GridPatchDataset.__iter___": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/grid_dataset.py_GridPatchDataset.__iter___", "embedding": null, "metadata": {"file_path": "monai/data/grid_dataset.py", "file_name": "grid_dataset.py", "file_type": "text/x-python", "category": "implementation", "start_line": 60, "end_line": 78, "span_ids": ["GridPatchDataset.__iter__"], "tokens": 168}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class GridPatchDataset(IterableDataset):\n\n def __iter__(self):\n worker_info = torch.utils.data.get_worker_info()\n iter_start = 0\n iter_end = len(self.dataset)\n\n if worker_info is not None:\n # split workload\n per_worker = int(math.ceil((iter_end - iter_start) / float(worker_info.num_workers)))\n worker_id = worker_info.id\n iter_start = iter_start + worker_id * per_worker\n iter_end = min(iter_start + per_worker, iter_end)\n\n for index in range(iter_start, iter_end):\n arrays = self.dataset[index]\n\n iters = [iter_patch(a, self.patch_size, self.start_pos, False, self.mode, **self.pad_opts) for a in arrays]\n\n yield from zip(*iters)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_reader.py_from_typing_import_Callab_NiftiDataset.randomize.self._seed.self_R_randint_np_iinfo_n": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_reader.py_from_typing_import_Callab_NiftiDataset.randomize.self._seed.self_R_randint_np_iinfo_n", "embedding": null, "metadata": {"file_path": "monai/data/nifti_reader.py", "file_name": "nifti_reader.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 76, "span_ids": ["NiftiDataset", "NiftiDataset.randomize", "NiftiDataset.__init__", "NiftiDataset.__len__", "docstring"], "tokens": 539}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Optional, Sequence, Union, Any\n\nimport numpy as np\nfrom torch.utils.data import Dataset\n\nfrom monai.transforms import LoadNifti, Randomizable, apply_transform\nfrom monai.utils import get_seed\n\n\nclass NiftiDataset(Dataset, Randomizable):\n \"\"\"\n Loads image/segmentation pairs of Nifti files from the given filename lists. Transformations can be specified\n for the image and segmentation arrays separately.\n \"\"\"\n\n def __init__(\n self,\n image_files: Sequence[str],\n seg_files: Optional[Sequence[str]] = None,\n labels: Optional[Sequence[Union[int, float]]] = None,\n as_closest_canonical: bool = False,\n transform: Optional[Callable] = None,\n seg_transform: Optional[Callable] = None,\n image_only: bool = True,\n dtype: Optional[np.dtype] = np.float32,\n ) -> None:\n \"\"\"\n Initializes the dataset with the image and segmentation filename lists. The transform `transform` is applied\n to the images and `seg_transform` to the segmentations.\n\n Args:\n image_files: list of image filenames\n seg_files: if in segmentation task, list of segmentation filenames\n labels (list or array): if in classification task, list of classification labels\n as_closest_canonical: if True, load the image as closest to canonical orientation\n transform: transform to apply to image arrays\n seg_transform: transform to apply to segmentation arrays\n image_only: if True return only the image volume, other return image volume and header dict\n dtype: if not None convert the loaded image to this data type\n\n Raises:\n ValueError: Must have same number of image and segmentation files\n\n \"\"\"\n\n if seg_files is not None and len(image_files) != len(seg_files):\n raise ValueError(\"Must have same number of image and segmentation files\")\n\n self.image_files = image_files\n self.seg_files = seg_files\n self.labels = labels\n self.as_closest_canonical = as_closest_canonical\n self.transform = transform\n self.seg_transform = seg_transform\n self.image_only = image_only\n self.dtype = dtype\n self.set_random_state(seed=get_seed())\n\n self._seed = 0 # transform synchronization seed\n\n def __len__(self) -> int:\n return len(self.image_files)\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self._seed = self.R.randint(np.iinfo(np.int32).max)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_reader.py_NiftiDataset.__getitem___": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_reader.py_NiftiDataset.__getitem___", "embedding": null, "metadata": {"file_path": "monai/data/nifti_reader.py", "file_name": "nifti_reader.py", "file_type": "text/x-python", "category": "implementation", "start_line": 78, "end_line": 117, "span_ids": ["NiftiDataset.__getitem__"], "tokens": 308}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class NiftiDataset(Dataset, Randomizable):\n\n def __getitem__(self, index: int):\n self.randomize()\n meta_data = None\n img_loader = LoadNifti(\n as_closest_canonical=self.as_closest_canonical, image_only=self.image_only, dtype=self.dtype\n )\n if self.image_only:\n img = img_loader(self.image_files[index])\n else:\n img, meta_data = img_loader(self.image_files[index])\n seg = None\n if self.seg_files is not None:\n seg_loader = LoadNifti(image_only=True)\n seg = seg_loader(self.seg_files[index])\n label = None\n if self.labels is not None:\n label = self.labels[index]\n\n if self.transform is not None:\n if isinstance(self.transform, Randomizable):\n self.transform.set_random_state(seed=self._seed)\n img = apply_transform(self.transform, img)\n\n data = [img]\n\n if self.seg_transform is not None:\n if isinstance(self.seg_transform, Randomizable):\n self.seg_transform.set_random_state(seed=self._seed)\n seg = apply_transform(self.seg_transform, seg)\n\n if seg is not None:\n data.append(seg)\n if label is not None:\n data.append(label)\n if not self.image_only and meta_data is not None:\n data.append(meta_data)\n if len(data) == 1:\n return data[0]\n return data", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_saver.py_from_typing_import_Option_NiftiSaver.__init__.self._data_index.0": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_saver.py_from_typing_import_Option_NiftiSaver.__init__.self._data_index.0", "embedding": null, "metadata": {"file_path": "monai/data/nifti_saver.py", "file_name": "nifti_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 64, "span_ids": ["NiftiSaver", "NiftiSaver.__init__", "docstring"], "tokens": 530}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Union, Dict\n\nimport numpy as np\nimport torch\n\nfrom monai.data.nifti_writer import write_nifti\nfrom monai.data.utils import create_file_basename\nfrom monai.utils import GridSampleMode, GridSamplePadMode\n\n\nclass NiftiSaver:\n \"\"\"\n Save the data as NIfTI file, it can support single data content or a batch of data.\n Typically, the data can be segmentation predictions, call `save` for single data\n or call `save_batch` to save a batch of data together. If no meta data provided,\n use index from 0 as the filename prefix.\n \"\"\"\n\n def __init__(\n self,\n output_dir: str = \"./\",\n output_postfix: str = \"seg\",\n output_ext: str = \".nii.gz\",\n resample: bool = True,\n mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,\n padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.BORDER,\n dtype: Optional[np.dtype] = None,\n ) -> None:\n \"\"\"\n Args:\n output_dir: output image directory.\n output_postfix: a string appended to all output file names.\n output_ext: output file extension name.\n resample: whether to resample before saving the data array.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n This option is used when ``resample = True``.\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n This option is used when ``resample = True``.\n Padding mode for outside grid values. Defaults to ``\"border\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n dtype: convert the image data to save to this data type.\n If None, keep the original type of data.\n \"\"\"\n self.output_dir = output_dir\n self.output_postfix = output_postfix\n self.output_ext = output_ext\n self.resample = resample\n self.mode: GridSampleMode = GridSampleMode(mode)\n self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)\n self.dtype = dtype\n self._data_index = 0", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_saver.py_NiftiSaver.save_NiftiSaver.save.write_nifti_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_saver.py_NiftiSaver.save_NiftiSaver.save.write_nifti_", "embedding": null, "metadata": {"file_path": "monai/data/nifti_saver.py", "file_name": "nifti_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 66, "end_line": 114, "span_ids": ["NiftiSaver.save"], "tokens": 542}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class NiftiSaver:\n\n def save(self, data: Union[torch.Tensor, np.ndarray], meta_data: Optional[Dict] = None) -> None:\n \"\"\"\n Save data into a Nifti file.\n The meta_data could optionally have the following keys:\n\n - ``'filename_or_obj'`` -- for output file name creation, corresponding to filename or object.\n - ``'original_affine'`` -- for data orientation handling, defaulting to an identity matrix.\n - ``'affine'`` -- for data output affine, defaulting to an identity matrix.\n - ``'spatial_shape'`` -- for data output shape.\n\n When meta_data is specified, the saver will try to resample batch data from the space\n defined by \"affine\" to the space defined by \"original_affine\".\n\n If meta_data is None, use the default index (starting from 0) as the filename.\n\n Args:\n data: target data content that to be saved as a NIfTI format file.\n Assuming the data shape starts with a channel dimension and followed by spatial dimensions.\n meta_data: the meta data information corresponding to the data.\n\n See Also\n :py:meth:`monai.data.nifti_writer.write_nifti`\n \"\"\"\n filename = meta_data[\"filename_or_obj\"] if meta_data else str(self._data_index)\n self._data_index += 1\n original_affine = meta_data.get(\"original_affine\", None) if meta_data else None\n affine = meta_data.get(\"affine\", None) if meta_data else None\n spatial_shape = meta_data.get(\"spatial_shape\", None) if meta_data else None\n\n if torch.is_tensor(data):\n data = data.detach().cpu().numpy()\n filename = create_file_basename(self.output_postfix, filename, self.output_dir)\n filename = f\"{filename}{self.output_ext}\"\n # change data shape to be (channel, h, w, d)\n while len(data.shape) < 4:\n data = np.expand_dims(data, -1)\n # change data to \"channel last\" format and write to nifti format file\n data = np.moveaxis(data, 0, -1)\n write_nifti(\n data,\n file_name=filename,\n affine=affine,\n target_affine=original_affine,\n resample=self.resample,\n output_spatial_shape=spatial_shape,\n mode=self.mode,\n padding_mode=self.padding_mode,\n dtype=self.dtype or data.dtype,\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_saver.py_NiftiSaver.save_batch_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_saver.py_NiftiSaver.save_batch_", "embedding": null, "metadata": {"file_path": "monai/data/nifti_saver.py", "file_name": "nifti_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 116, "end_line": 136, "span_ids": ["NiftiSaver.save_batch"], "tokens": 291}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class NiftiSaver:\n\n def save_batch(self, batch_data: Union[torch.Tensor, np.ndarray], meta_data: Optional[Dict] = None) -> None:\n \"\"\"\n Save a batch of data into Nifti format files.\n\n Spatially it supports up to three dimensions, that is, H, HW, HWD for\n 1D, 2D, 3D respectively (with resampling supports for 2D and 3D only).\n\n When saving multiple time steps or multiple channels `batch_data`,\n time and/or modality axes should be appended after the batch dimensions.\n For example, the shape of a batch of 2D eight-class\n segmentation probabilities to be saved could be `(batch, 8, 64, 64)`;\n in this case each item in the batch will be saved as (64, 64, 1, 8)\n NIfTI file (the third dimension is reserved as a spatial dimension).\n\n Args:\n batch_data: target batch data content that save into NIfTI format.\n meta_data: every key-value in the meta_data is corresponding to a batch of data.\n \"\"\"\n for i, data in enumerate(batch_data): # save a batch of files\n self.save(data, {k: meta_data[k][i] for k in meta_data} if meta_data else None)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_writer.py_from_typing_import_Option_write_nifti._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_writer.py_from_typing_import_Option_write_nifti._", "embedding": null, "metadata": {"file_path": "monai/data/nifti_writer.py", "file_name": "nifti_writer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 84, "span_ids": ["write_nifti", "docstring"], "tokens": 938}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Sequence, Union\n\nimport numpy as np\nimport torch\n\nfrom monai.data.utils import compute_shape_offset, to_affine_nd\nfrom monai.networks.layers import AffineTransform\nfrom monai.utils import optional_import, GridSampleMode, GridSamplePadMode\n\nnib, _ = optional_import(\"nibabel\")\n\n\ndef write_nifti(\n data: np.ndarray,\n file_name: str,\n affine: Optional[np.ndarray] = None,\n target_affine: Optional[np.ndarray] = None,\n resample: bool = True,\n output_spatial_shape: Optional[Sequence[int]] = None,\n mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,\n padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.BORDER,\n dtype: Optional[np.dtype] = None,\n) -> None:\n \"\"\"\n Write numpy data into NIfTI files to disk. This function converts data\n into the coordinate system defined by `target_affine` when `target_affine`\n is specified.\n\n If the coordinate transform between `affine` and `target_affine` could be\n achieved by simply transposing and flipping `data`, no resampling will\n happen. otherwise this function will resample `data` using the coordinate\n transform computed from `affine` and `target_affine`. Note that the shape\n of the resampled `data` may subject to some rounding errors. For example,\n resampling a 20x20 pixel image from pixel size (1.5, 1.5)-mm to (3.0,\n 3.0)-mm space will return a 10x10-pixel image. However, resampling a\n 20x20-pixel image from pixel size (2.0, 2.0)-mm to (3.0, 3.0)-mma space\n will output a 14x14-pixel image, where the image shape is rounded from\n 13.333x13.333 pixels. In this case `output_spatial_shape` could be specified so\n that this function writes image data to a designated shape.\n\n When `affine` and `target_affine` are None, the data will be saved with an\n identity matrix as the image affine.\n\n This function assumes the NIfTI dimension notations.\n Spatially it supports up to three dimensions, that is, H, HW, HWD for\n 1D, 2D, 3D respectively.\n When saving multiple time steps or multiple channels `data`, time and/or\n modality axes should be appended after the first three dimensions. For\n example, shape of 2D eight-class segmentation probabilities to be saved\n could be `(64, 64, 1, 8)`. Also, data in shape (64, 64, 8), (64, 64, 8, 1)\n will be considered as a single-channel 3D image.\n\n Args:\n data: input data to write to file.\n file_name: expected file name that saved on disk.\n affine: the current affine of `data`. Defaults to `np.eye(4)`\n target_affine: before saving\n the (`data`, `affine`) as a Nifti1Image,\n transform the data into the coordinates defined by `target_affine`.\n resample: whether to run resampling when the target affine\n could not be achieved by swapping/flipping data axes.\n output_spatial_shape: spatial shape of the output image.\n This option is used when resample = True.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n This option is used when ``resample = True``.\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n This option is used when ``resample = True``.\n Padding mode for outside grid values. Defaults to ``\"border\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n dtype: convert the image to save to this data type.\n \"\"\"\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_writer.py_write_nifti.assert_isinstance_data_n_write_nifti.output_spatial_shape_.list_output_spatial_shape": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_writer.py_write_nifti.assert_isinstance_data_n_write_nifti.output_spatial_shape_.list_output_spatial_shape", "embedding": null, "metadata": {"file_path": "monai/data/nifti_writer.py", "file_name": "nifti_writer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 85, "end_line": 120, "span_ids": ["write_nifti"], "tokens": 535}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def write_nifti(\n data: np.ndarray,\n file_name: str,\n affine: Optional[np.ndarray] = None,\n target_affine: Optional[np.ndarray] = None,\n resample: bool = True,\n output_spatial_shape: Optional[Sequence[int]] = None,\n mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,\n padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.BORDER,\n dtype: Optional[np.dtype] = None,\n) -> None:\n assert isinstance(data, np.ndarray), \"input data must be numpy array.\"\n sr = min(data.ndim, 3)\n if affine is None:\n affine = np.eye(4, dtype=np.float64)\n affine = to_affine_nd(sr, affine)\n\n if target_affine is None:\n target_affine = affine\n target_affine = to_affine_nd(sr, target_affine)\n\n if np.allclose(affine, target_affine, atol=1e-3):\n # no affine changes, save (data, affine)\n results_img = nib.Nifti1Image(data.astype(dtype), to_affine_nd(3, target_affine))\n nib.save(results_img, file_name)\n return\n\n # resolve orientation\n start_ornt = nib.orientations.io_orientation(affine)\n target_ornt = nib.orientations.io_orientation(target_affine)\n ornt_transform = nib.orientations.ornt_transform(start_ornt, target_ornt)\n data_shape = data.shape\n data = nib.orientations.apply_orientation(data, ornt_transform)\n _affine = affine @ nib.orientations.inv_ornt_aff(ornt_transform, data_shape)\n if np.allclose(_affine, target_affine, atol=1e-3) or not resample:\n results_img = nib.Nifti1Image(data.astype(dtype), to_affine_nd(3, target_affine))\n nib.save(results_img, file_name)\n return\n\n # need resampling\n affine_xform = AffineTransform(\n normalized=False, mode=mode, padding_mode=padding_mode, align_corners=True, reverse_indexing=True\n )\n transform = np.linalg.inv(_affine) @ target_affine\n if output_spatial_shape is None:\n output_spatial_shape, _ = compute_shape_offset(data.shape, _affine, target_affine)\n output_spatial_shape_ = list(output_spatial_shape)\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_writer.py_write_nifti.if_data_ndim_3_mult_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_writer.py_write_nifti.if_data_ndim_3_mult_", "embedding": null, "metadata": {"file_path": "monai/data/nifti_writer.py", "file_name": "nifti_writer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 121, "end_line": 148, "span_ids": ["write_nifti"], "tokens": 488}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def write_nifti(\n data: np.ndarray,\n file_name: str,\n affine: Optional[np.ndarray] = None,\n target_affine: Optional[np.ndarray] = None,\n resample: bool = True,\n output_spatial_shape: Optional[Sequence[int]] = None,\n mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,\n padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.BORDER,\n dtype: Optional[np.dtype] = None,\n) -> None:\n # ... other code\n if data.ndim > 3: # multi channel, resampling each channel\n while len(output_spatial_shape_) < 3:\n output_spatial_shape_ = output_spatial_shape_ + [1]\n spatial_shape, channel_shape = data.shape[:3], data.shape[3:]\n data_ = data.reshape(list(spatial_shape) + [-1])\n data_ = np.moveaxis(data_, -1, 0) # channel first for pytorch\n data_ = affine_xform(\n torch.from_numpy(data_.astype(np.float64)).unsqueeze(0),\n torch.from_numpy(transform.astype(np.float64)),\n spatial_size=output_spatial_shape_[:3],\n )\n data_ = data_.squeeze(0).detach().cpu().numpy()\n data_ = np.moveaxis(data_, 0, -1) # channel last for nifti\n data_ = data_.reshape(list(data_.shape[:3]) + list(channel_shape))\n else: # single channel image, need to expand to have batch and channel\n while len(output_spatial_shape_) < len(data.shape):\n output_spatial_shape_ = output_spatial_shape_ + [1]\n data_ = affine_xform(\n torch.from_numpy((data.astype(np.float64))[None, None]),\n torch.from_numpy(transform.astype(np.float64)),\n spatial_size=output_spatial_shape_[: len(data.shape)],\n )\n data_ = data_.squeeze(0).squeeze(0).detach().cpu().numpy()\n dtype = dtype or data.dtype\n results_img = nib.Nifti1Image(data_.astype(dtype), to_affine_nd(3, target_affine))\n nib.save(results_img, file_name)\n return", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/png_saver.py_from_typing_import_Option_PNGSaver.__init__.self._data_index.0": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/png_saver.py_from_typing_import_Option_PNGSaver.__init__.self._data_index.0", "embedding": null, "metadata": {"file_path": "monai/data/png_saver.py", "file_name": "png_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 59, "span_ids": ["PNGSaver.__init__", "PNGSaver", "docstring"], "tokens": 446}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Union, Dict\n\nimport numpy as np\nimport torch\n\nfrom monai.data.png_writer import write_png\nfrom monai.data.utils import create_file_basename\nfrom monai.utils import InterpolateMode\n\n\nclass PNGSaver:\n \"\"\"\n Save the data as png file, it can support single data content or a batch of data.\n Typically, the data can be segmentation predictions, call `save` for single data\n or call `save_batch` to save a batch of data together. If no meta data provided,\n use index from 0 as the filename prefix.\n \"\"\"\n\n def __init__(\n self,\n output_dir: str = \"./\",\n output_postfix: str = \"seg\",\n output_ext: str = \".png\",\n resample: bool = True,\n mode: Union[InterpolateMode, str] = InterpolateMode.NEAREST,\n scale: Optional[int] = None,\n ) -> None:\n \"\"\"\n Args:\n output_dir: output image directory.\n output_postfix: a string appended to all output file names.\n output_ext: output file extension name.\n resample: whether to resample and resize if providing spatial_shape in the metadata.\n mode: {``\"nearest\"``, ``\"linear\"``, ``\"bilinear\"``, ``\"bicubic\"``, ``\"trilinear\"``, ``\"area\"``}\n The interpolation mode. Defaults to ``\"nearest\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n scale: {``255``, ``65535``} postprocess data by clipping to [0, 1] and scaling\n [0, 255] (uint8) or [0, 65535] (uint16). Default is None to disable scaling.\n\n \"\"\"\n self.output_dir = output_dir\n self.output_postfix = output_postfix\n self.output_ext = output_ext\n self.resample = resample\n self.mode: InterpolateMode = InterpolateMode(mode)\n self.scale = scale\n\n self._data_index = 0", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/png_saver.py_PNGSaver.save_PNGSaver.save.write_png_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/png_saver.py_PNGSaver.save_PNGSaver.save.write_png_", "embedding": null, "metadata": {"file_path": "monai/data/png_saver.py", "file_name": "png_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 61, "end_line": 103, "span_ids": ["PNGSaver.save"], "tokens": 416}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class PNGSaver:\n\n def save(self, data: Union[torch.Tensor, np.ndarray], meta_data: Optional[Dict] = None) -> None:\n \"\"\"\n Save data into a png file.\n The meta_data could optionally have the following keys:\n\n - ``'filename_or_obj'`` -- for output file name creation, corresponding to filename or object.\n - ``'spatial_shape'`` -- for data output shape.\n\n If meta_data is None, use the default index (starting from 0) as the filename.\n\n Args:\n data: target data content that to be saved as a png format file.\n Assuming the data shape are spatial dimensions.\n Shape of the spatial dimensions (C,H,W).\n C should be 1, 3 or 4\n meta_data: the meta data information corresponding to the data.\n\n Raises:\n ValueError: PNG image should only have 1, 3 or 4 channels.\n\n See Also\n :py:meth:`monai.data.png_writer.write_png`\n \"\"\"\n filename = meta_data[\"filename_or_obj\"] if meta_data else str(self._data_index)\n self._data_index += 1\n spatial_shape = meta_data.get(\"spatial_shape\", None) if meta_data and self.resample else None\n\n if torch.is_tensor(data):\n data = data.detach().cpu().numpy()\n\n filename = create_file_basename(self.output_postfix, filename, self.output_dir)\n filename = f\"{filename}{self.output_ext}\"\n\n if data.shape[0] == 1:\n data = data.squeeze(0)\n elif 2 < data.shape[0] < 5:\n data = np.moveaxis(data, 0, -1)\n else:\n raise ValueError(\"PNG image should only have 1, 3 or 4 channels.\")\n\n write_png(\n data, file_name=filename, output_spatial_shape=spatial_shape, mode=self.mode, scale=self.scale,\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/png_saver.py_PNGSaver.save_batch_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/png_saver.py_PNGSaver.save_batch_", "embedding": null, "metadata": {"file_path": "monai/data/png_saver.py", "file_name": "png_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 105, "end_line": 114, "span_ids": ["PNGSaver.save_batch"], "tokens": 129}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class PNGSaver:\n\n def save_batch(self, batch_data: Union[torch.Tensor, np.ndarray], meta_data: Optional[Dict] = None) -> None:\n \"\"\"Save a batch of data into png format files.\n\n Args:\n batch_data: target batch data content that save into png format.\n meta_data: every key-value in the meta_data is corresponding to a batch of data.\n \"\"\"\n for i, data in enumerate(batch_data): # save a batch of files\n self.save(data, {k: meta_data[k][i] for k in meta_data} if meta_data else None)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/png_writer.py_from_typing_import_Option_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/png_writer.py_from_typing_import_Option_", "embedding": null, "metadata": {"file_path": "monai/data/png_writer.py", "file_name": "png_writer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 81, "span_ids": ["write_png", "docstring"], "tokens": 790}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Sequence, Union\n\nimport numpy as np\n\nfrom monai.transforms import Resize\nfrom monai.utils import ensure_tuple_rep, optional_import, InterpolateMode\n\nImage, _ = optional_import(\"PIL\", name=\"Image\")\n\n\ndef write_png(\n data: np.ndarray,\n file_name: str,\n output_spatial_shape: Optional[Sequence[int]] = None,\n mode: Union[InterpolateMode, str] = InterpolateMode.BICUBIC,\n scale: Optional[int] = None,\n) -> None:\n \"\"\"\n Write numpy data into png files to disk.\n Spatially it supports HW for 2D.(H,W) or (H,W,3) or (H,W,4).\n If `scale` is None, expect the input data in `np.uint8` or `np.uint16` type.\n It's based on the Image module in PIL library:\n https://pillow.readthedocs.io/en/stable/reference/Image.html\n\n Args:\n data: input data to write to file.\n file_name: expected file name that saved on disk.\n output_spatial_shape: spatial shape of the output image.\n mode: {``\"nearest\"``, ``\"linear\"``, ``\"bilinear\"``, ``\"bicubic\"``, ``\"trilinear\"``, ``\"area\"``}\n The interpolation mode. Defaults to ``\"bicubic\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n scale: {``255``, ``65535``} postprocess data by clipping to [0, 1] and scaling to\n [0, 255] (uint8) or [0, 65535] (uint16). Default is None to disable scaling.\n\n Raises:\n ValueError: unsupported scale value: {scale}.\n\n \"\"\"\n assert isinstance(data, np.ndarray), \"input data must be numpy array.\"\n if len(data.shape) == 3 and data.shape[2] == 1: # PIL Image can't save image with 1 channel\n data = data.squeeze(2)\n if output_spatial_shape is not None:\n output_spatial_shape_ = ensure_tuple_rep(output_spatial_shape, 2)\n mode = InterpolateMode(mode)\n align_corners = None if mode in (InterpolateMode.NEAREST, InterpolateMode.AREA) else False\n xform = Resize(spatial_size=output_spatial_shape_, mode=mode, align_corners=align_corners)\n _min, _max = np.min(data), np.max(data)\n if len(data.shape) == 3:\n data = np.moveaxis(data, -1, 0) # to channel first\n data = xform(data)\n data = np.moveaxis(data, 0, -1)\n else: # (H, W)\n data = np.expand_dims(data, 0) # make a channel\n data = xform(data)[0] # first channel\n if mode != InterpolateMode.NEAREST:\n data = np.clip(data, _min, _max)\n\n if scale is not None:\n data = np.clip(data, 0.0, 1.0) # png writer only can scale data in range [0, 1]\n if scale == np.iinfo(np.uint8).max:\n data = (scale * data).astype(np.uint8)\n elif scale == np.iinfo(np.uint16).max:\n data = (scale * data).astype(np.uint16)\n else:\n raise ValueError(f\"unsupported scale value: {scale}.\")\n\n img = Image.fromarray(data)\n img.save(file_name, \"PNG\")\n return", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/synthetic.py_from_typing_import_Option_create_test_image_2d.return.noisyimage_labels": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/synthetic.py_from_typing_import_Option_create_test_image_2d.return.noisyimage_labels", "embedding": null, "metadata": {"file_path": "monai/data/synthetic.py", "file_name": "synthetic.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 65, "span_ids": ["create_test_image_2d", "docstring"], "tokens": 543}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional\n\nimport numpy as np\n\nfrom monai.transforms.utils import rescale_array\n\n__all__ = [\"create_test_image_2d\", \"create_test_image_3d\"]\n\n\ndef create_test_image_2d(\n width: int,\n height: int,\n num_objs: int = 12,\n rad_max: int = 30,\n noise_max: float = 0.0,\n num_seg_classes: int = 5,\n channel_dim: Optional[int] = None,\n random_state: Optional[np.random.RandomState] = None,\n):\n \"\"\"\n Return a noisy 2D image with `num_objs` circles and a 2D mask image. The maximum radius of the circles is given as\n `rad_max`. The mask will have `num_seg_classes` number of classes for segmentations labeled sequentially from 1, plus a\n background class represented as 0. If `noise_max` is greater than 0 then noise will be added to the image taken from\n the uniform distribution on range `[0,noise_max)`. If `channel_dim` is None, will create an image without channel\n dimension, otherwise create an image with channel dimension as first dim or last dim.\n \"\"\"\n image = np.zeros((width, height))\n rs = np.random if random_state is None else random_state\n\n for _ in range(num_objs):\n x = rs.randint(rad_max, width - rad_max)\n y = rs.randint(rad_max, height - rad_max)\n rad = rs.randint(5, rad_max)\n spy, spx = np.ogrid[-x : width - x, -y : height - y]\n circle = (spx * spx + spy * spy) <= rad * rad\n\n if num_seg_classes > 1:\n image[circle] = np.ceil(rs.random() * num_seg_classes)\n else:\n image[circle] = rs.random() * 0.5 + 0.5\n\n labels = np.ceil(image).astype(np.int32)\n\n norm = rs.uniform(0, num_seg_classes * noise_max, size=image.shape)\n noisyimage = rescale_array(np.maximum(image, norm))\n\n if channel_dim is not None:\n assert isinstance(channel_dim, int) and channel_dim in (-1, 0, 2), \"invalid channel dim.\"\n noisyimage, labels = (\n noisyimage[None],\n labels[None] if channel_dim == 0 else (noisyimage[..., None], labels[..., None]),\n )\n\n return noisyimage, labels", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/synthetic.py_create_test_image_3d_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/synthetic.py_create_test_image_3d_", "embedding": null, "metadata": {"file_path": "monai/data/synthetic.py", "file_name": "synthetic.py", "file_type": "text/x-python", "category": "implementation", "start_line": 68, "end_line": 113, "span_ids": ["create_test_image_3d"], "tokens": 432}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def create_test_image_3d(\n height: int,\n width: int,\n depth: int,\n num_objs: int = 12,\n rad_max: int = 30,\n noise_max: float = 0.0,\n num_seg_classes: int = 5,\n channel_dim: Optional[int] = None,\n random_state: Optional[np.random.RandomState] = None,\n):\n \"\"\"\n Return a noisy 3D image and segmentation.\n\n See also:\n :py:meth:`~create_test_image_2d`\n \"\"\"\n image = np.zeros((width, height, depth))\n rs = np.random if random_state is None else random_state\n\n for _ in range(num_objs):\n x = rs.randint(rad_max, width - rad_max)\n y = rs.randint(rad_max, height - rad_max)\n z = rs.randint(rad_max, depth - rad_max)\n rad = rs.randint(5, rad_max)\n spy, spx, spz = np.ogrid[-x : width - x, -y : height - y, -z : depth - z]\n circle = (spx * spx + spy * spy + spz * spz) <= rad * rad\n\n if num_seg_classes > 1:\n image[circle] = np.ceil(rs.random() * num_seg_classes)\n else:\n image[circle] = rs.random() * 0.5 + 0.5\n\n labels = np.ceil(image).astype(np.int32)\n\n norm = rs.uniform(0, num_seg_classes * noise_max, size=image.shape)\n noisyimage = rescale_array(np.maximum(image, norm))\n\n if channel_dim is not None:\n assert isinstance(channel_dim, int) and channel_dim in (-1, 0, 3), \"invalid channel dim.\"\n noisyimage, labels = (\n (noisyimage[None], labels[None]) if channel_dim == 0 else (noisyimage[..., None], labels[..., None])\n )\n\n return noisyimage, labels", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_from_typing_import_List__get_random_patch.return.tuple_slice_mc_mc_ps_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_from_typing_import_List__get_random_patch.return.tuple_slice_mc_mc_ps_", "embedding": null, "metadata": {"file_path": "monai/data/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 51, "span_ids": ["get_random_patch", "docstring"], "tokens": 363}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import List, Optional, Sequence, Tuple, Union, Dict\n\nimport os\nimport warnings\nimport math\nfrom itertools import starmap, product\n\nimport torch\nfrom torch.utils.data._utils.collate import default_collate\nimport numpy as np\n\nfrom monai.utils import ensure_tuple_size, optional_import, NumpyPadMode, BlendMode\nfrom monai.networks.layers.simplelayers import GaussianFilter\n\nnib, _ = optional_import(\"nibabel\")\n\n\ndef get_random_patch(\n dims: Sequence[int], patch_size: Sequence[int], rand_state: Optional[np.random.RandomState] = None\n) -> Tuple[slice, ...]:\n \"\"\"\n Returns a tuple of slices to define a random patch in an array of shape `dims` with size `patch_size` or the as\n close to it as possible within the given dimension. It is expected that `patch_size` is a valid patch for a source\n of shape `dims` as returned by `get_valid_patch_size`.\n\n Args:\n dims: shape of source array\n patch_size: shape of patch size to generate\n rand_state: a random state object to generate random numbers from\n\n Returns:\n (tuple of slice): a tuple of slice objects defining the patch\n \"\"\"\n\n # choose the minimal corner of the patch\n rand_int = np.random.randint if rand_state is None else rand_state.randint\n min_corner = tuple(rand_int(0, ms - ps) if ms > ps else 0 for ms, ps in zip(dims, patch_size))\n\n # create the slices for each dimension which define the patch in the source array\n return tuple(slice(mc, mc + ps) for mc, ps in zip(min_corner, patch_size))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_iter_patch_slices_iter_patch_slices.for_position_in_product_.yield_tuple_slice_s_s_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_iter_patch_slices_iter_patch_slices.for_position_in_product_.yield_tuple_slice_s_s_", "embedding": null, "metadata": {"file_path": "monai/data/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 54, "end_line": 79, "span_ids": ["iter_patch_slices"], "tokens": 299}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def iter_patch_slices(dims: Sequence[int], patch_size: Union[Sequence[int], int], start_pos: Sequence[int] = ()):\n \"\"\"\n Yield successive tuples of slices defining patches of size `patch_size` from an array of dimensions `dims`. The\n iteration starts from position `start_pos` in the array, or starting at the origin if this isn't provided. Each\n patch is chosen in a contiguous grid using a first dimension as least significant ordering.\n\n Args:\n dims: dimensions of array to iterate over\n patch_size: size of patches to generate slices for, 0 or None selects whole dimension\n start_pos: starting position in the array, default is 0 for each dimension\n\n Yields:\n Tuples of slice objects defining each patch\n \"\"\"\n\n # ensure patchSize and startPos are the right length\n ndim = len(dims)\n patch_size_ = get_valid_patch_size(dims, patch_size)\n start_pos = ensure_tuple_size(start_pos, ndim)\n\n # collect the ranges to step over each dimension\n ranges = tuple(starmap(range, zip(start_pos, dims, patch_size_)))\n\n # choose patches by applying product to the ranges\n for position in product(*ranges[::-1]): # reverse ranges order to iterate in index order\n yield tuple(slice(s, s + p) for s, p in zip(position[::-1], patch_size_))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_dense_patch_slices_dense_patch_slices.return.slices": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_dense_patch_slices_dense_patch_slices.return.slices", "embedding": null, "metadata": {"file_path": "monai/data/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 82, "end_line": 138, "span_ids": ["dense_patch_slices"], "tokens": 591}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def dense_patch_slices(\n image_size: Sequence[int], patch_size: Sequence[int], scan_interval: Sequence[int],\n) -> List[Tuple[slice, ...]]:\n \"\"\"\n Enumerate all slices defining 2D/3D patches of size `patch_size` from an `image_size` input image.\n\n Args:\n image_size: dimensions of image to iterate over\n patch_size: size of patches to generate slices\n scan_interval: dense patch sampling interval\n\n Returns:\n a list of slice objects defining each patch\n\n Raises:\n ValueError: image_size should have 2 or 3 elements\n\n \"\"\"\n num_spatial_dims = len(image_size)\n if num_spatial_dims not in (2, 3):\n raise ValueError(\"image_size should have 2 or 3 elements\")\n patch_size = get_valid_patch_size(image_size, patch_size)\n scan_interval = ensure_tuple_size(scan_interval, num_spatial_dims)\n\n scan_num = [\n int(math.ceil(float(image_size[i]) / scan_interval[i])) if scan_interval[i] != 0 else 1\n for i in range(num_spatial_dims)\n ]\n slices: List[Tuple[slice, ...]] = []\n if num_spatial_dims == 3:\n for i in range(scan_num[0]):\n start_i = i * scan_interval[0]\n start_i -= max(start_i + patch_size[0] - image_size[0], 0)\n slice_i = slice(start_i, start_i + patch_size[0])\n\n for j in range(scan_num[1]):\n start_j = j * scan_interval[1]\n start_j -= max(start_j + patch_size[1] - image_size[1], 0)\n slice_j = slice(start_j, start_j + patch_size[1])\n\n for k in range(0, scan_num[2]):\n start_k = k * scan_interval[2]\n start_k -= max(start_k + patch_size[2] - image_size[2], 0)\n slice_k = slice(start_k, start_k + patch_size[2])\n slices.append((slice_i, slice_j, slice_k))\n else:\n for i in range(scan_num[0]):\n start_i = i * scan_interval[0]\n start_i -= max(start_i + patch_size[0] - image_size[0], 0)\n slice_i = slice(start_i, start_i + patch_size[0])\n\n for j in range(scan_num[1]):\n start_j = j * scan_interval[1]\n start_j -= max(start_j + patch_size[1] - image_size[1], 0)\n slice_j = slice(start_j, start_j + patch_size[1])\n slices.append((slice_i, slice_j))\n return slices", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_iter_patch_iter_patch.if_copy_back_.arr_arrpad_slices_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_iter_patch_iter_patch.if_copy_back_.arr_arrpad_slices_", "embedding": null, "metadata": {"file_path": "monai/data/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 141, "end_line": 189, "span_ids": ["iter_patch"], "tokens": 641}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def iter_patch(\n arr: np.ndarray,\n patch_size: Union[Sequence[int], int] = 0,\n start_pos: Sequence[int] = (),\n copy_back: bool = True,\n mode: Union[NumpyPadMode, str] = NumpyPadMode.WRAP,\n **pad_opts: Dict,\n):\n \"\"\"\n Yield successive patches from `arr` of size `patch_size`. The iteration can start from position `start_pos` in `arr`\n but drawing from a padded array extended by the `patch_size` in each dimension (so these coordinates can be negative\n to start in the padded region). If `copy_back` is True the values from each patch are written back to `arr`.\n\n Args:\n arr: array to iterate over\n patch_size: size of patches to generate slices for, 0 or None selects whole dimension\n start_pos: starting position in the array, default is 0 for each dimension\n copy_back: if True data from the yielded patches is copied back to `arr` once the generator completes\n mode: {``\"constant\"``, ``\"edge\"``, ``\"linear_ramp\"``, ``\"maximum\"``, ``\"mean\"``,\n ``\"median\"``, ``\"minimum\"``, ``\"reflect\"``, ``\"symmetric\"``, ``\"wrap\"``, ``\"empty\"``}\n One of the listed string values or a user supplied function. Defaults to ``\"wrap\"``.\n See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html\n pad_opts: padding options, see `numpy.pad`\n\n Yields:\n Patches of array data from `arr` which are views into a padded array which can be modified, if `copy_back` is\n True these changes will be reflected in `arr` once the iteration completes.\n \"\"\"\n # ensure patchSize and startPos are the right length\n patch_size_ = get_valid_patch_size(arr.shape, patch_size)\n start_pos = ensure_tuple_size(start_pos, arr.ndim)\n\n # pad image by maximum values needed to ensure patches are taken from inside an image\n arrpad = np.pad(arr, tuple((p, p) for p in patch_size_), NumpyPadMode(mode).value, **pad_opts)\n\n # choose a start position in the padded image\n start_pos_padded = tuple(s + p for s, p in zip(start_pos, patch_size_))\n\n # choose a size to iterate over which is smaller than the actual padded image to prevent producing\n # patches which are only in the padded regions\n iter_size = tuple(s + p for s, p in zip(arr.shape, patch_size_))\n\n for slices in iter_patch_slices(iter_size, patch_size_, start_pos_padded):\n yield arrpad[slices]\n\n # copy back data from the padded image if required\n if copy_back:\n slices = tuple(slice(p, p + s) for p, s in zip(patch_size_, arr.shape))\n arr[...] = arrpad[slices]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_get_valid_patch_size_get_valid_patch_size.return.tuple_min_ms_ps_or_ms_f": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_get_valid_patch_size_get_valid_patch_size.return.tuple_min_ms_ps_or_ms_f", "embedding": null, "metadata": {"file_path": "monai/data/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 192, "end_line": 203, "span_ids": ["get_valid_patch_size"], "tokens": 205}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def get_valid_patch_size(image_size: Sequence[int], patch_size: Union[Sequence[int], int]):\n \"\"\"\n Given an image of dimensions `image_size`, return a patch size tuple taking the dimension from `patch_size` if this is\n not 0/None. Otherwise, or if `patch_size` is shorter than `image_size`, the dimension from `image_size` is taken. This ensures\n the returned patch size is within the bounds of `image_size`. If `patch_size` is a single number this is interpreted as a\n patch of the same dimensionality of `image_size` with that size in each dimension.\n \"\"\"\n ndim = len(image_size)\n patch_size_ = ensure_tuple_size(patch_size, ndim)\n\n # ensure patch size dimensions are not larger than image dimension, if a dimension is None or 0 use whole dimension\n return tuple(min(ms, ps or ms) for ms, ps in zip(image_size, patch_size_))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_list_data_collate_worker_init_fn.if_hasattr_worker_info_da.worker_info_dataset_trans": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_list_data_collate_worker_init_fn.if_hasattr_worker_info_da.worker_info_dataset_trans", "embedding": null, "metadata": {"file_path": "monai/data/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 206, "end_line": 229, "span_ids": ["list_data_collate", "worker_init_fn"], "tokens": 212}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def list_data_collate(batch: Sequence):\n \"\"\"\n Enhancement for PyTorch DataLoader default collate.\n If dataset already returns a list of batch data that generated in transforms, need to merge all data to 1 list.\n Then it's same as the default collate behavior.\n\n Note:\n Need to use this collate if apply some transforms that can generate batch data.\n\n \"\"\"\n elem = batch[0]\n data = [i for k in batch for i in k] if isinstance(elem, list) else batch\n return default_collate(data)\n\n\ndef worker_init_fn(worker_id: int) -> None:\n \"\"\"\n Callback function for PyTorch DataLoader `worker_init_fn`.\n It can set different random seed for the transforms in different workers.\n\n \"\"\"\n worker_info = torch.utils.data.get_worker_info()\n if hasattr(worker_info.dataset, \"transform\") and hasattr(worker_info.dataset.transform, \"set_random_state\"):\n worker_info.dataset.transform.set_random_state(worker_info.seed % (2 ** 32))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_correct_nifti_header_if_necessary_correct_nifti_header_if_necessary.return.img_nii": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_correct_nifti_header_if_necessary_correct_nifti_header_if_necessary.return.img_nii", "embedding": null, "metadata": {"file_path": "monai/data/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 232, "end_line": 250, "span_ids": ["correct_nifti_header_if_necessary"], "tokens": 192}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def correct_nifti_header_if_necessary(img_nii):\n \"\"\"\n Check nifti object header's format, update the header if needed.\n In the updated image pixdim matches the affine.\n\n Args:\n img_nii (nifti image object)\n \"\"\"\n dim = img_nii.header[\"dim\"][0]\n if dim >= 5:\n return img_nii # do nothing for high-dimensional array\n # check that affine matches zooms\n pixdim = np.asarray(img_nii.header.get_zooms())[:dim]\n norm_affine = np.sqrt(np.sum(np.square(img_nii.affine[:dim, :dim]), 0))\n if np.allclose(pixdim, norm_affine):\n return img_nii\n if hasattr(img_nii, \"get_sform\"):\n return rectify_header_sform_qform(img_nii)\n return img_nii", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_rectify_header_sform_qform_rectify_header_sform_qform.return.img_nii": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_rectify_header_sform_qform_rectify_header_sform_qform.return.img_nii", "embedding": null, "metadata": {"file_path": "monai/data/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 253, "end_line": 285, "span_ids": ["rectify_header_sform_qform"], "tokens": 374}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def rectify_header_sform_qform(img_nii):\n \"\"\"\n Look at the sform and qform of the nifti object and correct it if any\n incompatibilities with pixel dimensions\n\n Adapted from https://github.com/NifTK/NiftyNet/blob/v0.6.0/niftynet/io/misc_io.py\n \"\"\"\n d = img_nii.header[\"dim\"][0]\n pixdim = np.asarray(img_nii.header.get_zooms())[:d]\n sform, qform = img_nii.get_sform(), img_nii.get_qform()\n norm_sform = np.sqrt(np.sum(np.square(sform[:d, :d]), 0))\n norm_qform = np.sqrt(np.sum(np.square(qform[:d, :d]), 0))\n sform_mismatch = not np.allclose(norm_sform, pixdim)\n qform_mismatch = not np.allclose(norm_qform, pixdim)\n\n if img_nii.header[\"sform_code\"] != 0:\n if not sform_mismatch:\n return img_nii\n if not qform_mismatch:\n img_nii.set_sform(img_nii.get_qform())\n return img_nii\n if img_nii.header[\"qform_code\"] != 0:\n if not qform_mismatch:\n return img_nii\n if not sform_mismatch:\n img_nii.set_qform(img_nii.get_sform())\n return img_nii\n\n norm = np.sqrt(np.sum(np.square(img_nii.affine[:d, :d]), 0))\n warnings.warn(f\"Modifying image pixdim from {pixdim} to {norm}\")\n\n img_nii.header.set_zooms(norm)\n return img_nii", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_zoom_affine_zoom_affine.return.new_affine": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_zoom_affine_zoom_affine.return.new_affine", "embedding": null, "metadata": {"file_path": "monai/data/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 288, "end_line": 333, "span_ids": ["zoom_affine"], "tokens": 496}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def zoom_affine(affine, scale: Sequence[float], diagonal: bool = True):\n \"\"\"\n To make column norm of `affine` the same as `scale`. If diagonal is False,\n returns an affine that combines orthogonal rotation and the new scale.\n This is done by first decomposing `affine`, then setting the zoom factors to\n `scale`, and composing a new affine; the shearing factors are removed. If\n diagonal is True, returns a diagonal matrix, the scaling factors are set\n to the diagonal elements. This function always return an affine with zero\n translations.\n\n Args:\n affine (nxn matrix): a square matrix.\n scale: new scaling factor along each dimension.\n diagonal: whether to return a diagonal scaling matrix.\n Defaults to True.\n\n Returns:\n the updated `n x n` affine.\n\n Raises:\n ValueError: affine should be a square matrix\n ValueError: scale must be a sequence of positive numbers.\n\n \"\"\"\n affine = np.array(affine, dtype=float, copy=True)\n if len(affine) != len(affine[0]):\n raise ValueError(\"affine should be a square matrix\")\n scale_ = np.array(scale, dtype=float, copy=True)\n if np.any(scale_ <= 0):\n raise ValueError(\"scale must be a sequence of positive numbers.\")\n d = len(affine) - 1\n if len(scale_) < d: # defaults based on affine\n norm = np.sqrt(np.sum(np.square(affine), 0))[:-1]\n scale_ = np.append(scale_, norm[len(scale_) :])\n scale_ = scale_[:d]\n scale_[scale_ == 0] = 1.0\n if diagonal:\n return np.diag(np.append(scale_, [1.0]))\n rzs = affine[:-1, :-1] # rotation zoom scale\n zs = np.linalg.cholesky(rzs.T @ rzs).T\n rotation = rzs @ np.linalg.inv(zs)\n s = np.sign(np.diag(zs)) * np.abs(scale_)\n # construct new affine with rotation and zoom\n new_affine = np.eye(len(affine))\n new_affine[:-1, :-1] = rotation @ np.diag(s)\n return new_affine", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_compute_shape_offset_compute_shape_offset.return.out_shape_astype_int_of": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_compute_shape_offset_compute_shape_offset.return.out_shape_astype_int_of", "embedding": null, "metadata": {"file_path": "monai/data/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 336, "end_line": 362, "span_ids": ["compute_shape_offset"], "tokens": 345}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def compute_shape_offset(spatial_shape, in_affine, out_affine):\n \"\"\"\n Given input and output affine, compute appropriate shapes\n in the output space based on the input array's shape.\n This function also returns the offset to put the shape\n in a good position with respect to the world coordinate system.\n \"\"\"\n shape = np.array(spatial_shape, copy=True, dtype=float)\n sr = len(shape)\n in_affine = to_affine_nd(sr, in_affine)\n out_affine = to_affine_nd(sr, out_affine)\n in_coords = [(0.0, dim - 1.0) for dim in shape]\n corners = np.asarray(np.meshgrid(*in_coords, indexing=\"ij\")).reshape((len(shape), -1))\n corners = np.concatenate((corners, np.ones_like(corners[:1])))\n corners = in_affine @ corners\n corners_out = np.linalg.inv(out_affine) @ corners\n corners_out = corners_out[:-1] / corners_out[-1]\n out_shape = np.round(corners_out.ptp(axis=1) + 1.0)\n if np.allclose(nib.io_orientation(in_affine), nib.io_orientation(out_affine)):\n # same orientation, get translate from the origin\n offset = in_affine @ ([0] * sr + [1])\n offset = offset[:-1] / offset[-1]\n else:\n # different orientation, the min is the origin\n corners = corners[:-1] / corners[-1]\n offset = np.min(corners, 1)\n return out_shape.astype(int), offset", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_to_affine_nd_to_affine_nd.return.new_affine": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_to_affine_nd_to_affine_nd.return.new_affine", "embedding": null, "metadata": {"file_path": "monai/data/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 365, "end_line": 406, "span_ids": ["to_affine_nd"], "tokens": 494}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def to_affine_nd(r, affine):\n \"\"\"\n Using elements from affine, to create a new affine matrix by\n assigning the rotation/zoom/scaling matrix and the translation vector.\n\n when ``r`` is an integer, output is an (r+1)x(r+1) matrix,\n where the top left kxk elements are copied from ``affine``,\n the last column of the output affine is copied from ``affine``'s last column.\n `k` is determined by `min(r, len(affine) - 1)`.\n\n when ``r`` is an affine matrix, the output has the same as ``r``,\n the top left kxk elements are copied from ``affine``,\n the last column of the output affine is copied from ``affine``'s last column.\n `k` is determined by `min(len(r) - 1, len(affine) - 1)`.\n\n\n Args:\n r (int or matrix): number of spatial dimensions or an output affine to be filled.\n affine (matrix): 2D affine matrix\n\n Returns:\n an (r+1) x (r+1) matrix\n\n Raises:\n ValueError: input affine matrix must have two dimensions, got {affine.ndim}.\n ValueError: r must be positive, got {sr}.\n\n \"\"\"\n affine_ = np.array(affine, dtype=np.float64)\n if affine_.ndim != 2:\n raise ValueError(f\"input affine matrix must have two dimensions, got {affine_.ndim}.\")\n new_affine = np.array(r, dtype=np.float64, copy=True)\n if new_affine.ndim == 0:\n sr = new_affine.astype(int)\n if not np.isfinite(sr) or sr < 0:\n raise ValueError(f\"r must be positive, got {sr}.\")\n new_affine = np.eye(sr + 1, dtype=np.float64)\n d = max(min(len(new_affine) - 1, len(affine_) - 1), 1)\n new_affine[:d, :d] = affine_[:d, :d]\n if d > 1:\n new_affine[:d, -1] = affine_[:d, -1]\n return new_affine", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_create_file_basename_create_file_basename.return.os_path_join_subfolder_pa": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_create_file_basename_create_file_basename.return.os_path_join_subfolder_pa", "embedding": null, "metadata": {"file_path": "monai/data/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 409, "end_line": 443, "span_ids": ["create_file_basename"], "tokens": 354}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def create_file_basename(postfix: str, input_file_name: str, folder_path: str, data_root_dir: str = \"\") -> str:\n \"\"\"\n Utility function to create the path to the output file based on the input\n filename (extension is added by lib level writer before writing the file)\n\n Args:\n postfix: output name's postfix\n input_file_name: path to the input image file\n folder_path: path for the output file\n data_root_dir: if not empty, it specifies the beginning parts of the input file's\n absolute path. This is used to compute `input_file_rel_path`, the relative path to the file from\n `data_root_dir` to preserve folder structure when saving in case there are files in different\n folders with the same file names.\n \"\"\"\n\n # get the filename and directory\n filedir, filename = os.path.split(input_file_name)\n\n # jettison the extension to have just filename\n filename, ext = os.path.splitext(filename)\n while ext != \"\":\n filename, ext = os.path.splitext(filename)\n\n # use data_root_dir to find relative path to file\n filedir_rel_path = \"\"\n if data_root_dir:\n filedir_rel_path = os.path.relpath(filedir, data_root_dir)\n\n # sub-folder path will be original name without the extension\n subfolder_path = os.path.join(folder_path, filedir_rel_path, filename)\n if not os.path.exists(subfolder_path):\n os.makedirs(subfolder_path)\n\n # add the sub-folder plus the postfix name to become the file basename in the output path\n return os.path.join(subfolder_path, filename + \"_\" + postfix)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_compute_importance_map_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_compute_importance_map_", "embedding": null, "metadata": {"file_path": "monai/data/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 446, "end_line": 494, "span_ids": ["compute_importance_map"], "tokens": 459}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def compute_importance_map(\n patch_size: Tuple[int, ...],\n mode: Union[BlendMode, str] = BlendMode.CONSTANT,\n sigma_scale: float = 0.125,\n device: Optional[torch.device] = None,\n):\n \"\"\"Get importance map for different weight modes.\n\n Args:\n patch_size: Size of the required importance map. This should be either H, W [,D].\n mode: {``\"constant\"``, ``\"gaussian\"``}\n How to blend output of overlapping windows. Defaults to ``\"constant\"``.\n\n - ``\"constant``\": gives equal weight to all predictions.\n - ``\"gaussian``\": gives less weight to predictions on edges of windows.\n\n sigma_scale: Sigma_scale to calculate sigma for each dimension\n (sigma = sigma_scale * dim_size). Used for gaussian mode only.\n device: Device to put importance map on.\n\n Returns:\n Tensor of size patch_size.\n\n Raises:\n ValueError: mode must be \"constant\" or \"gaussian\".\n\n \"\"\"\n mode = BlendMode(mode)\n if mode == BlendMode.CONSTANT:\n importance_map = torch.ones(patch_size, device=device).float()\n elif mode == BlendMode.GAUSSIAN:\n center_coords = [i // 2 for i in patch_size]\n sigmas = [i * sigma_scale for i in patch_size]\n\n importance_map = torch.zeros(patch_size, device=device)\n importance_map[tuple(center_coords)] = 1\n pt_gaussian = GaussianFilter(len(patch_size), sigmas).to(device=device, dtype=torch.float)\n importance_map = pt_gaussian(importance_map.unsqueeze(0).unsqueeze(0))\n importance_map = importance_map.squeeze(0).squeeze(0)\n importance_map = importance_map / torch.max(importance_map)\n importance_map = importance_map.float()\n\n # importance_map cannot be 0, otherwise we may end up with nans!\n importance_map[importance_map == 0] = torch.min(importance_map[importance_map != 0])\n else:\n raise ValueError('mode must be \"constant\" or \"gaussian\".')\n\n return importance_map", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/__init__.py_from_multi_gpu_supervise_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/__init__.py_from_multi_gpu_supervise_", "embedding": null, "metadata": {"file_path": "monai/engines/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 15, "span_ids": ["docstring"], "tokens": 21}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from .multi_gpu_supervised_trainer import *\nfrom .trainer import *\nfrom .evaluator import *", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_from_typing_import_Callab_if_TYPE_CHECKING_.else_.Metric___optional_impo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_from_typing_import_Callab_if_TYPE_CHECKING_.else_.Metric___optional_impo", "embedding": null, "metadata": {"file_path": "monai/engines/evaluator.py", "file_name": "evaluator.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 29, "span_ids": ["docstring"], "tokens": 164}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Dict, Optional, Sequence, Union, TYPE_CHECKING\n\nimport torch\nfrom torch.utils.data import DataLoader\n\nfrom monai.inferers import Inferer, SimpleInferer\nfrom monai.transforms import Transform\nfrom monai.engines.utils import CommonKeys as Keys\nfrom monai.engines.utils import default_prepare_batch\nfrom monai.engines.workflow import Workflow\nfrom monai.utils import exact_version, optional_import, ensure_tuple\n\nif TYPE_CHECKING:\n from ignite.engine import Engine\n from ignite.metrics import Metric\nelse:\n Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")\n Metric, _ = optional_import(\"ignite.metrics\", \"0.3.0\", exact_version, \"Metric\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_Evaluator_Evaluator.get_validation_stats.return._best_validation_metric_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_Evaluator_Evaluator.get_validation_stats.return._best_validation_metric_", "embedding": null, "metadata": {"file_path": "monai/engines/evaluator.py", "file_name": "evaluator.py", "file_type": "text/x-python", "category": "implementation", "start_line": 32, "end_line": 92, "span_ids": ["Evaluator.get_validation_stats", "Evaluator.__init__", "Evaluator", "Evaluator.run"], "tokens": 540}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Evaluator(Workflow):\n \"\"\"\n Base class for all kinds of evaluators, inherits from Workflow.\n\n Args:\n device: an object representing the device on which to run.\n val_data_loader: Ignite engine use data_loader to run, must be torch.DataLoader.\n prepare_batch: function to parse image and label for current iteration.\n iteration_update: the callable function for every iteration, expect to accept `engine`\n and `batchdata` as input parameters. if not provided, use `self._iteration()` instead.\n post_transform: execute additional transformation for the model output data.\n Typically, several Tensor based transforms composed by `Compose`.\n key_val_metric: compute metric when every iteration completed, and save average value to\n engine.state.metrics when epoch completed. key_val_metric is the main metric to compare and save the\n checkpoint into files.\n additional_metrics: more Ignite metrics that also attach to Ignite Engine.\n val_handlers: every handler is a set of Ignite Event-Handlers, must have `attach` function, like:\n CheckpointHandler, StatsHandler, SegmentationSaver, etc.\n\n \"\"\"\n\n def __init__(\n self,\n device: torch.device,\n val_data_loader: DataLoader,\n prepare_batch: Callable = default_prepare_batch,\n iteration_update: Optional[Callable] = None,\n post_transform: Optional[Transform] = None,\n key_val_metric: Optional[Dict[str, Metric]] = None,\n additional_metrics: Optional[Dict[str, Metric]] = None,\n val_handlers: Optional[Sequence] = None,\n ) -> None:\n super().__init__(\n device=device,\n max_epochs=1,\n amp=False,\n data_loader=val_data_loader,\n prepare_batch=prepare_batch,\n iteration_update=iteration_update,\n post_transform=post_transform,\n key_metric=key_val_metric,\n additional_metrics=additional_metrics,\n handlers=val_handlers,\n )\n\n def run(self, global_epoch: int = 1) -> None:\n \"\"\"\n Execute validation/evaluation based on Ignite Engine.\n\n Args:\n global_epoch: the overall epoch if during a training. evaluator engine can get it from trainer.\n\n \"\"\"\n # init env value for current validation process\n self.state.max_epochs = global_epoch\n self.state.epoch = global_epoch - 1\n self.state.iteration = 0\n super().run()\n\n def get_validation_stats(self) -> Dict[str, Union[int, float]]:\n return {\"best_validation_metric\": self.state.best_metric, \"best_validation_epoch\": self.state.best_metric_epoch}", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_SupervisedEvaluator_SupervisedEvaluator.__init__.self.inferer.inferer": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_SupervisedEvaluator_SupervisedEvaluator.__init__.self.inferer.inferer", "embedding": null, "metadata": {"file_path": "monai/engines/evaluator.py", "file_name": "evaluator.py", "file_type": "text/x-python", "category": "implementation", "start_line": 95, "end_line": 143, "span_ids": ["SupervisedEvaluator.__init__", "SupervisedEvaluator"], "tokens": 463}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SupervisedEvaluator(Evaluator):\n \"\"\"\n Standard supervised evaluation method with image and label(optional), inherits from evaluator and Workflow.\n\n Args:\n device: an object representing the device on which to run.\n val_data_loader: Ignite engine use data_loader to run, must be torch.DataLoader.\n network: use the network to run model forward.\n prepare_batch: function to parse image and label for current iteration.\n iteration_update: the callable function for every iteration, expect to accept `engine`\n and `batchdata` as input parameters. if not provided, use `self._iteration()` instead.\n inferer: inference method that execute model forward on input data, like: SlidingWindow, etc.\n post_transform: execute additional transformation for the model output data.\n Typically, several Tensor based transforms composed by `Compose`.\n key_val_metric: compute metric when every iteration completed, and save average value to\n engine.state.metrics when epoch completed. key_val_metric is the main metric to compare and save the\n checkpoint into files.\n additional_metrics: more Ignite metrics that also attach to Ignite Engine.\n val_handlers: every handler is a set of Ignite Event-Handlers, must have `attach` function, like:\n CheckpointHandler, StatsHandler, SegmentationSaver, etc.\n\n \"\"\"\n\n def __init__(\n self,\n device: torch.device,\n val_data_loader: DataLoader,\n network: torch.nn.Module,\n prepare_batch: Callable = default_prepare_batch,\n iteration_update: Optional[Callable] = None,\n inferer: Inferer = SimpleInferer(),\n post_transform: Optional[Transform] = None,\n key_val_metric: Optional[Dict[str, Metric]] = None,\n additional_metrics: Optional[Dict[str, Metric]] = None,\n val_handlers: Optional[Sequence] = None,\n ):\n super().__init__(\n device=device,\n val_data_loader=val_data_loader,\n prepare_batch=prepare_batch,\n iteration_update=iteration_update,\n post_transform=post_transform,\n key_val_metric=key_val_metric,\n additional_metrics=additional_metrics,\n val_handlers=val_handlers,\n )\n\n self.network = network\n self.inferer = inferer", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_SupervisedEvaluator._iteration_SupervisedEvaluator._iteration.return._Keys_IMAGE_inputs_Keys": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_SupervisedEvaluator._iteration_SupervisedEvaluator._iteration.return._Keys_IMAGE_inputs_Keys", "embedding": null, "metadata": {"file_path": "monai/engines/evaluator.py", "file_name": "evaluator.py", "file_type": "text/x-python", "category": "implementation", "start_line": 145, "end_line": 173, "span_ids": ["SupervisedEvaluator._iteration"], "tokens": 265}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SupervisedEvaluator(Evaluator):\n\n def _iteration(self, engine: Engine, batchdata: Union[Dict, Sequence]) -> Dict[str, torch.Tensor]:\n \"\"\"\n callback function for the Supervised Evaluation processing logic of 1 iteration in Ignite Engine.\n Return below items in a dictionary:\n - IMAGE: image Tensor data for model input, already moved to device.\n - LABEL: label Tensor data corresponding to the image, already moved to device.\n - PRED: prediction result of model.\n\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n batchdata: input data for this iteration, usually can be dictionary or tuple of Tensor data.\n\n Raises:\n ValueError: must provide batch data for current iteration.\n\n \"\"\"\n if batchdata is None:\n raise ValueError(\"must provide batch data for current iteration.\")\n inputs, targets = self.prepare_batch(batchdata)\n inputs = inputs.to(engine.state.device)\n if targets is not None:\n targets = targets.to(engine.state.device)\n\n # execute forward computation\n self.network.eval()\n with torch.no_grad():\n predictions = self.inferer(inputs, self.network)\n\n return {Keys.IMAGE: inputs, Keys.LABEL: targets, Keys.PRED: predictions}", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_EnsembleEvaluator_EnsembleEvaluator.__init__.self.inferer.inferer": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_EnsembleEvaluator_EnsembleEvaluator.__init__.self.inferer.inferer", "embedding": null, "metadata": {"file_path": "monai/engines/evaluator.py", "file_name": "evaluator.py", "file_type": "text/x-python", "category": "implementation", "start_line": 176, "end_line": 229, "span_ids": ["EnsembleEvaluator", "EnsembleEvaluator.__init__"], "tokens": 525}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class EnsembleEvaluator(Evaluator):\n \"\"\"\n Ensemble evaluation for multiple models, inherits from evaluator and Workflow.\n It accepts a list of models for inference and outputs a list of predictions for further operations.\n\n Args:\n device: an object representing the device on which to run.\n val_data_loader: Ignite engine use data_loader to run, must be torch.DataLoader.\n networks: use the networks to run model forward in order.\n pred_keys: the keys to store every prediction data.\n the length must exactly match the number of networks.\n prepare_batch: function to parse image and label for current iteration.\n iteration_update: the callable function for every iteration, expect to accept `engine`\n and `batchdata` as input parameters. if not provided, use `self._iteration()` instead.\n inferer: inference method that execute model forward on input data, like: SlidingWindow, etc.\n post_transform: execute additional transformation for the model output data.\n Typically, several Tensor based transforms composed by `Compose`.\n key_val_metric: compute metric when every iteration completed, and save average value to\n engine.state.metrics when epoch completed. key_val_metric is the main metric to compare and save the\n checkpoint into files.\n additional_metrics: more Ignite metrics that also attach to Ignite Engine.\n val_handlers: every handler is a set of Ignite Event-Handlers, must have `attach` function, like:\n CheckpointHandler, StatsHandler, SegmentationSaver, etc.\n\n \"\"\"\n\n def __init__(\n self,\n device: torch.device,\n val_data_loader: DataLoader,\n networks: Sequence[torch.nn.Module],\n pred_keys: Sequence[str],\n prepare_batch: Callable = default_prepare_batch,\n iteration_update: Optional[Callable] = None,\n inferer: Inferer = SimpleInferer(),\n post_transform: Optional[Transform] = None,\n key_val_metric: Optional[Dict[str, Metric]] = None,\n additional_metrics: Optional[Dict[str, Metric]] = None,\n val_handlers: Optional[Sequence] = None,\n ):\n super().__init__(\n device=device,\n val_data_loader=val_data_loader,\n prepare_batch=prepare_batch,\n iteration_update=iteration_update,\n post_transform=post_transform,\n key_val_metric=key_val_metric,\n additional_metrics=additional_metrics,\n val_handlers=val_handlers,\n )\n\n self.networks = ensure_tuple(networks)\n self.pred_keys = ensure_tuple(pred_keys)\n self.inferer = inferer", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_EnsembleEvaluator._iteration_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_EnsembleEvaluator._iteration_", "embedding": null, "metadata": {"file_path": "monai/engines/evaluator.py", "file_name": "evaluator.py", "file_type": "text/x-python", "category": "implementation", "start_line": 231, "end_line": 265, "span_ids": ["EnsembleEvaluator._iteration"], "tokens": 319}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class EnsembleEvaluator(Evaluator):\n\n def _iteration(self, engine: Engine, batchdata: Union[Dict, Sequence]) -> Dict[str, torch.Tensor]:\n \"\"\"\n callback function for the Supervised Evaluation processing logic of 1 iteration in Ignite Engine.\n Return below items in a dictionary:\n - IMAGE: image Tensor data for model input, already moved to device.\n - LABEL: label Tensor data corresponding to the image, already moved to device.\n - pred_keys[0]: prediction result of network 0.\n - pred_keys[1]: prediction result of network 1.\n - ... ...\n - pred_keys[N]: prediction result of network N.\n\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n batchdata: input data for this iteration, usually can be dictionary or tuple of Tensor data.\n\n Raises:\n ValueError: must provide batch data for current iteration.\n\n \"\"\"\n if batchdata is None:\n raise ValueError(\"must provide batch data for current iteration.\")\n inputs, targets = self.prepare_batch(batchdata)\n inputs = inputs.to(engine.state.device)\n if targets is not None:\n targets = targets.to(engine.state.device)\n\n # execute forward computation\n predictions: Dict[str, torch.Tensor] = {Keys.IMAGE: inputs, Keys.LABEL: targets}\n for idx, network in enumerate(self.networks):\n network.eval()\n with torch.no_grad():\n predictions.update({self.pred_keys[idx]: self.inferer(inputs, network)})\n\n return predictions", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/multi_gpu_supervised_trainer.py_from_typing_import_Callab__default_eval_transform.return.y_pred_y": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/multi_gpu_supervised_trainer.py_from_typing_import_Callab__default_eval_transform.return.y_pred_y", "embedding": null, "metadata": {"file_path": "monai/engines/multi_gpu_supervised_trainer.py", "file_name": "multi_gpu_supervised_trainer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 34, "span_ids": ["_default_eval_transform", "_default_transform", "docstring"], "tokens": 212}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Dict, Optional, Sequence, TYPE_CHECKING\n\nimport torch\nfrom torch.optim.optimizer import Optimizer\n\nfrom monai.utils import exact_version, optional_import\nfrom monai.engines.utils import get_devices_spec\n\ncreate_supervised_trainer, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"create_supervised_trainer\")\ncreate_supervised_evaluator, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"create_supervised_evaluator\")\n_prepare_batch, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"_prepare_batch\")\nif TYPE_CHECKING:\n from ignite.metrics import Metric\nelse:\n Metric, _ = optional_import(\"ignite.metrics\", \"0.3.0\", exact_version, \"Metric\")\n\n\ndef _default_transform(_x, _y, _y_pred, loss):\n return loss.item()\n\n\ndef _default_eval_transform(x, y, y_pred):\n return y_pred, y", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/multi_gpu_supervised_trainer.py_create_multigpu_supervised_trainer_create_multigpu_supervised_trainer.return.create_supervised_trainer": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/multi_gpu_supervised_trainer.py_create_multigpu_supervised_trainer_create_multigpu_supervised_trainer.return.create_supervised_trainer", "embedding": null, "metadata": {"file_path": "monai/engines/multi_gpu_supervised_trainer.py", "file_name": "multi_gpu_supervised_trainer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 37, "end_line": 79, "span_ids": ["create_multigpu_supervised_trainer"], "tokens": 385}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def create_multigpu_supervised_trainer(\n net: torch.nn.Module,\n optimizer: Optimizer,\n loss_fn: Callable,\n devices: Optional[Sequence[torch.device]] = None,\n non_blocking: bool = False,\n prepare_batch: Callable = _prepare_batch,\n output_transform: Callable = _default_transform,\n):\n \"\"\"\n Derived from `create_supervised_trainer` in Ignite.\n\n Factory function for creating a trainer for supervised models.\n\n Args:\n net: the network to train.\n optimizer: the optimizer to use.\n loss_fn: the loss function to use.\n devices: device(s) type specification (default: None).\n Applies to both model and batches. None is all devices used, empty list is CPU only.\n non_blocking: if True and this copy is between CPU and GPU, the copy may occur asynchronously\n with respect to the host. For other cases, this argument has no effect.\n prepare_batch: function that receives `batch`, `device`, `non_blocking` and outputs\n tuple of tensors `(batch_x, batch_y)`.\n output_transform: function that receives 'x', 'y', 'y_pred', 'loss' and returns value\n to be assigned to engine's state.output after each iteration. Default is returning `loss.item()`.\n\n Returns:\n Engine: a trainer engine with supervised update function.\n\n Note:\n `engine.state.output` for this engine is defined by `output_transform` parameter and is the loss\n of the processed batch by default.\n \"\"\"\n\n devices_ = get_devices_spec(devices)\n\n if len(devices_) > 1:\n net = torch.nn.parallel.DataParallel(net)\n\n return create_supervised_trainer(\n net, optimizer, loss_fn, devices_[0], non_blocking, prepare_batch, output_transform\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/multi_gpu_supervised_trainer.py_create_multigpu_supervised_evaluator_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/multi_gpu_supervised_trainer.py_create_multigpu_supervised_evaluator_", "embedding": null, "metadata": {"file_path": "monai/engines/multi_gpu_supervised_trainer.py", "file_name": "multi_gpu_supervised_trainer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 82, "end_line": 122, "span_ids": ["create_multigpu_supervised_evaluator"], "tokens": 399}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def create_multigpu_supervised_evaluator(\n net: torch.nn.Module,\n metrics: Optional[Dict[str, Metric]] = None,\n devices: Optional[Sequence[torch.device]] = None,\n non_blocking: bool = False,\n prepare_batch: Callable = _prepare_batch,\n output_transform: Callable = _default_eval_transform,\n):\n \"\"\"\n Derived from `create_supervised_evaluator` in Ignite.\n\n Factory function for creating an evaluator for supervised models.\n\n Args:\n net: the model to train.\n metrics: a map of metric names to Metrics.\n devices: device(s) type specification (default: None).\n Applies to both model and batches. None is all devices used, empty list is CPU only.\n non_blocking: if True and this copy is between CPU and GPU, the copy may occur asynchronously\n with respect to the host. For other cases, this argument has no effect.\n prepare_batch: function that receives `batch`, `device`, `non_blocking` and outputs\n tuple of tensors `(batch_x, batch_y)`.\n output_transform: function that receives 'x', 'y', 'y_pred' and returns value\n to be assigned to engine's state.output after each iteration. Default is returning `(y_pred, y,)` which fits\n output expected by metrics. If you change it you should use `output_transform` in metrics.\n\n Note:\n `engine.state.output` for this engine is defined by `output_transform` parameter and is\n a tuple of `(batch_pred, batch_y)` by default.\n\n Returns:\n Engine: an evaluator engine with supervised inference function.\n \"\"\"\n\n devices_ = get_devices_spec(devices)\n\n if len(devices_) > 1:\n net = torch.nn.parallel.DataParallel(net)\n\n return create_supervised_evaluator(net, metrics, devices_[0], non_blocking, prepare_batch, output_transform)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_from_typing_import_Callab_if_TYPE_CHECKING_.else_.Metric___optional_impo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_from_typing_import_Callab_if_TYPE_CHECKING_.else_.Metric___optional_impo", "embedding": null, "metadata": {"file_path": "monai/engines/trainer.py", "file_name": "trainer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 30, "span_ids": ["docstring"], "tokens": 169}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Dict, Optional, Union, Sequence, TYPE_CHECKING\n\nimport torch\nfrom torch.optim.optimizer import Optimizer\nfrom torch.utils.data import DataLoader\n\nfrom monai.inferers import Inferer, SimpleInferer\nfrom monai.transforms import Transform\nfrom monai.engines.utils import CommonKeys as Keys\nfrom monai.engines.utils import default_prepare_batch\nfrom monai.engines.workflow import Workflow\nfrom monai.utils import exact_version, optional_import\n\nif TYPE_CHECKING:\n from ignite.engine import Engine\n from ignite.metrics import Metric\nelse:\n Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")\n Metric, _ = optional_import(\"ignite.metrics\", \"0.3.0\", exact_version, \"Metric\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_Trainer_Trainer.get_train_stats.return._total_epochs_self_sta": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_Trainer_Trainer.get_train_stats.return._total_epochs_self_sta", "embedding": null, "metadata": {"file_path": "monai/engines/trainer.py", "file_name": "trainer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 33, "end_line": 50, "span_ids": ["Trainer.run", "Trainer.get_train_stats", "Trainer"], "tokens": 131}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Trainer(Workflow):\n \"\"\"\n Base class for all kinds of trainers, inherits from Workflow.\n\n \"\"\"\n\n def run(self) -> None:\n \"\"\"\n Execute training based on Ignite Engine.\n If call this function multiple times, it will continuously run from the previous state.\n\n \"\"\"\n if self._is_done(self.state):\n self.state.iteration = 0 # to avoid creating new State instance in ignite Engine.run\n super().run()\n\n def get_train_stats(self) -> Dict[str, Union[int, float]]:\n return {\"total_epochs\": self.state.max_epochs, \"total_iterations\": self.state.epoch_length}", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_SupervisedTrainer_SupervisedTrainer.__init__.self.inferer.inferer": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_SupervisedTrainer_SupervisedTrainer.__init__.self.inferer.inferer", "embedding": null, "metadata": {"file_path": "monai/engines/trainer.py", "file_name": "trainer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 53, "end_line": 114, "span_ids": ["SupervisedTrainer.__init__", "SupervisedTrainer"], "tokens": 578}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SupervisedTrainer(Trainer):\n \"\"\"\n Standard supervised training method with image and label, inherits from trainer and Workflow.\n\n Args:\n device: an object representing the device on which to run.\n max_epochs: the total epoch number for engine to run, validator and evaluator have only 1 epoch.\n train_data_loader: Ignite engine use data_loader to run, must be torch.DataLoader.\n network: to train with this network.\n optimizer: the optimizer associated to the network.\n loss_function: the loss function associated to the optimizer.\n prepare_batch: function to parse image and label for current iteration.\n iteration_update: the callable function for every iteration, expect to accept `engine`\n and `batchdata` as input parameters. if not provided, use `self._iteration()` instead.\n inferer: inference method that execute model forward on input data, like: SlidingWindow, etc.\n amp: whether to enable auto-mixed-precision training, reserved.\n post_transform: execute additional transformation for the model output data.\n Typically, several Tensor based transforms composed by `Compose`.\n key_train_metric: compute metric when every iteration completed, and save average value to\n engine.state.metrics when epoch completed. key_train_metric is the main metric to compare and save the\n checkpoint into files.\n additional_metrics: more Ignite metrics that also attach to Ignite Engine.\n train_handlers: every handler is a set of Ignite Event-Handlers, must have `attach` function, like:\n CheckpointHandler, StatsHandler, SegmentationSaver, etc.\n\n \"\"\"\n\n def __init__(\n self,\n device: torch.device,\n max_epochs: int,\n train_data_loader: DataLoader,\n network: torch.nn.Module,\n optimizer: Optimizer,\n loss_function: Callable,\n prepare_batch: Callable = default_prepare_batch,\n iteration_update: Optional[Callable] = None,\n inferer: Inferer = SimpleInferer(),\n amp: bool = True,\n post_transform: Optional[Transform] = None,\n key_train_metric: Optional[Dict[str, Metric]] = None,\n additional_metrics: Optional[Dict[str, Metric]] = None,\n train_handlers: Optional[Sequence] = None,\n ):\n # set up Ignite engine and environments\n super().__init__(\n device=device,\n max_epochs=max_epochs,\n amp=amp,\n data_loader=train_data_loader,\n prepare_batch=prepare_batch,\n iteration_update=iteration_update,\n key_metric=key_train_metric,\n additional_metrics=additional_metrics,\n handlers=train_handlers,\n post_transform=post_transform,\n )\n\n self.network = network\n self.optimizer = optimizer\n self.loss_function = loss_function\n self.inferer = inferer", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_SupervisedTrainer._iteration_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_SupervisedTrainer._iteration_", "embedding": null, "metadata": {"file_path": "monai/engines/trainer.py", "file_name": "trainer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 116, "end_line": 148, "span_ids": ["SupervisedTrainer._iteration"], "tokens": 304}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SupervisedTrainer(Trainer):\n\n def _iteration(self, engine: Engine, batchdata: Union[Dict, Sequence]) -> Dict[str, torch.Tensor]:\n \"\"\"\n Callback function for the Supervised Training processing logic of 1 iteration in Ignite Engine.\n Return below items in a dictionary:\n - IMAGE: image Tensor data for model input, already moved to device.\n - LABEL: label Tensor data corresponding to the image, already moved to device.\n - PRED: prediction result of model.\n - LOSS: loss value computed by loss function.\n\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n batchdata: input data for this iteration, usually can be dictionary or tuple of Tensor data.\n\n Raises:\n ValueError: must provide batch data for current iteration.\n\n \"\"\"\n if batchdata is None:\n raise ValueError(\"must provide batch data for current iteration.\")\n inputs, targets = self.prepare_batch(batchdata)\n inputs, targets = inputs.to(engine.state.device), targets.to(engine.state.device)\n\n self.network.train()\n self.optimizer.zero_grad()\n # execute forward computation\n predictions = self.inferer(inputs, self.network)\n # compute loss\n loss = self.loss_function(predictions, targets).mean()\n loss.backward()\n self.optimizer.step()\n\n return {Keys.IMAGE: inputs, Keys.LABEL: targets, Keys.PRED: predictions, Keys.LOSS: loss.item()}", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/utils.py_from_typing_import_Sequen_CommonKeys.LOSS._loss_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/utils.py_from_typing_import_Sequen_CommonKeys.LOSS._loss_", "embedding": null, "metadata": {"file_path": "monai/engines/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 30, "span_ids": ["CommonKeys", "docstring"], "tokens": 128}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Sequence, Dict, Optional\nimport torch\n\n\nclass CommonKeys:\n \"\"\"\n A set of common keys for dictionary based supervised training process.\n `IMAGE` is the input image data.\n `LABEL` is the training or evaluation label of segmentation or classification task.\n `PRED` is the prediction data of model output.\n `LOSS` is the loss value of current iteration.\n `INFO` is some useful information during training or evaluation, like loss value, etc.\n\n \"\"\"\n\n IMAGE = \"image\"\n LABEL = \"label\"\n PRED = \"pred\"\n LOSS = \"loss\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/utils.py_get_devices_spec_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/utils.py_get_devices_spec_", "embedding": null, "metadata": {"file_path": "monai/engines/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 33, "end_line": 68, "span_ids": ["default_prepare_batch", "get_devices_spec"], "tokens": 264}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def get_devices_spec(devices: Optional[Sequence[torch.device]] = None):\n \"\"\"\n Get a valid specification for one or more devices. If `devices` is None get devices for all CUDA devices available.\n If `devices` is and zero-length structure a single CPU compute device is returned. In any other cases `devices` is\n returned unchanged.\n\n Args:\n devices: list of devices to request, None for all GPU devices, [] for CPU.\n\n Returns:\n list of torch.device: list of devices.\n\n Raises:\n ValueError: No GPU devices available\n\n \"\"\"\n if devices is None:\n devices = [torch.device(f\"cuda:{d:d}\") for d in range(torch.cuda.device_count())]\n\n if len(devices) == 0:\n raise ValueError(\"No GPU devices available\")\n\n elif len(devices) == 0:\n devices = [torch.device(\"cpu\")]\n\n return devices\n\n\ndef default_prepare_batch(batchdata: Dict):\n assert isinstance(batchdata, dict), \"default prepare_batch expects dictionary input data.\"\n return (\n (batchdata[CommonKeys.IMAGE], batchdata[CommonKeys.LABEL])\n if CommonKeys.LABEL in batchdata\n else (batchdata[CommonKeys.IMAGE], None)\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/workflow.py_from_typing_import_Callab_if_TYPE_CHECKING_.else_.Metric___optional_impo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/workflow.py_from_typing_import_Callab_if_TYPE_CHECKING_.else_.Metric___optional_impo", "embedding": null, "metadata": {"file_path": "monai/engines/workflow.py", "file_name": "workflow.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 29, "span_ids": ["docstring"], "tokens": 200}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Optional, Dict, Sequence, Union, TYPE_CHECKING\n\nimport torch\nfrom torch.utils.data import DataLoader\n\nfrom monai.transforms import apply_transform\nfrom monai.utils import exact_version, optional_import, ensure_tuple\nfrom monai.engines.utils import default_prepare_batch\n\nIgniteEngine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")\nState, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"State\")\nEvents, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Events\")\nif TYPE_CHECKING:\n from ignite.engine import Engine\n from ignite.metrics import Metric\nelse:\n Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")\n Metric, _ = optional_import(\"ignite.metrics\", \"0.3.0\", exact_version, \"Metric\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/workflow.py_Workflow_Workflow._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/workflow.py_Workflow_Workflow._", "embedding": null, "metadata": {"file_path": "monai/engines/workflow.py", "file_name": "workflow.py", "file_type": "text/x-python", "category": "implementation", "start_line": 32, "end_line": 59, "span_ids": ["Workflow"], "tokens": 369}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Workflow(IgniteEngine): # type: ignore # incorrectly typed due to optional_import\n \"\"\"\n Workflow defines the core work process inheriting from Ignite engine.\n All trainer, validator and evaluator share this same workflow as base class,\n because they all can be treated as same Ignite engine loops.\n It initializes all the sharable data in Ignite engine.state.\n And attach additional processing logics to Ignite engine based on Event-Handler mechanism.\n\n Users should consider to inherit from `trainer` or `evaluator` to develop more trainers or evaluators.\n\n Args:\n device: an object representing the device on which to run.\n max_epochs: the total epoch number for engine to run, validator and evaluator have only 1 epoch.\n amp: whether to enable auto-mixed-precision training, reserved.\n data_loader: Ignite engine use data_loader to run, must be torch.DataLoader.\n prepare_batch: function to parse image and label for every iteration.\n iteration_update: the callable function for every iteration, expect to accept `engine`\n and `batchdata` as input parameters. if not provided, use `self._iteration()` instead.\n post_transform: execute additional transformation for the model output data.\n Typically, several Tensor based transforms composed by `Compose`.\n key_metric: compute metric when every iteration completed, and save average value to\n engine.state.metrics when epoch completed. key_metric is the main metric to compare and save the\n checkpoint into files.\n additional_metrics: more Ignite metrics that also attach to Ignite Engine.\n handlers: every handler is a set of Ignite Event-Handlers, must have `attach` function, like:\n CheckpointHandler, StatsHandler, SegmentationSaver, etc.\n\n \"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/workflow.py_Workflow.__init___Workflow.run.super_run_data_self_dat": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/workflow.py_Workflow.__init___Workflow.run.super_run_data_self_dat", "embedding": null, "metadata": {"file_path": "monai/engines/workflow.py", "file_name": "workflow.py", "file_type": "text/x-python", "category": "implementation", "start_line": 61, "end_line": 145, "span_ids": ["Workflow.__init__", "Workflow.run"], "tokens": 674}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Workflow(IgniteEngine):\n\n def __init__(\n self,\n device: torch.device,\n max_epochs: int,\n amp: bool,\n data_loader: DataLoader,\n prepare_batch: Callable = default_prepare_batch,\n iteration_update: Optional[Callable] = None,\n post_transform: Optional[Callable] = None,\n key_metric: Optional[Dict[str, Metric]] = None,\n additional_metrics: Optional[Dict[str, Metric]] = None,\n handlers: Optional[Sequence] = None,\n ) -> None:\n if iteration_update is not None:\n super().__init__(iteration_update)\n else:\n super().__init__(self._iteration)\n # FIXME:\n if amp:\n self.logger.info(\"Will add AMP support when PyTorch v1.6 released.\")\n if not isinstance(device, torch.device):\n raise ValueError(\"device must be PyTorch device object.\")\n if not isinstance(data_loader, DataLoader):\n raise ValueError(\"data_loader must be PyTorch DataLoader.\")\n\n # set all sharable data for the workflow based on Ignite engine.state\n self.state = State(\n seed=0,\n iteration=0,\n epoch=0,\n max_epochs=max_epochs,\n epoch_length=-1,\n output=None,\n batch=None,\n metrics={},\n dataloader=None,\n device=device,\n amp=amp,\n key_metric_name=None, # we can set many metrics, only use key_metric to compare and save the best model\n best_metric=-1,\n best_metric_epoch=-1,\n )\n self.data_loader = data_loader\n self.prepare_batch = prepare_batch\n\n if post_transform is not None:\n\n @self.on(Events.ITERATION_COMPLETED)\n def run_post_transform(engine: Engine):\n assert post_transform is not None\n engine.state.output = apply_transform(post_transform, engine.state.output)\n\n if key_metric is not None:\n\n if not isinstance(key_metric, dict):\n raise ValueError(\"key_metric must be a dict object.\")\n self.state.key_metric_name = list(key_metric.keys())[0]\n metrics = key_metric\n if additional_metrics is not None and len(additional_metrics) > 0:\n if not isinstance(additional_metrics, dict):\n raise ValueError(\"additional_metrics must be a dict object.\")\n metrics.update(additional_metrics)\n for name, metric in metrics.items():\n metric.attach(self, name)\n\n @self.on(Events.EPOCH_COMPLETED)\n def _compare_metrics(engine: Engine):\n if engine.state.key_metric_name is not None:\n current_val_metric = engine.state.metrics[engine.state.key_metric_name]\n if current_val_metric > engine.state.best_metric:\n self.logger.info(f\"Got new best metric of {engine.state.key_metric_name}: {current_val_metric}\")\n engine.state.best_metric = current_val_metric\n engine.state.best_metric_epoch = engine.state.epoch\n\n if handlers is not None:\n handlers = ensure_tuple(handlers)\n for handler in handlers:\n handler.attach(self)\n\n def run(self) -> None:\n \"\"\"\n Execute training, validation or evaluation based on Ignite Engine.\n\n \"\"\"\n super().run(data=self.data_loader, epoch_length=len(self.data_loader))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/workflow.py_Workflow._iteration_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/workflow.py_Workflow._iteration_", "embedding": null, "metadata": {"file_path": "monai/engines/workflow.py", "file_name": "workflow.py", "file_type": "text/x-python", "category": "implementation", "start_line": 147, "end_line": 161, "span_ids": ["Workflow._iteration"], "tokens": 154}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Workflow(IgniteEngine):\n\n def _iteration(self, engine: Engine, batchdata: Union[Dict, Sequence]):\n \"\"\"\n Abstract callback function for the processing logic of 1 iteration in Ignite Engine.\n Need subclass to implement different logics, like SupervisedTrainer/Evaluator, GANTrainer, etc.\n\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n batchdata: input data for this iteration, usually can be dictionary or tuple of Tensor data.\n\n Raises:\n NotImplementedError: Subclass {self.__class__.__name__} must implement the compute method\n\n \"\"\"\n raise NotImplementedError(f\"Subclass {self.__class__.__name__} must implement the compute method\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/__init__.py_CheckpointLoader_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/__init__.py_CheckpointLoader_", "embedding": null, "metadata": {"file_path": "monai/handlers/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 24, "span_ids": ["docstring"], "tokens": 114}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from .checkpoint_loader import CheckpointLoader\nfrom .checkpoint_saver import CheckpointSaver\nfrom .classification_saver import ClassificationSaver\nfrom .lr_schedule_handler import LrScheduleHandler\nfrom .mean_dice import MeanDice\nfrom .metric_logger import MetricLogger\nfrom .roc_auc import ROCAUC\nfrom .segmentation_saver import SegmentationSaver\nfrom .stats_handler import StatsHandler\nfrom .tensorboard_handlers import TensorBoardImageHandler, TensorBoardStatsHandler\nfrom .utils import *\nfrom .validation_handler import ValidationHandler", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_loader.py_from_typing_import_Option_if_TYPE_CHECKING_.else_.Engine___optional_impo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_loader.py_from_typing_import_Option_if_TYPE_CHECKING_.else_.Engine___optional_impo", "embedding": null, "metadata": {"file_path": "monai/handlers/checkpoint_loader.py", "file_name": "checkpoint_loader.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 25, "span_ids": ["docstring"], "tokens": 112}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Dict, TYPE_CHECKING\n\nimport logging\n\nimport torch\n\nfrom monai.utils import exact_version, optional_import\n\nEvents, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Events\")\nCheckpoint, _ = optional_import(\"ignite.handlers\", \"0.3.0\", exact_version, \"Checkpoint\")\nif TYPE_CHECKING:\n from ignite.engine import Engine\nelse:\n Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_loader.py_CheckpointLoader_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_loader.py_CheckpointLoader_", "embedding": null, "metadata": {"file_path": "monai/handlers/checkpoint_loader.py", "file_name": "checkpoint_loader.py", "file_type": "text/x-python", "category": "implementation", "start_line": 28, "end_line": 71, "span_ids": ["CheckpointLoader.attach", "CheckpointLoader", "CheckpointLoader.__call__", "CheckpointLoader.__init__"], "tokens": 410}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CheckpointLoader:\n \"\"\"\n CheckpointLoader acts as an Ignite handler to load checkpoint data from file.\n It can load variables for network, optimizer, lr_scheduler, etc.\n If saving checkpoint after `torch.nn.DataParallel`, need to save `model.module` instead\n as PyTorch recommended and then use this loader to load the model.\n\n Args:\n load_path: the file path of checkpoint, it should be a PyTorch `pth` file.\n load_dict: target objects that load checkpoint to. examples::\n\n {'network': net, 'optimizer': optimizer, 'lr_scheduler': lr_scheduler}\n\n name: identifier of logging.logger to use, if None, defaulting to ``engine.logger``.\n\n \"\"\"\n\n def __init__(self, load_path: str, load_dict: Dict, name: Optional[str] = None) -> None:\n assert load_path is not None, \"must provide clear path to load checkpoint.\"\n self.load_path = load_path\n assert load_dict is not None and len(load_dict) > 0, \"must provide target objects to load.\"\n self.logger = logging.getLogger(name)\n for k, v in load_dict.items():\n if hasattr(v, \"module\"):\n load_dict[k] = v.module\n self.load_dict = load_dict\n\n self._name = name\n\n def attach(self, engine: Engine):\n if self._name is None:\n self.logger = engine.logger\n return engine.add_event_handler(Events.STARTED, self)\n\n def __call__(self, engine: Engine) -> None:\n checkpoint = torch.load(self.load_path)\n if len(self.load_dict) == 1:\n key = list(self.load_dict.keys())[0]\n if not (key in checkpoint):\n checkpoint = {key: checkpoint}\n\n Checkpoint.load_objects(to_load=self.load_dict, checkpoint=checkpoint)\n self.logger.info(f\"Restored all variables from {self.load_path}\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_from_typing_import_Any_D_if_TYPE_CHECKING_.else_.Engine___optional_impo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_from_typing_import_Any_D_if_TYPE_CHECKING_.else_.Engine___optional_impo", "embedding": null, "metadata": {"file_path": "monai/handlers/checkpoint_saver.py", "file_name": "checkpoint_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 23, "span_ids": ["docstring"], "tokens": 113}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Any, Dict, Optional, TYPE_CHECKING\n\nimport logging\n\nfrom monai.utils import exact_version, optional_import\n\nEvents, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Events\")\nModelCheckpoint, _ = optional_import(\"ignite.handlers\", \"0.3.0\", exact_version, \"ModelCheckpoint\")\nif TYPE_CHECKING:\n from ignite.engine import Engine\nelse:\n Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver_CheckpointSaver._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver_CheckpointSaver._", "embedding": null, "metadata": {"file_path": "monai/handlers/checkpoint_saver.py", "file_name": "checkpoint_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 26, "end_line": 63, "span_ids": ["CheckpointSaver"], "tokens": 400}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CheckpointSaver:\n \"\"\"\n CheckpointSaver acts as an Ignite handler to save checkpoint data into files.\n It supports to save according to metrics result, epoch number, iteration number\n and last model or exception.\n\n Args:\n save_dir: the target directory to save the checkpoints.\n save_dict: source objects that save to the checkpoint. examples::\n\n {'network': net, 'optimizer': optimizer, 'lr_scheduler': lr_scheduler}\n\n name: identifier of logging.logger to use, if None, defaulting to ``engine.logger``.\n file_prefix: prefix for the filenames to which objects will be saved.\n save_final: whether to save checkpoint or session at final iteration or exception.\n save_key_metric: whether to save checkpoint or session when the value of key_metric is\n higher than all the previous values during training.keep 4 decimal places of metric,\n checkpoint name is: {file_prefix}_key_metric=0.XXXX.pth.\n key_metric_name: the name of key_metric in ignite metrics dictionary.\n if None, use `engine.state.key_metric` instead.\n key_metric_n_saved: save top N checkpoints or sessions, sorted by the value of key\n metric in descending order.\n epoch_level: save checkpoint during training for every N epochs or every N iterations.\n `True` is epoch level, `False` is iteration level.\n save_interval: save checkpoint every N epochs, default is 0 to save no checkpoint.\n n_saved: save latest N checkpoints of epoch level or iteration level, 'None' is to save all.\n\n Note:\n CheckpointHandler can be used during training, validation or evaluation.\n example of saved files:\n\n - checkpoint_iteration=400.pth\n - checkpoint_iteration=800.pth\n - checkpoint_epoch=1.pth\n - checkpoint_final_iteration=1000.pth\n - checkpoint_key_metric=0.9387.pth\n\n \"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver.__init___CheckpointSaver.__init__.if_save_interval_0_.self._interval_checkpoint.ModelCheckpoint_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver.__init___CheckpointSaver.__init__.if_save_interval_0_.self._interval_checkpoint.ModelCheckpoint_", "embedding": null, "metadata": {"file_path": "monai/handlers/checkpoint_saver.py", "file_name": "checkpoint_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 65, "end_line": 135, "span_ids": ["CheckpointSaver.__init__"], "tokens": 537}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CheckpointSaver:\n\n def __init__(\n self,\n save_dir: str,\n save_dict: Dict[str, Any],\n name: Optional[str] = None,\n file_prefix: str = \"\",\n save_final: bool = False,\n save_key_metric: bool = False,\n key_metric_name: Optional[str] = None,\n key_metric_n_saved: int = 1,\n epoch_level: bool = True,\n save_interval: int = 0,\n n_saved: Optional[int] = None,\n ) -> None:\n assert save_dir is not None, \"must provide directory to save the checkpoints.\"\n self.save_dir = save_dir\n assert save_dict is not None and len(save_dict) > 0, \"must provide source objects to save.\"\n for k, v in save_dict.items():\n if hasattr(v, \"module\"):\n save_dict[k] = v.module\n self.save_dict = save_dict\n self.logger = logging.getLogger(name)\n self.epoch_level = epoch_level\n self.save_interval = save_interval\n self._final_checkpoint = self._key_metric_checkpoint = self._interval_checkpoint = None\n self._name = name\n\n if save_final:\n\n def _final_func(engine: Engine):\n return engine.state.iteration\n\n self._final_checkpoint = ModelCheckpoint(\n self.save_dir,\n file_prefix,\n score_function=_final_func,\n score_name=\"final_iteration\",\n require_empty=False,\n )\n if save_key_metric:\n\n def _score_func(engine: Engine):\n if isinstance(key_metric_name, str):\n metric_name = key_metric_name\n elif hasattr(engine.state, \"key_metric_name\") and isinstance(engine.state.key_metric_name, str):\n metric_name = engine.state.key_metric_name\n else:\n raise ValueError(\"must provde key_metric_name to save best validation model.\")\n return round(engine.state.metrics[metric_name], 4)\n\n self._key_metric_checkpoint = ModelCheckpoint(\n self.save_dir,\n file_prefix,\n score_function=_score_func,\n score_name=\"key_metric\",\n n_saved=key_metric_n_saved,\n require_empty=False,\n )\n if save_interval > 0:\n\n def _interval_func(engine: Engine):\n return engine.state.epoch if self.epoch_level else engine.state.iteration\n\n self._interval_checkpoint = ModelCheckpoint(\n self.save_dir,\n file_prefix,\n score_function=_interval_func,\n score_name=\"epoch\" if self.epoch_level else \"iteration\",\n n_saved=n_saved,\n require_empty=False,\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver.attach_CheckpointSaver.attach.if_self__interval_checkpo.if_self_epoch_level_.else_.engine_add_event_handler_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver.attach_CheckpointSaver.attach.if_self__interval_checkpo.if_self_epoch_level_.else_.engine_add_event_handler_", "embedding": null, "metadata": {"file_path": "monai/handlers/checkpoint_saver.py", "file_name": "checkpoint_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 137, "end_line": 149, "span_ids": ["CheckpointSaver.attach"], "tokens": 159}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CheckpointSaver:\n\n def attach(self, engine: Engine) -> None:\n if self._name is None:\n self.logger = engine.logger\n if self._final_checkpoint is not None:\n engine.add_event_handler(Events.COMPLETED, self.completed)\n engine.add_event_handler(Events.EXCEPTION_RAISED, self.exception_raised)\n if self._key_metric_checkpoint is not None:\n engine.add_event_handler(Events.EPOCH_COMPLETED, self.metrics_completed)\n if self._interval_checkpoint is not None:\n if self.epoch_level:\n engine.add_event_handler(Events.EPOCH_COMPLETED(every=self.save_interval), self.interval_completed)\n else:\n engine.add_event_handler(Events.ITERATION_COMPLETED(every=self.save_interval), self.interval_completed)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver.completed_CheckpointSaver.completed.self_logger_info_f_Train_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver.completed_CheckpointSaver.completed.self_logger_info_f_Train_", "embedding": null, "metadata": {"file_path": "monai/handlers/checkpoint_saver.py", "file_name": "checkpoint_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 151, "end_line": 160, "span_ids": ["CheckpointSaver.completed"], "tokens": 120}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CheckpointSaver:\n\n def completed(self, engine: Engine) -> None:\n \"\"\"Callback for train or validation/evaluation completed Event.\n Save final checkpoint if configure save_final is True.\n\n \"\"\"\n assert callable(self._final_checkpoint), \"Error: _final_checkpoint function not specified.\"\n self._final_checkpoint(engine, self.save_dict)\n assert self.logger is not None\n assert hasattr(self.logger, \"info\"), \"Error, provided logger has not info attribute.\"\n self.logger.info(f\"Train completed, saved final checkpoint: {self._final_checkpoint.last_checkpoint}\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver.exception_raised_CheckpointSaver.metrics_completed.self__key_metric_checkpoi": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver.exception_raised_CheckpointSaver.metrics_completed.self__key_metric_checkpoi", "embedding": null, "metadata": {"file_path": "monai/handlers/checkpoint_saver.py", "file_name": "checkpoint_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 162, "end_line": 178, "span_ids": ["CheckpointSaver.metrics_completed", "CheckpointSaver.exception_raised"], "tokens": 195}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CheckpointSaver:\n\n def exception_raised(self, engine: Engine, e: Exception) -> None:\n \"\"\"Callback for train or validation/evaluation exception raised Event.\n Save current data as final checkpoint if configure save_final is True.\n\n \"\"\"\n assert callable(self._final_checkpoint), \"Error: _final_checkpoint function not specified.\"\n self._final_checkpoint(engine, self.save_dict)\n assert self.logger is not None\n assert hasattr(self.logger, \"info\"), \"Error, provided logger has not info attribute.\"\n self.logger.info(f\"Exception_raised, saved exception checkpoint: {self._final_checkpoint.last_checkpoint}\")\n\n def metrics_completed(self, engine: Engine) -> None:\n \"\"\"Callback to compare metrics and save models in train or validation when epoch completed.\n\n \"\"\"\n assert callable(self._key_metric_checkpoint), \"Error: _key_metric_checkpoint function not specified.\"\n self._key_metric_checkpoint(engine, self.save_dict)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver.interval_completed_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver.interval_completed_", "embedding": null, "metadata": {"file_path": "monai/handlers/checkpoint_saver.py", "file_name": "checkpoint_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 180, "end_line": 193, "span_ids": ["CheckpointSaver.interval_completed"], "tokens": 140}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CheckpointSaver:\n\n def interval_completed(self, engine: Engine) -> None:\n \"\"\"Callback for train epoch/iteration completed Event.\n Save checkpoint if configure save_interval = N\n\n \"\"\"\n assert callable(self._interval_checkpoint), \"Error: _interval_checkpoint function not specified.\"\n self._interval_checkpoint(engine, self.save_dict)\n assert self.logger is not None\n assert hasattr(self.logger, \"info\"), \"Error, provided logger has not info attribute.\"\n if self.epoch_level:\n self.logger.info(f\"Saved checkpoint at epoch: {engine.state.epoch}\")\n else:\n self.logger.info(f\"Saved checkpoint at iteration: {engine.state.iteration}\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/classification_saver.py_from_typing_import_Callab_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/classification_saver.py_from_typing_import_Callab_", "embedding": null, "metadata": {"file_path": "monai/handlers/classification_saver.py", "file_name": "classification_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 78, "span_ids": ["ClassificationSaver.__init__", "ClassificationSaver.__call__", "docstring", "ClassificationSaver", "ClassificationSaver.attach"], "tokens": 564}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Optional, TYPE_CHECKING\n\nimport logging\n\nfrom monai.data import CSVSaver\nfrom monai.utils import exact_version, optional_import\n\nEvents, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Events\")\nif TYPE_CHECKING:\n from ignite.engine import Engine\nelse:\n Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")\n\n\nclass ClassificationSaver:\n \"\"\"\n Event handler triggered on completing every iteration to save the classification predictions as CSV file.\n \"\"\"\n\n def __init__(\n self,\n output_dir: str = \"./\",\n filename: str = \"predictions.csv\",\n overwrite: bool = True,\n batch_transform: Callable = lambda x: x,\n output_transform: Callable = lambda x: x,\n name: Optional[str] = None,\n ) -> None:\n \"\"\"\n Args:\n output_dir: output CSV file directory.\n filename: name of the saved CSV file name.\n overwrite: whether to overwriting existing CSV file content. If we are not overwriting,\n then we check if the results have been previously saved, and load them to the prediction_dict.\n batch_transform: a callable that is used to transform the\n ignite.engine.batch into expected format to extract the meta_data dictionary.\n output_transform: a callable that is used to transform the\n ignite.engine.output into the form expected model prediction data.\n The first dimension of this transform's output will be treated as the\n batch dimension. Each item in the batch will be saved individually.\n name: identifier of logging.logger to use, defaulting to `engine.logger`.\n\n \"\"\"\n self.saver = CSVSaver(output_dir, filename, overwrite)\n self.batch_transform = batch_transform\n self.output_transform = output_transform\n\n self.logger = None if name is None else logging.getLogger(name)\n self._name = name\n\n def attach(self, engine: Engine) -> None:\n if self._name is None:\n self.logger = engine.logger\n if not engine.has_event_handler(self, Events.ITERATION_COMPLETED):\n engine.add_event_handler(Events.ITERATION_COMPLETED, self)\n if not engine.has_event_handler(self.saver.finalize, Events.COMPLETED):\n engine.add_event_handler(Events.COMPLETED, lambda engine: self.saver.finalize())\n\n def __call__(self, engine: Engine) -> None:\n \"\"\"\n This method assumes self.batch_transform will extract metadata from the input batch.\n\n \"\"\"\n meta_data = self.batch_transform(engine.state.batch)\n engine_output = self.output_transform(engine.state.output)\n self.saver.save_batch(engine_output, meta_data)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/lr_schedule_handler.py_from_typing_import_Callab_if_TYPE_CHECKING_.else_.Engine___optional_impo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/lr_schedule_handler.py_from_typing_import_Callab_if_TYPE_CHECKING_.else_.Engine___optional_impo", "embedding": null, "metadata": {"file_path": "monai/handlers/lr_schedule_handler.py", "file_name": "lr_schedule_handler.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 24, "span_ids": ["docstring"], "tokens": 109}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Optional, Union, TYPE_CHECKING\n\nimport logging\n\nfrom torch.optim.lr_scheduler import _LRScheduler, ReduceLROnPlateau\n\nfrom monai.utils import ensure_tuple, exact_version, optional_import\n\nEvents, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Events\")\nif TYPE_CHECKING:\n from ignite.engine import Engine\nelse:\n Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/lr_schedule_handler.py_LrScheduleHandler_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/lr_schedule_handler.py_LrScheduleHandler_", "embedding": null, "metadata": {"file_path": "monai/handlers/lr_schedule_handler.py", "file_name": "lr_schedule_handler.py", "file_type": "text/x-python", "category": "implementation", "start_line": 27, "end_line": 80, "span_ids": ["LrScheduleHandler.__init__", "LrScheduleHandler", "LrScheduleHandler.__call__", "LrScheduleHandler.attach"], "tokens": 453}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LrScheduleHandler:\n \"\"\"\n Ignite handler to update the Learning Rate based on PyTorch LR scheduler.\n \"\"\"\n\n def __init__(\n self,\n lr_scheduler: Union[_LRScheduler, ReduceLROnPlateau],\n print_lr: bool = True,\n name: Optional[str] = None,\n epoch_level: bool = True,\n step_transform: Callable = lambda engine: (),\n ) -> None:\n \"\"\"\n Args:\n lr_scheduler: typically, lr_scheduler should be PyTorch\n lr_scheduler object. If customized version, must have `step` and `get_last_lr` methods.\n print_lr: whether to print out the latest learning rate with logging.\n name: identifier of logging.logger to use, if None, defaulting to ``engine.logger``.\n epoch_level: execute lr_scheduler.step() after every epoch or every iteration.\n `True` is epoch level, `False` is iteration level.\n step_transform: a callable that is used to transform the information from `engine`\n to expected input data of lr_scheduler.step() function if necessary.\n\n Raises:\n ValueError: argument `step_transform` must be a callable.\n\n \"\"\"\n self.lr_scheduler = lr_scheduler\n self.print_lr = print_lr\n self.logger = logging.getLogger(name)\n self.epoch_level = epoch_level\n if not callable(step_transform):\n raise ValueError(\"argument `step_transform` must be a callable.\")\n self.step_transform = step_transform\n\n self._name = name\n\n def attach(self, engine: Engine) -> None:\n if self._name is None:\n self.logger = engine.logger\n if self.epoch_level:\n engine.add_event_handler(Events.EPOCH_COMPLETED, self)\n else:\n engine.add_event_handler(Events.ITERATION_COMPLETED, self)\n\n def __call__(self, engine: Engine) -> None:\n args = ensure_tuple(self.step_transform(engine))\n self.lr_scheduler.step(*args)\n if self.print_lr:\n self.logger.info(\n f\"Current learning rate: {self.lr_scheduler._last_lr[0]}\" # type: ignore # Module has no attribute\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/mean_dice.py_from_typing_import_Callab_sync_all_reduce___opti": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/mean_dice.py_from_typing_import_Callab_sync_all_reduce___opti", "embedding": null, "metadata": {"file_path": "monai/handlers/mean_dice.py", "file_name": "mean_dice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 22, "span_ids": ["docstring"], "tokens": 149}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Optional, Sequence\n\nimport torch\n\nfrom monai.metrics import DiceMetric\nfrom monai.utils import exact_version, optional_import, MetricReduction\n\nNotComputableError, _ = optional_import(\"ignite.exceptions\", \"0.3.0\", exact_version, \"NotComputableError\")\nMetric, _ = optional_import(\"ignite.metrics\", \"0.3.0\", exact_version, \"Metric\")\nreinit__is_reduced, _ = optional_import(\"ignite.metrics.metric\", \"0.3.0\", exact_version, \"reinit__is_reduced\")\nsync_all_reduce, _ = optional_import(\"ignite.metrics.metric\", \"0.3.0\", exact_version, \"sync_all_reduce\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/mean_dice.py_MeanDice_MeanDice.reset.self._num_examples.0": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/mean_dice.py_MeanDice_MeanDice.reset.self._num_examples.0", "embedding": null, "metadata": {"file_path": "monai/handlers/mean_dice.py", "file_name": "mean_dice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 25, "end_line": 72, "span_ids": ["MeanDice", "MeanDice.__init__", "MeanDice.reset"], "tokens": 437}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class MeanDice(Metric): # type: ignore # incorrectly typed due to optional_import\n \"\"\"\n Computes Dice score metric from full size Tensor and collects average over batch, class-channels, iterations.\n \"\"\"\n\n def __init__(\n self,\n include_background: bool = True,\n to_onehot_y: bool = False,\n mutually_exclusive: bool = False,\n sigmoid: bool = False,\n logit_thresh: float = 0.5,\n output_transform: Callable = lambda x: x,\n device: Optional[torch.device] = None,\n ) -> None:\n \"\"\"\n\n Args:\n include_background: whether to include dice computation on the first channel of the predicted output.\n Defaults to True.\n to_onehot_y: whether to convert the output prediction into the one-hot format. Defaults to False.\n mutually_exclusive: if True, the output prediction will be converted into a binary matrix using\n a combination of argmax and to_onehot. Defaults to False.\n sigmoid: whether to add sigmoid function to the output prediction before computing Dice.\n Defaults to False.\n logit_thresh: the threshold value to round value to 0.0 and 1.0. Defaults to None (no thresholding).\n output_transform: transform the ignite.engine.state.output into [y_pred, y] pair.\n device: device specification in case of distributed computation usage.\n\n See also:\n :py:meth:`monai.metrics.meandice.compute_meandice`\n \"\"\"\n super().__init__(output_transform, device=device)\n self.dice = DiceMetric(\n include_background=include_background,\n to_onehot_y=to_onehot_y,\n mutually_exclusive=mutually_exclusive,\n sigmoid=sigmoid,\n logit_thresh=logit_thresh,\n reduction=MetricReduction.MEAN,\n )\n self._sum = 0\n self._num_examples = 0\n\n @reinit__is_reduced\n def reset(self) -> None:\n self._sum = 0\n self._num_examples = 0", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/mean_dice.py_MeanDice.update_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/mean_dice.py_MeanDice.update_", "embedding": null, "metadata": {"file_path": "monai/handlers/mean_dice.py", "file_name": "mean_dice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 74, "end_line": 92, "span_ids": ["MeanDice.compute", "MeanDice.update"], "tokens": 193}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class MeanDice(Metric):\n\n @reinit__is_reduced\n def update(self, output: Sequence[torch.Tensor]) -> None:\n if not len(output) == 2:\n raise ValueError(\"MeanDice metric can only support y_pred and y.\")\n y_pred, y = output\n score = self.dice(y_pred, y)\n assert self.dice.not_nans is not None\n not_nans = int(self.dice.not_nans.item())\n\n # add all items in current batch\n self._sum += score.item() * not_nans\n self._num_examples += not_nans\n\n @sync_all_reduce(\"_sum\", \"_num_examples\")\n def compute(self) -> float:\n if self._num_examples == 0:\n raise NotComputableError(\"MeanDice must have at least one example before it can be computed.\")\n return self._sum / self._num_examples", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/metric_logger.py_from_typing_import_Callab_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/metric_logger.py_from_typing_import_Callab_", "embedding": null, "metadata": {"file_path": "monai/handlers/metric_logger.py", "file_name": "metric_logger.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 49, "span_ids": ["MetricLogger.attach", "MetricLogger", "impl:5", "docstring", "MetricLogger.__init__", "MetricLogger.__call__"], "tokens": 302}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, TYPE_CHECKING\n\nfrom collections import defaultdict\n\nfrom monai.utils import exact_version, optional_import\n\nEvents, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Events\")\nif TYPE_CHECKING:\n from ignite.engine import Engine\nelse:\n Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")\n\n\nclass MetricLogger:\n def __init__(self, loss_transform: Callable = lambda x: x, metric_transform: Callable = lambda x: x) -> None:\n self.loss_transform = loss_transform\n self.metric_transform = metric_transform\n self.loss: list = []\n self.metrics: defaultdict = defaultdict(list)\n\n def attach(self, engine: Engine):\n return engine.add_event_handler(Events.ITERATION_COMPLETED, self)\n\n def __call__(self, engine: Engine) -> None:\n self.loss.append(self.loss_transform(engine.state.output))\n\n for m, v in engine.state.metrics.items():\n v = self.metric_transform(v)\n # # metrics may not be added on the first timestep, pad the list if this is the case\n # # so that each metric list is the same length as self.loss\n # if len(self.metrics[m])==0:\n # self.metrics[m].append([v[0]]*len(self.loss))\n\n self.metrics[m].append(v)\n\n\nmetriclogger = MetricLogger", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/roc_auc.py_from_typing_import_Callab_ROCAUC.reset.self._targets._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/roc_auc.py_from_typing_import_Callab_ROCAUC.reset.self._targets._", "embedding": null, "metadata": {"file_path": "monai/handlers/roc_auc.py", "file_name": "roc_auc.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 67, "span_ids": ["ROCAUC.reset", "ROCAUC", "ROCAUC.__init__", "docstring"], "tokens": 568}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, List, Optional, Sequence, Union\n\nimport torch\n\nfrom monai.metrics import compute_roc_auc\nfrom monai.utils import exact_version, optional_import, Average\n\nMetric, _ = optional_import(\"ignite.metrics\", \"0.3.0\", exact_version, \"Metric\")\n\n\nclass ROCAUC(Metric): # type: ignore # incorrectly typed due to optional_import\n \"\"\"\n Computes Area Under the Receiver Operating Characteristic Curve (ROC AUC).\n accumulating predictions and the ground-truth during an epoch and applying `compute_roc_auc`.\n\n Args:\n to_onehot_y: whether to convert `y` into the one-hot format. Defaults to False.\n softmax: whether to add softmax function to `y_pred` before computation. Defaults to False.\n average: {``\"macro\"``, ``\"weighted\"``, ``\"micro\"``, ``\"none\"``}\n Type of averaging performed if not binary classification. Defaults to ``\"macro\"``.\n\n - ``\"macro\"``: calculate metrics for each label, and find their unweighted mean.\n This does not take label imbalance into account.\n - ``\"weighted\"``: calculate metrics for each label, and find their average,\n weighted by support (the number of true instances for each label).\n - ``\"micro\"``: calculate metrics globally by considering each element of the label\n indicator matrix as a label.\n - ``\"none\"``: the scores for each class are returned.\n\n output_transform: a callable that is used to transform the\n :class:`~ignite.engine.Engine` `process_function` output into the\n form expected by the metric. This can be useful if, for example, you have a multi-output model and\n you want to compute the metric with respect to one of the outputs.\n device: device specification in case of distributed computation usage.\n\n Note:\n ROCAUC expects y to be comprised of 0's and 1's. y_pred must either be probability estimates or confidence values.\n\n \"\"\"\n\n def __init__(\n self,\n to_onehot_y: bool = False,\n softmax: bool = False,\n average: Union[Average, str] = Average.MACRO,\n output_transform: Callable = lambda x: x,\n device: Optional[Union[str, torch.device]] = None,\n ) -> None:\n super().__init__(output_transform, device=device)\n self.to_onehot_y = to_onehot_y\n self.softmax = softmax\n self.average: Average = Average(average)\n\n def reset(self) -> None:\n self._predictions: List[torch.Tensor] = []\n self._targets: List[torch.Tensor] = []", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/roc_auc.py_ROCAUC.update_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/roc_auc.py_ROCAUC.update_", "embedding": null, "metadata": {"file_path": "monai/handlers/roc_auc.py", "file_name": "roc_auc.py", "file_type": "text/x-python", "category": "implementation", "start_line": 69, "end_line": 83, "span_ids": ["ROCAUC.update", "ROCAUC.compute"], "tokens": 183}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ROCAUC(Metric):\n\n def update(self, output: Sequence[torch.Tensor]) -> None:\n y_pred, y = output\n if y_pred.ndimension() not in (1, 2):\n raise ValueError(\"predictions should be of shape (batch_size, n_classes) or (batch_size, ).\")\n if y.ndimension() not in (1, 2):\n raise ValueError(\"targets should be of shape (batch_size, n_classes) or (batch_size, ).\")\n\n self._predictions.append(y_pred.clone())\n self._targets.append(y.clone())\n\n def compute(self):\n _prediction_tensor = torch.cat(self._predictions, dim=0)\n _target_tensor = torch.cat(self._targets, dim=0)\n return compute_roc_auc(_prediction_tensor, _target_tensor, self.to_onehot_y, self.softmax, self.average)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/segmentation_saver.py_from_typing_import_Callab_if_TYPE_CHECKING_.else_.Engine___optional_impo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/segmentation_saver.py_from_typing_import_Callab_if_TYPE_CHECKING_.else_.Engine___optional_impo", "embedding": null, "metadata": {"file_path": "monai/handlers/segmentation_saver.py", "file_name": "segmentation_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 25, "span_ids": ["docstring"], "tokens": 121}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Optional, Union, TYPE_CHECKING\n\nimport logging\n\nimport numpy as np\n\nfrom monai.data import NiftiSaver, PNGSaver\nfrom monai.utils import exact_version, optional_import, GridSampleMode, GridSamplePadMode, InterpolateMode\n\nEvents, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Events\")\nif TYPE_CHECKING:\n from ignite.engine import Engine\nelse:\n Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/segmentation_saver.py_SegmentationSaver_SegmentationSaver.__init__.self._name.name": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/segmentation_saver.py_SegmentationSaver_SegmentationSaver.__init__.self._name.name", "embedding": null, "metadata": {"file_path": "monai/handlers/segmentation_saver.py", "file_name": "segmentation_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 28, "end_line": 108, "span_ids": ["SegmentationSaver", "SegmentationSaver.__init__"], "tokens": 815}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SegmentationSaver:\n \"\"\"\n Event handler triggered on completing every iteration to save the segmentation predictions into files.\n \"\"\"\n\n def __init__(\n self,\n output_dir: str = \"./\",\n output_postfix: str = \"seg\",\n output_ext: str = \".nii.gz\",\n resample: bool = True,\n mode: Union[GridSampleMode, InterpolateMode, str] = \"nearest\",\n padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.BORDER,\n scale: Optional[int] = None,\n dtype: Optional[np.dtype] = None,\n batch_transform: Callable = lambda x: x,\n output_transform: Callable = lambda x: x,\n name: Optional[str] = None,\n ) -> None:\n \"\"\"\n Args:\n output_dir: output image directory.\n output_postfix: a string appended to all output file names.\n output_ext: output file extension name.\n resample: whether to resample before saving the data array.\n mode: This option is used when ``resample = True``. Defaults to ``\"nearest\"``.\n\n - NIfTI files {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n - PNG files {``\"nearest\"``, ``\"linear\"``, ``\"bilinear\"``, ``\"bicubic\"``, ``\"trilinear\"``, ``\"area\"``}\n The interpolation mode.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n\n padding_mode: This option is used when ``resample = True``. Defaults to ``\"border\"``.\n\n - NIfTI files {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n - PNG files\n This option is ignored.\n\n scale: {``255``, ``65535``} postprocess data by clipping to [0, 1] and scaling\n [0, 255] (uint8) or [0, 65535] (uint16). Default is None to disable scaling.\n It's used for PNG format only.\n dtype: convert the image data to save to this data type.\n If None, keep the original type of data. It's used for Nifti format only.\n batch_transform: a callable that is used to transform the\n ignite.engine.batch into expected format to extract the meta_data dictionary.\n output_transform: a callable that is used to transform the\n ignite.engine.output into the form expected image data.\n The first dimension of this transform's output will be treated as the\n batch dimension. Each item in the batch will be saved individually.\n name: identifier of logging.logger to use, defaulting to `engine.logger`.\n\n \"\"\"\n self.saver: Union[NiftiSaver, PNGSaver]\n if output_ext in (\".nii.gz\", \".nii\"):\n self.saver = NiftiSaver(\n output_dir=output_dir,\n output_postfix=output_postfix,\n output_ext=output_ext,\n resample=resample,\n mode=GridSampleMode(mode),\n padding_mode=padding_mode,\n dtype=dtype,\n )\n elif output_ext == \".png\":\n self.saver = PNGSaver(\n output_dir=output_dir,\n output_postfix=output_postfix,\n output_ext=output_ext,\n resample=resample,\n mode=InterpolateMode(mode),\n scale=scale,\n )\n self.batch_transform = batch_transform\n self.output_transform = output_transform\n\n self.logger = logging.getLogger(name)\n self._name = name", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/segmentation_saver.py_SegmentationSaver.attach_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/segmentation_saver.py_SegmentationSaver.attach_", "embedding": null, "metadata": {"file_path": "monai/handlers/segmentation_saver.py", "file_name": "segmentation_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 110, "end_line": 126, "span_ids": ["SegmentationSaver.__call__", "SegmentationSaver.attach"], "tokens": 156}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SegmentationSaver:\n\n def attach(self, engine: Engine) -> None:\n if self._name is None:\n self.logger = engine.logger\n if not engine.has_event_handler(self, Events.ITERATION_COMPLETED):\n engine.add_event_handler(Events.ITERATION_COMPLETED, self)\n\n def __call__(self, engine: Engine) -> None:\n \"\"\"\n This method assumes self.batch_transform will extract metadata from the input batch.\n Output file datatype is determined from ``engine.state.output.dtype``.\n\n \"\"\"\n meta_data = self.batch_transform(engine.state.batch)\n engine_output = self.output_transform(engine.state.output)\n self.saver.save_batch(engine_output, meta_data)\n self.logger.info(\"saved all the model outputs into files.\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_from_typing_import_Callab_DEFAULT_TAG._Loss_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_from_typing_import_Callab_DEFAULT_TAG._Loss_", "embedding": null, "metadata": {"file_path": "monai/handlers/stats_handler.py", "file_name": "stats_handler.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 28, "span_ids": ["docstring"], "tokens": 113}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Optional, TYPE_CHECKING\n\nimport logging\nimport warnings\n\nimport torch\n\nfrom monai.utils import exact_version, is_scalar, optional_import\n\nEvents, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Events\")\nif TYPE_CHECKING:\n from ignite.engine import Engine\nelse:\n Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")\n\nDEFAULT_KEY_VAL_FORMAT = \"{}: {:.4f} \"\nDEFAULT_TAG = \"Loss\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler_StatsHandler.__init__.if_logger_handler_is_not_.self_logger_addHandler_lo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler_StatsHandler.__init__.if_logger_handler_is_not_.self_logger_addHandler_lo", "embedding": null, "metadata": {"file_path": "monai/handlers/stats_handler.py", "file_name": "stats_handler.py", "file_type": "text/x-python", "category": "implementation", "start_line": 31, "end_line": 87, "span_ids": ["StatsHandler.__init__", "StatsHandler"], "tokens": 574}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class StatsHandler(object):\n \"\"\"\n StatsHandler defines a set of Ignite Event-handlers for all the log printing logics.\n It's can be used for any Ignite Engine(trainer, validator and evaluator).\n And it can support logging for epoch level and iteration level with pre-defined loggers.\n\n Default behaviors:\n - When EPOCH_COMPLETED, logs ``engine.state.metrics`` using ``self.logger``.\n - When ITERATION_COMPLETED, logs\n ``self.output_transform(engine.state.output)`` using ``self.logger``.\n\n \"\"\"\n\n def __init__(\n self,\n epoch_print_logger: Optional[Callable] = None,\n iteration_print_logger: Optional[Callable] = None,\n output_transform: Callable = lambda x: x,\n global_epoch_transform: Callable = lambda x: x,\n name: Optional[str] = None,\n tag_name: str = DEFAULT_TAG,\n key_var_format: str = DEFAULT_KEY_VAL_FORMAT,\n logger_handler: Optional[logging.Handler] = None,\n ) -> None:\n \"\"\"\n\n Args:\n epoch_print_logger: customized callable printer for epoch level logging.\n Must accept parameter \"engine\", use default printer if None.\n iteration_print_logger: customized callable printer for iteration level logging.\n Must accept parameter \"engine\", use default printer if None.\n output_transform: a callable that is used to transform the\n ``ignite.engine.output`` into a scalar to print, or a dictionary of {key: scalar}.\n In the latter case, the output string will be formatted as key: value.\n By default this value logging happens when every iteration completed.\n global_epoch_transform: a callable that is used to customize global epoch number.\n For example, in evaluation, the evaluator engine might want to print synced epoch number\n with the trainer engine.\n name: identifier of logging.logger to use, defaulting to ``engine.logger``.\n tag_name: when iteration output is a scalar, tag_name is used to print\n tag_name: scalar_value to logger. Defaults to ``'Loss'``.\n key_var_format: a formatting string to control the output string format of key: value.\n logger_handler: add additional handler to handle the stats data: save to file, etc.\n add existing python logging handlers: https://docs.python.org/3/library/logging.handlers.html\n \"\"\"\n\n self.epoch_print_logger = epoch_print_logger\n self.iteration_print_logger = iteration_print_logger\n self.output_transform = output_transform\n self.global_epoch_transform = global_epoch_transform\n self.logger = logging.getLogger(name)\n self._name = name\n\n self.tag_name = tag_name\n self.key_var_format = key_var_format\n if logger_handler is not None:\n self.logger.addHandler(logger_handler)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler.attach_StatsHandler.attach.None_3.engine_add_event_handler_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler.attach_StatsHandler.attach.None_3.engine_add_event_handler_", "embedding": null, "metadata": {"file_path": "monai/handlers/stats_handler.py", "file_name": "stats_handler.py", "file_type": "text/x-python", "category": "implementation", "start_line": 89, "end_line": 104, "span_ids": ["StatsHandler.attach"], "tokens": 174}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class StatsHandler(object):\n\n def attach(self, engine: Engine) -> None:\n \"\"\"\n Register a set of Ignite Event-Handlers to a specified Ignite engine.\n\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n\n \"\"\"\n if self._name is None:\n self.logger = engine.logger\n if not engine.has_event_handler(self.iteration_completed, Events.ITERATION_COMPLETED):\n engine.add_event_handler(Events.ITERATION_COMPLETED, self.iteration_completed)\n if not engine.has_event_handler(self.epoch_completed, Events.EPOCH_COMPLETED):\n engine.add_event_handler(Events.EPOCH_COMPLETED, self.epoch_completed)\n if not engine.has_event_handler(self.exception_raised, Events.EXCEPTION_RAISED):\n engine.add_event_handler(Events.EXCEPTION_RAISED, self.exception_raised)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler.epoch_completed_StatsHandler.exception_raised._traceback_print_exc_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler.epoch_completed_StatsHandler.exception_raised._traceback_print_exc_", "embedding": null, "metadata": {"file_path": "monai/handlers/stats_handler.py", "file_name": "stats_handler.py", "file_type": "text/x-python", "category": "implementation", "start_line": 106, "end_line": 146, "span_ids": ["StatsHandler.epoch_completed", "StatsHandler.exception_raised", "StatsHandler.iteration_completed"], "tokens": 291}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class StatsHandler(object):\n\n def epoch_completed(self, engine: Engine) -> None:\n \"\"\"\n Handler for train or validation/evaluation epoch completed Event.\n Print epoch level log, default values are from Ignite state.metrics dict.\n\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n\n \"\"\"\n if self.epoch_print_logger is not None:\n self.epoch_print_logger(engine)\n else:\n self._default_epoch_print(engine)\n\n def iteration_completed(self, engine: Engine) -> None:\n \"\"\"\n Handler for train or validation/evaluation iteration completed Event.\n Print iteration level log, default values are from Ignite state.logs dict.\n\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n\n \"\"\"\n if self.iteration_print_logger is not None:\n self.iteration_print_logger(engine)\n else:\n self._default_iteration_print(engine)\n\n def exception_raised(self, engine: Engine, e: Exception) -> None:\n \"\"\"\n Handler for train or validation/evaluation exception raised Event.\n Print the exception information and traceback.\n\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n e: the exception caught in Ignite during engine.run().\n\n \"\"\"\n self.logger.exception(f\"Exception: {e}\")\n # import traceback\n # traceback.print_exc()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler._default_epoch_print_StatsHandler._default_epoch_print.None_1": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler._default_epoch_print_StatsHandler._default_epoch_print.None_1", "embedding": null, "metadata": {"file_path": "monai/handlers/stats_handler.py", "file_name": "stats_handler.py", "file_type": "text/x-python", "category": "implementation", "start_line": 148, "end_line": 172, "span_ids": ["StatsHandler._default_epoch_print"], "tokens": 228}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class StatsHandler(object):\n\n def _default_epoch_print(self, engine: Engine) -> None:\n \"\"\"\n Execute epoch level log operation based on Ignite engine.state data.\n print the values from Ignite state.metrics dict.\n\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n\n \"\"\"\n prints_dict = engine.state.metrics\n if not prints_dict:\n return\n current_epoch = self.global_epoch_transform(engine.state.epoch)\n\n out_str = f\"Epoch[{current_epoch}] Metrics -- \"\n for name in sorted(prints_dict):\n value = prints_dict[name]\n out_str += self.key_var_format.format(name, value)\n self.logger.info(out_str)\n\n if hasattr(engine.state, \"key_metric_name\"):\n if hasattr(engine.state, \"best_metric\") and hasattr(engine.state, \"best_metric_epoch\"):\n out_str = f\"Key metric: {engine.state.key_metric_name} \"\n out_str += f\"best value: {engine.state.best_metric} at epoch: {engine.state.best_metric_epoch}\"\n self.logger.info(out_str)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler._default_iteration_print_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler._default_iteration_print_", "embedding": null, "metadata": {"file_path": "monai/handlers/stats_handler.py", "file_name": "stats_handler.py", "file_type": "text/x-python", "category": "implementation", "start_line": 174, "end_line": 223, "span_ids": ["StatsHandler._default_iteration_print"], "tokens": 447}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class StatsHandler(object):\n\n def _default_iteration_print(self, engine: Engine) -> None:\n \"\"\"\n Execute iteration log operation based on Ignite engine.state data.\n Print the values from Ignite state.logs dict.\n Default behavior is to print loss from output[1], skip if output[1] is not loss.\n\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n\n \"\"\"\n loss = self.output_transform(engine.state.output)\n if loss is None:\n return # no printing if the output is empty\n\n out_str = \"\"\n if isinstance(loss, dict): # print dictionary items\n for name in sorted(loss):\n value = loss[name]\n if not is_scalar(value):\n warnings.warn(\n \"ignoring non-scalar output in StatsHandler,\"\n \" make sure `output_transform(engine.state.output)` returns\"\n \" a scalar or dictionary of key and scalar pairs to avoid this warning.\"\n \" {}:{}\".format(name, type(value))\n )\n continue # not printing multi dimensional output\n out_str += self.key_var_format.format(name, value.item() if torch.is_tensor(value) else value)\n else:\n if is_scalar(loss): # not printing multi dimensional output\n out_str += self.key_var_format.format(self.tag_name, loss.item() if torch.is_tensor(loss) else loss)\n else:\n warnings.warn(\n \"ignoring non-scalar output in StatsHandler,\"\n \" make sure `output_transform(engine.state.output)` returns\"\n \" a scalar or a dictionary of key and scalar pairs to avoid this warning.\"\n \" {}\".format(type(loss))\n )\n\n if not out_str:\n return # no value to print\n\n num_iterations = engine.state.epoch_length\n current_iteration = (engine.state.iteration - 1) % num_iterations + 1\n current_epoch = engine.state.epoch\n num_epochs = engine.state.max_epochs\n\n base_str = f\"Epoch: {current_epoch}/{num_epochs}, Iter: {current_iteration}/{num_iterations} --\"\n\n self.logger.info(\" \".join([base_str, out_str]))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_from_typing_import_Callab_DEFAULT_TAG._Loss_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_from_typing_import_Callab_DEFAULT_TAG._Loss_", "embedding": null, "metadata": {"file_path": "monai/handlers/tensorboard_handlers.py", "file_name": "tensorboard_handlers.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 30, "span_ids": ["docstring"], "tokens": 148}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Optional, TYPE_CHECKING\n\nimport warnings\n\nimport numpy as np\nimport torch\n\nfrom monai.utils import exact_version, optional_import, is_scalar\nfrom monai.visualize import plot_2d_or_3d_image\n\nEvents, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Events\")\nif TYPE_CHECKING:\n from ignite.engine import Engine\n from torch.utils.tensorboard import SummaryWriter\nelse:\n Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")\n SummaryWriter, _ = optional_import(\"torch.utils.tensorboard\", name=\"SummaryWriter\")\n\nDEFAULT_TAG = \"Loss\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardStatsHandler_TensorBoardStatsHandler.__init__.self.tag_name.tag_name": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardStatsHandler_TensorBoardStatsHandler.__init__.self.tag_name.tag_name", "embedding": null, "metadata": {"file_path": "monai/handlers/tensorboard_handlers.py", "file_name": "tensorboard_handlers.py", "file_type": "text/x-python", "category": "implementation", "start_line": 33, "end_line": 80, "span_ids": ["TensorBoardStatsHandler.__init__", "TensorBoardStatsHandler"], "tokens": 548}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TensorBoardStatsHandler(object):\n \"\"\"\n TensorBoardStatsHandler defines a set of Ignite Event-handlers for all the TensorBoard logics.\n It's can be used for any Ignite Engine(trainer, validator and evaluator).\n And it can support both epoch level and iteration level with pre-defined TensorBoard event writer.\n The expected data source is Ignite ``engine.state.output`` and ``engine.state.metrics``.\n\n Default behaviors:\n - When EPOCH_COMPLETED, write each dictionary item in\n ``engine.state.metrics`` to TensorBoard.\n - When ITERATION_COMPLETED, write each dictionary item in\n ``self.output_transform(engine.state.output)`` to TensorBoard.\n \"\"\"\n\n def __init__(\n self,\n summary_writer: Optional[SummaryWriter] = None,\n log_dir: str = \"./runs\",\n epoch_event_writer: Optional[Callable] = None,\n iteration_event_writer: Optional[Callable] = None,\n output_transform: Callable = lambda x: x,\n global_epoch_transform: Callable = lambda x: x,\n tag_name: str = DEFAULT_TAG,\n ) -> None:\n \"\"\"\n Args:\n summary_writer: user can specify TensorBoard SummaryWriter,\n default to create a new writer.\n log_dir: if using default SummaryWriter, write logs to this directory, default is `./runs`.\n epoch_event_writer: customized callable TensorBoard writer for epoch level.\n Must accept parameter \"engine\" and \"summary_writer\", use default event writer if None.\n iteration_event_writer: customized callable TensorBoard writer for iteration level.\n Must accept parameter \"engine\" and \"summary_writer\", use default event writer if None.\n output_transform: a callable that is used to transform the\n ``ignite.engine.output`` into a scalar to plot, or a dictionary of {key: scalar}.\n In the latter case, the output string will be formatted as key: value.\n By default this value plotting happens when every iteration completed.\n global_epoch_transform: a callable that is used to customize global epoch number.\n For example, in evaluation, the evaluator engine might want to use trainer engines epoch number\n when plotting epoch vs metric curves.\n tag_name: when iteration output is a scalar, tag_name is used to plot, defaults to ``'Loss'``.\n \"\"\"\n self._writer = SummaryWriter(log_dir=log_dir) if summary_writer is None else summary_writer\n self.epoch_event_writer = epoch_event_writer\n self.iteration_event_writer = iteration_event_writer\n self.output_transform = output_transform\n self.global_epoch_transform = global_epoch_transform\n self.tag_name = tag_name", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardStatsHandler.attach_TensorBoardStatsHandler.attach.None_1.engine_add_event_handler_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardStatsHandler.attach_TensorBoardStatsHandler.attach.None_1.engine_add_event_handler_", "embedding": null, "metadata": {"file_path": "monai/handlers/tensorboard_handlers.py", "file_name": "tensorboard_handlers.py", "file_type": "text/x-python", "category": "implementation", "start_line": 82, "end_line": 93, "span_ids": ["TensorBoardStatsHandler.attach"], "tokens": 126}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TensorBoardStatsHandler(object):\n\n def attach(self, engine: Engine) -> None:\n \"\"\"\n Register a set of Ignite Event-Handlers to a specified Ignite engine.\n\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n\n \"\"\"\n if not engine.has_event_handler(self.iteration_completed, Events.ITERATION_COMPLETED):\n engine.add_event_handler(Events.ITERATION_COMPLETED, self.iteration_completed)\n if not engine.has_event_handler(self.epoch_completed, Events.EPOCH_COMPLETED):\n engine.add_event_handler(Events.EPOCH_COMPLETED, self.epoch_completed)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardStatsHandler.epoch_completed_TensorBoardStatsHandler.iteration_completed.if_self_iteration_event_w.else_.self__default_iteration_w": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardStatsHandler.epoch_completed_TensorBoardStatsHandler.iteration_completed.if_self_iteration_event_w.else_.self__default_iteration_w", "embedding": null, "metadata": {"file_path": "monai/handlers/tensorboard_handlers.py", "file_name": "tensorboard_handlers.py", "file_type": "text/x-python", "category": "implementation", "start_line": 95, "end_line": 121, "span_ids": ["TensorBoardStatsHandler.iteration_completed", "TensorBoardStatsHandler.epoch_completed"], "tokens": 211}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TensorBoardStatsHandler(object):\n\n def epoch_completed(self, engine: Engine) -> None:\n \"\"\"\n Handler for train or validation/evaluation epoch completed Event.\n Write epoch level events, default values are from Ignite state.metrics dict.\n\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n\n \"\"\"\n if self.epoch_event_writer is not None:\n self.epoch_event_writer(engine, self._writer)\n else:\n self._default_epoch_writer(engine, self._writer)\n\n def iteration_completed(self, engine: Engine) -> None:\n \"\"\"\n Handler for train or validation/evaluation iteration completed Event.\n Write iteration level events, default values are from Ignite state.logs dict.\n\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n\n \"\"\"\n if self.iteration_event_writer is not None:\n self.iteration_event_writer(engine, self._writer)\n else:\n self._default_iteration_writer(engine, self._writer)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardStatsHandler._default_epoch_writer_TensorBoardStatsHandler._default_epoch_writer.writer_flush_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardStatsHandler._default_epoch_writer_TensorBoardStatsHandler._default_epoch_writer.writer_flush_", "embedding": null, "metadata": {"file_path": "monai/handlers/tensorboard_handlers.py", "file_name": "tensorboard_handlers.py", "file_type": "text/x-python", "category": "implementation", "start_line": 123, "end_line": 137, "span_ids": ["TensorBoardStatsHandler._default_epoch_writer"], "tokens": 138}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TensorBoardStatsHandler(object):\n\n def _default_epoch_writer(self, engine: Engine, writer: SummaryWriter) -> None:\n \"\"\"\n Execute epoch level event write operation based on Ignite engine.state data.\n Default is to write the values from Ignite state.metrics dict.\n\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n writer: TensorBoard writer, created in TensorBoardHandler.\n\n \"\"\"\n current_epoch = self.global_epoch_transform(engine.state.epoch)\n summary_dict = engine.state.metrics\n for name, value in summary_dict.items():\n writer.add_scalar(name, value, current_epoch)\n writer.flush()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardStatsHandler._default_iteration_writer_TensorBoardStatsHandler._default_iteration_writer.writer_flush_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardStatsHandler._default_iteration_writer_TensorBoardStatsHandler._default_iteration_writer.writer_flush_", "embedding": null, "metadata": {"file_path": "monai/handlers/tensorboard_handlers.py", "file_name": "tensorboard_handlers.py", "file_type": "text/x-python", "category": "implementation", "start_line": 139, "end_line": 173, "span_ids": ["TensorBoardStatsHandler._default_iteration_writer"], "tokens": 340}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TensorBoardStatsHandler(object):\n\n def _default_iteration_writer(self, engine: Engine, writer: SummaryWriter) -> None:\n \"\"\"\n Execute iteration level event write operation based on Ignite engine.state data.\n Default is to write the loss value of current iteration.\n\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n writer: TensorBoard writer, created in TensorBoardHandler.\n\n \"\"\"\n loss = self.output_transform(engine.state.output)\n if loss is None:\n return # do nothing if output is empty\n if isinstance(loss, dict):\n for name in sorted(loss):\n value = loss[name]\n if not is_scalar(value):\n warnings.warn(\n \"ignoring non-scalar output in TensorBoardStatsHandler,\"\n \" make sure `output_transform(engine.state.output)` returns\"\n \" a scalar or dictionary of key and scalar pairs to avoid this warning.\"\n \" {}:{}\".format(name, type(value))\n )\n continue # not plot multi dimensional output\n writer.add_scalar(name, value.item() if torch.is_tensor(value) else value, engine.state.iteration)\n elif is_scalar(loss): # not printing multi dimensional output\n writer.add_scalar(self.tag_name, loss.item() if torch.is_tensor(loss) else loss, engine.state.iteration)\n else:\n warnings.warn(\n \"ignoring non-scalar output in TensorBoardStatsHandler,\"\n \" make sure `output_transform(engine.state.output)` returns\"\n \" a scalar or a dictionary of key and scalar pairs to avoid this warning.\"\n \" {}\".format(type(loss))\n )\n writer.flush()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardImageHandler_TensorBoardImageHandler.__init__.self.max_channels.max_channels": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardImageHandler_TensorBoardImageHandler.__init__.self.max_channels.max_channels", "embedding": null, "metadata": {"file_path": "monai/handlers/tensorboard_handlers.py", "file_name": "tensorboard_handlers.py", "file_type": "text/x-python", "category": "implementation", "start_line": 176, "end_line": 237, "span_ids": ["TensorBoardImageHandler.__init__", "TensorBoardImageHandler"], "tokens": 734}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TensorBoardImageHandler(object):\n \"\"\"\n TensorBoardImageHandler is an Ignite Event handler that can visualise images, labels and outputs as 2D/3D images.\n 2D output (shape in Batch, channel, H, W) will be shown as simple image using the first element in the batch,\n for 3D to ND output (shape in Batch, channel, H, W, D) input, each of ``self.max_channels`` number of images'\n last three dimensions will be shown as animated GIF along the last axis (typically Depth).\n\n It can be used for any Ignite Engine (trainer, validator and evaluator).\n User can easily add it to engine for any expected Event, for example: ``EPOCH_COMPLETED``,\n ``ITERATION_COMPLETED``. The expected data source is ignite's ``engine.state.batch`` and ``engine.state.output``.\n\n Default behavior:\n - Show y_pred as images (GIF for 3D) on TensorBoard when Event triggered,\n - Need to use ``batch_transform`` and ``output_transform`` to specify\n how many images to show and show which channel.\n - Expects ``batch_transform(engine.state.batch)`` to return data\n format: (image[N, channel, ...], label[N, channel, ...]).\n - Expects ``output_transform(engine.state.output)`` to return a torch\n tensor in format (y_pred[N, channel, ...], loss).\n\n \"\"\"\n\n def __init__(\n self,\n summary_writer: Optional[SummaryWriter] = None,\n log_dir: str = \"./runs\",\n interval: int = 1,\n epoch_level: bool = True,\n batch_transform: Callable = lambda x: x,\n output_transform: Callable = lambda x: x,\n global_iter_transform: Callable = lambda x: x,\n index: int = 0,\n max_channels: int = 1,\n max_frames: int = 64,\n ) -> None:\n \"\"\"\n Args:\n summary_writer: user can specify TensorBoard SummaryWriter,\n default to create a new writer.\n log_dir: if using default SummaryWriter, write logs to this directory, default is `./runs`.\n interval: plot content from engine.state every N epochs or every N iterations, default is 1.\n epoch_level: plot content from engine.state every N epochs or N iterations. `True` is epoch level,\n `False` is iteration level.\n batch_transform: a callable that is used to transform the\n ``ignite.engine.batch`` into expected format to extract several label data.\n output_transform: a callable that is used to transform the\n ``ignite.engine.output`` into expected format to extract several output data.\n global_iter_transform: a callable that is used to customize global step number for TensorBoard.\n For example, in evaluation, the evaluator engine needs to know current epoch from trainer.\n index: plot which element in a data batch, default is the first element.\n max_channels: number of channels to plot.\n max_frames: number of frames for 2D-t plot.\n \"\"\"\n self._writer = SummaryWriter(log_dir=log_dir) if summary_writer is None else summary_writer\n self.interval = interval\n self.epoch_level = epoch_level\n self.batch_transform = batch_transform\n self.output_transform = output_transform\n self.global_iter_transform = global_iter_transform\n self.index = index\n self.max_frames = max_frames\n self.max_channels = max_channels", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardImageHandler.attach_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_TensorBoardImageHandler.attach_", "embedding": null, "metadata": {"file_path": "monai/handlers/tensorboard_handlers.py", "file_name": "tensorboard_handlers.py", "file_type": "text/x-python", "category": "implementation", "start_line": 239, "end_line": 278, "span_ids": ["TensorBoardImageHandler.__call__", "TensorBoardImageHandler.attach"], "tokens": 424}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TensorBoardImageHandler(object):\n\n def attach(self, engine: Engine) -> None:\n if self.epoch_level:\n engine.add_event_handler(Events.EPOCH_COMPLETED(every=self.interval), self)\n else:\n engine.add_event_handler(Events.ITERATION_COMPLETED(every=self.interval), self)\n\n def __call__(self, engine: Engine) -> None:\n step = self.global_iter_transform(engine.state.epoch if self.epoch_level else engine.state.iteration)\n show_images = self.batch_transform(engine.state.batch)[0]\n if torch.is_tensor(show_images):\n show_images = show_images.detach().cpu().numpy()\n if show_images is not None:\n if not isinstance(show_images, np.ndarray):\n raise ValueError(\"output_transform(engine.state.output)[0] must be an ndarray or tensor.\")\n plot_2d_or_3d_image(\n show_images, step, self._writer, self.index, self.max_channels, self.max_frames, \"input_0\"\n )\n\n show_labels = self.batch_transform(engine.state.batch)[1]\n if torch.is_tensor(show_labels):\n show_labels = show_labels.detach().cpu().numpy()\n if show_labels is not None:\n if not isinstance(show_labels, np.ndarray):\n raise ValueError(\"batch_transform(engine.state.batch)[1] must be an ndarray or tensor.\")\n plot_2d_or_3d_image(\n show_labels, step, self._writer, self.index, self.max_channels, self.max_frames, \"input_1\"\n )\n\n show_outputs = self.output_transform(engine.state.output)\n if torch.is_tensor(show_outputs):\n show_outputs = show_outputs.detach().cpu().numpy()\n if show_outputs is not None:\n if not isinstance(show_outputs, np.ndarray):\n raise ValueError(\"output_transform(engine.state.output) must be an ndarray or tensor.\")\n plot_2d_or_3d_image(\n show_outputs, step, self._writer, self.index, self.max_channels, self.max_frames, \"output\"\n )\n\n self._writer.flush()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/utils.py_from_typing_import_Callab_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/utils.py_from_typing_import_Callab_", "embedding": null, "metadata": {"file_path": "monai/handlers/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 41, "span_ids": ["stopping_fn_from_metric", "stopping_fn_from_loss", "docstring"], "tokens": 164}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, TYPE_CHECKING\nfrom monai.utils import exact_version, optional_import\n\nif TYPE_CHECKING:\n from ignite.engine import Engine\nelse:\n Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")\n\n\ndef stopping_fn_from_metric(metric_name: str) -> Callable:\n \"\"\"\n Returns a stopping function for ignite.handlers.EarlyStopping using the given metric name.\n \"\"\"\n\n def stopping_fn(engine: Engine):\n return engine.state.metrics[metric_name]\n\n return stopping_fn\n\n\ndef stopping_fn_from_loss() -> Callable:\n \"\"\"\n Returns a stopping function for ignite.handlers.EarlyStopping using the loss value.\n \"\"\"\n\n def stopping_fn(engine: Engine):\n return -engine.state.output\n\n return stopping_fn", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/validation_handler.py_from_typing_import_TYPE_C_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/validation_handler.py_from_typing_import_TYPE_C_", "embedding": null, "metadata": {"file_path": "monai/handlers/validation_handler.py", "file_name": "validation_handler.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 57, "span_ids": ["ValidationHandler.__init__", "ValidationHandler.__call__", "docstring", "ValidationHandler.attach", "ValidationHandler"], "tokens": 350}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import TYPE_CHECKING\n\nfrom monai.engines.evaluator import Evaluator\nfrom monai.utils import exact_version, optional_import\n\nEvents, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Events\")\nif TYPE_CHECKING:\n from ignite.engine import Engine\nelse:\n Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")\n\n\nclass ValidationHandler:\n \"\"\"\n Attach validator to the trainer engine in Ignite.\n It can support to execute validation every N epochs or every N iterations.\n\n \"\"\"\n\n def __init__(self, validator: Evaluator, interval: int, epoch_level: bool = True) -> None:\n \"\"\"\n Args:\n validator: run the validator when trigger validation, suppose to be Evaluator.\n interval: do validation every N epochs or every N iterations during training.\n epoch_level: execute validation every N epochs or N iterations.\n `True` is epoch level, `False` is iteration level.\n\n Raises:\n ValueError: validator must be Evaluator ignite engine.\n\n \"\"\"\n if not isinstance(validator, Evaluator):\n raise ValueError(\"validator must be Evaluator ignite engine.\")\n self.validator = validator\n self.interval = interval\n self.epoch_level = epoch_level\n\n def attach(self, engine: Engine) -> None:\n if self.epoch_level:\n engine.add_event_handler(Events.EPOCH_COMPLETED(every=self.interval), self)\n else:\n engine.add_event_handler(Events.ITERATION_COMPLETED(every=self.interval), self)\n\n def __call__(self, engine: Engine) -> None:\n self.validator.run(engine.state.epoch)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/__init__.py_sliding_window_inference_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/__init__.py_sliding_window_inference_", "embedding": null, "metadata": {"file_path": "monai/inferers/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 14, "span_ids": ["docstring"], "tokens": 15}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from .utils import sliding_window_inference\nfrom .inferer import *", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/inferer.py_from_typing_import_Sequen_SimpleInferer.__call__.return.network_inputs_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/inferer.py_from_typing_import_Sequen_SimpleInferer.__call__.return.network_inputs_", "embedding": null, "metadata": {"file_path": "monai/inferers/inferer.py", "file_name": "inferer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 61, "span_ids": ["SimpleInferer", "Inferer.__call__", "SimpleInferer.__call__", "Inferer", "SimpleInferer.__init__", "docstring"], "tokens": 257}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Sequence, Union\n\nfrom abc import ABC, abstractmethod\n\nimport torch\n\nfrom monai.inferers.utils import sliding_window_inference\nfrom monai.utils import BlendMode\n\n\nclass Inferer(ABC):\n \"\"\"\n A base class for model inference.\n Extend this class to support operations during inference, e.g. a sliding window method.\n \"\"\"\n\n @abstractmethod\n def __call__(self, inputs: torch.Tensor, network):\n \"\"\"\n Run inference on `inputs` with the `network` model.\n\n Args:\n inputs: input of the model inference.\n network (Network): model for inference.\n\n Raises:\n NotImplementedError: subclass will implement the operations.\n\n \"\"\"\n raise NotImplementedError(\"subclass will implement the operations.\")\n\n\nclass SimpleInferer(Inferer):\n \"\"\"\n SimpleInferer is the normal inference method that run model forward() directly.\n\n \"\"\"\n\n def __init__(self) -> None:\n Inferer.__init__(self)\n\n def __call__(self, inputs: torch.Tensor, network):\n \"\"\"Unified callable function API of Inferers.\n\n Args:\n inputs: model input data for inference.\n network (Network): target model to execute inference.\n\n \"\"\"\n return network(inputs)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/inferer.py_SlidingWindowInferer_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/inferer.py_SlidingWindowInferer_", "embedding": null, "metadata": {"file_path": "monai/inferers/inferer.py", "file_name": "inferer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 64, "end_line": 112, "span_ids": ["SlidingWindowInferer", "SlidingWindowInferer.__init__", "SlidingWindowInferer.__call__"], "tokens": 440}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SlidingWindowInferer(Inferer):\n \"\"\"\n Sliding window method for model inference,\n with `sw_batch_size` windows for every model.forward().\n\n Args:\n roi_size: the window size to execute SlidingWindow evaluation.\n If it has non-positive components, the corresponding `inputs` size will be used.\n if the components of the `roi_size` are non-positive values, the transform will use the\n corresponding components of img size. For example, `roi_size=(32, -1)` will be adapted\n to `(32, 64)` if the second spatial dimension size of img is `64`.\n sw_batch_size: the batch size to run window slices.\n overlap: Amount of overlap between scans.\n mode: {``\"constant\"``, ``\"gaussian\"``}\n How to blend output of overlapping windows. Defaults to ``\"constant\"``.\n\n - ``\"constant``\": gives equal weight to all predictions.\n - ``\"gaussian``\": gives less weight to predictions on edges of windows.\n\n Note:\n the \"sw_batch_size\" here is to run a batch of window slices of 1 input image,\n not batch size of input images.\n\n \"\"\"\n\n def __init__(\n self,\n roi_size: Union[Sequence[int], int],\n sw_batch_size: int = 1,\n overlap: float = 0.25,\n mode: Union[BlendMode, str] = BlendMode.CONSTANT,\n ) -> None:\n Inferer.__init__(self)\n self.roi_size = roi_size\n self.sw_batch_size = sw_batch_size\n self.overlap = overlap\n self.mode: BlendMode = BlendMode(mode)\n\n def __call__(self, inputs: torch.Tensor, network):\n \"\"\"\n Unified callable function API of Inferers.\n\n Args:\n inputs: model input data for inference.\n network (Network): target model to execute inference.\n\n \"\"\"\n return sliding_window_inference(inputs, self.roi_size, self.sw_batch_size, network, self.overlap, self.mode)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/utils.py_from_typing_import_Callab_sliding_window_inference.pad_size._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/utils.py_from_typing_import_Callab_sliding_window_inference.pad_size._", "embedding": null, "metadata": {"file_path": "monai/inferers/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 82, "span_ids": ["sliding_window_inference", "docstring"], "tokens": 799}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Sequence, Union\n\nimport torch\nimport torch.nn.functional as F\n\nfrom monai.data.utils import compute_importance_map, dense_patch_slices, get_valid_patch_size\nfrom monai.utils import BlendMode, PytorchPadMode, fall_back_tuple\n\n\ndef sliding_window_inference(\n inputs: torch.Tensor,\n roi_size: Union[Sequence[int], int],\n sw_batch_size: int,\n predictor: Callable,\n overlap: float = 0.25,\n mode: Union[BlendMode, str] = BlendMode.CONSTANT,\n padding_mode: Union[PytorchPadMode, str] = PytorchPadMode.CONSTANT,\n cval: float = 0.0,\n):\n \"\"\"\n Sliding window inference on `inputs` with `predictor`.\n\n When roi_size is larger than the inputs' spatial size, the input image are padded during inference.\n To maintain the same spatial sizes, the output image will be cropped to the original input size.\n\n Args:\n inputs: input image to be processed (assuming NCHW[D])\n roi_size: the spatial window size for inferences.\n When its components have None or non-positives, the corresponding inputs dimension will be used.\n if the components of the `roi_size` are non-positive values, the transform will use the\n corresponding components of img size. For example, `roi_size=(32, -1)` will be adapted\n to `(32, 64)` if the second spatial dimension size of img is `64`.\n sw_batch_size: the batch size to run window slices.\n predictor: given input tensor `patch_data` in shape NCHW[D], `predictor(patch_data)`\n should return a prediction with the same spatial shape and batch_size, i.e. NMHW[D];\n where HW[D] represents the patch spatial size, M is the number of output channels, N is `sw_batch_size`.\n overlap: Amount of overlap between scans.\n mode: {``\"constant\"``, ``\"gaussian\"``}\n How to blend output of overlapping windows. Defaults to ``\"constant\"``.\n\n - ``\"constant``\": gives equal weight to all predictions.\n - ``\"gaussian``\": gives less weight to predictions on edges of windows.\n\n padding_mode: {``\"constant\"``, ``\"reflect\"``, ``\"replicate\"``, ``\"circular\"``}\n Padding mode when ``roi_size`` is larger than inputs. Defaults to ``\"constant\"``\n See also: https://pytorch.org/docs/stable/nn.functional.html#pad\n cval: fill value for 'constant' padding mode. Default: 0\n\n Raises:\n NotImplementedError: inputs must have batch_size=1.\n\n Note:\n - input must be channel-first and have a batch dim, support both spatial 2D and 3D.\n - currently only supports `inputs` with batch_size=1.\n \"\"\"\n num_spatial_dims = len(inputs.shape) - 2\n assert 0 <= overlap < 1, \"overlap must be >= 0 and < 1.\"\n\n # determine image spatial size and batch size\n # Note: all input images must have the same image size and batch size\n image_size_ = list(inputs.shape[2:])\n batch_size = inputs.shape[0]\n\n # TODO: Enable batch sizes > 1 in future\n if batch_size > 1:\n raise NotImplementedError(\"inputs must have batch_size=1.\")\n\n roi_size = fall_back_tuple(roi_size, image_size_)\n # in case that image size is smaller than roi size\n image_size = tuple(max(image_size_[i], roi_size[i]) for i in range(num_spatial_dims))\n pad_size = []\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/utils.py_sliding_window_inference.for_k_in_range_len_inputs_sliding_window_inference.output_image_count_map": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/utils.py_sliding_window_inference.for_k_in_range_len_inputs_sliding_window_inference.output_image_count_map", "embedding": null, "metadata": {"file_path": "monai/inferers/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 83, "end_line": 141, "span_ids": ["sliding_window_inference"], "tokens": 767}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def sliding_window_inference(\n inputs: torch.Tensor,\n roi_size: Union[Sequence[int], int],\n sw_batch_size: int,\n predictor: Callable,\n overlap: float = 0.25,\n mode: Union[BlendMode, str] = BlendMode.CONSTANT,\n padding_mode: Union[PytorchPadMode, str] = PytorchPadMode.CONSTANT,\n cval: float = 0.0,\n):\n # ... other code\n for k in range(len(inputs.shape) - 1, 1, -1):\n diff = max(roi_size[k - 2] - inputs.shape[k], 0)\n half = diff // 2\n pad_size.extend([half, diff - half])\n inputs = F.pad(inputs, pad=pad_size, mode=PytorchPadMode(padding_mode).value, value=cval)\n\n scan_interval = _get_scan_interval(image_size, roi_size, num_spatial_dims, overlap)\n\n # Store all slices in list\n slices = dense_patch_slices(image_size, roi_size, scan_interval)\n\n slice_batches = []\n for slice_index in range(0, len(slices), sw_batch_size):\n slice_index_range = range(slice_index, min(slice_index + sw_batch_size, len(slices)))\n input_slices = []\n for curr_index in slice_index_range:\n curr_slice = slices[curr_index]\n if len(curr_slice) == 3:\n input_slices.append(inputs[0, :, curr_slice[0], curr_slice[1], curr_slice[2]])\n else:\n input_slices.append(inputs[0, :, curr_slice[0], curr_slice[1]])\n slice_batches.append(torch.stack(input_slices))\n\n # Perform predictions\n output_rois = list()\n for data in slice_batches:\n seg_prob = predictor(data) # batched patch segmentation\n output_rois.append(seg_prob)\n\n # stitching output image\n output_classes = output_rois[0].shape[1]\n output_shape = [batch_size, output_classes] + list(image_size)\n\n # Create importance map\n importance_map = compute_importance_map(get_valid_patch_size(image_size, roi_size), mode=mode, device=inputs.device)\n\n # allocate memory to store the full output and the count for overlapping parts\n output_image = torch.zeros(output_shape, dtype=torch.float32, device=inputs.device)\n count_map = torch.zeros(output_shape, dtype=torch.float32, device=inputs.device)\n\n for window_id, slice_index in enumerate(range(0, len(slices), sw_batch_size)):\n slice_index_range = range(slice_index, min(slice_index + sw_batch_size, len(slices)))\n\n # store the result in the proper location of the full output. Apply weights from importance map.\n for curr_index in slice_index_range:\n curr_slice = slices[curr_index]\n if len(curr_slice) == 3:\n output_image[0, :, curr_slice[0], curr_slice[1], curr_slice[2]] += (\n importance_map * output_rois[window_id][curr_index - slice_index, :]\n )\n count_map[0, :, curr_slice[0], curr_slice[1], curr_slice[2]] += importance_map\n else:\n output_image[0, :, curr_slice[0], curr_slice[1]] += (\n importance_map * output_rois[window_id][curr_index - slice_index, :]\n )\n count_map[0, :, curr_slice[0], curr_slice[1]] += importance_map\n\n # account for any overlapping sections\n output_image /= count_map\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/utils.py_sliding_window_inference.if_num_spatial_dims_3__sliding_window_inference._2D": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/utils.py_sliding_window_inference.if_num_spatial_dims_3__sliding_window_inference._2D", "embedding": null, "metadata": {"file_path": "monai/inferers/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 143, "end_line": 152, "span_ids": ["sliding_window_inference"], "tokens": 224}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def sliding_window_inference(\n inputs: torch.Tensor,\n roi_size: Union[Sequence[int], int],\n sw_batch_size: int,\n predictor: Callable,\n overlap: float = 0.25,\n mode: Union[BlendMode, str] = BlendMode.CONSTANT,\n padding_mode: Union[PytorchPadMode, str] = PytorchPadMode.CONSTANT,\n cval: float = 0.0,\n):\n # ... other code\n\n if num_spatial_dims == 3:\n return output_image[\n ...,\n pad_size[4] : image_size_[0] + pad_size[4],\n pad_size[2] : image_size_[1] + pad_size[2],\n pad_size[0] : image_size_[2] + pad_size[0],\n ]\n return output_image[\n ..., pad_size[2] : image_size_[0] + pad_size[2], pad_size[0] : image_size_[1] + pad_size[0]\n ] # 2D", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/utils.py__get_scan_interval_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/utils.py__get_scan_interval_", "embedding": null, "metadata": {"file_path": "monai/inferers/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 155, "end_line": 167, "span_ids": ["_get_scan_interval"], "tokens": 137}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def _get_scan_interval(image_size, roi_size, num_spatial_dims: int, overlap: float):\n assert len(image_size) == num_spatial_dims, \"image coord different from spatial dims.\"\n assert len(roi_size) == num_spatial_dims, \"roi coord different from spatial dims.\"\n\n scan_interval = []\n for i in range(num_spatial_dims):\n if roi_size[i] == image_size[i]:\n scan_interval.append(int(roi_size[i]))\n else:\n # scan interval is (1-overlap)*roi_size\n scan_interval.append(int(roi_size[i] * (1 - overlap)))\n return tuple(scan_interval)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/__init__.py_Dice_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/__init__.py_Dice_", "embedding": null, "metadata": {"file_path": "monai/losses/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 15, "span_ids": ["docstring"], "tokens": 44}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from .dice import Dice, DiceLoss, GeneralizedDiceLoss, dice, generalized_dice, MaskedDiceLoss\nfrom .focal_loss import FocalLoss\nfrom .tversky import TverskyLoss", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_from_typing_import_Callab_DiceLoss.__init__.self.jaccard.jaccard": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_from_typing_import_Callab_DiceLoss.__init__.self.jaccard.jaccard", "embedding": null, "metadata": {"file_path": "monai/losses/dice.py", "file_name": "dice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 79, "span_ids": ["DiceLoss.__init__", "DiceLoss", "docstring"], "tokens": 717}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Optional, Union\n\nimport warnings\n\nimport torch\nfrom torch.nn.modules.loss import _Loss\n\nfrom monai.networks import one_hot\nfrom monai.utils import LossReduction, Weight\n\n\nclass DiceLoss(_Loss):\n \"\"\"\n Compute average Dice loss between two tensors. It can support both multi-classes and multi-labels tasks.\n Input logits `input` (BNHW[D] where N is number of classes) is compared with ground truth `target` (BNHW[D]).\n Axis N of `input` is expected to have logit predictions for each class rather than being image channels,\n while the same axis of `target` can be 1 or N (one-hot format). The `smooth` parameter is a value added to the\n intersection and union components of the inter-over-union calculation to smooth results and prevent divide by 0,\n this value should be small. The `include_background` class attribute can be set to False for an instance of\n DiceLoss to exclude the first category (channel index 0) which is by convention assumed to be background.\n If the non-background segmentations are small compared to the total image size they can get overwhelmed by\n the signal from the background so excluding it in such cases helps convergence.\n\n Milletari, F. et. al. (2016) V-Net: Fully Convolutional Neural Networks forVolumetric Medical Image Segmentation, 3DV, 2016.\n\n \"\"\"\n\n def __init__(\n self,\n include_background: bool = True,\n to_onehot_y: bool = False,\n sigmoid: bool = False,\n softmax: bool = False,\n squared_pred: bool = False,\n jaccard: bool = False,\n reduction: Union[LossReduction, str] = LossReduction.MEAN,\n ) -> None:\n \"\"\"\n Args:\n include_background: If False channel index 0 (background category) is excluded from the calculation.\n to_onehot_y: whether to convert `y` into the one-hot format. Defaults to False.\n sigmoid: If True, apply a sigmoid function to the prediction.\n softmax: If True, apply a softmax function to the prediction.\n squared_pred: use squared versions of targets and predictions in the denominator or not.\n jaccard: compute Jaccard Index (soft IoU) instead of dice or not.\n reduction: {``\"none\"``, ``\"mean\"``, ``\"sum\"``}\n Specifies the reduction to apply to the output. Defaults to ``\"mean\"``.\n\n - ``\"none\"``: no reduction will be applied.\n - ``\"mean\"``: the sum of the output will be divided by the number of elements in the output.\n - ``\"sum\"``: the output will be summed.\n\n Raises:\n ValueError: reduction={reduction} is invalid. Valid options are: none, mean or sum.\n ValueError: sigmoid=True and softmax=True are not compatible.\n\n \"\"\"\n super().__init__(reduction=LossReduction(reduction).value)\n\n if sigmoid and softmax:\n raise ValueError(\"sigmoid=True and softmax=True are not compatible.\")\n\n self.include_background = include_background\n self.to_onehot_y = to_onehot_y\n self.sigmoid = sigmoid\n self.softmax = softmax\n self.squared_pred = squared_pred\n self.jaccard = jaccard", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_DiceLoss.forward_DiceLoss.forward.return.f": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_DiceLoss.forward_DiceLoss.forward.return.f", "embedding": null, "metadata": {"file_path": "monai/losses/dice.py", "file_name": "dice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 81, "end_line": 145, "span_ids": ["DiceLoss.forward"], "tokens": 537}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DiceLoss(_Loss):\n\n def forward(self, input: torch.Tensor, target: torch.Tensor, smooth: float = 1e-5):\n \"\"\"\n Args:\n input: the shape should be BNH[WD].\n target: the shape should be BNH[WD].\n smooth: a small constant to avoid nan.\n\n Raises:\n ValueError: reduction={self.reduction} is invalid.\n\n \"\"\"\n if self.sigmoid:\n input = torch.sigmoid(input)\n\n n_pred_ch = input.shape[1]\n if n_pred_ch == 1:\n if self.softmax:\n warnings.warn(\"single channel prediction, `softmax=True` ignored.\")\n if self.to_onehot_y:\n warnings.warn(\"single channel prediction, `to_onehot_y=True` ignored.\")\n if not self.include_background:\n warnings.warn(\"single channel prediction, `include_background=False` ignored.\")\n else:\n if self.softmax:\n input = torch.softmax(input, 1)\n\n if self.to_onehot_y:\n target = one_hot(target, num_classes=n_pred_ch)\n if not self.include_background:\n # if skipping background, removing first channel\n target = target[:, 1:]\n input = input[:, 1:]\n\n assert (\n target.shape == input.shape\n ), f\"ground truth has differing shape ({target.shape}) from input ({input.shape})\"\n\n # reducing only spatial dimensions (not batch nor channels)\n reduce_axis = list(range(2, len(input.shape)))\n intersection = torch.sum(target * input, dim=reduce_axis)\n\n if self.squared_pred:\n target = torch.pow(target, 2)\n input = torch.pow(input, 2)\n\n ground_o = torch.sum(target, dim=reduce_axis)\n pred_o = torch.sum(input, dim=reduce_axis)\n\n denominator = ground_o + pred_o\n\n if self.jaccard:\n denominator = 2.0 * (denominator - intersection)\n\n f = 1.0 - (2.0 * intersection + smooth) / (denominator + smooth)\n\n if self.reduction == LossReduction.MEAN.value:\n f = torch.mean(f) # the batch and channel average\n elif self.reduction == LossReduction.SUM.value:\n f = torch.sum(f) # sum over the batch and channel dims\n elif self.reduction == LossReduction.NONE.value:\n pass # returns [N, n_classes] losses\n else:\n raise ValueError(f\"reduction={self.reduction} is invalid.\")\n\n return f", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_MaskedDiceLoss_MaskedDiceLoss.forward.return.super_forward_input_inp": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_MaskedDiceLoss_MaskedDiceLoss.forward.return.super_forward_input_inp", "embedding": null, "metadata": {"file_path": "monai/losses/dice.py", "file_name": "dice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 148, "end_line": 179, "span_ids": ["MaskedDiceLoss.forward", "MaskedDiceLoss"], "tokens": 331}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class MaskedDiceLoss(DiceLoss):\n \"\"\"\n Same as DiceLoss, but accepts a binary mask ([0,1]) indicating a region over which to compute the dice.\n \"\"\"\n\n def forward(\n self, input: torch.Tensor, target: torch.Tensor, smooth: float = 1e-5, mask: Optional[torch.Tensor] = None\n ):\n \"\"\"\n Args:\n input: the shape should be BNH[WD].\n target: the shape should be BNH[WD].\n smooth: a small constant to avoid nan.\n mask: the shape should B1H[WD] or 11H[WD].\n \"\"\"\n if mask is not None:\n # checking if mask is of proper shape\n assert input.dim() == mask.dim(), f\"dim of input ({input.shape}) is different from mask ({mask.shape})\"\n assert (\n input.shape[0] == mask.shape[0] or mask.shape[0] == 1\n ), f\" batch size of mask ({mask.shape}) must be 1 or equal to input ({input.shape})\"\n\n if target.dim() > 1:\n assert mask.shape[1] == 1, f\"mask ({mask.shape}) must have only 1 channel\"\n assert (\n input.shape[2:] == mask.shape[2:]\n ), f\"spatial size of input ({input.shape}) is different from mask ({mask.shape})\"\n\n input = input * mask\n target = target * mask\n\n return super().forward(input=input, target=target, smooth=smooth)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedDiceLoss_GeneralizedDiceLoss.__init__.if_w_type_Weight_SIMPL.elif_w_type_Weight_SQU.self.w_func.lambda_x_torch_reciproca": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedDiceLoss_GeneralizedDiceLoss.__init__.if_w_type_Weight_SIMPL.elif_w_type_Weight_SQU.self.w_func.lambda_x_torch_reciproca", "embedding": null, "metadata": {"file_path": "monai/losses/dice.py", "file_name": "dice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 182, "end_line": 236, "span_ids": ["GeneralizedDiceLoss.__init__", "GeneralizedDiceLoss"], "tokens": 556}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class GeneralizedDiceLoss(_Loss):\n \"\"\"\n Compute the generalised Dice loss defined in:\n\n Sudre, C. et. al. (2017) Generalised Dice overlap as a deep learning\n loss function for highly unbalanced segmentations. DLMIA 2017.\n\n Adapted from:\n https://github.com/NifTK/NiftyNet/blob/v0.6.0/niftynet/layer/loss_segmentation.py#L279\n \"\"\"\n\n def __init__(\n self,\n include_background: bool = True,\n to_onehot_y: bool = False,\n sigmoid: bool = False,\n softmax: bool = False,\n w_type: Union[Weight, str] = Weight.SQUARE,\n reduction: Union[LossReduction, str] = LossReduction.MEAN,\n ) -> None:\n \"\"\"\n Args:\n include_background: If False channel index 0 (background category) is excluded from the calculation.\n to_onehot_y: whether to convert `y` into the one-hot format. Defaults to False.\n sigmoid: If True, apply a sigmoid function to the prediction.\n softmax: If True, apply a softmax function to the prediction.\n w_type: {``\"square\"``, ``\"simple\"``, ``\"uniform\"``}\n Type of function to transform ground truth volume to a weight factor. Defaults to ``\"square\"``.\n reduction: {``\"none\"``, ``\"mean\"``, ``\"sum\"``}\n Specifies the reduction to apply to the output. Defaults to ``\"mean\"``.\n\n - ``\"none\"``: no reduction will be applied.\n - ``\"mean\"``: the sum of the output will be divided by the number of elements in the output.\n - ``\"sum\"``: the output will be summed.\n\n Raises:\n ValueError: reduction={reduction} is invalid. Valid options are: none, mean or sum.\n ValueError: sigmoid=True and softmax=True are not compatible.\n\n \"\"\"\n super().__init__(reduction=LossReduction(reduction).value)\n\n self.include_background = include_background\n self.to_onehot_y = to_onehot_y\n if sigmoid and softmax:\n raise ValueError(\"sigmoid=True and softmax=True are not compatible.\")\n self.sigmoid = sigmoid\n self.softmax = softmax\n\n w_type = Weight(w_type)\n self.w_func: Callable = torch.ones_like\n if w_type == Weight.SIMPLE:\n self.w_func = torch.reciprocal\n elif w_type == Weight.SQUARE:\n self.w_func = lambda x: torch.reciprocal(x * x)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedDiceLoss.forward_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedDiceLoss.forward_", "embedding": null, "metadata": {"file_path": "monai/losses/dice.py", "file_name": "dice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 238, "end_line": 303, "span_ids": ["GeneralizedDiceLoss.forward", "impl"], "tokens": 561}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class GeneralizedDiceLoss(_Loss):\n\n def forward(self, input: torch.Tensor, target: torch.Tensor, smooth: float = 1e-5):\n \"\"\"\n Args:\n input: the shape should be BNH[WD].\n target: the shape should be BNH[WD].\n smooth: a small constant to avoid nan.\n\n Raises:\n ValueError: reduction={self.reduction} is invalid.\n\n \"\"\"\n if self.sigmoid:\n input = torch.sigmoid(input)\n n_pred_ch = input.shape[1]\n if n_pred_ch == 1:\n if self.softmax:\n warnings.warn(\"single channel prediction, `softmax=True` ignored.\")\n if self.to_onehot_y:\n warnings.warn(\"single channel prediction, `to_onehot_y=True` ignored.\")\n if not self.include_background:\n warnings.warn(\"single channel prediction, `include_background=False` ignored.\")\n else:\n if self.softmax:\n input = torch.softmax(input, 1)\n if self.to_onehot_y:\n target = one_hot(target, n_pred_ch)\n if not self.include_background:\n # if skipping background, removing first channel\n target = target[:, 1:]\n input = input[:, 1:]\n assert (\n target.shape == input.shape\n ), f\"ground truth has differing shape ({target.shape}) from input ({input.shape})\"\n\n # reducing only spatial dimensions (not batch nor channels)\n reduce_axis = list(range(2, len(input.shape)))\n intersection = torch.sum(target * input, reduce_axis)\n\n ground_o = torch.sum(target, reduce_axis)\n pred_o = torch.sum(input, reduce_axis)\n\n denominator = ground_o + pred_o\n\n w = self.w_func(ground_o.float())\n for b in w:\n infs = torch.isinf(b)\n b[infs] = 0.0\n b[infs] = torch.max(b)\n\n f = 1.0 - (2.0 * (intersection * w).sum(1) + smooth) / ((denominator * w).sum(1) + smooth)\n\n if self.reduction == LossReduction.MEAN.value:\n f = torch.mean(f) # the batch and channel average\n elif self.reduction == LossReduction.SUM.value:\n f = torch.sum(f) # sum over the batch and channel dims\n elif self.reduction == LossReduction.NONE.value:\n pass # returns [N, n_classes] losses\n else:\n raise ValueError(f\"reduction={self.reduction} is invalid.\")\n\n return f\n\n\ndice = Dice = DiceLoss\ngeneralized_dice = GeneralizedDiceLoss", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/focal_loss.py_from_typing_import_Option_FocalLoss.__init__.self.weight": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/focal_loss.py_from_typing_import_Option_FocalLoss.__init__.self.weight", "embedding": null, "metadata": {"file_path": "monai/losses/focal_loss.py", "file_name": "focal_loss.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 62, "span_ids": ["FocalLoss.__init__", "FocalLoss", "docstring"], "tokens": 447}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Union\n\nimport torch\nimport torch.nn.functional as F\nfrom torch.nn.modules.loss import _WeightedLoss\n\nfrom monai.utils import LossReduction\n\n\nclass FocalLoss(_WeightedLoss):\n \"\"\"\n Reimplementation of the Focal Loss described in:\n\n - \"Focal Loss for Dense Object Detection\", T. Lin et al., ICCV 2017\n - \"AnatomyNet: Deep learning for fast and fully automated whole\u2010volume segmentation of head and neck anatomy\",\n Zhu et al., Medical Physics 2018\n \"\"\"\n\n def __init__(\n self,\n gamma: float = 2.0,\n weight: Optional[torch.Tensor] = None,\n reduction: Union[LossReduction, str] = LossReduction.MEAN,\n ) -> None:\n \"\"\"\n Args:\n gamma: value of the exponent gamma in the definition of the Focal loss.\n weight: weights to apply to the voxels of each class. If None no weights are applied.\n This corresponds to the weights `\\alpha` in [1].\n reduction: {``\"none\"``, ``\"mean\"``, ``\"sum\"``}\n Specifies the reduction to apply to the output. Defaults to ``\"mean\"``.\n\n - ``\"none\"``: no reduction will be applied.\n - ``\"mean\"``: the sum of the output will be divided by the number of elements in the output.\n - ``\"sum\"``: the output will be summed.\n\n Example:\n .. code-block:: python\n\n import torch\n from monai.losses import FocalLoss\n\n pred = torch.tensor([[1, 0], [0, 1], [1, 0]], dtype=torch.float32)\n grnd = torch.tensor([[0], [1], [0]], dtype=torch.int64)\n fl = FocalLoss()\n fl(pred, grnd)\n\n \"\"\"\n super(FocalLoss, self).__init__(weight=weight, reduction=LossReduction(reduction).value)\n self.gamma = gamma\n self.weight: Optional[torch.Tensor]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/focal_loss.py_FocalLoss.forward_FocalLoss.forward._N_H_W_or_N_C_H_W": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/focal_loss.py_FocalLoss.forward_FocalLoss.forward._N_H_W_or_N_C_H_W", "embedding": null, "metadata": {"file_path": "monai/losses/focal_loss.py", "file_name": "focal_loss.py", "file_type": "text/x-python", "category": "implementation", "start_line": 64, "end_line": 110, "span_ids": ["FocalLoss.forward"], "tokens": 659}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class FocalLoss(_WeightedLoss):\n\n def forward(self, input: torch.Tensor, target: torch.Tensor):\n \"\"\"\n Args:\n input: the shape should be BCH[WD].\n where C is the number of classes.\n target: the shape should be B1H[WD] or BCH[WD].\n If the target's shape is B1H[WD], the target that this loss expects should be a class index\n in the range [0, C-1] where C is the number of classes.\n\n Raises:\n ValueError: input and target must have the same number of dimensions, got {i.ndim} and {t.ndim}\n ValueError: target must have one channel or have the same shape as the input.\n If it has one channel, it should be a class index in the range [0, C-1]\n where C is the number of classes inferred from 'input': C={i.shape[1]}.\n ValueError: reduction={self.reduction} is invalid.\n\n \"\"\"\n i = input\n t = target\n\n if i.ndim != t.ndim:\n raise ValueError(f\"input and target must have the same number of dimensions, got {i.ndim} and {t.ndim}\")\n\n if target.shape[1] != 1 and target.shape[1] != i.shape[1]:\n raise ValueError(\n \"target must have one channel or have the same shape as the input. \"\n \"If it has one channel, it should be a class index in the range [0, C-1] \"\n f\"where C is the number of classes inferred from 'input': C={i.shape[1]}. \"\n )\n # Change the shape of input and target to\n # num_batch x num_class x num_voxels.\n if input.dim() > 2:\n i = i.view(i.size(0), i.size(1), -1) # N,C,H,W => N,C,H*W\n t = t.view(t.size(0), t.size(1), -1) # N,1,H,W => N,1,H*W or N,C,H*W\n else: # Compatibility with classification.\n i = i.unsqueeze(2) # N,C => N,C,1\n t = t.unsqueeze(2) # N,1 => N,1,1 or N,C,1\n\n # Compute the log proba (more stable numerically than softmax).\n logpt = F.log_softmax(i, dim=1) # N,C,H*W\n # Keep only log proba values of the ground truth class for each voxel.\n if target.shape[1] == 1:\n logpt = logpt.gather(1, t.long()) # N,C,H*W => N,1,H*W\n logpt = torch.squeeze(logpt, dim=1) # N,1,H*W => N,H*W\n\n # Get the proba\n pt = torch.exp(logpt) # N,H*W or N,C,H*W\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/focal_loss.py_FocalLoss.forward.if_self_weight_is_not_Non_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/focal_loss.py_FocalLoss.forward.if_self_weight_is_not_Non_", "embedding": null, "metadata": {"file_path": "monai/losses/focal_loss.py", "file_name": "focal_loss.py", "file_type": "text/x-python", "category": "implementation", "start_line": 112, "end_line": 139, "span_ids": ["FocalLoss.forward"], "tokens": 367}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class FocalLoss(_WeightedLoss):\n\n def forward(self, input: torch.Tensor, target: torch.Tensor):\n # ... other code\n\n if self.weight is not None:\n self.weight = self.weight.to(i)\n # Convert the weight to a map in which each voxel\n # has the weight associated with the ground-truth label\n # associated with this voxel in target.\n at = self.weight[None, :, None] # C => 1,C,1\n at = at.expand((t.size(0), -1, t.size(2))) # 1,C,1 => N,C,H*W\n if target.shape[1] == 1:\n at = at.gather(1, t.long()) # selection of the weights => N,1,H*W\n at = torch.squeeze(at, dim=1) # N,1,H*W => N,H*W\n # Multiply the log proba by their weights.\n logpt = logpt * at\n\n # Compute the loss mini-batch.\n weight = torch.pow(-pt + 1.0, self.gamma)\n if target.shape[1] == 1:\n loss = torch.mean(-weight * logpt, dim=1) # N\n else:\n loss = torch.mean(-weight * t * logpt, dim=-1) # N,C\n\n if self.reduction == LossReduction.SUM.value:\n return loss.sum()\n if self.reduction == LossReduction.NONE.value:\n return loss\n if self.reduction == LossReduction.MEAN.value:\n return loss.mean()\n raise ValueError(f\"reduction={self.reduction} is invalid.\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/tversky.py_from_typing_import_Union_TverskyLoss.__init__.self.beta.beta": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/tversky.py_from_typing_import_Union_TverskyLoss.__init__.self.beta.beta", "embedding": null, "metadata": {"file_path": "monai/losses/tversky.py", "file_name": "tversky.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 75, "span_ids": ["TverskyLoss.__init__", "TverskyLoss", "docstring"], "tokens": 504}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Union\n\nimport warnings\n\nimport torch\nfrom torch.nn.modules.loss import _Loss\n\nfrom monai.networks import one_hot\nfrom monai.utils import LossReduction\n\n\nclass TverskyLoss(_Loss):\n\n \"\"\"\n Compute the Tversky loss defined in:\n\n Sadegh et al. (2017) Tversky loss function for image segmentation\n using 3D fully convolutional deep networks. (https://arxiv.org/abs/1706.05721)\n\n Adapted from:\n https://github.com/NifTK/NiftyNet/blob/v0.6.0/niftynet/layer/loss_segmentation.py#L631\n\n \"\"\"\n\n def __init__(\n self,\n include_background: bool = True,\n to_onehot_y: bool = False,\n sigmoid: bool = False,\n softmax: bool = False,\n alpha: float = 0.5,\n beta: float = 0.5,\n reduction: Union[LossReduction, str] = LossReduction.MEAN,\n ) -> None:\n \"\"\"\n Args:\n include_background: If False channel index 0 (background category) is excluded from the calculation.\n to_onehot_y: whether to convert `y` into the one-hot format. Defaults to False.\n sigmoid: If True, apply a sigmoid function to the prediction.\n softmax: If True, apply a softmax function to the prediction.\n alpha: weight of false positives\n beta: weight of false negatives\n reduction: {``\"none\"``, ``\"mean\"``, ``\"sum\"``}\n Specifies the reduction to apply to the output. Defaults to ``\"mean\"``.\n\n - ``\"none\"``: no reduction will be applied.\n - ``\"mean\"``: the sum of the output will be divided by the number of elements in the output.\n - ``\"sum\"``: the output will be summed.\n\n Raises:\n ValueError: sigmoid=True and softmax=True are not compatible.\n\n \"\"\"\n\n super().__init__(reduction=LossReduction(reduction).value)\n self.include_background = include_background\n self.to_onehot_y = to_onehot_y\n\n if sigmoid and softmax:\n raise ValueError(\"sigmoid=True and softmax=True are not compatible.\")\n self.sigmoid = sigmoid\n self.softmax = softmax\n self.alpha = alpha\n self.beta = beta", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/tversky.py_TverskyLoss.forward_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/tversky.py_TverskyLoss.forward_", "embedding": null, "metadata": {"file_path": "monai/losses/tversky.py", "file_name": "tversky.py", "file_type": "text/x-python", "category": "implementation", "start_line": 77, "end_line": 135, "span_ids": ["TverskyLoss.forward"], "tokens": 509}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TverskyLoss(_Loss):\n\n def forward(self, input: torch.Tensor, target: torch.Tensor, smooth: float = 1e-5):\n \"\"\"\n Args:\n input: the shape should be BNH[WD].\n target: the shape should be BNH[WD].\n smooth: a small constant to avoid nan.\n\n Raises:\n ValueError: reduction={self.reduction} is invalid.\n\n \"\"\"\n if self.sigmoid:\n input = torch.sigmoid(input)\n n_pred_ch = input.shape[1]\n if n_pred_ch == 1:\n if self.softmax:\n warnings.warn(\"single channel prediction, `softmax=True` ignored.\")\n if self.to_onehot_y:\n warnings.warn(\"single channel prediction, `to_onehot_y=True` ignored.\")\n if not self.include_background:\n warnings.warn(\"single channel prediction, `include_background=False` ignored.\")\n else:\n if self.softmax:\n input = torch.softmax(input, 1)\n if self.to_onehot_y:\n target = one_hot(target, n_pred_ch)\n if not self.include_background:\n # if skipping background, removing first channel\n target = target[:, 1:]\n input = input[:, 1:]\n assert (\n target.shape == input.shape\n ), f\"ground truth has differing shape ({target.shape}) from input ({input.shape})\"\n\n p0 = input\n p1 = 1 - p0\n g0 = target\n g1 = 1 - g0\n\n # reducing only spatial dimensions (not batch nor channels)\n reduce_axis = list(range(2, len(input.shape)))\n\n tp = torch.sum(p0 * g0, reduce_axis)\n fp = self.alpha * torch.sum(p0 * g1, reduce_axis)\n fn = self.beta * torch.sum(p1 * g0, reduce_axis)\n\n numerator = tp + smooth\n denominator = tp + fp + fn + smooth\n\n score = 1.0 - numerator / denominator\n\n if self.reduction == LossReduction.SUM.value:\n return score.sum() # sum over the batch and channel dims\n if self.reduction == LossReduction.NONE.value:\n return score # returns [N, n_classes] losses\n if self.reduction == LossReduction.MEAN.value:\n return score.mean()\n raise ValueError(f\"reduction={self.reduction} is invalid.\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/__init__.py_compute_meandice_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/__init__.py_compute_meandice_", "embedding": null, "metadata": {"file_path": "monai/metrics/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 14, "span_ids": ["docstring"], "tokens": 24}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from .meandice import compute_meandice, DiceMetric\nfrom .rocauc import compute_roc_auc", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/meandice.py_from_typing_import_Option_DiceMetric.__init__._keep_track_for_valid_el": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/meandice.py_from_typing_import_Option_DiceMetric.__init__._keep_track_for_valid_el", "embedding": null, "metadata": {"file_path": "monai/metrics/meandice.py", "file_name": "meandice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 64, "span_ids": ["DiceMetric.__init__", "DiceMetric", "docstring"], "tokens": 591}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Union\n\nimport warnings\n\nimport torch\n\nfrom monai.networks import one_hot\nfrom monai.utils import MetricReduction\n\n\nclass DiceMetric:\n \"\"\"\n Compute average Dice loss between two tensors. It can support both multi-classes and multi-labels tasks.\n Input logits `y_pred` (BNHW[D] where N is number of classes) is compared with ground truth `y` (BNHW[D]).\n Axis N of `y_preds` is expected to have logit predictions for each class rather than being image channels,\n while the same axis of `y` can be 1 or N (one-hot format). The `include_background` class attribute can be\n set to False for an instance of DiceLoss to exclude the first category (channel index 0) which is by\n convention assumed to be background. If the non-background segmentations are small compared to the total\n image size they can get overwhelmed by the signal from the background so excluding it in such cases helps\n convergence.\n\n Args:\n include_background: whether to skip Dice computation on the first channel of\n the predicted output. Defaults to True.\n to_onehot_y: whether to convert `y` into the one-hot format. Defaults to False.\n mutually_exclusive: if True, `y_pred` will be converted into a binary matrix using\n a combination of argmax and to_onehot. Defaults to False.\n sigmoid: whether to add sigmoid function to y_pred before computation. Defaults to False.\n logit_thresh: the threshold value used to convert (after sigmoid if `sigmoid=True`)\n `y_pred` into a binary matrix. Defaults to 0.5.\n reduction: {``\"none\"``, ``\"mean\"``, ``\"sum\"``, ``\"mean_batch\"``, ``\"sum_batch\"``, ``\"mean_channel\"``, ``\"sum_channel\"``}\n Define the mode to reduce computation result of 1 batch data. Defaults to ``\"mean\"``.\n\n \"\"\"\n\n def __init__(\n self,\n include_background: bool = True,\n to_onehot_y: bool = False,\n mutually_exclusive: bool = False,\n sigmoid: bool = False,\n logit_thresh: float = 0.5,\n reduction: Union[MetricReduction, str] = MetricReduction.MEAN,\n ) -> None:\n super().__init__()\n self.include_background = include_background\n self.to_onehot_y = to_onehot_y\n self.mutually_exclusive = mutually_exclusive\n self.sigmoid = sigmoid\n self.logit_thresh = logit_thresh\n self.reduction: MetricReduction = MetricReduction(reduction)\n\n self.not_nans: Optional[torch.Tensor] = None # keep track for valid elements in the batch", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/meandice.py_DiceMetric.__call___DiceMetric.__call__.return.f": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/meandice.py_DiceMetric.__call___DiceMetric.__call__.return.f", "embedding": null, "metadata": {"file_path": "monai/metrics/meandice.py", "file_name": "meandice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 66, "end_line": 120, "span_ids": ["DiceMetric.__call__"], "tokens": 598}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DiceMetric:\n\n def __call__(self, y_pred: torch.Tensor, y: torch.Tensor):\n\n # compute dice (BxC) for each channel for each batch\n f = compute_meandice(\n y_pred=y_pred,\n y=y,\n include_background=self.include_background,\n to_onehot_y=self.to_onehot_y,\n mutually_exclusive=self.mutually_exclusive,\n sigmoid=self.sigmoid,\n logit_thresh=self.logit_thresh,\n )\n\n # some dice elements might be Nan (if ground truth y was missing (zeros))\n # we need to account for it\n\n nans = torch.isnan(f)\n not_nans = (~nans).float()\n f[nans] = 0\n\n t_zero = torch.zeros(1, device=f.device, dtype=torch.float)\n\n if self.reduction == MetricReduction.MEAN:\n # 2 steps, first, mean by channel (accounting for nans), then by batch\n\n not_nans = not_nans.sum(dim=1)\n f = torch.where(not_nans > 0, f.sum(dim=1) / not_nans, t_zero) # channel average\n\n not_nans = (not_nans > 0).float().sum()\n f = torch.where(not_nans > 0, f.sum() / not_nans, t_zero) # batch average\n\n elif self.reduction == MetricReduction.SUM:\n not_nans = not_nans.sum()\n f = torch.sum(f) # sum over the batch and channel dims\n elif self.reduction == MetricReduction.MEAN_BATCH:\n not_nans = not_nans.sum(dim=0)\n f = torch.where(not_nans > 0, f.sum(dim=0) / not_nans, t_zero) # batch average\n elif self.reduction == MetricReduction.SUM_BATCH:\n not_nans = not_nans.sum(dim=0)\n f = f.sum(dim=0) # the batch sum\n elif self.reduction == MetricReduction.MEAN_CHANNEL:\n not_nans = not_nans.sum(dim=1)\n f = torch.where(not_nans > 0, f.sum(dim=1) / not_nans, t_zero) # channel average\n elif self.reduction == MetricReduction.SUM_CHANNEL:\n not_nans = not_nans.sum(dim=1)\n f = f.sum(dim=1) # the channel sum\n elif self.reduction == MetricReduction.NONE:\n pass\n else:\n raise ValueError(f\"reduction={self.reduction} is invalid.\")\n\n # save not_nans since we may need it later to know how many elements were valid\n self.not_nans = not_nans\n\n return f", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/meandice.py_compute_meandice_compute_meandice.if_not_include_background.y_pred.y_pred_1_if_y_pred_s": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/meandice.py_compute_meandice_compute_meandice.if_not_include_background.y_pred.y_pred_1_if_y_pred_s", "embedding": null, "metadata": {"file_path": "monai/metrics/meandice.py", "file_name": "meandice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 123, "end_line": 192, "span_ids": ["compute_meandice"], "tokens": 784}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def compute_meandice(\n y_pred: torch.Tensor,\n y: torch.Tensor,\n include_background: bool = True,\n to_onehot_y: bool = False,\n mutually_exclusive: bool = False,\n sigmoid: bool = False,\n logit_thresh: float = 0.5,\n):\n \"\"\"Computes Dice score metric from full size Tensor and collects average.\n\n Args:\n y_pred: input data to compute, typical segmentation model output.\n it must be one-hot format and first dim is batch, example shape: [16, 3, 32, 32].\n y: ground truth to compute mean dice metric, the first dim is batch.\n example shape: [16, 1, 32, 32] will be converted into [16, 3, 32, 32].\n alternative shape: [16, 3, 32, 32] and set `to_onehot_y=False` to use 3-class labels directly.\n include_background: whether to skip Dice computation on the first channel of\n the predicted output. Defaults to True.\n to_onehot_y: whether to convert `y` into the one-hot format. Defaults to False.\n mutually_exclusive: if True, `y_pred` will be converted into a binary matrix using\n a combination of argmax and to_onehot. Defaults to False.\n sigmoid: whether to add sigmoid function to y_pred before computation. Defaults to False.\n logit_thresh: the threshold value used to convert (after sigmoid if `sigmoid=True`)\n `y_pred` into a binary matrix. Defaults to 0.5.\n\n Returns:\n Dice scores per batch and per class, (shape [batch_size, n_classes]).\n\n Raises:\n ValueError: sigmoid=True is incompatible with mutually_exclusive=True.\n\n Note:\n This method provides two options to convert `y_pred` into a binary matrix\n (1) when `mutually_exclusive` is True, it uses a combination of ``argmax`` and ``to_onehot``,\n (2) when `mutually_exclusive` is False, it uses a threshold ``logit_thresh``\n (optionally with a ``sigmoid`` function before thresholding).\n\n \"\"\"\n n_classes = y_pred.shape[1]\n n_len = len(y_pred.shape)\n\n if sigmoid:\n y_pred = y_pred.float().sigmoid()\n\n if n_classes == 1:\n if mutually_exclusive:\n warnings.warn(\"y_pred has only one class, mutually_exclusive=True ignored.\")\n if to_onehot_y:\n warnings.warn(\"y_pred has only one channel, to_onehot_y=True ignored.\")\n if not include_background:\n warnings.warn(\"y_pred has only one channel, include_background=False ignored.\")\n # make both y and y_pred binary\n y_pred = (y_pred >= logit_thresh).float()\n y = (y > 0).float()\n else: # multi-channel y_pred\n # make both y and y_pred binary\n if mutually_exclusive:\n if sigmoid:\n raise ValueError(\"sigmoid=True is incompatible with mutually_exclusive=True.\")\n y_pred = torch.argmax(y_pred, dim=1, keepdim=True)\n y_pred = one_hot(y_pred, num_classes=n_classes)\n else:\n y_pred = (y_pred >= logit_thresh).float()\n if to_onehot_y:\n y = one_hot(y, num_classes=n_classes)\n\n if not include_background:\n y = y[:, 1:] if y.shape[1] > 1 else y\n y_pred = y_pred[:, 1:] if y_pred.shape[1] > 1 else y_pred\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/meandice.py_compute_meandice.assert_y_shape_y_pred__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/meandice.py_compute_meandice.assert_y_shape_y_pred__", "embedding": null, "metadata": {"file_path": "monai/metrics/meandice.py", "file_name": "meandice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 194, "end_line": 211, "span_ids": ["compute_meandice"], "tokens": 248}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def compute_meandice(\n y_pred: torch.Tensor,\n y: torch.Tensor,\n include_background: bool = True,\n to_onehot_y: bool = False,\n mutually_exclusive: bool = False,\n sigmoid: bool = False,\n logit_thresh: float = 0.5,\n):\n # ... other code\n\n assert y.shape == y_pred.shape, \"Ground truth one-hot has differing shape (%r) from source (%r)\" % (\n y.shape,\n y_pred.shape,\n )\n y = y.float()\n y_pred = y_pred.float()\n\n # reducing only spatial dimensions (not batch nor channels)\n reduce_axis = list(range(2, n_len))\n intersection = torch.sum(y * y_pred, dim=reduce_axis)\n\n y_o = torch.sum(y, reduce_axis)\n y_pred_o = torch.sum(y_pred, dim=reduce_axis)\n denominator = y_o + y_pred_o\n\n f = torch.where(y_o > 0, (2.0 * intersection) / denominator, torch.tensor(float(\"nan\"), device=y_o.device))\n return f # returns array of Dice shape: [batch, n_classes]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/rocauc.py_from_typing_import_cast___calculate.return.auc_nneg_n_nneg_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/rocauc.py_from_typing_import_cast___calculate.return.auc_nneg_n_nneg_", "embedding": null, "metadata": {"file_path": "monai/metrics/rocauc.py", "file_name": "rocauc.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 53, "span_ids": ["_calculate", "docstring"], "tokens": 353}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import cast, Union\n\nimport warnings\n\nimport torch\nimport numpy as np\n\nfrom monai.networks import one_hot\nfrom monai.utils import Average\n\n\ndef _calculate(y: torch.Tensor, y_pred: torch.Tensor):\n assert y.ndimension() == y_pred.ndimension() == 1 and len(y) == len(\n y_pred\n ), \"y and y_pred must be 1 dimension data with same length.\"\n assert y.unique().equal(\n torch.tensor([0, 1], dtype=y.dtype, device=y.device)\n ), \"y values must be 0 or 1, can not be all 0 or all 1.\"\n n = len(y)\n indexes = y_pred.argsort()\n y = y[indexes].cpu().numpy()\n y_pred = y_pred[indexes].cpu().numpy()\n nneg = auc = tmp_pos = tmp_neg = 0.0\n\n for i in range(n):\n y_i = cast(float, y[i])\n if i + 1 < n and y_pred[i] == y_pred[i + 1]:\n tmp_pos += y_i\n tmp_neg += 1 - y_i\n continue\n if tmp_pos + tmp_neg > 0:\n tmp_pos += y_i\n tmp_neg += 1 - y_i\n nneg += tmp_neg\n auc += tmp_pos * (nneg - tmp_neg / 2)\n tmp_pos = tmp_neg = 0\n continue\n if y_i == 1:\n auc += nneg\n else:\n nneg += 1\n return auc / (nneg * (n - nneg))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/rocauc.py_compute_roc_auc_compute_roc_auc.if_y_ndim_2_and_y_shap.y.y_squeeze_dim_1_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/rocauc.py_compute_roc_auc_compute_roc_auc.if_y_ndim_2_and_y_shap.y.y_squeeze_dim_1_", "embedding": null, "metadata": {"file_path": "monai/metrics/rocauc.py", "file_name": "rocauc.py", "file_type": "text/x-python", "category": "implementation", "start_line": 56, "end_line": 105, "span_ids": ["compute_roc_auc"], "tokens": 655}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def compute_roc_auc(\n y_pred: torch.Tensor,\n y: torch.Tensor,\n to_onehot_y: bool = False,\n softmax: bool = False,\n average: Union[Average, str] = Average.MACRO,\n):\n \"\"\"Computes Area Under the Receiver Operating Characteristic Curve (ROC AUC). Referring to:\n `sklearn.metrics.roc_auc_score `_.\n\n Args:\n y_pred: input data to compute, typical classification model output.\n it must be One-Hot format and first dim is batch, example shape: [16] or [16, 2].\n y: ground truth to compute ROC AUC metric, the first dim is batch.\n example shape: [16, 1] will be converted into [16, 2] (where `2` is inferred from `y_pred`).\n to_onehot_y: whether to convert `y` into the one-hot format. Defaults to False.\n softmax: whether to add softmax function to `y_pred` before computation. Defaults to False.\n average: {``\"macro\"``, ``\"weighted\"``, ``\"micro\"``, ``\"none\"``}\n Type of averaging performed if not binary classification.\n Defaults to ``\"macro\"``.\n\n - ``\"macro\"``: calculate metrics for each label, and find their unweighted mean.\n This does not take label imbalance into account.\n - ``\"weighted\"``: calculate metrics for each label, and find their average,\n weighted by support (the number of true instances for each label).\n - ``\"micro\"``: calculate metrics globally by considering each element of the label\n indicator matrix as a label.\n - ``\"none\"``: the scores for each class are returned.\n\n Raises:\n ValueError: predictions should be of shape (batch_size, n_classes) or (batch_size, ).\n ValueError: targets should be of shape (batch_size, n_classes) or (batch_size, ).\n ValueError: unsupported average method.\n\n Note:\n ROCAUC expects y to be comprised of 0's and 1's. `y_pred` must be either prob. estimates or confidence values.\n\n \"\"\"\n y_pred_ndim = y_pred.ndimension()\n y_ndim = y.ndimension()\n if y_pred_ndim not in (1, 2):\n raise ValueError(\"predictions should be of shape (batch_size, n_classes) or (batch_size, ).\")\n if y_ndim not in (1, 2):\n raise ValueError(\"targets should be of shape (batch_size, n_classes) or (batch_size, ).\")\n if y_pred_ndim == 2 and y_pred.shape[1] == 1:\n y_pred = y_pred.squeeze(dim=-1)\n y_pred_ndim = 1\n if y_ndim == 2 and y.shape[1] == 1:\n y = y.squeeze(dim=-1)\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/rocauc.py_compute_roc_auc.if_y_pred_ndim_1__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/rocauc.py_compute_roc_auc.if_y_pred_ndim_1__", "embedding": null, "metadata": {"file_path": "monai/metrics/rocauc.py", "file_name": "rocauc.py", "file_type": "text/x-python", "category": "implementation", "start_line": 107, "end_line": 136, "span_ids": ["compute_roc_auc"], "tokens": 338}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def compute_roc_auc(\n y_pred: torch.Tensor,\n y: torch.Tensor,\n to_onehot_y: bool = False,\n softmax: bool = False,\n average: Union[Average, str] = Average.MACRO,\n):\n # ... other code\n\n if y_pred_ndim == 1:\n if to_onehot_y:\n warnings.warn(\"y_pred has only one channel, to_onehot_y=True ignored.\")\n if softmax:\n warnings.warn(\"y_pred has only one channel, softmax=True ignored.\")\n return _calculate(y, y_pred)\n else:\n n_classes = y_pred.shape[1]\n if to_onehot_y:\n y = one_hot(y, n_classes)\n if softmax:\n y_pred = y_pred.float().softmax(dim=1)\n\n assert y.shape == y_pred.shape, \"data shapes of y_pred and y do not match.\"\n\n average = Average(average)\n if average == Average.MICRO:\n return _calculate(y.flatten(), y_pred.flatten())\n else:\n y, y_pred = y.transpose(0, 1), y_pred.transpose(0, 1)\n auc_values = [_calculate(y_, y_pred_) for y_, y_pred_ in zip(y, y_pred)]\n if average == Average.NONE:\n return auc_values\n if average == Average.MACRO:\n return np.mean(auc_values)\n if average == Average.WEIGHTED:\n weights = [sum(y_) for y_ in y]\n return np.average(auc_values, weights=weights)\n raise ValueError(\"unsupported average method.\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/__init__.py_from_utils_import__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/__init__.py_from_utils_import__", "embedding": null, "metadata": {"file_path": "monai/networks/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 13, "span_ids": ["docstring"], "tokens": 5}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from .utils import *", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/__init__.py_SimpleASPP_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/__init__.py_SimpleASPP_", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 17, "span_ids": ["docstring"], "tokens": 56}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from .aspp import SimpleASPP\nfrom .convolutions import Convolution, ResidualUnit\nfrom .downsample import MaxAvgPool\nfrom .squeeze_and_excitation import ChannelSELayer, ResidualSELayer, SEBlock\nfrom .upsample import UpSample", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/aspp.py_torch_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/aspp.py_torch_", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/aspp.py", "file_name": "aspp.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 96, "span_ids": ["SimpleASPP", "SimpleASPP.forward", "SimpleASPP.__init__", "docstring"], "tokens": 760}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import torch\nimport torch.nn as nn\n\nfrom monai.networks.blocks.convolutions import Convolution\nfrom monai.networks.layers import same_padding\nfrom monai.networks.layers.factories import Act, Conv, Norm\n\n\nclass SimpleASPP(nn.Module):\n \"\"\"\n A simplified version of the atrous spatial pyramid pooling (ASPP) module.\n\n Chen et al., Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation.\n https://arxiv.org/abs/1802.02611\n\n Wang et al., A Noise-robust Framework for Automatic Segmentation of COVID-19 Pneumonia Lesions\n from CT Images. https://ieeexplore.ieee.org/document/9109297\n \"\"\"\n\n def __init__(\n self,\n spatial_dims: int,\n in_channels: int,\n conv_out_channels: int,\n kernel_sizes=(1, 3, 3, 3),\n dilations=(1, 2, 4, 6),\n norm_type=Norm.BATCH,\n acti_type=Act.LEAKYRELU,\n ) -> None:\n \"\"\"\n Args:\n spatial_dims: number of spatial dimensions, could be 1, 2, or 3.\n in_channels: number of input channels.\n conv_out_channels: number of output channels of each atrous conv.\n The final number of output channels is conv_out_channels * len(kernel_sizes).\n kernel_sizes: a sequence of four convolutional kernel sizes.\n Defaults to (1, 3, 3, 3) for four (dilated) convolutions.\n dilations: a sequence of four convolutional dilation parameters.\n Defaults to (1, 2, 4, 6) for four (dilated) convolutions.\n norm_type: final kernel-size-one convolution normalization type.\n Defaults to batch norm.\n acti_type: final kernel-size-one convolution activation type.\n Defaults to leaky ReLU.\n\n Raises:\n ValueError: len(kernel_sizes) and len(dilations) must be the same.\n\n See also:\n\n :py:class:`monai.networks.layers.Act`\n :py:class:`monai.networks.layers.Conv`\n :py:class:`monai.networks.layers.Norm`\n\n \"\"\"\n super().__init__()\n if len(kernel_sizes) != len(dilations):\n raise ValueError(\"len(kernel_sizes) and len(dilations) must be the same.\")\n pads = tuple(same_padding(k, d) for k, d in zip(kernel_sizes, dilations))\n\n self.convs = nn.ModuleList()\n for k, d, p in zip(kernel_sizes, dilations, pads):\n _conv = Conv[Conv.CONV, spatial_dims](\n in_channels=in_channels, out_channels=conv_out_channels, kernel_size=k, dilation=d, padding=p\n )\n self.convs.append(_conv)\n\n out_channels = conv_out_channels * len(pads) # final conv. output channels\n self.conv_k1 = Convolution(\n dimensions=spatial_dims,\n in_channels=out_channels,\n out_channels=out_channels,\n kernel_size=1,\n act=acti_type,\n norm=norm_type,\n )\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Args:\n x: in shape (batch, channel, spatial_1[, spatial_2, ...]).\n \"\"\"\n x_out = torch.cat([conv(x) for conv in self.convs], dim=1)\n x_out = self.conv_k1(x_out)\n return x_out", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/convolutions.py_np_Convolution.__init__.if_not_conv_only_.if_act_is_not_None_.self_add_module_act_ac": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/convolutions.py_np_Convolution.__init__.if_not_conv_only_.if_act_is_not_None_.self_add_module_act_ac", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/convolutions.py", "file_name": "convolutions.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 110, "span_ids": ["Convolution", "Convolution.__init__", "docstring"], "tokens": 787}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import numpy as np\nimport torch.nn as nn\n\nfrom monai.networks.layers.convutils import same_padding\nfrom monai.networks.layers.factories import Act, Conv, Dropout, Norm, split_args\n\n\nclass Convolution(nn.Sequential):\n \"\"\"\n Constructs a convolution with normalization, optional dropout, and optional activation layers::\n\n -- (Conv|ConvTrans) -- Norm -- (Dropout) -- (Acti) --\n\n if ``conv_only`` set to ``True``::\n\n -- (Conv|ConvTrans) --\n\n Args:\n dimensions: number of spatial dimensions.\n in_channels: number of input channels.\n out_channels: number of output channels.\n strides: convolution stride. Defaults to 1.\n kernel_size: convolution kernel size. Defaults to 3.\n act: activation type and arguments. Defaults to PReLU.\n norm: feature normalization type and arguments. Defaults to instance norm.\n dropout: dropout ratio. Defaults to no dropout.\n dilation: dilation rate. Defaults to 1.\n bias: whether to have a bias term. Defaults to True.\n conv_only: whether to use the convolutional layer only. Defaults to False.\n is_transposed: if True uses ConvTrans instead of Conv. Defaults to False.\n\n See also:\n\n :py:class:`monai.networks.layers.Conv`\n :py:class:`monai.networks.layers.Dropout`\n :py:class:`monai.networks.layers.Act`\n :py:class:`monai.networks.layers.Norm`\n :py:class:`monai.networks.layers.split_args`\n\n \"\"\"\n\n def __init__(\n self,\n dimensions: int,\n in_channels: int,\n out_channels: int,\n strides=1,\n kernel_size=3,\n act=Act.PRELU,\n norm=Norm.INSTANCE,\n dropout=None,\n dilation=1,\n bias: bool = True,\n conv_only: bool = False,\n is_transposed: bool = False,\n ) -> None:\n super().__init__()\n self.dimensions = dimensions\n self.in_channels = in_channels\n self.out_channels = out_channels\n self.is_transposed = is_transposed\n\n padding = same_padding(kernel_size, dilation)\n conv_type = Conv[Conv.CONVTRANS if is_transposed else Conv.CONV, dimensions]\n\n # define the normalisation type and the arguments to the constructor\n norm_name, norm_args = split_args(norm)\n norm_type = Norm[norm_name, dimensions]\n\n # define the activation type and the arguments to the constructor\n if act is not None:\n act_name, act_args = split_args(act)\n act_type = Act[act_name]\n else:\n act_type = act_args = None\n\n if dropout:\n # if dropout was specified simply as a p value, use default name and make a keyword map with the value\n if isinstance(dropout, (int, float)):\n drop_name = Dropout.DROPOUT\n drop_args = {\"p\": dropout}\n else:\n drop_name, drop_args = split_args(dropout)\n\n drop_type = Dropout[drop_name, dimensions]\n\n if is_transposed:\n conv = conv_type(in_channels, out_channels, kernel_size, strides, padding, strides - 1, 1, bias, dilation)\n else:\n conv = conv_type(in_channels, out_channels, kernel_size, strides, padding, dilation, bias=bias)\n\n self.add_module(\"conv\", conv)\n\n if not conv_only:\n self.add_module(\"norm\", norm_type(out_channels, **norm_args))\n if dropout:\n self.add_module(\"dropout\", drop_type(**drop_args))\n if act is not None:\n self.add_module(\"act\", act_type(**act_args))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/convolutions.py_ResidualUnit_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/convolutions.py_ResidualUnit_", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/convolutions.py", "file_name": "convolutions.py", "file_type": "text/x-python", "category": "implementation", "start_line": 113, "end_line": 188, "span_ids": ["ResidualUnit", "ResidualUnit.forward", "ResidualUnit.__init__"], "tokens": 516}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ResidualUnit(nn.Module):\n \"\"\"\n Residual module with multiple convolutions and a residual connection.\n\n See also:\n\n :py:class:`monai.networks.blocks.Convolution`\n\n \"\"\"\n\n def __init__(\n self,\n dimensions: int,\n in_channels: int,\n out_channels: int,\n strides=1,\n kernel_size=3,\n subunits: int = 2,\n act=Act.PRELU,\n norm=Norm.INSTANCE,\n dropout=None,\n dilation=1,\n bias: bool = True,\n last_conv_only: bool = False,\n ) -> None:\n super().__init__()\n self.dimensions = dimensions\n self.in_channels = in_channels\n self.out_channels = out_channels\n self.conv = nn.Sequential()\n self.residual = nn.Identity()\n\n padding = same_padding(kernel_size, dilation)\n schannels = in_channels\n sstrides = strides\n subunits = max(1, subunits)\n\n for su in range(subunits):\n conv_only = last_conv_only and su == (subunits - 1)\n unit = Convolution(\n dimensions,\n schannels,\n out_channels,\n sstrides,\n kernel_size,\n act,\n norm,\n dropout,\n dilation,\n bias,\n conv_only,\n )\n\n self.conv.add_module(f\"unit{su:d}\", unit)\n\n # after first loop set channels and strides to what they should be for subsequent units\n schannels = out_channels\n sstrides = 1\n\n # apply convolution to input to change number of output channels and size to match that coming from self.conv\n if np.prod(strides) != 1 or in_channels != out_channels:\n rkernel_size = kernel_size\n rpadding = padding\n\n if np.prod(strides) == 1: # if only adapting number of channels a 1x1 kernel is used with no padding\n rkernel_size = 1\n rpadding = 0\n\n conv_type = Conv[Conv.CONV, dimensions]\n self.residual = conv_type(in_channels, out_channels, rkernel_size, strides, rpadding, bias=bias)\n\n def forward(self, x):\n res = self.residual(x) # create the additive residual from x\n cx = self.conv(x) # apply x to sequence of operations\n return cx + res # add the residual to the output", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/downsample.py_from_typing_import_Option_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/downsample.py_from_typing_import_Option_", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/downsample.py", "file_name": "downsample.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 63, "span_ids": ["MaxAvgPool", "MaxAvgPool.__init__", "MaxAvgPool.forward", "docstring"], "tokens": 418}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Sequence, Union\n\nimport torch\nimport torch.nn as nn\n\nfrom monai.networks.layers.factories import Pool\nfrom monai.utils import ensure_tuple_rep\n\n\nclass MaxAvgPool(nn.Module):\n \"\"\"\n Downsample with both maxpooling and avgpooling,\n double the channel size by concatenating the downsampled feature maps.\n \"\"\"\n\n def __init__(\n self,\n spatial_dims: int,\n kernel_size: Union[Sequence[int], int],\n stride: Optional[Union[Sequence[int], int]] = None,\n padding: Union[Sequence[int], int] = 0,\n ceil_mode: bool = False,\n ) -> None:\n \"\"\"\n Args:\n spatial_dims: number of spatial dimensions of the input image.\n kernel_size: the kernel size of both pooling operations.\n stride: the stride of the window. Default value is `kernel_size`.\n padding: implicit zero padding to be added to both pooling operations.\n ceil_mode: when True, will use ceil instead of floor to compute the output shape.\n \"\"\"\n super().__init__()\n _params = {\n \"kernel_size\": ensure_tuple_rep(kernel_size, spatial_dims),\n \"stride\": None if stride is None else ensure_tuple_rep(stride, spatial_dims),\n \"padding\": ensure_tuple_rep(padding, spatial_dims),\n \"ceil_mode\": ceil_mode,\n }\n self.max_pool = Pool[Pool.MAX, spatial_dims](**_params)\n self.avg_pool = Pool[Pool.AVG, spatial_dims](**_params)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Args:\n x: Tensor in shape (batch, channel, spatial_1[, spatial_2, ...]).\n\n Returns:\n Tensor in shape (batch, 2*channel, spatial_1[, spatial_2, ...]).\n \"\"\"\n x_d = torch.cat([self.max_pool(x), self.avg_pool(x)], dim=1)\n return x_d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/squeeze_and_excitation.py_from_typing_import_Dict__ChannelSELayer.forward.return.x_y": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/squeeze_and_excitation.py_from_typing_import_Dict__ChannelSELayer.forward.return.x_y", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/squeeze_and_excitation.py", "file_name": "squeeze_and_excitation.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 77, "span_ids": ["ChannelSELayer.__init__", "ChannelSELayer", "ChannelSELayer.forward", "docstring"], "tokens": 560}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Dict, Optional\n\nimport torch\nimport torch.nn as nn\n\nfrom monai.networks.blocks import Convolution\nfrom monai.networks.layers.factories import Act, Conv, Norm, Pool, split_args\n\n\nclass ChannelSELayer(nn.Module):\n \"\"\"\n Re-implementation of the Squeeze-and-Excitation block based on:\n \"Hu et al., Squeeze-and-Excitation Networks, https://arxiv.org/abs/1709.01507\".\n \"\"\"\n\n def __init__(\n self,\n spatial_dims: int,\n in_channels: int,\n r: int = 2,\n acti_type_1=(\"relu\", {\"inplace\": True}),\n acti_type_2=\"sigmoid\",\n ) -> None:\n \"\"\"\n Args:\n spatial_dims: number of spatial dimensions, could be 1, 2, or 3.\n in_channels: number of input channels.\n r: the reduction ratio r in the paper. Defaults to 2.\n acti_type_1: activation type of the hidden squeeze layer. Defaults to ``(\"relu\", {\"inplace\": True})``.\n acti_type_2: activation type of the output squeeze layer. Defaults to \"sigmoid\".\n\n See also:\n\n :py:class:`monai.networks.layers.Act`\n\n Raises:\n ValueError: r must be a positive number smaller than `in_channels`.\n\n \"\"\"\n super(ChannelSELayer, self).__init__()\n\n pool_type = Pool[Pool.ADAPTIVEAVG, spatial_dims]\n self.avg_pool = pool_type(1) # spatial size (1, 1, ...)\n\n channels = int(in_channels // r)\n if channels <= 0:\n raise ValueError(\"r must be a positive number smaller than `in_channels`.\")\n\n act_1, act_1_args = split_args(acti_type_1)\n act_2, act_2_args = split_args(acti_type_2)\n self.fc = nn.Sequential(\n nn.Linear(in_channels, channels, bias=True),\n Act[act_1](**act_1_args),\n nn.Linear(channels, in_channels, bias=True),\n Act[act_2](**act_2_args),\n )\n\n def forward(self, x: torch.Tensor):\n \"\"\"\n Args:\n x: in shape (batch, in_channels, spatial_1[, spatial_2, ...]).\n \"\"\"\n b, c = x.shape[:2]\n y = self.avg_pool(x).view(b, c)\n y = self.fc(y).view([b, c] + [1] * (x.ndim - 2))\n return x * y", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/squeeze_and_excitation.py_ResidualSELayer_ResidualSELayer.forward.return.x_super_forward_x_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/squeeze_and_excitation.py_ResidualSELayer_ResidualSELayer.forward.return.x_super_forward_x_", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/squeeze_and_excitation.py", "file_name": "squeeze_and_excitation.py", "file_type": "text/x-python", "category": "implementation", "start_line": 80, "end_line": 115, "span_ids": ["ResidualSELayer.__init__", "ResidualSELayer", "ResidualSELayer.forward"], "tokens": 283}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ResidualSELayer(ChannelSELayer):\n \"\"\"\n A \"squeeze-and-excitation\"-like layer with a residual connection::\n\n --+-- SE --o--\n | |\n +--------+\n\n \"\"\"\n\n def __init__(\n self, spatial_dims: int, in_channels: int, r: int = 2, acti_type_1=\"leakyrelu\", acti_type_2=\"relu\"\n ) -> None:\n \"\"\"\n Args:\n spatial_dims: number of spatial dimensions, could be 1, 2, or 3.\n in_channels: number of input channels.\n r: the reduction ratio r in the paper. Defaults to 2.\n acti_type_1: defaults to \"leakyrelu\".\n acti_type_2: defaults to \"relu\".\n\n See also:\n\n :py:class:`monai.networks.blocks.ChannelSELayer`\n\n \"\"\"\n super().__init__(\n spatial_dims=spatial_dims, in_channels=in_channels, r=r, acti_type_1=acti_type_1, acti_type_2=acti_type_2\n )\n\n def forward(self, x: torch.Tensor):\n \"\"\"\n Args:\n x: in shape (batch, in_channels, spatial_1[, spatial_2, ...]).\n \"\"\"\n return x + super().forward(x)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/squeeze_and_excitation.py_SEBlock_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/squeeze_and_excitation.py_SEBlock_", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/squeeze_and_excitation.py", "file_name": "squeeze_and_excitation.py", "file_type": "text/x-python", "category": "implementation", "start_line": 118, "end_line": 203, "span_ids": ["SEBlock", "SEBlock.__init__", "SEBlock.forward"], "tokens": 941}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SEBlock(nn.Module):\n \"\"\"\n Residual module enhanced with Squeeze-and-Excitation::\n\n ----+- conv1 -- conv2 -- conv3 -- SE -o---\n | |\n +---(channel project if needed)----+\n\n Re-implementation of the SE-Resnet block based on:\n \"Hu et al., Squeeze-and-Excitation Networks, https://arxiv.org/abs/1709.01507\".\n \"\"\"\n\n def __init__(\n self,\n spatial_dims: int,\n in_channels: int,\n n_chns_1: int,\n n_chns_2: int,\n n_chns_3: int,\n conv_param_1: Optional[Dict] = None,\n conv_param_2: Optional[Dict] = None,\n conv_param_3: Optional[Dict] = None,\n r: int = 2,\n acti_type_1=\"relu\",\n acti_type_2=\"sigmoid\",\n ):\n \"\"\"\n Args:\n spatial_dims: number of spatial dimensions, could be 1, 2, or 3.\n in_channels: number of input channels.\n n_chns_1: number of output channels in the 1st convolution.\n n_chns_2: number of output channels in the 2nd convolution.\n n_chns_3: number of output channels in the 3rd convolution.\n conv_param_1: additional parameters to the 1st convolution.\n Defaults to ``{\"kernel_size\": 1, \"norm\": Norm.BATCH, \"act\": Act.RELU}``\n conv_param_2: additional parameters to the 2nd convolution.\n Defaults to ``{\"kernel_size\": 3, \"norm\": Norm.BATCH, \"act\": Act.RELU}``\n conv_param_3: additional parameters to the 3rd convolution.\n Defaults to ``{\"kernel_size\": 1, \"norm\": Norm.BATCH, \"act\": None}``\n r: the reduction ratio r in the paper. Defaults to 2.\n acti_type_1: activation type of the hidden squeeze layer. Defaults to \"relu\".\n acti_type_2: activation type of the output squeeze layer. Defaults to \"sigmoid\".\n\n See also:\n\n :py:class:`monai.networks.blocks.ChannelSELayer`\n\n \"\"\"\n super(SEBlock, self).__init__()\n\n if not conv_param_1:\n conv_param_1 = {\"kernel_size\": 1, \"norm\": Norm.BATCH, \"act\": Act.RELU}\n self.conv1 = Convolution(\n dimensions=spatial_dims, in_channels=in_channels, out_channels=n_chns_1, **conv_param_1\n )\n\n if not conv_param_2:\n conv_param_2 = {\"kernel_size\": 3, \"norm\": Norm.BATCH, \"act\": Act.RELU}\n self.conv2 = Convolution(dimensions=spatial_dims, in_channels=n_chns_1, out_channels=n_chns_2, **conv_param_2)\n\n if not conv_param_3:\n conv_param_3 = {\"kernel_size\": 1, \"norm\": Norm.BATCH, \"act\": None}\n self.conv3 = Convolution(dimensions=spatial_dims, in_channels=n_chns_2, out_channels=n_chns_3, **conv_param_3)\n\n self.se_layer = ChannelSELayer(\n spatial_dims=spatial_dims, in_channels=n_chns_3, r=r, acti_type_1=acti_type_1, acti_type_2=acti_type_2\n )\n\n if in_channels != n_chns_3: # in the case of residual chns and output chns doesn't match\n self.project = Conv[Conv.CONV, spatial_dims](in_channels, n_chns_3, kernel_size=1)\n else:\n self.project = None\n\n def forward(self, x: torch.Tensor):\n \"\"\"\n Args:\n x: in shape (batch, in_channels, spatial_1[, spatial_2, ...]).\n \"\"\"\n residual = x if self.project is None else self.project(x)\n x = self.conv1(x)\n x = self.conv2(x)\n x = self.conv3(x)\n x = self.se_layer(x)\n x += residual\n return x", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/upsample.py_from_typing_import_Option_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/upsample.py_from_typing_import_Option_", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/upsample.py", "file_name": "upsample.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 74, "span_ids": ["UpSample", "UpSample.__init__", "UpSample.forward", "docstring"], "tokens": 634}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Sequence, Union\n\nimport torch\nimport torch.nn as nn\n\nfrom monai.networks.layers.factories import Conv\nfrom monai.utils import ensure_tuple_rep, UpsampleMode\n\n\nclass UpSample(nn.Module):\n \"\"\"\n Upsample with either kernel 1 conv + interpolation or transposed conv.\n \"\"\"\n\n def __init__(\n self,\n spatial_dims: int,\n in_channels: int,\n out_channels: Optional[int] = None,\n scale_factor: Union[Sequence[float], float] = 2,\n with_conv: bool = False,\n mode: Union[UpsampleMode, str] = UpsampleMode.LINEAR,\n align_corners: Optional[bool] = True,\n ) -> None:\n \"\"\"\n Args:\n spatial_dims: number of spatial dimensions of the input image.\n in_channels: number of channels of the input image.\n out_channels: number of channels of the output image. Defaults to `in_channels`.\n scale_factor: multiplier for spatial size. Has to match input size if it is a tuple. Defaults to 2.\n with_conv: whether to use a transposed convolution for upsampling. Defaults to False.\n mode: {``\"nearest\"``, ``\"linear\"``, ``\"bilinear\"``, ``\"bicubic\"``, ``\"trilinear\"``}\n If ends with ``\"linear\"`` will use ``spatial dims`` to determine the correct interpolation.\n This corresponds to linear, bilinear, trilinear for 1D, 2D, and 3D respectively.\n The interpolation mode. Defaults to ``\"linear\"``.\n See also: https://pytorch.org/docs/stable/nn.html#upsample\n align_corners: set the align_corners parameter of `torch.nn.Upsample`. Defaults to True.\n \"\"\"\n super().__init__()\n scale_factor_ = ensure_tuple_rep(scale_factor, spatial_dims)\n if not out_channels:\n out_channels = in_channels\n if not with_conv:\n mode = UpsampleMode(mode)\n linear_mode = [UpsampleMode.LINEAR, UpsampleMode.BILINEAR, UpsampleMode.TRILINEAR]\n if mode in linear_mode: # choose mode based on spatial_dims\n mode = linear_mode[spatial_dims - 1]\n self.upsample = nn.Sequential(\n Conv[Conv.CONV, spatial_dims](in_channels=in_channels, out_channels=out_channels, kernel_size=1),\n nn.Upsample(scale_factor=scale_factor_, mode=mode.value, align_corners=align_corners),\n )\n else:\n self.upsample = Conv[Conv.CONVTRANS, spatial_dims](\n in_channels=in_channels, out_channels=out_channels, kernel_size=scale_factor_, stride=scale_factor_\n )\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Args:\n x: Tensor in shape (batch, channel, spatial_1[, spatial_2, ...).\n \"\"\"\n return self.upsample(x)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/__init__.py_from_convutils_import__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/__init__.py_from_convutils_import__", "embedding": null, "metadata": {"file_path": "monai/networks/layers/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 16, "span_ids": ["docstring"], "tokens": 26}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from .convutils import *\nfrom .factories import *\nfrom .simplelayers import *\nfrom .spatial_transforms import *", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/convutils.py_np_same_padding.return.tuple_padding_if_len_pad": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/convutils.py_np_same_padding.return.tuple_padding_if_len_pad", "embedding": null, "metadata": {"file_path": "monai/networks/layers/convutils.py", "file_name": "convutils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 36, "span_ids": ["same_padding", "docstring"], "tokens": 223}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import numpy as np\n\n__all__ = [\"same_padding\", \"calculate_out_shape\", \"gaussian_1d\"]\n\n\ndef same_padding(kernel_size, dilation=1):\n \"\"\"\n Return the padding value needed to ensure a convolution using the given kernel size produces an output of the same\n shape as the input for a stride of 1, otherwise ensure a shape of the input divided by the stride rounded down.\n\n Raises:\n NotImplementedError: same padding not available for k={kernel_size} and d={dilation}.\n\n \"\"\"\n\n kernel_size = np.atleast_1d(kernel_size)\n dilation = np.atleast_1d(dilation)\n\n if np.any((kernel_size - 1) * dilation % 2 == 1):\n raise NotImplementedError(f\"Same padding not available for k={kernel_size} and d={dilation}.\")\n\n padding = (kernel_size - 1) / 2 * dilation\n padding = tuple(int(p) for p in padding)\n\n return tuple(padding) if len(padding) > 1 else padding[0]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/convutils.py_calculate_out_shape_calculate_out_shape.return.tuple_out_shape_if_len_o": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/convutils.py_calculate_out_shape_calculate_out_shape.return.tuple_out_shape_if_len_o", "embedding": null, "metadata": {"file_path": "monai/networks/layers/convutils.py", "file_name": "convutils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 39, "end_line": 49, "span_ids": ["calculate_out_shape"], "tokens": 151}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def calculate_out_shape(in_shape, kernel_size, stride, padding):\n \"\"\"\n Calculate the output tensor shape when applying a convolution to a tensor of shape `inShape` with kernel size\n `kernel_size`, stride value `stride`, and input padding value `padding`. All arguments can be scalars or multiple\n values, return value is a scalar if all inputs are scalars.\n \"\"\"\n in_shape = np.atleast_1d(in_shape)\n out_shape = ((in_shape - kernel_size + padding + padding) // stride) + 1\n out_shape = tuple(int(s) for s in out_shape)\n\n return tuple(out_shape) if len(out_shape) > 1 else out_shape[0]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/convutils.py_gaussian_1d_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/convutils.py_gaussian_1d_", "embedding": null, "metadata": {"file_path": "monai/networks/layers/convutils.py", "file_name": "convutils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 52, "end_line": 76, "span_ids": ["gaussian_1d"], "tokens": 138}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def gaussian_1d(sigma, truncated=4.0):\n \"\"\"\n one dimensional gaussian kernel.\n\n Args:\n sigma: std of the kernel\n truncated: tail length\n\n Returns:\n 1D numpy array\n\n Raises:\n ValueError: sigma must be positive\n\n \"\"\"\n if sigma <= 0:\n raise ValueError(\"sigma must be positive\")\n\n tail = int(sigma * truncated + 0.5)\n sigma2 = sigma * sigma\n x = np.arange(-tail, tail + 1)\n out = np.exp(-0.5 / sigma2 * x ** 2)\n out /= out.sum()\n return out", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py_from_typing_import_Any_C_LayerFactory.add_factory_callable.self.__doc__._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py_from_typing_import_Any_C_LayerFactory.add_factory_callable.self.__doc__._", "embedding": null, "metadata": {"file_path": "monai/networks/layers/factories.py", "file_name": "factories.py", "file_type": "text/x-python", "category": "implementation", "start_line": 63, "end_line": 98, "span_ids": ["LayerFactory", "LayerFactory.add_factory_callable", "docstring:11", "LayerFactory.__init__", "LayerFactory.names"], "tokens": 260}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Any, Callable, Dict\n\nimport torch.nn as nn\n\n__all__ = [\"LayerFactory\", \"Dropout\", \"Norm\", \"Act\", \"Conv\", \"Pool\", \"split_args\"]\n\n\nclass LayerFactory:\n \"\"\"\n Factory object for creating layers, this uses given factory functions to actually produce the types or constructing\n callables. These functions are referred to by name and can be added at any time.\n \"\"\"\n\n def __init__(self) -> None:\n self.factories: Dict[str, Callable] = {}\n\n @property\n def names(self):\n \"\"\"\n Produces all factory names.\n \"\"\"\n\n return tuple(self.factories)\n\n def add_factory_callable(self, name: str, func: Callable):\n \"\"\"\n Add the factory function to this object under the given name.\n \"\"\"\n\n self.factories[name.upper()] = func\n self.__doc__ = (\n \"The supported member\"\n + (\"s are: \" if len(self.names) > 1 else \" is: \")\n + \", \".join(f\"``{name}``\" for name in self.names)\n + \".\\nPlease see :py:class:`monai.networks.layers.split_args` for additional args parsing.\"\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py_LayerFactory.factory_function_LayerFactory.get_constructor.return.fact_args_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py_LayerFactory.factory_function_LayerFactory.get_constructor.return.fact_args_", "embedding": null, "metadata": {"file_path": "monai/networks/layers/factories.py", "file_name": "factories.py", "file_type": "text/x-python", "category": "implementation", "start_line": 100, "end_line": 124, "span_ids": ["LayerFactory.get_constructor", "LayerFactory.factory_function"], "tokens": 142}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LayerFactory:\n\n def factory_function(self, name: str):\n \"\"\"\n Decorator for adding a factory function with the given name.\n \"\"\"\n\n def _add(func: Callable):\n self.add_factory_callable(name, func)\n return func\n\n return _add\n\n def get_constructor(self, factory_name: str, *args) -> Any:\n \"\"\"\n Get the constructor for the given factory name and arguments.\n\n Raises:\n ValueError: Factories must be selected by name\n\n \"\"\"\n\n if not isinstance(factory_name, str):\n raise ValueError(\"Factories must be selected by name\")\n\n fact = self.factories[factory_name.upper()]\n return fact(*args)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py_LayerFactory.__getitem___LayerFactory.__getattr__.return.super___getattribute___": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py_LayerFactory.__getitem___LayerFactory.__getattr__.return.super___getattribute___", "embedding": null, "metadata": {"file_path": "monai/networks/layers/factories.py", "file_name": "factories.py", "file_type": "text/x-python", "category": "implementation", "start_line": 126, "end_line": 153, "span_ids": ["LayerFactory.__getitem__", "LayerFactory.__getattr__"], "tokens": 228}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LayerFactory:\n\n def __getitem__(self, args) -> Any:\n \"\"\"\n Get the given name or name/arguments pair. If `args` is a callable it is assumed to be the constructor\n itself and is returned, otherwise it should be the factory name or a pair containing the name and arguments.\n \"\"\"\n\n # `args[0]` is actually a type or constructor\n if callable(args):\n return args\n\n # `args` is a factory name or a name with arguments\n if isinstance(args, str):\n name_obj, args = args, ()\n else:\n name_obj, *args = args\n\n return self.get_constructor(name_obj, *args)\n\n def __getattr__(self, key):\n \"\"\"\n If `key` is a factory name, return it, otherwise behave as inherited. This allows referring to factory names\n as if they were constants, eg. `Fact.FOO` for a factory Fact with factory function foo.\n \"\"\"\n\n if key in self.factories:\n return key\n\n return super().__getattribute__(key)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py_split_args_split_args.if_isinstance_args_str_.else_.return.name_obj_name_args": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py_split_args_split_args.if_isinstance_args_str_.else_.return.name_obj_name_args", "embedding": null, "metadata": {"file_path": "monai/networks/layers/factories.py", "file_name": "factories.py", "file_type": "text/x-python", "category": "implementation", "start_line": 156, "end_line": 188, "span_ids": ["split_args"], "tokens": 262}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def split_args(args):\n \"\"\"\n Split arguments in a way to be suitable for using with the factory types. If `args` is a string it's interpreted as\n the type name.\n\n Args:\n args (str or a tuple of object name and kwarg dict): input arguments to be parsed.\n\n Examples::\n\n >>> act_type, args = split_args(\"PRELU\")\n >>> monai.networks.layers.Act[act_type]\n \n\n >>> act_type, args = split_args((\"PRELU\", {\"num_parameters\": 1, \"init\": 0.25}))\n >>> monai.networks.layers.Act[act_type](**args)\n PReLU(num_parameters=1)\n\n Raises:\n ValueError: Layer specifiers must be single strings or pairs of the form (name/object-types, argument dict)\n\n \"\"\"\n\n if isinstance(args, str):\n return args, {}\n else:\n name_obj, name_args = args\n\n if not isinstance(name_obj, (str, Callable)) or not isinstance(name_args, dict):\n msg = \"Layer specifiers must be single strings or pairs of the form (name/object-types, argument dict)\"\n raise ValueError(msg)\n\n return name_obj, name_args", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py__Define_factories_for_th_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py__Define_factories_for_th_", "embedding": null, "metadata": {"file_path": "monai/networks/layers/factories.py", "file_name": "factories.py", "file_type": "text/x-python", "category": "implementation", "start_line": 191, "end_line": 265, "span_ids": ["impl:3", "conv_factory", "avgpooling_factory", "adaptive_maxpooling_factory", "split_args", "maxpooling_factory", "adaptive_avgpooling_factory", "convtrans_factory", "dropout_factory", "impl:13", "batch_factory", "instance_factory"], "tokens": 618}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "# Define factories for these layer types\n\nDropout = LayerFactory()\nNorm = LayerFactory()\nAct = LayerFactory()\nConv = LayerFactory()\nPool = LayerFactory()\n\n\n@Dropout.factory_function(\"dropout\")\ndef dropout_factory(dim: int):\n types = [nn.Dropout, nn.Dropout2d, nn.Dropout3d]\n return types[dim - 1]\n\n\n@Norm.factory_function(\"instance\")\ndef instance_factory(dim: int):\n types = [nn.InstanceNorm1d, nn.InstanceNorm2d, nn.InstanceNorm3d]\n return types[dim - 1]\n\n\n@Norm.factory_function(\"batch\")\ndef batch_factory(dim: int):\n types = [nn.BatchNorm1d, nn.BatchNorm2d, nn.BatchNorm3d]\n return types[dim - 1]\n\n\nAct.add_factory_callable(\"relu\", lambda: nn.modules.ReLU)\nAct.add_factory_callable(\"leakyrelu\", lambda: nn.modules.LeakyReLU)\nAct.add_factory_callable(\"prelu\", lambda: nn.modules.PReLU)\nAct.add_factory_callable(\"relu6\", lambda: nn.modules.ReLU6)\nAct.add_factory_callable(\"selu\", lambda: nn.modules.SELU)\nAct.add_factory_callable(\"celu\", lambda: nn.modules.CELU)\nAct.add_factory_callable(\"gelu\", lambda: nn.modules.GELU)\nAct.add_factory_callable(\"sigmoid\", lambda: nn.modules.Sigmoid)\nAct.add_factory_callable(\"tanh\", lambda: nn.modules.Tanh)\nAct.add_factory_callable(\"softmax\", lambda: nn.modules.Softmax)\nAct.add_factory_callable(\"logsoftmax\", lambda: nn.modules.LogSoftmax)\n\n\n@Conv.factory_function(\"conv\")\ndef conv_factory(dim: int):\n types = [nn.Conv1d, nn.Conv2d, nn.Conv3d]\n return types[dim - 1]\n\n\n@Conv.factory_function(\"convtrans\")\ndef convtrans_factory(dim: int):\n types = [nn.ConvTranspose1d, nn.ConvTranspose2d, nn.ConvTranspose3d]\n return types[dim - 1]\n\n\n@Pool.factory_function(\"max\")\ndef maxpooling_factory(dim: int):\n types = [nn.MaxPool1d, nn.MaxPool2d, nn.MaxPool3d]\n return types[dim - 1]\n\n\n@Pool.factory_function(\"adaptivemax\")\ndef adaptive_maxpooling_factory(dim: int):\n types = [nn.AdaptiveMaxPool1d, nn.AdaptiveMaxPool2d, nn.AdaptiveMaxPool3d]\n return types[dim - 1]\n\n\n@Pool.factory_function(\"avg\")\ndef avgpooling_factory(dim: int):\n types = [nn.AvgPool1d, nn.AvgPool2d, nn.AvgPool3d]\n return types[dim - 1]\n\n\n@Pool.factory_function(\"adaptiveavg\")\ndef adaptive_avgpooling_factory(dim: int):\n types = [nn.AdaptiveAvgPool1d, nn.AdaptiveAvgPool2d, nn.AdaptiveAvgPool3d]\n return types[dim - 1]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_from_typing_import_Sequen_Flatten.forward.return.x_view_x_size_0_1_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_from_typing_import_Sequen_Flatten.forward.return.x_view_x_size_0_1_", "embedding": null, "metadata": {"file_path": "monai/networks/layers/simplelayers.py", "file_name": "simplelayers.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 44, "span_ids": ["Flatten", "SkipConnection.forward", "Flatten.forward", "docstring", "SkipConnection.__init__", "SkipConnection"], "tokens": 204}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Sequence, Union\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nfrom monai.networks.layers.convutils import gaussian_1d, same_padding\nfrom monai.utils import ensure_tuple_rep\n\n__all__ = [\"SkipConnection\", \"Flatten\", \"GaussianFilter\"]\n\n\nclass SkipConnection(nn.Module):\n \"\"\"\n Concats the forward pass input with the result from the given submodule.\n \"\"\"\n\n def __init__(self, submodule, cat_dim: int = 1) -> None:\n super().__init__()\n self.submodule = submodule\n self.cat_dim = cat_dim\n\n def forward(self, x):\n return torch.cat([x, self.submodule(x)], self.cat_dim)\n\n\nclass Flatten(nn.Module):\n \"\"\"\n Flattens the given input in the forward pass to be [B,-1] in shape.\n \"\"\"\n\n def forward(self, x):\n return x.view(x.size(0), -1)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_Reshape_Reshape.forward.return.x_reshape_shape_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_Reshape_Reshape.forward.return.x_reshape_shape_", "embedding": null, "metadata": {"file_path": "monai/networks/layers/simplelayers.py", "file_name": "simplelayers.py", "file_type": "text/x-python", "category": "implementation", "start_line": 47, "end_line": 66, "span_ids": ["Reshape.__init__", "Reshape", "Reshape.forward"], "tokens": 178}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Reshape(nn.Module):\n \"\"\"\n Reshapes input tensors to the given shape (minus batch dimension), retaining original batch size.\n \"\"\"\n\n def __init__(self, *shape) -> None:\n \"\"\"\n Given a shape list/tuple `shape` of integers (s0, s1, ... , sn), this layer will reshape input tensors of\n shape (batch, s0 * s1 * ... * sn) to shape (batch, s0, s1, ... , sn).\n\n Args:\n shape: list/tuple of integer shape dimensions\n \"\"\"\n super().__init__()\n self.shape = (1,) + tuple(shape)\n\n def forward(self, x):\n shape = list(self.shape)\n shape[0] = x.shape[0] # done this way for Torchscript\n return x.reshape(shape)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_GaussianFilter_GaussianFilter.__init__.for_idx_param_in_enumera.self_register_parameter_f": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_GaussianFilter_GaussianFilter.__init__.for_idx_param_in_enumera.self_register_parameter_f", "embedding": null, "metadata": {"file_path": "monai/networks/layers/simplelayers.py", "file_name": "simplelayers.py", "file_type": "text/x-python", "category": "implementation", "start_line": 69, "end_line": 87, "span_ids": ["GaussianFilter", "GaussianFilter.__init__"], "tokens": 219}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class GaussianFilter(nn.Module):\n def __init__(self, spatial_dims: int, sigma: Union[Sequence[float], float], truncated: float = 4.0) -> None:\n \"\"\"\n Args:\n spatial_dims: number of spatial dimensions of the input image.\n must have shape (Batch, channels, H[, W, ...]).\n sigma: std.\n truncated: spreads how many stds.\n \"\"\"\n super().__init__()\n self.spatial_dims = int(spatial_dims)\n _sigma = ensure_tuple_rep(sigma, self.spatial_dims)\n self.kernel = [\n torch.nn.Parameter(torch.as_tensor(gaussian_1d(s, truncated), dtype=torch.float), False) for s in _sigma\n ]\n self.padding = [same_padding(k.size()[0]) for k in self.kernel]\n self.conv_n = [F.conv1d, F.conv2d, F.conv3d][spatial_dims - 1]\n for idx, param in enumerate(self.kernel):\n self.register_parameter(f\"kernel_{idx}\", param)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_GaussianFilter.forward_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_GaussianFilter.forward_", "embedding": null, "metadata": {"file_path": "monai/networks/layers/simplelayers.py", "file_name": "simplelayers.py", "file_type": "text/x-python", "category": "implementation", "start_line": 89, "end_line": 116, "span_ids": ["GaussianFilter.forward"], "tokens": 252}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class GaussianFilter(nn.Module):\n\n def forward(self, x: torch.Tensor):\n \"\"\"\n Args:\n x: in shape [Batch, chns, H, W, D].\n\n Raises:\n TypeError: x must be a Tensor, got {type(x).__name__}.\n\n \"\"\"\n if not torch.is_tensor(x):\n raise TypeError(f\"x must be a Tensor, got {type(x).__name__}.\")\n chns = x.shape[1]\n sp_dim = self.spatial_dims\n x = x.clone() # no inplace change of x\n\n def _conv(input_, d):\n if d < 0:\n return input_\n s = [1] * (sp_dim + 2)\n s[d + 2] = -1\n kernel = self.kernel[d].reshape(s)\n kernel = kernel.repeat([chns, 1] + [1] * sp_dim)\n padding = [0] * sp_dim\n padding[d] = self.padding[d]\n return self.conv_n(input=_conv(input_, d - 1), weight=kernel, padding=padding, groups=chns)\n\n return _conv(x, sp_dim - 1)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/spatial_transforms.py_from_typing_import_Option_AffineTransform.__init__.self.reverse_indexing.reverse_indexing": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/spatial_transforms.py_from_typing_import_Option_AffineTransform.__init__.self.reverse_indexing.reverse_indexing", "embedding": null, "metadata": {"file_path": "monai/networks/layers/spatial_transforms.py", "file_name": "spatial_transforms.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 73, "span_ids": ["AffineTransform.__init__", "AffineTransform", "docstring"], "tokens": 752}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Sequence, Union\n\nimport torch\nimport torch.nn as nn\n\nfrom monai.networks import to_norm_affine\nfrom monai.utils import ensure_tuple, GridSampleMode, GridSamplePadMode\n\n__all__ = [\"AffineTransform\"]\n\n\nclass AffineTransform(nn.Module):\n def __init__(\n self,\n spatial_size: Optional[Union[Sequence[int], int]] = None,\n normalized: bool = False,\n mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,\n padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.ZEROS,\n align_corners: bool = False,\n reverse_indexing: bool = True,\n ) -> None:\n \"\"\"\n Apply affine transformations with a batch of affine matrices.\n\n When `normalized=False` and `reverse_indexing=True`,\n it does the commonly used resampling in the 'pull' direction\n following the ``scipy.ndimage.affine_transform`` convention.\n In this case `theta` is equivalent to (ndim+1, ndim+1) input ``matrix`` of ``scipy.ndimage.affine_transform``,\n operates on homogeneous coordinates.\n See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.affine_transform.html\n\n When `normalized=True` and `reverse_indexing=False`,\n it applies `theta` to the normalized coordinates (coords. in the range of [-1, 1]) directly.\n This is often used with `align_corners=False` to achieve resolution-agnostic resampling,\n thus useful as a part of trainable modules such as the spatial transformer networks.\n See also: https://pytorch.org/tutorials/intermediate/spatial_transformer_tutorial.html\n\n Args:\n spatial_size: output spatial shape, the full output shape will be\n `[N, C, *spatial_size]` where N and C are inferred from the `src` input of `self.forward`.\n normalized: indicating whether the provided affine matrix `theta` is defined\n for the normalized coordinates. If `normalized=False`, `theta` will be converted\n to operate on normalized coordinates as pytorch affine_grid works with the normalized\n coordinates.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``\"zeros\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n align_corners: see also https://pytorch.org/docs/stable/nn.functional.html#grid-sample.\n reverse_indexing: whether to reverse the spatial indexing of image and coordinates.\n set to `False` if `theta` follows pytorch's default \"D, H, W\" convention.\n set to `True` if `theta` follows `scipy.ndimage` default \"i, j, k\" convention.\n \"\"\"\n super().__init__()\n self.spatial_size = ensure_tuple(spatial_size) if spatial_size is not None else None\n self.normalized = normalized\n self.mode: GridSampleMode = GridSampleMode(mode)\n self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)\n self.align_corners = align_corners\n self.reverse_indexing = reverse_indexing", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/spatial_transforms.py_AffineTransform.forward_AffineTransform.forward.if_self_spatial_size_is_n.dst_size.src_size_2_self_spati": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/spatial_transforms.py_AffineTransform.forward_AffineTransform.forward.if_self_spatial_size_is_n.dst_size.src_size_2_self_spati", "embedding": null, "metadata": {"file_path": "monai/networks/layers/spatial_transforms.py", "file_name": "spatial_transforms.py", "file_type": "text/x-python", "category": "implementation", "start_line": 75, "end_line": 127, "span_ids": ["AffineTransform.forward"], "tokens": 784}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AffineTransform(nn.Module):\n\n def forward(self, src, theta, spatial_size: Optional[Union[Sequence[int], int]] = None):\n \"\"\"\n ``theta`` must be an affine transformation matrix with shape\n 3x3 or Nx3x3 or Nx2x3 or 2x3 for spatial 2D transforms,\n 4x4 or Nx4x4 or Nx3x4 or 3x4 for spatial 3D transforms,\n where `N` is the batch size. `theta` will be converted into float Tensor for the computation.\n\n Args:\n src (array_like): image in spatial 2D or 3D (N, C, spatial_dims),\n where N is the batch dim, C is the number of channels.\n theta (array_like): Nx3x3, Nx2x3, 3x3, 2x3 for spatial 2D inputs,\n Nx4x4, Nx3x4, 3x4, 4x4 for spatial 3D inputs. When the batch dimension is omitted,\n `theta` will be repeated N times, N is the batch dim of `src`.\n spatial_size: output spatial shape, the full output shape will be\n `[N, C, *spatial_size]` where N and C are inferred from the `src`.\n\n Raises:\n TypeError: both src and theta must be torch Tensor, got {type(src).__name__}, {type(theta).__name__}.\n ValueError: affine must be Nxdxd or dxd.\n ValueError: affine must be Nx3x3 or Nx4x4, got: {theta.shape}.\n ValueError: src must be spatially 2D or 3D.\n ValueError: batch dimension of affine and image does not match, got affine: {} and image: {}.\n\n \"\"\"\n # validate `theta`\n if not torch.is_tensor(theta) or not torch.is_tensor(src):\n raise TypeError(\n f\"both src and theta must be torch Tensor, got {type(src).__name__}, {type(theta).__name__}.\"\n )\n if theta.ndim not in (2, 3):\n raise ValueError(\"affine must be Nxdxd or dxd.\")\n if theta.ndim == 2:\n theta = theta[None] # adds a batch dim.\n theta = theta.clone() # no in-place change of theta\n theta_shape = tuple(theta.shape[1:])\n if theta_shape in ((2, 3), (3, 4)): # needs padding to dxd\n pad_affine = torch.tensor([0, 0, 1] if theta_shape[0] == 2 else [0, 0, 0, 1])\n pad_affine = pad_affine.repeat(theta.shape[0], 1, 1).to(theta)\n pad_affine.requires_grad = False\n theta = torch.cat([theta, pad_affine], dim=1)\n if tuple(theta.shape[1:]) not in ((3, 3), (4, 4)):\n raise ValueError(f\"affine must be Nx3x3 or Nx4x4, got: {theta.shape}.\")\n\n # validate `src`\n sr = src.ndim - 2 # input spatial rank\n if sr not in (2, 3):\n raise ValueError(\"src must be spatially 2D or 3D.\")\n\n # set output shape\n src_size = tuple(src.shape)\n dst_size = src_size # default to the src shape\n if self.spatial_size is not None:\n dst_size = src_size[:2] + self.spatial_size\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/spatial_transforms.py_AffineTransform.forward.if_spatial_size_is_not_No_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/spatial_transforms.py_AffineTransform.forward.if_spatial_size_is_not_No_", "embedding": null, "metadata": {"file_path": "monai/networks/layers/spatial_transforms.py", "file_name": "spatial_transforms.py", "file_type": "text/x-python", "category": "implementation", "start_line": 128, "end_line": 159, "span_ids": ["AffineTransform.forward"], "tokens": 353}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AffineTransform(nn.Module):\n\n def forward(self, src, theta, spatial_size: Optional[Union[Sequence[int], int]] = None):\n # ... other code\n if spatial_size is not None:\n dst_size = src_size[:2] + ensure_tuple(spatial_size)\n\n # reverse and normalise theta if needed\n if not self.normalized:\n theta = to_norm_affine(\n affine=theta, src_size=src_size[2:], dst_size=dst_size[2:], align_corners=self.align_corners\n )\n if self.reverse_indexing:\n rev_idx = torch.as_tensor(range(sr - 1, -1, -1), device=src.device)\n theta[:, :sr] = theta[:, rev_idx]\n theta[:, :, :sr] = theta[:, :, rev_idx]\n if (theta.shape[0] == 1) and src_size[0] > 1:\n # adds a batch dim to `theta` in order to match `src`\n theta = theta.repeat(src_size[0], 1, 1)\n if theta.shape[0] != src_size[0]:\n raise ValueError(\n \"batch dimension of affine and image does not match, got affine: {} and image: {}.\".format(\n theta.shape[0], src_size[0]\n )\n )\n\n grid = nn.functional.affine_grid(theta=theta[:, :sr], size=list(dst_size), align_corners=self.align_corners)\n dst = nn.functional.grid_sample(\n input=src.contiguous(),\n grid=grid,\n mode=self.mode.value,\n padding_mode=self.padding_mode.value,\n align_corners=self.align_corners,\n )\n return dst", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/__init__.py_DenseNet_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/__init__.py_DenseNet_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 18, "span_ids": ["docstring"], "tokens": 70}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from .densenet import DenseNet, densenet121, densenet169, densenet201, densenet264\nfrom .highresnet import HighResNet, HighResBlock\nfrom .unet import *\nfrom .generator import Generator\nfrom .regressor import Regressor\nfrom .classifier import *", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/classifier.py_from_typing_import_Option_Classifier.__init__.if_last_act_is_not_None_.self_final_add_module_la": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/classifier.py_from_typing_import_Option_Classifier.__init__.if_last_act_is_not_None_.self_final_add_module_la", "embedding": null, "metadata": {"file_path": "monai/networks/nets/classifier.py", "file_name": "classifier.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 46, "span_ids": ["Classifier.__init__", "Classifier", "docstring"], "tokens": 283}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Sequence, Union\n\nimport torch.nn as nn\nfrom monai.networks.layers.factories import Norm, Act, split_args\nfrom monai.networks.nets.regressor import Regressor\n\n\nclass Classifier(Regressor):\n \"\"\"\n Defines a classification network from Regressor by specifying the output shape as a single dimensional tensor\n with size equal to the number of classes to predict. The final activation function can also be specified, eg.\n softmax or sigmoid.\n \"\"\"\n\n def __init__(\n self,\n in_shape: Sequence[int],\n classes: int,\n channels: Sequence[int],\n strides: Sequence[int],\n kernel_size: Union[Sequence[int], int] = 3,\n num_res_units: int = 2,\n act=Act.PRELU,\n norm=Norm.INSTANCE,\n dropout: Optional[float] = None,\n bias: bool = True,\n last_act: Optional[str] = None,\n ) -> None:\n super().__init__(in_shape, (classes,), channels, strides, kernel_size, num_res_units, act, norm, dropout, bias)\n\n if last_act is not None:\n last_act_name, last_act_args = split_args(last_act)\n last_act_type = Act[last_act_name]\n\n self.final.add_module(\"lastact\", last_act_type(**last_act_args))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/classifier.py_Discriminator_Discriminator.__init__.super___init___in_shape": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/classifier.py_Discriminator_Discriminator.__init__.super___init___in_shape", "embedding": null, "metadata": {"file_path": "monai/networks/nets/classifier.py", "file_name": "classifier.py", "file_type": "text/x-python", "category": "implementation", "start_line": 49, "end_line": 68, "span_ids": ["Discriminator.__init__", "Discriminator"], "tokens": 180}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Discriminator(Classifier):\n \"\"\"\n Defines a discriminator network from Classifier with a single output value and sigmoid activation by default. This\n is meant for use with GANs or other applications requiring a generic discriminator network.\n \"\"\"\n\n def __init__(\n self,\n in_shape: Sequence[int],\n channels: Sequence[int],\n strides: Sequence[int],\n kernel_size: Union[Sequence[int], int] = 3,\n num_res_units: int = 2,\n act=Act.PRELU,\n norm=Norm.INSTANCE,\n dropout: Optional[float] = 0.25,\n bias: bool = True,\n last_act=Act.SIGMOID,\n ) -> None:\n super().__init__(in_shape, 1, channels, strides, kernel_size, num_res_units, act, norm, dropout, bias, last_act)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/classifier.py_Critic_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/classifier.py_Critic_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/classifier.py", "file_name": "classifier.py", "file_type": "text/x-python", "category": "implementation", "start_line": 71, "end_line": 100, "span_ids": ["Critic", "Critic.forward", "Critic.__init__", "Critic._get_final_layer"], "tokens": 254}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Critic(Classifier):\n \"\"\"\n Defines a critic network from Classifier with a single output value and no final activation. The final layer is\n `nn.Flatten` instead of `nn.Linear`, the final result is computed as the mean over the first dimension. This is\n meant to be used with Wassertein GANs.\n \"\"\"\n\n def __init__(\n self,\n in_shape: Sequence[int],\n channels: Sequence[int],\n strides: Sequence[int],\n kernel_size: Union[Sequence[int], int] = 3,\n num_res_units: int = 2,\n act=Act.PRELU,\n norm=Norm.INSTANCE,\n dropout: Optional[float] = 0.25,\n bias: bool = True,\n ) -> None:\n super().__init__(in_shape, 1, channels, strides, kernel_size, num_res_units, act, norm, dropout, bias, None)\n\n def _get_final_layer(self, in_shape):\n return nn.Flatten()\n\n def forward(self, x):\n x = self.net(x)\n x = self.final(x)\n x = x.mean(1)\n return x.view((x.shape[0], -1))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py_from_collections_import_O__DenseLayer.forward.return.torch_cat_x_new_feature": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py_from_collections_import_O__DenseLayer.forward.return.torch_cat_x_new_feature", "embedding": null, "metadata": {"file_path": "monai/networks/nets/densenet.py", "file_name": "densenet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 45, "span_ids": ["_DenseLayer.__init__", "_DenseLayer.forward", "_DenseLayer", "docstring"], "tokens": 317}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from collections import OrderedDict\nfrom typing import Callable, Sequence, Type, Union\n\nimport torch\nimport torch.nn as nn\n\nfrom monai.networks.layers.factories import Conv, Dropout, Pool, Norm\n\n\nclass _DenseLayer(nn.Sequential):\n def __init__(\n self, spatial_dims: int, in_channels: int, growth_rate: int, bn_size: int, dropout_prob: float\n ) -> None:\n super(_DenseLayer, self).__init__()\n\n out_channels = bn_size * growth_rate\n conv_type: Callable = Conv[Conv.CONV, spatial_dims]\n norm_type: Callable = Norm[Norm.BATCH, spatial_dims]\n dropout_type: Callable = Dropout[Dropout.DROPOUT, spatial_dims]\n\n self.add_module(\"norm1\", norm_type(in_channels))\n self.add_module(\"relu1\", nn.ReLU(inplace=True))\n self.add_module(\"conv1\", conv_type(in_channels, out_channels, kernel_size=1, bias=False))\n\n self.add_module(\"norm2\", norm_type(out_channels))\n self.add_module(\"relu2\", nn.ReLU(inplace=True))\n self.add_module(\"conv2\", conv_type(out_channels, growth_rate, kernel_size=3, padding=1, bias=False))\n\n if dropout_prob > 0:\n self.add_module(\"dropout\", dropout_type(dropout_prob))\n\n def forward(self, x):\n new_features = super(_DenseLayer, self).forward(x)\n return torch.cat([x, new_features], 1)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py__DenseBlock__DenseBlock.__init__.for_i_in_range_layers_.self_add_module_denselay": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py__DenseBlock__DenseBlock.__init__.for_i_in_range_layers_.self_add_module_denselay", "embedding": null, "metadata": {"file_path": "monai/networks/nets/densenet.py", "file_name": "densenet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 48, "end_line": 56, "span_ids": ["_DenseBlock.__init__", "_DenseBlock"], "tokens": 117}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class _DenseBlock(nn.Sequential):\n def __init__(\n self, spatial_dims: int, layers: int, in_channels: int, bn_size: int, growth_rate: int, dropout_prob: float\n ) -> None:\n super(_DenseBlock, self).__init__()\n for i in range(layers):\n layer = _DenseLayer(spatial_dims, in_channels, growth_rate, bn_size, dropout_prob)\n in_channels += growth_rate\n self.add_module(\"denselayer%d\" % (i + 1), layer)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py__Transition__Transition.__init__.self_add_module_pool_p": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py__Transition__Transition.__init__.self_add_module_pool_p", "embedding": null, "metadata": {"file_path": "monai/networks/nets/densenet.py", "file_name": "densenet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 59, "end_line": 70, "span_ids": ["_Transition", "_Transition.__init__"], "tokens": 150}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class _Transition(nn.Sequential):\n def __init__(self, spatial_dims: int, in_channels: int, out_channels: int) -> None:\n super(_Transition, self).__init__()\n\n conv_type: Callable = Conv[Conv.CONV, spatial_dims]\n norm_type: Callable = Norm[Norm.BATCH, spatial_dims]\n pool_type: Callable = Pool[Pool.AVG, spatial_dims]\n\n self.add_module(\"norm\", norm_type(in_channels))\n self.add_module(\"relu\", nn.ReLU(inplace=True))\n self.add_module(\"conv\", conv_type(in_channels, out_channels, kernel_size=1, bias=False))\n self.add_module(\"pool\", pool_type(kernel_size=2, stride=2))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py_DenseNet_DenseNet._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py_DenseNet_DenseNet._", "embedding": null, "metadata": {"file_path": "monai/networks/nets/densenet.py", "file_name": "densenet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 73, "end_line": 89, "span_ids": ["DenseNet"], "tokens": 190}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DenseNet(nn.Module):\n \"\"\"\n Densenet based on: \"Densely Connected Convolutional Networks\" https://arxiv.org/pdf/1608.06993.pdf\n Adapted from PyTorch Hub 2D version:\n https://github.com/pytorch/vision/blob/master/torchvision/models/densenet.py\n\n Args:\n spatial_dims: number of spatial dimensions of the input image.\n in_channels: number of the input channel.\n out_channels: number of the output classes.\n init_features: number of filters in the first convolution layer.\n growth_rate: how many filters to add each layer (k in paper).\n block_config: how many layers in each pooling block.\n bn_size: multiplicative factor for number of bottle neck layers.\n (i.e. bn_size * k features in the bottleneck layer)\n dropout_prob: dropout rate after each dense layer.\n \"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py_DenseNet.__init___DenseNet.forward.return.x": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py_DenseNet.__init___DenseNet.forward.return.x", "embedding": null, "metadata": {"file_path": "monai/networks/nets/densenet.py", "file_name": "densenet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 91, "end_line": 167, "span_ids": ["DenseNet.__init__", "DenseNet.forward"], "tokens": 695}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DenseNet(nn.Module):\n\n def __init__(\n self,\n spatial_dims: int,\n in_channels: int,\n out_channels: int,\n init_features: int = 64,\n growth_rate: int = 32,\n block_config: Sequence[int] = (6, 12, 24, 16),\n bn_size: int = 4,\n dropout_prob: float = 0.0,\n ) -> None:\n\n super(DenseNet, self).__init__()\n\n conv_type: Type[Union[nn.Conv1d, nn.Conv2d, nn.Conv3d]] = Conv[Conv.CONV, spatial_dims]\n norm_type: Type[Union[nn.BatchNorm1d, nn.BatchNorm2d, nn.BatchNorm3d]] = Norm[Norm.BATCH, spatial_dims]\n pool_type: Type[Union[nn.MaxPool1d, nn.MaxPool2d, nn.MaxPool3d]] = Pool[Pool.MAX, spatial_dims]\n avg_pool_type: Type[Union[nn.AdaptiveAvgPool1d, nn.AdaptiveAvgPool2d, nn.AdaptiveAvgPool3d]] = Pool[\n Pool.ADAPTIVEAVG, spatial_dims\n ]\n\n self.features = nn.Sequential(\n OrderedDict(\n [\n (\"conv0\", conv_type(in_channels, init_features, kernel_size=7, stride=2, padding=3, bias=False)),\n (\"norm0\", norm_type(init_features)),\n (\"relu0\", nn.ReLU(inplace=True)),\n (\"pool0\", pool_type(kernel_size=3, stride=2, padding=1)),\n ]\n )\n )\n\n in_channels = init_features\n for i, num_layers in enumerate(block_config):\n block = _DenseBlock(\n spatial_dims=spatial_dims,\n layers=num_layers,\n in_channels=in_channels,\n bn_size=bn_size,\n growth_rate=growth_rate,\n dropout_prob=dropout_prob,\n )\n self.features.add_module(f\"denseblock{i + 1}\", block)\n in_channels += num_layers * growth_rate\n if i == len(block_config) - 1:\n self.features.add_module(\"norm5\", norm_type(in_channels))\n else:\n _out_channels = in_channels // 2\n trans = _Transition(spatial_dims, in_channels=in_channels, out_channels=_out_channels)\n self.features.add_module(f\"transition{i + 1}\", trans)\n in_channels = _out_channels\n\n # pooling and classification\n self.class_layers = nn.Sequential(\n OrderedDict(\n [\n (\"relu\", nn.ReLU(inplace=True)),\n (\"norm\", avg_pool_type(1)),\n (\"flatten\", nn.Flatten(1)), # type: ignore # Module has no attribute\n (\"class\", nn.Linear(in_channels, out_channels)),\n ]\n )\n )\n\n for m in self.modules():\n if isinstance(m, conv_type):\n nn.init.kaiming_normal_(m.weight)\n elif isinstance(m, norm_type):\n nn.init.constant_(m.weight, 1)\n nn.init.constant_(m.bias, 0)\n elif isinstance(m, nn.Linear):\n nn.init.constant_(m.bias, 0)\n\n def forward(self, x):\n x = self.features(x)\n x = self.class_layers(x)\n return x", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py_densenet121_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/densenet.py_densenet121_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/densenet.py", "file_name": "densenet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 170, "end_line": 188, "span_ids": ["densenet264", "densenet169", "densenet121", "densenet201"], "tokens": 191}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def densenet121(**kwargs) -> DenseNet:\n model = DenseNet(init_features=64, growth_rate=32, block_config=(6, 12, 24, 16), **kwargs)\n return model\n\n\ndef densenet169(**kwargs) -> DenseNet:\n model = DenseNet(init_features=64, growth_rate=32, block_config=(6, 12, 32, 32), **kwargs)\n return model\n\n\ndef densenet201(**kwargs) -> DenseNet:\n model = DenseNet(init_features=64, growth_rate=32, block_config=(6, 12, 48, 32), **kwargs)\n return model\n\n\ndef densenet264(**kwargs) -> DenseNet:\n model = DenseNet(init_features=64, growth_rate=32, block_config=(6, 12, 64, 48), **kwargs)\n return model", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/generator.py_from_typing_import_Option_Generator._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/generator.py_from_typing_import_Option_Generator._", "embedding": null, "metadata": {"file_path": "monai/networks/nets/generator.py", "file_name": "generator.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 34, "span_ids": ["Generator", "docstring"], "tokens": 222}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Sequence, Union\n\nimport numpy as np\nimport torch.nn as nn\n\nfrom monai.networks.layers.factories import Norm, Act\nfrom monai.networks.blocks import Convolution, ResidualUnit\nfrom monai.networks.layers.simplelayers import Reshape\nfrom monai.utils import ensure_tuple, ensure_tuple_rep\n\n\nclass Generator(nn.Module):\n \"\"\"\n Defines a simple generator network accepting a latent vector and through a sequence of convolution layers\n constructs an output tensor of greater size and high dimensionality. The method `_get_layer` is used to\n create each of these layers, override this method to define layers beyond the default Convolution or\n ResidualUnit layers.\n\n For example, a generator accepting a latent vector if shape (42,24) and producing an output volume of\n shape (1,64,64) can be constructed as:\n\n gen = Generator((42, 24), (64, 8, 8), (32, 16, 1), (2, 2, 2))\n \"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/generator.py_Generator.__init___Generator.__init__.for_i_c_s_in_enumerat.echannel.c": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/generator.py_Generator.__init___Generator.__init__.for_i_c_s_in_enumerat.echannel.c", "embedding": null, "metadata": {"file_path": "monai/networks/nets/generator.py", "file_name": "generator.py", "file_type": "text/x-python", "category": "implementation", "start_line": 36, "end_line": 96, "span_ids": ["Generator.__init__"], "tokens": 664}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Generator(nn.Module):\n\n def __init__(\n self,\n latent_shape: Sequence[int],\n start_shape: Sequence[int],\n channels: Sequence[int],\n strides: Sequence[int],\n kernel_size: Union[Sequence[int], int] = 3,\n num_res_units: int = 2,\n act=Act.PRELU,\n norm=Norm.INSTANCE,\n dropout: Optional[float] = None,\n bias: bool = True,\n ) -> None:\n \"\"\"\n Construct the generator network with the number of layers defined by `channels` and `strides`. In the\n forward pass a `nn.Linear` layer relates the input latent vector to a tensor of dimensions `start_shape`,\n this is then fed forward through the sequence of convolutional layers. The number of layers is defined by\n the length of `channels` and `strides` which must match, each layer having the number of output channels\n given in `channels` and an upsample factor given in `strides` (ie. a transpose convolution with that stride\n size).\n\n Args:\n latent_shape: tuple of integers stating the dimension of the input latent vector (minus batch dimension)\n start_shape: tuple of integers stating the dimension of the tensor to pass to convolution subnetwork\n channels: tuple of integers stating the output channels of each convolutional layer\n strides: tuple of integers stating the stride (upscale factor) of each convolutional layer\n kernel_size: integer or tuple of integers stating size of convolutional kernels\n num_res_units: integer stating number of convolutions in residual units, 0 means no residual units\n act: name or type defining activation layers\n norm: name or type defining normalization layers\n dropout: optional float value in range [0, 1] stating dropout probability for layers, None for no dropout\n bias: boolean stating if convolution layers should have a bias component\n \"\"\"\n super().__init__()\n\n self.in_channels, *self.start_shape = ensure_tuple(start_shape)\n self.dimensions = len(self.start_shape)\n\n self.latent_shape = ensure_tuple(latent_shape)\n self.channels = ensure_tuple(channels)\n self.strides = ensure_tuple(strides)\n self.kernel_size = ensure_tuple_rep(kernel_size, self.dimensions)\n self.num_res_units = num_res_units\n self.act = act\n self.norm = norm\n self.dropout = dropout\n self.bias = bias\n\n self.flatten = nn.Flatten() # type: ignore # Module has no attribute\n self.linear = nn.Linear(int(np.prod(self.latent_shape)), int(np.prod(start_shape)))\n self.reshape = Reshape(*start_shape)\n self.conv = nn.Sequential()\n\n echannel = self.in_channels\n\n # transform tensor of shape `start_shape' into output shape through transposed convolutions and residual units\n for i, (c, s) in enumerate(zip(channels, strides)):\n is_last = i == len(channels) - 1\n layer = self._get_layer(echannel, c, s, is_last)\n self.conv.add_module(\"layer_%i\" % i, layer)\n echannel = c", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/generator.py_Generator._get_layer_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/generator.py_Generator._get_layer_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/generator.py", "file_name": "generator.py", "file_type": "text/x-python", "category": "implementation", "start_line": 98, "end_line": 145, "span_ids": ["Generator.forward", "Generator._get_layer"], "tokens": 318}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Generator(nn.Module):\n\n def _get_layer(self, in_channels: int, out_channels: int, strides, is_last: bool):\n \"\"\"\n Returns a layer accepting inputs with `in_channels` number of channels and producing outputs of `out_channels`\n number of channels. The `strides` indicates upsampling factor, ie. transpose convolutional stride. If `is_last`\n is True this is the final layer and is not expected to include activation and normalization layers.\n \"\"\"\n\n layer: Union[Convolution, nn.Sequential]\n\n layer = Convolution(\n in_channels=in_channels,\n strides=strides,\n is_transposed=True,\n conv_only=is_last or self.num_res_units > 0,\n dimensions=self.dimensions,\n out_channels=out_channels,\n kernel_size=self.kernel_size,\n act=self.act,\n norm=self.norm,\n dropout=self.dropout,\n bias=self.bias,\n )\n\n if self.num_res_units > 0:\n ru = ResidualUnit(\n in_channels=out_channels,\n subunits=self.num_res_units,\n last_conv_only=is_last,\n dimensions=self.dimensions,\n out_channels=out_channels,\n kernel_size=self.kernel_size,\n act=self.act,\n norm=self.norm,\n dropout=self.dropout,\n bias=self.bias,\n )\n\n layer = nn.Sequential(layer, ru)\n\n return layer\n\n def forward(self, x):\n x = self.flatten(x)\n x = self.linear(x)\n x = self.reshape(x)\n x = self.conv(x)\n return x", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/highresnet.py_from_typing_import_Option_DEFAULT_LAYER_PARAMS_3D._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/highresnet.py_from_typing_import_Option_DEFAULT_LAYER_PARAMS_3D._", "embedding": null, "metadata": {"file_path": "monai/networks/nets/highresnet.py", "file_name": "highresnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 36, "span_ids": ["docstring"], "tokens": 320}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Sequence, Union\n\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nfrom monai.networks.layers.convutils import same_padding\nfrom monai.networks.layers.factories import Conv, Dropout, Norm\nfrom monai.utils import Normalisation, Activation, ChannelMatching\n\nSUPPORTED_NORM = {\n Normalisation.BATCH: lambda spatial_dims: Norm[Norm.BATCH, spatial_dims],\n Normalisation.INSTANCE: lambda spatial_dims: Norm[Norm.INSTANCE, spatial_dims],\n}\nSUPPORTED_ACTI = {Activation.RELU: nn.ReLU, Activation.PRELU: nn.PReLU, Activation.RELU6: nn.ReLU6}\nDEFAULT_LAYER_PARAMS_3D = (\n # initial conv layer\n {\"name\": \"conv_0\", \"n_features\": 16, \"kernel_size\": 3},\n # residual blocks\n {\"name\": \"res_1\", \"n_features\": 16, \"kernels\": (3, 3), \"repeat\": 3},\n {\"name\": \"res_2\", \"n_features\": 32, \"kernels\": (3, 3), \"repeat\": 3},\n {\"name\": \"res_3\", \"n_features\": 64, \"kernels\": (3, 3), \"repeat\": 3},\n # final conv layers\n {\"name\": \"conv_1\", \"n_features\": 80, \"kernel_size\": 1},\n {\"name\": \"conv_2\", \"kernel_size\": 1},\n)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/highresnet.py_ConvNormActi_ConvNormActi.forward.return.self_layers_x_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/highresnet.py_ConvNormActi_ConvNormActi.forward.return.self_layers_x_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/highresnet.py", "file_name": "highresnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 39, "end_line": 72, "span_ids": ["ConvNormActi.__init__", "ConvNormActi.forward", "ConvNormActi"], "tokens": 278}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ConvNormActi(nn.Module):\n def __init__(\n self,\n spatial_dims: int,\n in_channels: int,\n out_channels: int,\n kernel_size: int,\n norm_type: Optional[Union[Normalisation, str]] = None,\n acti_type: Optional[Union[Activation, str]] = None,\n dropout_prob: Optional[float] = None,\n ) -> None:\n\n super(ConvNormActi, self).__init__()\n\n layers = nn.ModuleList()\n\n conv_type = Conv[Conv.CONV, spatial_dims]\n padding_size = same_padding(kernel_size)\n conv = conv_type(in_channels, out_channels, kernel_size, padding=padding_size)\n layers.append(conv)\n\n if norm_type is not None:\n norm_type = Normalisation(norm_type)\n layers.append(SUPPORTED_NORM[norm_type](spatial_dims)(out_channels))\n if acti_type is not None:\n acti_type = Activation(acti_type)\n layers.append(SUPPORTED_ACTI[acti_type](inplace=True))\n if dropout_prob is not None:\n dropout_type = Dropout[Dropout.DROPOUT, spatial_dims]\n layers.append(dropout_type(p=dropout_prob))\n self.layers = nn.Sequential(*layers)\n\n def forward(self, x):\n return self.layers(x)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/highresnet.py_HighResBlock_HighResBlock.forward.return.x_conv_x": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/highresnet.py_HighResBlock_HighResBlock.forward.return.x_conv_x", "embedding": null, "metadata": {"file_path": "monai/networks/nets/highresnet.py", "file_name": "highresnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 75, "end_line": 142, "span_ids": ["HighResBlock.__init__", "HighResBlock", "HighResBlock.forward"], "tokens": 708}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class HighResBlock(nn.Module):\n def __init__(\n self,\n spatial_dims: int,\n in_channels: int,\n out_channels: int,\n kernels: Sequence[int] = (3, 3),\n dilation=1,\n norm_type: Union[Normalisation, str] = Normalisation.INSTANCE,\n acti_type: Union[Activation, str] = Activation.RELU,\n channel_matching: Union[ChannelMatching, str] = ChannelMatching.PAD,\n ) -> None:\n \"\"\"\n Args:\n kernels: each integer k in `kernels` corresponds to a convolution layer with kernel size k.\n norm_type: {``\"batch\"``, ``\"instance\"``}\n Feature normalisation with batchnorm or instancenorm. Defaults to ``\"instance\"``.\n acti_type: {``\"relu\"``, ``\"prelu\"``, ``\"relu6\"``}\n Non-linear activation using ReLU or PReLU. Defaults to ``\"relu\"``.\n channel_matching: {``\"pad\"``, ``\"project\"``}\n Specifies handling residual branch and conv branch channel mismatches. Defaults to ``\"pad\"``.\n\n - ``\"pad\"``: with zero padding.\n - ``\"project\"``: with a trainable conv with kernel size.\n\n Raises:\n ValueError: channel matching must be pad or project, got {channel_matching}.\n ValueError: in_channels > out_channels is incompatible with `channel_matching=pad`.\n\n \"\"\"\n super(HighResBlock, self).__init__()\n conv_type = Conv[Conv.CONV, spatial_dims]\n norm_type = Normalisation(norm_type)\n acti_type = Activation(acti_type)\n\n self.project, self.pad = None, None\n if in_channels != out_channels:\n channel_matching = ChannelMatching(channel_matching)\n if channel_matching == ChannelMatching.PROJECT:\n self.project = conv_type(in_channels, out_channels, kernel_size=1)\n if channel_matching == ChannelMatching.PAD:\n if in_channels > out_channels:\n raise ValueError(\"in_channels > out_channels is incompatible with `channel_matching=pad`.\")\n pad_1 = (out_channels - in_channels) // 2\n pad_2 = out_channels - in_channels - pad_1\n pad = [0, 0] * spatial_dims + [pad_1, pad_2] + [0, 0]\n self.pad = lambda input: F.pad(input, pad)\n\n layers = nn.ModuleList()\n _in_chns, _out_chns = in_channels, out_channels\n for kernel_size in kernels:\n layers.append(SUPPORTED_NORM[norm_type](spatial_dims)(_in_chns))\n layers.append(SUPPORTED_ACTI[acti_type](inplace=True))\n layers.append(\n conv_type(\n _in_chns, _out_chns, kernel_size, padding=same_padding(kernel_size, dilation), dilation=dilation\n )\n )\n _in_chns = _out_chns\n self.layers = nn.Sequential(*layers)\n\n def forward(self, x):\n x_conv = self.layers(x)\n if self.project is not None:\n return x_conv + self.project(x)\n if self.pad is not None:\n return x_conv + self.pad(x)\n return x_conv + x", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/highresnet.py_HighResNet_HighResNet._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/highresnet.py_HighResNet_HighResNet._", "embedding": null, "metadata": {"file_path": "monai/networks/nets/highresnet.py", "file_name": "highresnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 145, "end_line": 166, "span_ids": ["HighResNet"], "tokens": 265}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class HighResNet(nn.Module):\n \"\"\"\n Reimplementation of highres3dnet based on\n Li et al., \"On the compactness, efficiency, and representation of 3D\n convolutional networks: Brain parcellation as a pretext task\", IPMI '17\n\n Adapted from:\n https://github.com/NifTK/NiftyNet/blob/v0.6.0/niftynet/network/highres3dnet.py\n https://github.com/fepegar/highresnet\n\n Args:\n spatial_dims: number of spatial dimensions of the input image.\n in_channels: number of input channels.\n out_channels: number of output channels.\n norm_type: {``\"batch\"``, ``\"instance\"``}\n Feature normalisation with batchnorm or instancenorm. Defaults to ``\"batch\"``.\n acti_type: {``\"relu\"``, ``\"prelu\"``, ``\"relu6\"``}\n Non-linear activation using ReLU or PReLU. Defaults to ``\"relu\"``.\n dropout_prob: probability of the feature map to be zeroed\n (only applies to the penultimate conv layer).\n layer_params (a list of dictionaries): specifying key parameters of each layer/block.\n \"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/highresnet.py_HighResNet.__init___": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/highresnet.py_HighResNet.__init___", "embedding": null, "metadata": {"file_path": "monai/networks/nets/highresnet.py", "file_name": "highresnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 168, "end_line": 248, "span_ids": ["HighResNet.forward", "HighResNet.__init__"], "tokens": 567}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class HighResNet(nn.Module):\n\n def __init__(\n self,\n spatial_dims: int = 3,\n in_channels: int = 1,\n out_channels: int = 1,\n norm_type: Union[Normalisation, str] = Normalisation.BATCH,\n acti_type: Union[Activation, str] = Activation.RELU,\n dropout_prob: Optional[float] = None,\n layer_params=DEFAULT_LAYER_PARAMS_3D,\n ) -> None:\n\n super(HighResNet, self).__init__()\n blocks = nn.ModuleList()\n\n # intial conv layer\n params = layer_params[0]\n _in_chns, _out_chns = in_channels, params[\"n_features\"]\n blocks.append(\n ConvNormActi(\n spatial_dims,\n _in_chns,\n _out_chns,\n kernel_size=params[\"kernel_size\"],\n norm_type=norm_type,\n acti_type=acti_type,\n dropout_prob=None,\n )\n )\n\n # residual blocks\n for (idx, params) in enumerate(layer_params[1:-2]): # res blocks except the 1st and last two conv layers.\n _in_chns, _out_chns = _out_chns, params[\"n_features\"]\n _dilation = 2 ** idx\n for _ in range(params[\"repeat\"]):\n blocks.append(\n HighResBlock(\n spatial_dims,\n _in_chns,\n _out_chns,\n params[\"kernels\"],\n dilation=_dilation,\n norm_type=norm_type,\n acti_type=acti_type,\n )\n )\n _in_chns = _out_chns\n\n # final conv layers\n params = layer_params[-2]\n _in_chns, _out_chns = _out_chns, params[\"n_features\"]\n blocks.append(\n ConvNormActi(\n spatial_dims,\n _in_chns,\n _out_chns,\n kernel_size=params[\"kernel_size\"],\n norm_type=norm_type,\n acti_type=acti_type,\n dropout_prob=dropout_prob,\n )\n )\n\n params = layer_params[-1]\n _in_chns = _out_chns\n blocks.append(\n ConvNormActi(\n spatial_dims,\n _in_chns,\n out_channels,\n kernel_size=params[\"kernel_size\"],\n norm_type=norm_type,\n acti_type=None,\n dropout_prob=None,\n )\n )\n\n self.blocks = nn.Sequential(*blocks)\n\n def forward(self, x):\n return self.blocks(x)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/regressor.py_from_typing_import_Option_Regressor.__init__.self.final.self__get_final_layer_ec": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/regressor.py_from_typing_import_Option_Regressor.__init__.self.final.self__get_final_layer_ec", "embedding": null, "metadata": {"file_path": "monai/networks/nets/regressor.py", "file_name": "regressor.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 90, "span_ids": ["Regressor", "Regressor.__init__", "docstring"], "tokens": 762}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Sequence, Union\n\nimport numpy as np\nimport torch.nn as nn\n\nfrom monai.networks.layers.factories import Norm, Act\nfrom monai.networks.blocks import Convolution, ResidualUnit\nfrom monai.networks.layers.simplelayers import Reshape\nfrom monai.networks.layers.convutils import same_padding, calculate_out_shape\nfrom monai.utils import ensure_tuple, ensure_tuple_rep\n\n\nclass Regressor(nn.Module):\n \"\"\"\n This defines a network for relating large-sized input tensors to small output tensors, ie. regressing large\n values to a prediction. An output of a single dimension can be used as value regression or multi-label\n classification prediction, an output of a single value can be used as a discriminator or critic prediction.\n \"\"\"\n\n def __init__(\n self,\n in_shape: Sequence[int],\n out_shape: Sequence[int],\n channels: Sequence[int],\n strides: Sequence[int],\n kernel_size: Union[Sequence[int], int] = 3,\n num_res_units: int = 2,\n act=Act.PRELU,\n norm=Norm.INSTANCE,\n dropout: Optional[float] = None,\n bias: bool = True,\n ):\n \"\"\"\n Construct the regressor network with the number of layers defined by `channels` and `strides`. Inputs are\n first passed through the convolutional layers in the forward pass, the output from this is then pass\n through a fully connected layer to relate them to the final output tensor.\n\n Args:\n in_shape: tuple of integers stating the dimension of the input tensor (minus batch dimension)\n out_shape: tuple of integers stating the dimension of the final output tensor\n channels: tuple of integers stating the output channels of each convolutional layer\n strides: tuple of integers stating the stride (downscale factor) of each convolutional layer\n kernel_size: integer or tuple of integers stating size of convolutional kernels\n num_res_units: integer stating number of convolutions in residual units, 0 means no residual units\n act: name or type defining activation layers\n norm: name or type defining normalization layers\n dropout: optional float value in range [0, 1] stating dropout probability for layers, None for no dropout\n bias: boolean stating if convolution layers should have a bias component\n \"\"\"\n super().__init__()\n\n self.in_channels, *self.in_shape = ensure_tuple(in_shape)\n self.dimensions = len(self.in_shape)\n self.channels = ensure_tuple(channels)\n self.strides = ensure_tuple(strides)\n self.out_shape = ensure_tuple(out_shape)\n self.kernel_size = ensure_tuple_rep(kernel_size, self.dimensions)\n self.num_res_units = num_res_units\n self.act = act\n self.norm = norm\n self.dropout = dropout\n self.bias = bias\n self.net = nn.Sequential()\n\n echannel = self.in_channels\n\n padding = same_padding(kernel_size)\n\n self.final_size = np.asarray(self.in_shape, np.int)\n self.reshape = Reshape(*self.out_shape)\n\n # encode stage\n for i, (c, s) in enumerate(zip(self.channels, self.strides)):\n layer = self._get_layer(echannel, c, s, i == len(channels) - 1)\n echannel = c # use the output channel number as the input for the next loop\n self.net.add_module(\"layer_%i\" % i, layer)\n self.final_size = calculate_out_shape(self.final_size, kernel_size, s, padding)\n\n self.final = self._get_final_layer((echannel,) + self.final_size)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/regressor.py_Regressor._get_layer_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/regressor.py_Regressor._get_layer_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/regressor.py", "file_name": "regressor.py", "file_type": "text/x-python", "category": "implementation", "start_line": 92, "end_line": 140, "span_ids": ["Regressor.forward", "Regressor._get_final_layer", "Regressor._get_layer"], "tokens": 337}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Regressor(nn.Module):\n\n def _get_layer(self, in_channels: int, out_channels: int, strides, is_last: bool):\n \"\"\"\n Returns a layer accepting inputs with `in_channels` number of channels and producing outputs of `out_channels`\n number of channels. The `strides` indicates downsampling factor, ie. convolutional stride. If `is_last`\n is True this is the final layer and is not expected to include activation and normalization layers.\n \"\"\"\n\n layer: Union[ResidualUnit, Convolution]\n\n if self.num_res_units > 0:\n layer = ResidualUnit(\n subunits=self.num_res_units,\n last_conv_only=is_last,\n dimensions=self.dimensions,\n in_channels=in_channels,\n out_channels=out_channels,\n strides=strides,\n kernel_size=self.kernel_size,\n act=self.act,\n norm=self.norm,\n dropout=self.dropout,\n bias=self.bias,\n )\n else:\n layer = Convolution(\n conv_only=is_last,\n dimensions=self.dimensions,\n in_channels=in_channels,\n out_channels=out_channels,\n strides=strides,\n kernel_size=self.kernel_size,\n act=self.act,\n norm=self.norm,\n dropout=self.dropout,\n bias=self.bias,\n )\n\n return layer\n\n def _get_final_layer(self, in_shape):\n linear = nn.Linear(int(np.product(in_shape)), int(np.product(self.out_shape)))\n return nn.Sequential(nn.Flatten(), linear)\n\n def forward(self, x):\n x = self.net(x)\n x = self.final(x)\n x = self.reshape(x)\n return x", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/unet.py_nn_UNet.__init__.self.model._create_block_in_channels": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/unet.py_nn_UNet.__init__.self.model._create_block_in_channels", "embedding": null, "metadata": {"file_path": "monai/networks/nets/unet.py", "file_name": "unet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 72, "span_ids": ["UNet", "UNet.__init__", "docstring"], "tokens": 513}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import torch.nn as nn\n\nfrom monai.networks.blocks.convolutions import Convolution, ResidualUnit\nfrom monai.networks.layers.factories import Norm, Act\nfrom monai.networks.layers.simplelayers import SkipConnection\nfrom monai.utils import export, alias\n\n\n@export(\"monai.networks.nets\")\n@alias(\"Unet\")\nclass UNet(nn.Module):\n def __init__(\n self,\n dimensions,\n in_channels: int,\n out_channels: int,\n channels,\n strides,\n kernel_size=3,\n up_kernel_size=3,\n num_res_units=0,\n act=Act.PRELU,\n norm=Norm.INSTANCE,\n dropout=0,\n ) -> None:\n super().__init__()\n\n self.dimensions = dimensions\n self.in_channels = in_channels\n self.out_channels = out_channels\n self.channels = channels\n self.strides = strides\n self.kernel_size = kernel_size\n self.up_kernel_size = up_kernel_size\n self.num_res_units = num_res_units\n self.act = act\n self.norm = norm\n self.dropout = dropout\n\n def _create_block(inc: int, outc: int, channels, strides, is_top: bool):\n \"\"\"\n Builds the UNet structure from the bottom up by recursing down to the bottom block, then creating sequential\n blocks containing the downsample path, a skip connection around the previous block, and the upsample path.\n \"\"\"\n c = channels[0]\n s = strides[0]\n\n if len(channels) > 2:\n subblock = _create_block(c, c, channels[1:], strides[1:], False) # continue recursion down\n upc = c * 2\n else:\n # the next layer is the bottom so stop recursion, create the bottom layer as the sublock for this layer\n subblock = self._get_bottom_layer(c, channels[1])\n upc = c + channels[1]\n\n down = self._get_down_layer(inc, c, s, is_top) # create layer in downsampling path\n up = self._get_up_layer(upc, outc, s, is_top) # create layer in upsampling path\n\n return nn.Sequential(down, SkipConnection(subblock), up)\n\n self.model = _create_block(in_channels, out_channels, self.channels, self.strides, True)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/unet.py_UNet._get_down_layer_UNet._get_bottom_layer.return.self__get_down_layer_in_c": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/unet.py_UNet._get_down_layer_UNet._get_bottom_layer.return.self__get_down_layer_in_c", "embedding": null, "metadata": {"file_path": "monai/networks/nets/unet.py", "file_name": "unet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 74, "end_line": 93, "span_ids": ["UNet._get_down_layer", "UNet._get_bottom_layer"], "tokens": 174}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "@export(\"monai.networks.nets\")\n@alias(\"Unet\")\nclass UNet(nn.Module):\n\n def _get_down_layer(self, in_channels: int, out_channels: int, strides, is_top: bool):\n if self.num_res_units > 0:\n return ResidualUnit(\n self.dimensions,\n in_channels,\n out_channels,\n strides,\n self.kernel_size,\n self.num_res_units,\n self.act,\n self.norm,\n self.dropout,\n )\n else:\n return Convolution(\n self.dimensions, in_channels, out_channels, strides, self.kernel_size, self.act, self.norm, self.dropout\n )\n\n def _get_bottom_layer(self, in_channels: int, out_channels: int):\n return self._get_down_layer(in_channels, out_channels, 1, False)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/unet.py_UNet._get_up_layer_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/unet.py_UNet._get_up_layer_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/unet.py", "file_name": "unet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 95, "end_line": 132, "span_ids": ["UNet.forward", "impl", "UNet._get_up_layer"], "tokens": 212}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "@export(\"monai.networks.nets\")\n@alias(\"Unet\")\nclass UNet(nn.Module):\n\n def _get_up_layer(self, in_channels: int, out_channels: int, strides, is_top: bool):\n conv = Convolution(\n self.dimensions,\n in_channels,\n out_channels,\n strides,\n self.up_kernel_size,\n self.act,\n self.norm,\n self.dropout,\n conv_only=is_top and self.num_res_units == 0,\n is_transposed=True,\n )\n\n if self.num_res_units > 0:\n ru = ResidualUnit(\n self.dimensions,\n out_channels,\n out_channels,\n 1,\n self.kernel_size,\n 1,\n self.act,\n self.norm,\n self.dropout,\n last_conv_only=is_top,\n )\n return nn.Sequential(conv, ru)\n else:\n return conv\n\n def forward(self, x):\n x = self.model(x)\n return x\n\n\nUnet = unet = UNet", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_warnings_one_hot.return.labels": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_warnings_one_hot.return.labels", "embedding": null, "metadata": {"file_path": "monai/networks/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 15, "end_line": 44, "span_ids": ["one_hot", "docstring"], "tokens": 269}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import warnings\nimport torch\nimport torch.nn as nn\n\n\ndef one_hot(labels, num_classes: int, dtype: torch.dtype = torch.float):\n \"\"\"\n For a tensor `labels` of dimensions B1[spatial_dims], return a tensor of dimensions `BN[spatial_dims]`\n for `num_classes` N number of classes.\n\n Example:\n\n For every value v = labels[b,1,h,w], the value in the result at [b,v,h,w] will be 1 and all others 0.\n Note that this will include the background label, thus a binary mask should be treated as having 2 classes.\n \"\"\"\n assert labels.dim() > 0, \"labels should have dim of 1 or more.\"\n\n # if 1D, add singelton dim at the end\n if labels.dim() == 1:\n labels = labels.view(-1, 1)\n\n sh = list(labels.shape)\n\n assert sh[1] == 1, \"labels should have a channel with length equals to one.\"\n sh[1] = num_classes\n\n o = torch.zeros(size=sh, dtype=dtype, device=labels.device)\n labels = o.scatter_(dim=1, index=labels.long(), value=1)\n\n return labels", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_slice_channels_predict_segmentation.if_not_mutually_exclusive.else_.return.logits_argmax_1_keepdim_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_slice_channels_predict_segmentation.if_not_mutually_exclusive.else_.return.logits_argmax_1_keepdim_", "embedding": null, "metadata": {"file_path": "monai/networks/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 47, "end_line": 72, "span_ids": ["predict_segmentation", "slice_channels"], "tokens": 267}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def slice_channels(tensor: torch.Tensor, *slicevals):\n slices = [slice(None)] * len(tensor.shape)\n slices[1] = slice(*slicevals)\n\n return tensor[slices]\n\n\ndef predict_segmentation(logits: torch.Tensor, mutually_exclusive: bool = False, threshold: float = 0.0):\n \"\"\"\n Given the logits from a network, computing the segmentation by thresholding all values above 0\n if multi-labels task, computing the `argmax` along the channel axis if multi-classes task,\n logits has shape `BCHW[D]`.\n\n Args:\n logits (Tensor): raw data of model output.\n mutually_exclusive: if True, `logits` will be converted into a binary matrix using\n a combination of argmax, which is suitable for multi-classes task. Defaults to False.\n threshold: thresholding the prediction values if multi-labels task.\n \"\"\"\n if not mutually_exclusive:\n return (logits >= threshold).int()\n else:\n if logits.shape[1] == 1:\n warnings.warn(\"single channel prediction, `mutually_exclusive=True` ignored, use threshold instead.\")\n return (logits >= threshold).int()\n return logits.argmax(1, keepdim=True)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_normalize_transform_normalize_transform.return.norm": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_normalize_transform_normalize_transform.return.norm", "embedding": null, "metadata": {"file_path": "monai/networks/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 75, "end_line": 102, "span_ids": ["normalize_transform"], "tokens": 355}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def normalize_transform(shape, device=None, dtype=None, align_corners: bool = False):\n \"\"\"\n Compute an affine matrix according to the input shape.\n The transform normalizes the homogeneous image coordinates to the\n range of `[-1, 1]`.\n\n Args:\n shape (sequence of int): input spatial shape\n device (torch device): device on which the returned affine will be allocated.\n dtype (torch dtype): data type of the returned affine\n align_corners: if True, consider -1 and 1 to refer to the centers of the\n corner pixels rather than the image corners.\n See also: https://pytorch.org/docs/stable/nn.functional.html#torch.nn.functional.grid_sample\n \"\"\"\n norm = torch.tensor(shape, dtype=torch.float64, device=device) # no in-place change\n if align_corners:\n norm[norm <= 1.0] = 2.0\n norm = 2.0 / (norm - 1.0)\n norm = torch.diag(torch.cat((norm, torch.ones((1,), dtype=torch.float64, device=device))))\n norm[:-1, -1] = -1.0\n else:\n norm[norm <= 0.0] = 2.0\n norm = 2.0 / norm\n norm = torch.diag(torch.cat((norm, torch.ones((1,), dtype=torch.float64, device=device))))\n norm[:-1, -1] = 1.0 / torch.tensor(shape, dtype=torch.float64, device=device) - 1.0\n norm = norm.unsqueeze(0).to(dtype=dtype)\n norm.requires_grad = False\n return norm", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_to_norm_affine_to_norm_affine.return.new_affine": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_to_norm_affine_to_norm_affine.return.new_affine", "embedding": null, "metadata": {"file_path": "monai/networks/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 105, "end_line": 137, "span_ids": ["to_norm_affine"], "tokens": 389}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def to_norm_affine(affine, src_size, dst_size, align_corners: bool = False):\n \"\"\"\n Given ``affine`` defined for coordinates in the pixel space, compute the corresponding affine\n for the normalized coordinates.\n\n Args:\n affine (torch Tensor): Nxdxd batched square matrix\n src_size (sequence of int): source image spatial shape\n dst_size (sequence of int): target image spatial shape\n align_corners: if True, consider -1 and 1 to refer to the centers of the\n corner pixels rather than the image corners.\n See also: https://pytorch.org/docs/stable/nn.functional.html#torch.nn.functional.grid_sample\n\n Raises:\n ValueError: affine must be a tensor\n ValueError: affine must be Nxdxd, got {tuple(affine.shape)}\n ValueError: affine suggests a {sr}-D transform, but the sizes are src_size={src_size}, dst_size={dst_size}\n\n \"\"\"\n if not torch.is_tensor(affine):\n raise ValueError(\"affine must be a tensor\")\n if affine.ndim != 3 or affine.shape[1] != affine.shape[2]:\n raise ValueError(f\"affine must be Nxdxd, got {tuple(affine.shape)}\")\n sr = affine.shape[1] - 1\n if sr != len(src_size) or sr != len(dst_size):\n raise ValueError(\n f\"affine suggests a {sr}-D transform, but the sizes are src_size={src_size}, dst_size={dst_size}\"\n )\n\n src_xform = normalize_transform(src_size, affine.device, affine.dtype, align_corners)\n dst_xform = normalize_transform(dst_size, affine.device, affine.dtype, align_corners)\n new_affine = src_xform @ affine @ torch.inverse(dst_xform)\n return new_affine", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_normal_init_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_normal_init_", "embedding": null, "metadata": {"file_path": "monai/networks/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 140, "end_line": 157, "span_ids": ["normal_init"], "tokens": 245}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def normal_init(m, std=0.02, normal_func=torch.nn.init.normal_):\n \"\"\"\n Initialize the weight and bias tensors of `m' and its submodules to values from a normal distribution with a\n stddev of `std'. Weight tensors of convolution and linear modules are initialized with a mean of 0, batch\n norm modules with a mean of 1. The callable `normal_func', used to assign values, should have the same arguments\n as its default normal_(). This can be used with `nn.Module.apply` to visit submodules of a network.\n \"\"\"\n cname = m.__class__.__name__\n\n if getattr(m, \"weight\", None) is not None and (cname.find(\"Conv\") != -1 or cname.find(\"Linear\") != -1):\n normal_func(m.weight.data, 0.0, std)\n if getattr(m, \"bias\", None) is not None:\n nn.init.constant_(m.bias.data, 0.0)\n\n elif cname.find(\"BatchNorm\") != -1:\n normal_func(m.weight.data, 1.0, std)\n nn.init.constant_(m.bias.data, 0)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/__init__.py_from_croppad_array_impor_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/__init__.py_from_croppad_array_impor_", "embedding": null, "metadata": {"file_path": "monai/transforms/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 27, "span_ids": ["docstring"], "tokens": 96}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from .croppad.array import *\nfrom .croppad.dictionary import *\nfrom .intensity.array import *\nfrom .intensity.dictionary import *\nfrom .io.array import *\nfrom .io.dictionary import *\nfrom .spatial.array import *\nfrom .spatial.dictionary import *\nfrom .utility.array import *\nfrom .utility.dictionary import *\nfrom .post.array import *\nfrom .post.dictionary import *\nfrom .adaptors import *\nfrom .compose import *\nfrom .utils import *", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/adaptors.py_from_monai_utils_import_e_adaptor.map_only_names.return._v_ditems_k_for_k_v_in": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/adaptors.py_from_monai_utils_import_e_adaptor.map_only_names.return._v_ditems_k_for_k_v_in", "embedding": null, "metadata": {"file_path": "monai/transforms/adaptors.py", "file_name": "adaptors.py", "file_type": "text/x-python", "category": "implementation", "start_line": 125, "end_line": 143, "span_ids": ["adaptor", "imports"], "tokens": 190}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from monai.utils import export as _monai_export\n\n\n@_monai_export(\"monai.transforms\")\ndef adaptor(function, outputs, inputs=None):\n def must_be_types_or_none(variable_name, variable, types):\n if variable is not None:\n if not isinstance(variable, types):\n raise ValueError(f\"'{variable_name}' must be None or {types} but is {type(variable)}\")\n\n def must_be_types(variable_name, variable, types):\n if not isinstance(variable, types):\n raise ValueError(f\"'{variable_name}' must be one of {types} but is {type(variable)}\")\n\n def map_names(ditems, input_map):\n return {input_map(k, k): v for k, v in ditems.items()}\n\n def map_only_names(ditems, input_map):\n return {v: ditems[k] for k, v in input_map.items()}\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/adaptors.py_adaptor._inner_adaptor.return._inner": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/adaptors.py_adaptor._inner_adaptor.return._inner", "embedding": null, "metadata": {"file_path": "monai/transforms/adaptors.py", "file_name": "adaptors.py", "file_type": "text/x-python", "category": "implementation", "start_line": 145, "end_line": 210, "span_ids": ["adaptor"], "tokens": 577}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "@_monai_export(\"monai.transforms\")\ndef adaptor(function, outputs, inputs=None):\n # ... other code\n\n def _inner(ditems):\n\n sig = FunctionSignature(function)\n\n if sig.found_kwargs:\n must_be_types_or_none(\"inputs\", inputs, (dict,))\n # we just forward all arguments unless we have been provided an input map\n if inputs is None:\n dinputs = dict(ditems)\n else:\n # dict\n dinputs = map_names(ditems, inputs)\n\n else:\n # no **kwargs\n # select only items from the method signature\n dinputs = {k: v for k, v in ditems.items() if k in sig.non_var_parameters}\n must_be_types_or_none(\"inputs\", inputs, (str, list, tuple, dict))\n if inputs is None:\n pass\n elif isinstance(inputs, str):\n if len(sig.non_var_parameters) != 1:\n raise ValueError(\"if 'inputs' is a string, function may only have a single non-variadic parameter\")\n dinputs = {inputs: ditems[inputs]}\n elif isinstance(inputs, (list, tuple)):\n dinputs = {k: dinputs[k] for k in inputs}\n else:\n # dict\n dinputs = map_only_names(ditems, inputs)\n\n ret = function(**dinputs)\n\n # now the mapping back to the output dictionary depends on outputs and what was returned from the function\n op = outputs\n if isinstance(ret, dict):\n must_be_types_or_none(\"outputs\", op, (dict,))\n if op is not None:\n ret = {v: ret[k] for k, v in op.items()}\n elif isinstance(ret, (list, tuple)):\n if len(ret) == 1:\n must_be_types(\"outputs\", op, (str, list, tuple))\n else:\n must_be_types(\"outputs\", op, (list, tuple))\n\n if isinstance(op, str):\n op = [op]\n\n if len(ret) != len(outputs):\n raise ValueError(\"'outputs' must have the same length as the number of elements that were returned\")\n\n ret = {k: v for k, v in zip(op, ret)}\n else:\n must_be_types(\"outputs\", op, (str, list, tuple))\n if isinstance(op, (list, tuple)):\n if len(op) != 1:\n raise ValueError(\"'outputs' must be of length one if it is a list or tuple\")\n op = op[0]\n ret = {op: ret}\n\n ditems = dict(ditems)\n for k, v in ret.items():\n ditems[k] = v\n\n return ditems\n\n return _inner", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/adaptors.py_apply_alias_to_kwargs.return._inner": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/adaptors.py_apply_alias_to_kwargs.return._inner", "embedding": null, "metadata": {"file_path": "monai/transforms/adaptors.py", "file_name": "adaptors.py", "file_type": "text/x-python", "category": "implementation", "start_line": 213, "end_line": 239, "span_ids": ["apply_alias", "to_kwargs"], "tokens": 145}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "@_monai_export(\"monai.transforms\")\ndef apply_alias(fn, name_map):\n def _inner(data):\n\n # map names\n pre_call = dict(data)\n for _from, _to in name_map.items():\n pre_call[_to] = pre_call.pop(_from)\n\n # execute\n post_call = fn(pre_call)\n\n # map names back\n for _from, _to in name_map.items():\n post_call[_from] = post_call.pop(_to)\n\n return post_call\n\n return _inner\n\n\n@_monai_export(\"monai.transforms\")\ndef to_kwargs(fn):\n def _inner(data):\n return fn(**data)\n\n return _inner", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/adaptors.py_FunctionSignature_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/adaptors.py_FunctionSignature_", "embedding": null, "metadata": {"file_path": "monai/transforms/adaptors.py", "file_name": "adaptors.py", "file_type": "text/x-python", "category": "implementation", "start_line": 242, "end_line": 266, "span_ids": ["FunctionSignature.__repr__", "FunctionSignature", "FunctionSignature.__str__", "FunctionSignature.__init__"], "tokens": 186}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class FunctionSignature:\n def __init__(self, function) -> None:\n import inspect\n\n sfn = inspect.signature(function)\n self.found_args = False\n self.found_kwargs = False\n self.defaults = {}\n self.non_var_parameters = set()\n for p in sfn.parameters.values():\n if p.kind is inspect.Parameter.VAR_POSITIONAL:\n self.found_args = True\n if p.kind is inspect.Parameter.VAR_KEYWORD:\n self.found_kwargs = True\n else:\n self.non_var_parameters.add(p.name)\n self.defaults[p.name] = p.default is not p.empty\n\n def __repr__(self):\n s = \" None:\n \"\"\"\n Within this method, :py:attr:`self.R` should be used, instead of `np.random`, to introduce random factors.\n\n all :py:attr:`self.R` calls happen here so that we have a better chance to\n identify errors of sync the random state.\n\n This method can generate the random factors based on properties of the input data.\n\n Raises:\n NotImplementedError: Subclass {self.__class__.__name__} must implement the compute method\n\n \"\"\"\n raise NotImplementedError(f\"Subclass {self.__class__.__name__} must implement the compute method\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_Compose_Compose.__init__.self_set_random_state_see": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_Compose_Compose.__init__.self_set_random_state_see", "embedding": null, "metadata": {"file_path": "monai/transforms/compose.py", "file_name": "compose.py", "file_type": "text/x-python", "category": "implementation", "start_line": 143, "end_line": 208, "span_ids": ["Compose.__init__", "Compose"], "tokens": 708}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Compose(Randomizable):\n \"\"\"\n ``Compose`` provides the ability to chain a series of calls together in a\n sequence. Each transform in the sequence must take a single argument and\n return a single value, so that the transforms can be called in a chain.\n\n ``Compose`` can be used in two ways:\n\n #. With a series of transforms that accept and return a single\n ndarray / tensor / tensor-like parameter.\n #. With a series of transforms that accept and return a dictionary that\n contains one or more parameters. Such transforms must have pass-through\n semantics; unused values in the dictionary must be copied to the return\n dictionary. It is required that the dictionary is copied between input\n and output of each transform.\n\n If some transform generates a list batch of data in the transform chain,\n every item in the list is still a dictionary, and all the following\n transforms will apply to every item of the list, for example:\n\n #. transformA normalizes the intensity of 'img' field in the dict data.\n #. transformB crops out a list batch of images on 'img' and 'seg' field.\n And constructs a list of dict data, other fields are copied::\n\n { [{ {\n 'img': [1, 2], 'img': [1], 'img': [2],\n 'seg': [1, 2], 'seg': [1], 'seg': [2],\n 'extra': 123, --> 'extra': 123, 'extra': 123,\n 'shape': 'CHWD' 'shape': 'CHWD' 'shape': 'CHWD'\n } }, }]\n\n #. transformC then randomly rotates or flips 'img' and 'seg' fields of\n every dictionary item in the list.\n\n The composed transforms will be set the same global random seed if user called\n `set_determinism()`.\n\n When using the pass-through dictionary operation, you can make use of\n :class:`monai.transforms.adaptors.adaptor` to wrap transforms that don't conform\n to the requirements. This approach allows you to use transforms from\n otherwise incompatible libraries with minimal additional work.\n\n Note:\n\n In many cases, Compose is not the best way to create pre-processing\n pipelines. Pre-processing is often not a strictly sequential series of\n operations, and much of the complexity arises when a not-sequential\n set of functions must be called as if it were a sequence.\n\n Example: images and labels\n Images typically require some kind of normalisation that labels do not.\n Both are then typically augmented through the use of random rotations,\n flips, and deformations.\n Compose can be used with a series of transforms that take a dictionary\n that contains 'image' and 'label' entries. This might require wrapping\n `torchvision` transforms before passing them to compose.\n Alternatively, one can create a class with a `__call__` function that\n calls your pre-processing functions taking into account that not all of\n them are called on the labels.\n \"\"\"\n\n def __init__(self, transforms=None) -> None:\n if transforms is None:\n transforms = []\n self.transforms = ensure_tuple(transforms)\n self.set_random_state(seed=get_seed())", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_Compose.set_random_state_Compose.__call__.return.input_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_Compose.set_random_state_Compose.__call__.return.input_", "embedding": null, "metadata": {"file_path": "monai/transforms/compose.py", "file_name": "compose.py", "file_type": "text/x-python", "category": "implementation", "start_line": 210, "end_line": 231, "span_ids": ["Compose.__call__", "Compose.randomize", "Compose.set_random_state"], "tokens": 198}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Compose(Randomizable):\n\n def set_random_state(self, seed: Optional[int] = None, state: Optional[np.random.RandomState] = None):\n for _transform in self.transforms:\n if not isinstance(_transform, Randomizable):\n continue\n _transform.set_random_state(seed, state)\n\n def randomize(self, data: Optional[Any] = None) -> None:\n for _transform in self.transforms:\n if not isinstance(_transform, Randomizable):\n continue\n try:\n _transform.randomize(data)\n except TypeError as type_error:\n tfm_name: str = type(_transform).__name__\n warnings.warn(\n f'Transform \"{tfm_name}\" in Compose not randomized\\n{tfm_name}.{type_error}.', RuntimeWarning\n )\n\n def __call__(self, input_):\n for _transform in self.transforms:\n input_ = apply_transform(_transform, input_)\n return input_", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_MapTransform_MapTransform.__init__.for_key_in_self_keys_.if_not_isinstance_key_Ha.raise_ValueError_f_keys_s": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_MapTransform_MapTransform.__init__.for_key_in_self_keys_.if_not_isinstance_key_Ha.raise_ValueError_f_keys_s", "embedding": null, "metadata": {"file_path": "monai/transforms/compose.py", "file_name": "compose.py", "file_type": "text/x-python", "category": "implementation", "start_line": 234, "end_line": 261, "span_ids": ["MapTransform", "MapTransform.__init__"], "tokens": 227}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class MapTransform(Transform):\n \"\"\"\n A subclass of :py:class:`monai.transforms.Transform` with an assumption\n that the ``data`` input of ``self.__call__`` is a MutableMapping such as ``dict``.\n\n The ``keys`` parameter will be used to get and set the actual data\n item to transform. That is, the callable of this transform should\n follow the pattern:\n\n .. code-block:: python\n\n def __call__(self, data):\n for key in self.keys:\n if key in data:\n # update output data with some_transform_function(data[key]).\n else:\n # do nothing or some exceptions handling.\n return data\n\n \"\"\"\n\n def __init__(self, keys: KeysCollection) -> None:\n self.keys: Tuple[Any, ...] = ensure_tuple(keys)\n if not self.keys:\n raise ValueError(\"keys unspecified\")\n for key in self.keys:\n if not isinstance(key, Hashable):\n raise ValueError(f\"keys should be a hashable or a sequence of hashables, got {type(key)}\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_MapTransform.__call___": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_MapTransform.__call___", "embedding": null, "metadata": {"file_path": "monai/transforms/compose.py", "file_name": "compose.py", "file_type": "text/x-python", "category": "implementation", "start_line": 263, "end_line": 288, "span_ids": ["MapTransform.__call__"], "tokens": 300}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class MapTransform(Transform):\n\n @abstractmethod\n def __call__(self, data):\n \"\"\"\n ``data`` often comes from an iteration over an iterable,\n such as :py:class:`torch.utils.data.Dataset`.\n\n To simplify the input validations, this method assumes:\n\n - ``data`` is a Python dictionary\n - ``data[key]`` is a Numpy ndarray, PyTorch Tensor or string, where ``key`` is an element\n of ``self.keys``, the data shape can be:\n\n #. string data without shape, `LoadNiftid` and `LoadPNGd` transforms expect file paths\n #. most of the pre-processing transforms expect: ``(num_channels, spatial_dim_1[, spatial_dim_2, ...])``,\n except that `AddChanneld` expects (spatial_dim_1[, spatial_dim_2, ...]) and\n `AsChannelFirstd` expects (spatial_dim_1[, spatial_dim_2, ...], num_channels)\n #. most of the post-processing transforms expect\n ``(batch_size, num_channels, spatial_dim_1[, spatial_dim_2, ...])``\n\n - the channel dimension is not omitted even if number of channels is one\n\n returns:\n An updated dictionary version of ``data`` by applying the transform.\n \"\"\"\n raise NotImplementedError(f\"Subclass {self.__class__.__name__} must implement the compute method\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/__init__.py__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/__init__.py__", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 11, "end_line": 11, "span_ids": [], "tokens": 0}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_from_typing_import_Callab_SpatialPad.__init__.self.mode.NumpyPadMode_mode_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_from_typing_import_Callab_SpatialPad.__init__.self.mode.NumpyPadMode_mode_", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 16, "end_line": 52, "span_ids": ["SpatialPad.__init__", "SpatialPad", "docstring"], "tokens": 427}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, List, Optional, Sequence, Tuple, Union, Any\n\nimport numpy as np\n\nfrom monai.config import IndexSelection\nfrom monai.data.utils import get_random_patch, get_valid_patch_size\nfrom monai.transforms.compose import Randomizable, Transform\nfrom monai.transforms.utils import generate_pos_neg_label_crop_centers, generate_spatial_bounding_box\nfrom monai.utils import ensure_tuple, fall_back_tuple, NumpyPadMode, Method\n\n\nclass SpatialPad(Transform):\n \"\"\"\n Performs padding to the data, symmetric for all sides or all on one side for each dimension.\n Uses np.pad so in practice, a mode needs to be provided. See numpy.lib.arraypad.pad\n for additional details.\n\n Args:\n spatial_size: the spatial size of output data after padding.\n If its components have non-positive values, the corresponding size of input image will be used (no padding).\n method: {``\"symmetric\"``, ``\"end\"``}\n Pad image symmetric on every side or only pad at the end sides. Defaults to ``\"symmetric\"``.\n mode: {``\"constant\"``, ``\"edge\"``, ``\"linear_ramp\"``, ``\"maximum\"``, ``\"mean\"``,\n ``\"median\"``, ``\"minimum\"``, ``\"reflect\"``, ``\"symmetric\"``, ``\"wrap\"``, ``\"empty\"``}\n One of the listed string values or a user supplied function. Defaults to ``\"constant\"``.\n See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html\n \"\"\"\n\n def __init__(\n self,\n spatial_size: Union[Sequence[int], int],\n method: Union[Method, str] = Method.SYMMETRIC,\n mode: Union[NumpyPadMode, str] = NumpyPadMode.CONSTANT,\n ) -> None:\n self.spatial_size = spatial_size\n self.method: Method = Method(method)\n self.mode: NumpyPadMode = NumpyPadMode(mode)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_SpatialPad._determine_data_pad_width_SpatialPad._determine_data_pad_width.if_self_method_Method_.else_.return._0_max_self_spatial_siz": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_SpatialPad._determine_data_pad_width_SpatialPad._determine_data_pad_width.if_self_method_Method_.else_.return._0_max_self_spatial_siz", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 54, "end_line": 63, "span_ids": ["SpatialPad._determine_data_pad_width"], "tokens": 132}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SpatialPad(Transform):\n\n def _determine_data_pad_width(self, data_shape):\n self.spatial_size = fall_back_tuple(self.spatial_size, data_shape)\n if self.method == Method.SYMMETRIC:\n pad_width = list()\n for i in range(len(self.spatial_size)):\n width = max(self.spatial_size[i] - data_shape[i], 0)\n pad_width.append((width // 2, width - (width // 2)))\n return pad_width\n else:\n return [(0, max(self.spatial_size[i] - data_shape[i], 0)) for i in range(len(self.spatial_size))]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_SpatialPad.__call___SpatialPad.__call__.if_not_np_asarray_all_pad.else_.return.img": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_SpatialPad.__call___SpatialPad.__call__.if_not_np_asarray_all_pad.else_.return.img", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 65, "end_line": 82, "span_ids": ["SpatialPad.__call__"], "tokens": 257}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SpatialPad(Transform):\n\n def __call__(self, img, mode: Optional[Union[NumpyPadMode, str]] = None):\n \"\"\"\n Args:\n img: data to be transformed, assuming `img` is channel-first and\n padding doesn't apply to the channel dim.\n mode: {``\"constant\"``, ``\"edge\"``, ``\"linear_ramp\"``, ``\"maximum\"``, ``\"mean\"``,\n ``\"median\"``, ``\"minimum\"``, ``\"reflect\"``, ``\"symmetric\"``, ``\"wrap\"``, ``\"empty\"``}\n One of the listed string values or a user supplied function. Defaults to ``self.mode``.\n See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html\n \"\"\"\n data_pad_width = self._determine_data_pad_width(img.shape[1:])\n all_pad_width = [(0, 0)] + data_pad_width\n if not np.asarray(all_pad_width).any():\n # all zeros, skip padding\n return img\n else:\n img = np.pad(img, all_pad_width, mode=self.mode.value if mode is None else NumpyPadMode(mode).value)\n return img", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_BorderPad_BorderPad.__init__.self.mode.NumpyPadMode_mode_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_BorderPad_BorderPad.__init__.self.mode.NumpyPadMode_mode_", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 85, "end_line": 111, "span_ids": ["BorderPad.__init__", "BorderPad"], "tokens": 411}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class BorderPad(Transform):\n \"\"\"\n Pad the input data by adding specified borders to every dimension.\n\n Args:\n spatial_border: specified size for every spatial border. it can be 3 shapes:\n\n - single int number, pad all the borders with the same size.\n - length equals the length of image shape, pad every spatial dimension separately.\n for example, image shape(CHW) is [1, 4, 4], spatial_border is [2, 1],\n pad every border of H dim with 2, pad every border of W dim with 1, result shape is [1, 8, 6].\n - length equals 2 x (length of image shape), pad every border of every dimension separately.\n for example, image shape(CHW) is [1, 4, 4], spatial_border is [1, 2, 3, 4], pad top of H dim with 1,\n pad bottom of H dim with 2, pad left of W dim with 3, pad right of W dim with 4.\n the result shape is [1, 7, 11].\n\n mode: {``\"constant\"``, ``\"edge\"``, ``\"linear_ramp\"``, ``\"maximum\"``, ``\"mean\"``,\n ``\"median\"``, ``\"minimum\"``, ``\"reflect\"``, ``\"symmetric\"``, ``\"wrap\"``, ``\"empty\"``}\n One of the listed string values or a user supplied function. Defaults to ``\"constant\"``.\n See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html\n \"\"\"\n\n def __init__(\n self, spatial_border: Union[Sequence[int], int], mode: Union[NumpyPadMode, str] = NumpyPadMode.CONSTANT\n ) -> None:\n self.spatial_border = spatial_border\n self.mode: NumpyPadMode = NumpyPadMode(mode)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_BorderPad.__call___BorderPad.__call__.return.np_pad_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_BorderPad.__call___BorderPad.__call__.return.np_pad_", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 113, "end_line": 144, "span_ids": ["BorderPad.__call__"], "tokens": 433}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class BorderPad(Transform):\n\n def __call__(self, img, mode: Optional[Union[NumpyPadMode, str]] = None):\n \"\"\"\n Args:\n img: data to be transformed, assuming `img` is channel-first and\n padding doesn't apply to the channel dim.\n mode: {``\"constant\"``, ``\"edge\"``, ``\"linear_ramp\"``, ``\"maximum\"``, ``\"mean\"``,\n ``\"median\"``, ``\"minimum\"``, ``\"reflect\"``, ``\"symmetric\"``, ``\"wrap\"``, ``\"empty\"``}\n One of the listed string values or a user supplied function. Defaults to ``self.mode``.\n See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html\n\n Raises:\n ValueError: spatial_border must be int number and can not be less than 0.\n ValueError: unsupported length of spatial_border definition.\n \"\"\"\n spatial_shape = img.shape[1:]\n spatial_border = ensure_tuple(self.spatial_border)\n for b in spatial_border:\n if b < 0 or not isinstance(b, int):\n raise ValueError(\"spatial_border must be int number and can not be less than 0.\")\n\n if len(spatial_border) == 1:\n data_pad_width = [(spatial_border[0], spatial_border[0]) for _ in range(len(spatial_shape))]\n elif len(spatial_border) == len(spatial_shape):\n data_pad_width = [(spatial_border[i], spatial_border[i]) for i in range(len(spatial_shape))]\n elif len(spatial_border) == len(spatial_shape) * 2:\n data_pad_width = [(spatial_border[2 * i], spatial_border[2 * i + 1]) for i in range(len(spatial_shape))]\n else:\n raise ValueError(\"unsupported length of spatial_border definition.\")\n\n return np.pad(\n img, [(0, 0)] + data_pad_width, mode=self.mode.value if mode is None else NumpyPadMode(mode).value\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_DivisiblePad_DivisiblePad.__init__.self.mode.NumpyPadMode_mode_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_DivisiblePad_DivisiblePad.__init__.self.mode.NumpyPadMode_mode_", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 147, "end_line": 166, "span_ids": ["DivisiblePad.__init__", "DivisiblePad"], "tokens": 263}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DivisiblePad(Transform):\n \"\"\"\n Pad the input data, so that the spatial sizes are divisible by `k`.\n \"\"\"\n\n def __init__(self, k: Union[Sequence[int], int], mode: Union[NumpyPadMode, str] = NumpyPadMode.CONSTANT) -> None:\n \"\"\"\n Args:\n k: the target k for each spatial dimension.\n if `k` is negative or 0, the original size is preserved.\n if `k` is an int, the same `k` be applied to all the input spatial dimensions.\n mode: {``\"constant\"``, ``\"edge\"``, ``\"linear_ramp\"``, ``\"maximum\"``, ``\"mean\"``,\n ``\"median\"``, ``\"minimum\"``, ``\"reflect\"``, ``\"symmetric\"``, ``\"wrap\"``, ``\"empty\"``}\n One of the listed string values or a user supplied function. Defaults to ``\"constant\"``.\n See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html\n\n See also :py:class:`monai.transforms.SpatialPad`\n \"\"\"\n self.k = k\n self.mode: NumpyPadMode = NumpyPadMode(mode)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_DivisiblePad.__call___DivisiblePad.__call__.return.spatial_pad_img_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_DivisiblePad.__call___DivisiblePad.__call__.return.spatial_pad_img_", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 168, "end_line": 186, "span_ids": ["DivisiblePad.__call__"], "tokens": 279}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DivisiblePad(Transform):\n\n def __call__(self, img, mode: Optional[Union[NumpyPadMode, str]] = None):\n \"\"\"\n Args:\n img: data to be transformed, assuming `img` is channel-first\n and padding doesn't apply to the channel dim.\n mode: {``\"constant\"``, ``\"edge\"``, ``\"linear_ramp\"``, ``\"maximum\"``, ``\"mean\"``,\n ``\"median\"``, ``\"minimum\"``, ``\"reflect\"``, ``\"symmetric\"``, ``\"wrap\"``, ``\"empty\"``}\n One of the listed string values or a user supplied function. Defaults to ``self.mode``.\n See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html\n \"\"\"\n spatial_shape = img.shape[1:]\n k = fall_back_tuple(self.k, (1,) * len(spatial_shape))\n new_size = []\n for k_d, dim in zip(k, spatial_shape):\n new_dim = int(np.ceil(dim / k_d) * k_d) if k_d > 0 else dim\n new_size.append(new_dim)\n\n spatial_pad = SpatialPad(spatial_size=new_size, method=Method.SYMMETRIC, mode=mode or self.mode)\n return spatial_pad(img)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_SpatialCrop_SpatialCrop.__init__.None_2": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_SpatialCrop_SpatialCrop.__init__.None_2", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 189, "end_line": 225, "span_ids": ["SpatialCrop.__init__", "SpatialCrop"], "tokens": 433}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SpatialCrop(Transform):\n \"\"\"\n General purpose cropper to produce sub-volume region of interest (ROI).\n It can support to crop ND spatial (channel-first) data.\n Either a spatial center and size must be provided, or alternatively if center and size\n are not provided, the start and end coordinates of the ROI must be provided.\n The sub-volume must sit the within original image.\n Note: This transform will not work if the crop region is larger than the image itself.\n \"\"\"\n\n def __init__(\n self,\n roi_center: Optional[Sequence[int]] = None,\n roi_size: Optional[Sequence[int]] = None,\n roi_start: Optional[Sequence[int]] = None,\n roi_end: Optional[Sequence[int]] = None,\n ) -> None:\n \"\"\"\n Args:\n roi_center: voxel coordinates for center of the crop ROI.\n roi_size: size of the crop ROI.\n roi_start: voxel coordinates for start of the crop ROI.\n roi_end: voxel coordinates for end of the crop ROI.\n \"\"\"\n if roi_center is not None and roi_size is not None:\n roi_center = np.asarray(roi_center, dtype=np.uint16)\n roi_size = np.asarray(roi_size, dtype=np.uint16)\n self.roi_start = np.subtract(roi_center, np.floor_divide(roi_size, 2))\n self.roi_end = np.add(self.roi_start, roi_size)\n else:\n assert roi_start is not None and roi_end is not None, \"roi_start and roi_end must be provided.\"\n self.roi_start = np.asarray(roi_start, dtype=np.uint16)\n self.roi_end = np.asarray(roi_end, dtype=np.uint16)\n\n assert np.all(self.roi_start >= 0), \"all elements of roi_start must be greater than or equal to 0.\"\n assert np.all(self.roi_end > 0), \"all elements of roi_end must be positive.\"\n assert np.all(self.roi_end >= self.roi_start), \"invalid roi range.\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_SpatialCrop.__call___SpatialCrop.__call__.return.img_tuple_slices_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_SpatialCrop.__call___SpatialCrop.__call__.return.img_tuple_slices_", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 227, "end_line": 238, "span_ids": ["SpatialCrop.__call__"], "tokens": 160}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SpatialCrop(Transform):\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`, assuming `img` is channel-first and\n slicing doesn't apply to the channel dim.\n \"\"\"\n max_end = img.shape[1:]\n sd = min(len(self.roi_start), len(max_end))\n assert np.all(max_end[:sd] >= self.roi_start[:sd]), \"roi start out of image space.\"\n assert np.all(max_end[:sd] >= self.roi_end[:sd]), \"roi end out of image space.\"\n\n slices = [slice(None)] + [slice(s, e) for s, e in zip(self.roi_start[:sd], self.roi_end[:sd])]\n return img[tuple(slices)]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_CenterSpatialCrop_CenterSpatialCrop.__call__.return.cropper_img_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_CenterSpatialCrop_CenterSpatialCrop.__call__.return.cropper_img_", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 241, "end_line": 261, "span_ids": ["CenterSpatialCrop", "CenterSpatialCrop.__call__", "CenterSpatialCrop.__init__"], "tokens": 194}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CenterSpatialCrop(Transform):\n \"\"\"\n Crop at the center of image with specified ROI size.\n\n Args:\n roi_size: the spatial size of the crop region e.g. [224,224,128]\n If its components have non-positive values, the corresponding size of input image will be used.\n \"\"\"\n\n def __init__(self, roi_size: Union[Sequence[int], int]) -> None:\n self.roi_size = roi_size\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`, assuming `img` is channel-first and\n slicing doesn't apply to the channel dim.\n \"\"\"\n self.roi_size = fall_back_tuple(self.roi_size, img.shape[1:])\n center = [i // 2 for i in img.shape[1:]]\n cropper = SpatialCrop(roi_center=center, roi_size=self.roi_size)\n return cropper(img)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandSpatialCrop_RandSpatialCrop.__init__.self._slices.None": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandSpatialCrop_RandSpatialCrop.__init__.self._slices.None", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 264, "end_line": 285, "span_ids": ["RandSpatialCrop.__init__", "RandSpatialCrop"], "tokens": 263}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandSpatialCrop(Randomizable, Transform):\n \"\"\"\n Crop image with random size or specific size ROI. It can crop at a random position as center\n or at the image center. And allows to set the minimum size to limit the randomly generated ROI.\n\n Args:\n roi_size: if `random_size` is True, it specifies the minimum crop region.\n if `random_size` is False, it specifies the expected ROI size to crop. e.g. [224, 224, 128]\n If its components have non-positive values, the corresponding size of input image will be used.\n random_center: crop at random position as center or the image center.\n random_size: crop with random size or specific size ROI.\n The actual size is sampled from `randint(roi_size, img_size)`.\n \"\"\"\n\n def __init__(\n self, roi_size: Union[Sequence[int], int], random_center: bool = True, random_size: bool = True\n ) -> None:\n self.roi_size = roi_size\n self.random_center = random_center\n self.random_size = random_size\n self._size: Optional[Sequence[int]] = None\n self._slices: Optional[Tuple[slice, ...]] = None", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandSpatialCrop.randomize_RandSpatialCrop.__call__.if_self_random_center_.else_.return.cropper_img_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandSpatialCrop.randomize_RandSpatialCrop.__call__.if_self_random_center_.else_.return.cropper_img_", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 287, "end_line": 305, "span_ids": ["RandSpatialCrop.randomize", "RandSpatialCrop.__call__"], "tokens": 207}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandSpatialCrop(Randomizable, Transform):\n\n def randomize(self, img_size: Sequence[int]) -> None:\n self._size = fall_back_tuple(self.roi_size, img_size)\n if self.random_size:\n self._size = tuple((self.R.randint(low=self._size[i], high=img_size[i] + 1) for i in range(len(img_size))))\n if self.random_center:\n valid_size = get_valid_patch_size(img_size, self._size)\n self._slices = (slice(None),) + get_random_patch(img_size, valid_size, self.R)\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`, assuming `img` is channel-first and\n slicing doesn't apply to the channel dim.\n \"\"\"\n self.randomize(img.shape[1:])\n if self.random_center:\n return img[self._slices]\n else:\n cropper = CenterSpatialCrop(self._size)\n return cropper(img)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandSpatialCropSamples_RandSpatialCropSamples.__call__.return._self_cropper_img_for___": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandSpatialCropSamples_RandSpatialCropSamples.__call__.return._self_cropper_img_for___", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 308, "end_line": 344, "span_ids": ["RandSpatialCropSamples.__call__", "RandSpatialCropSamples", "RandSpatialCropSamples.__init__", "RandSpatialCropSamples.randomize"], "tokens": 362}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandSpatialCropSamples(Randomizable, Transform):\n \"\"\"\n Crop image with random size or specific size ROI to generate a list of N samples.\n It can crop at a random position as center or at the image center. And allows to set\n the minimum size to limit the randomly generated ROI.\n It will return a list of cropped images.\n\n Args:\n roi_size: if `random_size` is True, the spatial size of the minimum crop region.\n if `random_size` is False, specify the expected ROI size to crop. e.g. [224, 224, 128]\n num_samples: number of samples (crop regions) to take in the returned list.\n random_center: crop at random position as center or the image center.\n random_size: crop with random size or specific size ROI.\n The actual size is sampled from `randint(roi_size, img_size)`.\n \"\"\"\n\n def __init__(\n self,\n roi_size: Union[Sequence[int], int],\n num_samples: int,\n random_center: bool = True,\n random_size: bool = True,\n ) -> None:\n if num_samples < 1:\n raise ValueError(\"number of samples must be greater than 0.\")\n self.num_samples = num_samples\n self.cropper = RandSpatialCrop(roi_size, random_center, random_size)\n\n def randomize(self, data: Optional[Any] = None) -> None:\n pass\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`, assuming `img` is channel-first and\n cropping doesn't change the channel dim.\n \"\"\"\n return [self.cropper(img) for _ in range(self.num_samples)]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_CropForeground_CropForeground.__call__.return.cropper_img_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_CropForeground_CropForeground.__call__.return.cropper_img_", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 347, "end_line": 393, "span_ids": ["CropForeground.__init__", "CropForeground", "CropForeground.__call__"], "tokens": 504}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CropForeground(Transform):\n \"\"\"\n Crop an image using a bounding box. The bounding box is generated by selecting foreground using select_fn\n at channels channel_indexes. margin is added in each spatial dimension of the bounding box.\n The typical usage is to help training and evaluation if the valid part is small in the whole medical image.\n Users can define arbitrary function to select expected foreground from the whole image or specified channels.\n And it can also add margin to every dim of the bounding box of foreground object.\n For example:\n\n .. code-block:: python\n\n image = np.array(\n [[[0, 0, 0, 0, 0],\n [0, 1, 2, 1, 0],\n [0, 1, 3, 2, 0],\n [0, 1, 2, 1, 0],\n [0, 0, 0, 0, 0]]]) # 1x5x5, single channel 5x5 image\n cropper = CropForeground(select_fn=lambda x: x > 1, margin=0)\n print(cropper(image))\n [[[2, 1],\n [3, 2],\n [2, 1]]]\n\n \"\"\"\n\n def __init__(\n self, select_fn: Callable = lambda x: x > 0, channel_indexes: Optional[IndexSelection] = None, margin: int = 0\n ) -> None:\n \"\"\"\n Args:\n select_fn: function to select expected foreground, default is to select values > 0.\n channel_indexes: if defined, select foreground only on the specified channels\n of image. if None, select foreground on the whole image.\n margin: add margin to all dims of the bounding box.\n \"\"\"\n self.select_fn = select_fn\n self.channel_indexes = ensure_tuple(channel_indexes) if channel_indexes is not None else None\n self.margin = margin\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`, assuming `img` is channel-first and\n slicing doesn't change the channel dim.\n \"\"\"\n box_start, box_end = generate_spatial_bounding_box(img, self.select_fn, self.channel_indexes, self.margin)\n cropper = SpatialCrop(roi_start=box_start, roi_end=box_end)\n return cropper(img)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandCropByPosNegLabel_RandCropByPosNegLabel.randomize.self.centers.generate_pos_neg_label_cr": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandCropByPosNegLabel_RandCropByPosNegLabel.randomize.self.centers.generate_pos_neg_label_cr", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 396, "end_line": 452, "span_ids": ["RandCropByPosNegLabel.__init__", "RandCropByPosNegLabel", "RandCropByPosNegLabel.randomize"], "tokens": 759}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandCropByPosNegLabel(Randomizable, Transform):\n \"\"\"\n Crop random fixed sized regions with the center being a foreground or background voxel\n based on the Pos Neg Ratio.\n And will return a list of arrays for all the cropped images.\n For example, crop two (3 x 3) arrays from (5 x 5) array with pos/neg=1::\n\n [[[0, 0, 0, 0, 0],\n [0, 1, 2, 1, 0], [[0, 1, 2], [[2, 1, 0],\n [0, 1, 3, 0, 0], --> [0, 1, 3], [3, 0, 0],\n [0, 0, 0, 0, 0], [0, 0, 0]] [0, 0, 0]]\n [0, 0, 0, 0, 0]]]\n\n Args:\n spatial_size: the spatial size of the crop region e.g. [224, 224, 128].\n If its components have non-positive values, the corresponding size of `label` will be used.\n label: the label image that is used for finding foreground/background, if None, must set at\n `self.__call__`. Non-zero indicates foreground, zero indicates background.\n pos: used to calculate the ratio ``pos / (pos + neg)`` for the probability to pick a\n foreground voxel as a center rather than a background voxel.\n neg: used to calculate the ratio ``pos / (pos + neg)`` for the probability to pick a\n foreground voxel as a center rather than a background voxel.\n num_samples: number of samples (crop regions) to take in each list.\n image: optional image data to help select valid area, can be same as `img` or another image array.\n if not None, use ``label == 0 & image > image_threshold`` to select the negative\n sample (background) center. So the crop center will only come from the valid image areas.\n image_threshold: if enabled `image`, use ``image > image_threshold`` to determine\n the valid image content areas.\n \"\"\"\n\n def __init__(\n self,\n spatial_size: Union[Sequence[int], int],\n label: Optional[np.ndarray] = None,\n pos: float = 1.0,\n neg: float = 1.0,\n num_samples: int = 1,\n image: Optional[np.ndarray] = None,\n image_threshold: float = 0.0,\n ) -> None:\n self.spatial_size = spatial_size\n self.label = label\n if pos < 0 or neg < 0:\n raise ValueError(\"pos and neg must be greater than or equal to 0.\")\n if pos + neg == 0:\n raise ValueError(\"pos and neg cannot both be 0.\")\n self.pos_ratio = pos / (pos + neg)\n self.num_samples = num_samples\n self.image = image\n self.image_threshold = image_threshold\n self.centers = None\n\n def randomize(self, label: np.ndarray, image: Optional[np.ndarray] = None) -> None:\n self.spatial_size = fall_back_tuple(self.spatial_size, default=label.shape[1:])\n self.centers = generate_pos_neg_label_crop_centers(\n label, self.spatial_size, self.num_samples, self.pos_ratio, image, self.image_threshold, self.R\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandCropByPosNegLabel.__call___": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandCropByPosNegLabel.__call___", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 454, "end_line": 472, "span_ids": ["RandCropByPosNegLabel.__call__"], "tokens": 252}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandCropByPosNegLabel(Randomizable, Transform):\n\n def __call__(self, img: np.ndarray, label: Optional[np.ndarray] = None, image: Optional[np.ndarray] = None):\n \"\"\"\n Args:\n img: input data to crop samples from based on the pos/neg ratio of `label` and `image`.\n Assumes `img` is a channel-first array.\n label: the label image that is used for finding foreground/background, if None, use `self.label`.\n image: optional image data to help select valid area, can be same as `img` or another image array.\n use ``label == 0 & image > image_threshold`` to select the negative sample(background) center.\n so the crop center will only exist on valid image area. if None, use `self.image`.\n \"\"\"\n self.randomize(self.label if label is None else label, self.image if image is None else image)\n results: List[np.ndarray] = list()\n if self.centers is not None:\n for center in self.centers:\n cropper = SpatialCrop(roi_center=tuple(center), roi_size=self.spatial_size)\n results.append(cropper(img))\n\n return results", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_from_typing_import_Callab_NumpyPadModeSequence.Union_Sequence_Union_Nump": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_from_typing_import_Callab_NumpyPadModeSequence.Union_Sequence_Union_Nump", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 18, "end_line": 27, "span_ids": ["docstring"], "tokens": 152}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Optional, Sequence, Tuple, Union, Any\nimport numpy as np\nfrom monai.config import IndexSelection, KeysCollection\nfrom monai.data.utils import get_random_patch, get_valid_patch_size\nfrom monai.transforms.compose import MapTransform, Randomizable\nfrom monai.transforms.croppad.array import CenterSpatialCrop, DivisiblePad, SpatialCrop, SpatialPad, BorderPad\nfrom monai.transforms.utils import generate_pos_neg_label_crop_centers, generate_spatial_bounding_box\nfrom monai.utils import ensure_tuple, ensure_tuple_rep, fall_back_tuple, NumpyPadMode, Method\n\nNumpyPadModeSequence = Union[Sequence[Union[NumpyPadMode, str]], NumpyPadMode, str]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_SpatialPadd_SpatialPadd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_SpatialPadd_SpatialPadd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 30, "end_line": 66, "span_ids": ["SpatialPadd", "SpatialPadd.__init__", "SpatialPadd.__call__"], "tokens": 421}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SpatialPadd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.SpatialPad`.\n Performs padding to the data, symmetric for all sides or all on one side for each dimension.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n spatial_size: Union[Sequence[int], int],\n method: Union[Method, str] = Method.SYMMETRIC,\n mode: NumpyPadModeSequence = NumpyPadMode.CONSTANT,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n spatial_size: the spatial size of output data after padding.\n If its components have non-positive values, the corresponding size of input image will be used.\n method: {``\"symmetric\"``, ``\"end\"``}\n Pad image symmetric on every side or only pad at the end sides. Defaults to ``\"symmetric\"``.\n mode: {``\"constant\"``, ``\"edge\"``, ``\"linear_ramp\"``, ``\"maximum\"``, ``\"mean\"``,\n ``\"median\"``, ``\"minimum\"``, ``\"reflect\"``, ``\"symmetric\"``, ``\"wrap\"``, ``\"empty\"``}\n One of the listed string values or a user supplied function. Defaults to ``\"constant\"``.\n See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n\n \"\"\"\n super().__init__(keys)\n self.mode = ensure_tuple_rep(mode, len(self.keys))\n self.padder = SpatialPad(spatial_size, method)\n\n def __call__(self, data):\n d = dict(data)\n for key, m in zip(self.keys, self.mode):\n d[key] = self.padder(d[key], mode=m)\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_BorderPadd_BorderPadd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_BorderPadd_BorderPadd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 69, "end_line": 111, "span_ids": ["BorderPadd.__init__", "BorderPadd.__call__", "BorderPadd"], "tokens": 542}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class BorderPadd(MapTransform):\n \"\"\"\n Pad the input data by adding specified borders to every dimension.\n Dictionary-based wrapper of :py:class:`monai.transforms.BorderPad`.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n spatial_border: Union[Sequence[int], int],\n mode: NumpyPadModeSequence = NumpyPadMode.CONSTANT,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n spatial_border: specified size for every spatial border. it can be 3 shapes:\n\n - single int number, pad all the borders with the same size.\n - length equals the length of image shape, pad every spatial dimension separately.\n for example, image shape(CHW) is [1, 4, 4], spatial_border is [2, 1],\n pad every border of H dim with 2, pad every border of W dim with 1, result shape is [1, 8, 6].\n - length equals 2 x (length of image shape), pad every border of every dimension separately.\n for example, image shape(CHW) is [1, 4, 4], spatial_border is [1, 2, 3, 4], pad top of H dim with 1,\n pad bottom of H dim with 2, pad left of W dim with 3, pad right of W dim with 4.\n the result shape is [1, 7, 11].\n\n mode: {``\"constant\"``, ``\"edge\"``, ``\"linear_ramp\"``, ``\"maximum\"``, ``\"mean\"``,\n ``\"median\"``, ``\"minimum\"``, ``\"reflect\"``, ``\"symmetric\"``, ``\"wrap\"``, ``\"empty\"``}\n One of the listed string values or a user supplied function. Defaults to ``\"constant\"``.\n See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n\n \"\"\"\n super().__init__(keys)\n self.mode = ensure_tuple_rep(mode, len(self.keys))\n self.padder = BorderPad(spatial_border=spatial_border)\n\n def __call__(self, data):\n d = dict(data)\n for key, m in zip(self.keys, self.mode):\n d[key] = self.padder(d[key], mode=m)\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_DivisiblePadd_DivisiblePadd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_DivisiblePadd_DivisiblePadd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 114, "end_line": 147, "span_ids": ["DivisiblePadd.__init__", "DivisiblePadd", "DivisiblePadd.__call__"], "tokens": 389}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DivisiblePadd(MapTransform):\n \"\"\"\n Pad the input data, so that the spatial sizes are divisible by `k`.\n Dictionary-based wrapper of :py:class:`monai.transforms.DivisiblePad`.\n \"\"\"\n\n def __init__(\n self, keys: KeysCollection, k: Union[Sequence[int], int], mode: NumpyPadModeSequence = NumpyPadMode.CONSTANT\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n k: the target k for each spatial dimension.\n if `k` is negative or 0, the original size is preserved.\n if `k` is an int, the same `k` be applied to all the input spatial dimensions.\n mode: {``\"constant\"``, ``\"edge\"``, ``\"linear_ramp\"``, ``\"maximum\"``, ``\"mean\"``,\n ``\"median\"``, ``\"minimum\"``, ``\"reflect\"``, ``\"symmetric\"``, ``\"wrap\"``, ``\"empty\"``}\n One of the listed string values or a user supplied function. Defaults to ``\"constant\"``.\n See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n\n See also :py:class:`monai.transforms.SpatialPad`\n\n \"\"\"\n super().__init__(keys)\n self.mode = ensure_tuple_rep(mode, len(self.keys))\n self.padder = DivisiblePad(k=k)\n\n def __call__(self, data):\n d = dict(data)\n for key, m in zip(self.keys, self.mode):\n d[key] = self.padder(d[key], mode=m)\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_SpatialCropd_SpatialCropd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_SpatialCropd_SpatialCropd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 150, "end_line": 181, "span_ids": ["SpatialCropd", "SpatialCropd.__call__", "SpatialCropd.__init__"], "tokens": 277}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SpatialCropd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.SpatialCrop`.\n Either a spatial center and size must be provided, or alternatively if center and size\n are not provided, the start and end coordinates of the ROI must be provided.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n roi_center: Optional[Sequence[int]] = None,\n roi_size: Optional[Sequence[int]] = None,\n roi_start: Optional[Sequence[int]] = None,\n roi_end: Optional[Sequence[int]] = None,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n roi_center: voxel coordinates for center of the crop ROI.\n roi_size: size of the crop ROI.\n roi_start: voxel coordinates for start of the crop ROI.\n roi_end: voxel coordinates for end of the crop ROI.\n \"\"\"\n super().__init__(keys)\n self.cropper = SpatialCrop(roi_center, roi_size, roi_start, roi_end)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.cropper(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_CenterSpatialCropd_CenterSpatialCropd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_CenterSpatialCropd_CenterSpatialCropd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 184, "end_line": 203, "span_ids": ["CenterSpatialCropd.__call__", "CenterSpatialCropd", "CenterSpatialCropd.__init__"], "tokens": 174}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CenterSpatialCropd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.CenterSpatialCrop`.\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: monai.transforms.MapTransform\n roi_size: the size of the crop region e.g. [224,224,128]\n If its components have non-positive values, the corresponding size of input image will be used.\n \"\"\"\n\n def __init__(self, keys: KeysCollection, roi_size: Union[Sequence[int], int]) -> None:\n super().__init__(keys)\n self.cropper = CenterSpatialCrop(roi_size)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.cropper(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandSpatialCropd_RandSpatialCropd.__init__.self._size.None": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandSpatialCropd_RandSpatialCropd.__init__.self._size.None", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 206, "end_line": 236, "span_ids": ["RandSpatialCropd", "RandSpatialCropd.__init__"], "tokens": 335}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandSpatialCropd(Randomizable, MapTransform):\n \"\"\"\n Dictionary-based version :py:class:`monai.transforms.RandSpatialCrop`.\n Crop image with random size or specific size ROI. It can crop at a random position as\n center or at the image center. And allows to set the minimum size to limit the randomly\n generated ROI. Suppose all the expected fields specified by `keys` have same shape.\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: monai.transforms.MapTransform\n roi_size: if `random_size` is True, it specifies the minimum crop region.\n if `random_size` is False, it specifies the expected ROI size to crop. e.g. [224, 224, 128]\n If its components have non-positive values, the corresponding size of input image will be used.\n random_center: crop at random position as center or the image center.\n random_size: crop with random size or specific size ROI.\n The actual size is sampled from `randint(roi_size, img_size)`.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n roi_size: Union[Sequence[int], int],\n random_center: bool = True,\n random_size: bool = True,\n ) -> None:\n super().__init__(keys)\n self.roi_size = roi_size\n self.random_center = random_center\n self.random_size = random_size\n self._slices: Optional[Tuple[slice, ...]] = None\n self._size: Optional[Sequence[int]] = None", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandSpatialCropd.randomize_RandSpatialCropd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandSpatialCropd.randomize_RandSpatialCropd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 238, "end_line": 255, "span_ids": ["RandSpatialCropd.__call__", "RandSpatialCropd.randomize"], "tokens": 217}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandSpatialCropd(Randomizable, MapTransform):\n\n def randomize(self, img_size: Sequence[int]) -> None:\n self._size = fall_back_tuple(self.roi_size, img_size)\n if self.random_size:\n self._size = [self.R.randint(low=self._size[i], high=img_size[i] + 1) for i in range(len(img_size))]\n if self.random_center:\n valid_size = get_valid_patch_size(img_size, self._size)\n self._slices = (slice(None),) + get_random_patch(img_size, valid_size, self.R)\n\n def __call__(self, data):\n d = dict(data)\n self.randomize(d[self.keys[0]].shape[1:]) # image shape from the first data key\n for key in self.keys:\n if self.random_center:\n d[key] = d[key][self._slices]\n else:\n cropper = CenterSpatialCrop(self._size)\n d[key] = cropper(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandSpatialCropSamplesd_RandSpatialCropSamplesd.__call__.return._self_cropper_data_for__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandSpatialCropSamplesd_RandSpatialCropSamplesd.__call__.return._self_cropper_data_for__", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 258, "end_line": 296, "span_ids": ["RandSpatialCropSamplesd", "RandSpatialCropSamplesd.__call__", "RandSpatialCropSamplesd.__init__", "RandSpatialCropSamplesd.randomize"], "tokens": 408}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandSpatialCropSamplesd(Randomizable, MapTransform):\n \"\"\"\n Dictionary-based version :py:class:`monai.transforms.RandSpatialCropSamples`.\n Crop image with random size or specific size ROI to generate a list of N samples.\n It can crop at a random position as center or at the image center. And allows to set\n the minimum size to limit the randomly generated ROI. Suppose all the expected fields\n specified by `keys` have same shape.\n It will return a list of dictionaries for all the cropped images.\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: monai.transforms.MapTransform\n roi_size: if `random_size` is True, the spatial size of the minimum crop region.\n if `random_size` is False, specify the expected ROI size to crop. e.g. [224, 224, 128]\n num_samples: number of samples (crop regions) to take in the returned list.\n random_center: crop at random position as center or the image center.\n random_size: crop with random size or specific size ROI.\n The actual size is sampled from `randint(roi_size, img_size)`.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n roi_size: Union[Sequence[int], int],\n num_samples: int,\n random_center: bool = True,\n random_size: bool = True,\n ) -> None:\n super().__init__(keys)\n if num_samples < 1:\n raise ValueError(\"number of samples must be greater than 0.\")\n self.num_samples = num_samples\n self.cropper = RandSpatialCropd(keys, roi_size, random_center, random_size)\n\n def randomize(self, data: Optional[Any] = None) -> None:\n pass\n\n def __call__(self, data):\n return [self.cropper(data) for _ in range(self.num_samples)]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_CropForegroundd_CropForegroundd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_CropForegroundd_CropForegroundd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 299, "end_line": 344, "span_ids": ["CropForegroundd.__init__", "CropForegroundd", "CropForegroundd.__call__"], "tokens": 503}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CropForegroundd(MapTransform):\n \"\"\"\n Dictionary-based version :py:class:`monai.transforms.CropForeground`.\n Crop only the foreground object of the expected images.\n The typical usage is to help training and evaluation if the valid part is small in the whole medical image.\n The valid part can be determined by any field in the data with `source_key`, for example:\n - Select values > 0 in image field as the foreground and crop on all fields specified by `keys`.\n - Select label = 3 in label field as the foreground to crop on all fields specified by `keys`.\n - Select label > 0 in the third channel of a One-Hot label field as the foreground to crop all `keys` fields.\n Users can define arbitrary function to select expected foreground from the whole source image or specified\n channels. And it can also add margin to every dim of the bounding box of foreground object.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n source_key: str,\n select_fn: Callable = lambda x: x > 0,\n channel_indexes: Optional[IndexSelection] = None,\n margin: int = 0,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n source_key: data source to generate the bounding box of foreground, can be image or label, etc.\n select_fn: function to select expected foreground, default is to select values > 0.\n channel_indexes: if defined, select foreground only on the specified channels\n of image. if None, select foreground on the whole image.\n margin: add margin to all dims of the bounding box.\n \"\"\"\n super().__init__(keys)\n self.source_key = source_key\n self.select_fn = select_fn\n self.channel_indexes = ensure_tuple(channel_indexes) if channel_indexes is not None else None\n self.margin = margin\n\n def __call__(self, data):\n d = dict(data)\n box_start, box_end = generate_spatial_bounding_box(\n d[self.source_key], self.select_fn, self.channel_indexes, self.margin\n )\n cropper = SpatialCrop(roi_start=box_start, roi_end=box_end)\n for key in self.keys:\n d[key] = cropper(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandCropByPosNegLabeld_RandCropByPosNegLabeld.randomize.self.centers.generate_pos_neg_label_cr": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandCropByPosNegLabeld_RandCropByPosNegLabeld.randomize.self.centers.generate_pos_neg_label_cr", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 347, "end_line": 404, "span_ids": ["RandCropByPosNegLabeld.randomize", "RandCropByPosNegLabeld", "RandCropByPosNegLabeld.__init__"], "tokens": 645}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandCropByPosNegLabeld(Randomizable, MapTransform):\n \"\"\"\n Dictionary-based version :py:class:`monai.transforms.RandCropByPosNegLabel`.\n Crop random fixed sized regions with the center being a foreground or background voxel\n based on the Pos Neg Ratio.\n And will return a list of dictionaries for all the cropped images.\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n label_key: name of key for label image, this will be used for finding foreground/background.\n spatial_size: the spatial size of the crop region e.g. [224, 224, 128].\n If its components have non-positive values, the corresponding size of `data[label_key]` will be used.\n pos: used to calculate the ratio ``pos / (pos + neg)`` for the probability to pick a\n foreground voxel as a center rather than a background voxel.\n neg: used to calculate the ratio ``pos / (pos + neg)`` for the probability to pick a\n foreground voxel as a center rather than a background voxel.\n num_samples: number of samples (crop regions) to take in each list.\n image_key: if image_key is not None, use ``label == 0 & image > image_threshold`` to select\n the negative sample(background) center. so the crop center will only exist on valid image area.\n image_threshold: if enabled image_key, use ``image > image_threshold`` to determine\n the valid image content area.\n\n Raises:\n ValueError: pos and neg must be greater than or equal to 0.\n ValueError: pos and neg cannot both be 0.\n\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n label_key: str,\n spatial_size: Union[Sequence[int], int],\n pos: float = 1.0,\n neg: float = 1.0,\n num_samples: int = 1,\n image_key: Optional[str] = None,\n image_threshold: float = 0.0,\n ) -> None:\n super().__init__(keys)\n self.label_key = label_key\n self.spatial_size = spatial_size\n if pos < 0 or neg < 0:\n raise ValueError(\"pos and neg must be greater than or equal to 0.\")\n if pos + neg == 0:\n raise ValueError(\"pos and neg cannot both be 0.\")\n self.pos_ratio = pos / (pos + neg)\n self.num_samples = num_samples\n self.image_key = image_key\n self.image_threshold = image_threshold\n self.centers = None\n\n def randomize(self, label: np.ndarray, image: Optional[np.ndarray] = None) -> None:\n self.spatial_size = fall_back_tuple(self.spatial_size, default=label.shape[1:])\n self.centers = generate_pos_neg_label_crop_centers(\n label, self.spatial_size, self.num_samples, self.pos_ratio, image, self.image_threshold, self.R\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandCropByPosNegLabeld.__call___RandCropByPosNegLabeld.__call__.return.results": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandCropByPosNegLabeld.__call___RandCropByPosNegLabeld.__call__.return.results", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 406, "end_line": 422, "span_ids": ["RandCropByPosNegLabeld.__call__"], "tokens": 160}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandCropByPosNegLabeld(Randomizable, MapTransform):\n\n def __call__(self, data):\n d = dict(data)\n label = d[self.label_key]\n image = d[self.image_key] if self.image_key else None\n self.randomize(label, image)\n results = [dict() for _ in range(self.num_samples)]\n for key in data.keys():\n if key in self.keys:\n img = d[key]\n for i, center in enumerate(self.centers):\n cropper = SpatialCrop(roi_center=tuple(center), roi_size=self.spatial_size)\n results[i][key] = cropper(img)\n else:\n for i in range(self.num_samples):\n results[i][key] = data[key]\n\n return results", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_SpatialPadD_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_SpatialPadD_", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 425, "end_line": 434, "span_ids": ["impl:3"], "tokens": 134}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "SpatialPadD = SpatialPadDict = SpatialPadd\nBorderPadD = BorderPadDict = BorderPadd\nDivisiblePadD = DivisiblePadDict = DivisiblePadd\nSpatialCropD = SpatialCropDict = SpatialCropd\nCenterSpatialCropD = CenterSpatialCropDict = CenterSpatialCropd\nRandSpatialCropD = RandSpatialCropDict = RandSpatialCropd\nRandSpatialCropSamplesD = RandSpatialCropSamplesDict = RandSpatialCropSamplesd\nCropForegroundD = CropForegroundDict = CropForegroundd\nRandCropByPosNegLabelD = RandCropByPosNegLabelDict = RandCropByPosNegLabeld", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/__init__.py__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/__init__.py__", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 11, "end_line": 11, "span_ids": [], "tokens": 0}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_from_typing_import_Option_ShiftIntensity.__call__.return._img_self_offset_astyp": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_from_typing_import_Option_ShiftIntensity.__call__.return._img_self_offset_astyp", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 16, "end_line": 70, "span_ids": ["ShiftIntensity.__call__", "RandGaussianNoise.randomize", "RandGaussianNoise.__init__", "RandGaussianNoise", "docstring", "ShiftIntensity.__init__", "ShiftIntensity", "RandGaussianNoise.__call__"], "tokens": 367}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Sequence, Tuple, Union, Any\n\nfrom warnings import warn\n\nimport numpy as np\n\nfrom monai.transforms.compose import Transform, Randomizable\nfrom monai.transforms.utils import rescale_array\n\n\nclass RandGaussianNoise(Randomizable, Transform):\n \"\"\"\n Add Gaussian noise to image.\n\n Args:\n prob: Probability to add Gaussian noise.\n mean: Mean or \u201ccentre\u201d of the distribution.\n std: Standard deviation (spread) of distribution.\n \"\"\"\n\n def __init__(self, prob: float = 0.1, mean: Union[Sequence[float], float] = 0.0, std: float = 0.1) -> None:\n self.prob = prob\n self.mean = mean\n self.std = std\n self._do_transform = False\n self._noise = None\n\n def randomize(self, im_shape: Sequence[int]) -> None:\n self._do_transform = self.R.random() < self.prob\n self._noise = self.R.normal(self.mean, self.R.uniform(0, self.std), size=im_shape)\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n self.randomize(img.shape)\n return img + self._noise.astype(img.dtype) if self._do_transform else img\n\n\nclass ShiftIntensity(Transform):\n \"\"\"\n Shift intensity uniformly for the entire image with specified `offset`.\n\n Args:\n offset: offset value to shift the intensity of image.\n \"\"\"\n\n def __init__(self, offset: float) -> None:\n self.offset = offset\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n return (img + self.offset).astype(img.dtype)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_RandShiftIntensity_RandShiftIntensity.__call__.return.shifter_img_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_RandShiftIntensity_RandShiftIntensity.__call__.return.shifter_img_", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 73, "end_line": 106, "span_ids": ["RandShiftIntensity.__call__", "RandShiftIntensity", "RandShiftIntensity.randomize", "RandShiftIntensity.__init__"], "tokens": 280}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandShiftIntensity(Randomizable, Transform):\n \"\"\"\n Randomly shift intensity with randomly picked offset.\n \"\"\"\n\n def __init__(self, offsets: Union[Tuple[float, float], float], prob: float = 0.1):\n \"\"\"\n Args:\n offsets: offset range to randomly shift.\n if single number, offset value is picked from (-offsets, offsets).\n prob: probability of shift.\n \"\"\"\n if isinstance(offsets, (int, float)):\n self.offsets = (min(-offsets, offsets), max(-offsets, offsets))\n else:\n assert len(offsets) == 2, \"offsets should be a number or pair of numbers.\"\n self.offsets = (min(offsets), max(offsets))\n\n self.prob = prob\n self._do_transform = False\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self._offset = self.R.uniform(low=self.offsets[0], high=self.offsets[1])\n self._do_transform = self.R.random() < self.prob\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n self.randomize()\n if not self._do_transform:\n return img\n shifter = ShiftIntensity(self._offset)\n return shifter(img)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensity_ScaleIntensity.__call__.if_self_minv_is_not_None_.else_.return._img_1_self_factor_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensity_ScaleIntensity.__call__.if_self_minv_is_not_None_.else_.return._img_1_self_factor_", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 109, "end_line": 135, "span_ids": ["ScaleIntensity", "ScaleIntensity.__init__", "ScaleIntensity.__call__"], "tokens": 247}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ScaleIntensity(Transform):\n \"\"\"\n Scale the intensity of input image to the given value range (minv, maxv).\n If `minv` and `maxv` not provided, use `factor` to scale image by ``v = v * (1 + factor)``.\n \"\"\"\n\n def __init__(\n self, minv: Optional[float] = 0.0, maxv: Optional[float] = 1.0, factor: Optional[float] = None\n ) -> None:\n \"\"\"\n Args:\n minv: minimum value of output data.\n maxv: maximum value of output data.\n factor: factor scale by ``v = v * (1 + factor)``.\n \"\"\"\n self.minv = minv\n self.maxv = maxv\n self.factor = factor\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n if self.minv is not None and self.maxv is not None:\n return rescale_array(img, self.minv, self.maxv, img.dtype)\n else:\n return (img * (1 + self.factor)).astype(img.dtype)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_RandScaleIntensity_RandScaleIntensity.__call__.return.scaler_img_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_RandScaleIntensity_RandScaleIntensity.__call__.return.scaler_img_", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 138, "end_line": 173, "span_ids": ["RandScaleIntensity.__init__", "RandScaleIntensity", "RandScaleIntensity.randomize", "RandScaleIntensity.__call__"], "tokens": 331}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandScaleIntensity(Randomizable, Transform):\n \"\"\"\n Randomly scale the intensity of input image by ``v = v * (1 + factor)`` where the `factor`\n is randomly picked from (factors[0], factors[0]).\n \"\"\"\n\n def __init__(self, factors: Union[Tuple[float, float], float], prob: float = 0.1) -> None:\n \"\"\"\n Args:\n factors: factor range to randomly scale by ``v = v * (1 + factor)``.\n if single number, factor value is picked from (-factors, factors).\n prob: probability of scale.\n\n \"\"\"\n if isinstance(factors, (int, float)):\n self.factors = (min(-factors, factors), max(-factors, factors))\n else:\n assert len(factors) == 2, \"factors should be a number or pair of numbers.\"\n self.factors = (min(factors), max(factors))\n\n self.prob = prob\n self._do_transform = False\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self.factor = self.R.uniform(low=self.factors[0], high=self.factors[1])\n self._do_transform = self.R.random() < self.prob\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n self.randomize()\n if not self._do_transform:\n return img\n scaler = ScaleIntensity(minv=None, maxv=None, factor=self.factor)\n return scaler(img)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_NormalizeIntensity_NormalizeIntensity.__init__.self.channel_wise.channel_wise": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_NormalizeIntensity_NormalizeIntensity.__init__.self.channel_wise.channel_wise", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 176, "end_line": 206, "span_ids": ["NormalizeIntensity.__init__", "NormalizeIntensity"], "tokens": 305}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class NormalizeIntensity(Transform):\n \"\"\"\n Normalize input based on provided args, using calculated mean and std if not provided\n (shape of subtrahend and divisor must match. if 0, entire volume uses same subtrahend and\n divisor, otherwise the shape can have dimension 1 for channels).\n This transform can normalize only non-zero values or entire image, and can also calculate\n mean and std on each channel separately.\n\n Args:\n subtrahend: the amount to subtract by (usually the mean).\n divisor: the amount to divide by (usually the standard deviation).\n nonzero: whether only normalize non-zero values.\n channel_wise: if using calculated mean and std, calculate on each channel separately\n or calculate on the entire image directly.\n \"\"\"\n\n def __init__(\n self,\n subtrahend: Optional[np.ndarray] = None,\n divisor: Optional[np.ndarray] = None,\n nonzero: bool = False,\n channel_wise: bool = False,\n ) -> None:\n if subtrahend is not None or divisor is not None:\n assert isinstance(subtrahend, np.ndarray) and isinstance(\n divisor, np.ndarray\n ), \"subtrahend and divisor must be set in pair and in numpy array.\"\n self.subtrahend = subtrahend\n self.divisor = divisor\n self.nonzero = nonzero\n self.channel_wise = channel_wise", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_NormalizeIntensity._normalize_NormalizeIntensity.__call__.return.img": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_NormalizeIntensity._normalize_NormalizeIntensity.__call__.return.img", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 208, "end_line": 227, "span_ids": ["NormalizeIntensity._normalize", "NormalizeIntensity.__call__"], "tokens": 200}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class NormalizeIntensity(Transform):\n\n def _normalize(self, img):\n slices = (img != 0) if self.nonzero else np.ones(img.shape, dtype=np.bool_)\n if np.any(slices):\n if self.subtrahend is not None and self.divisor is not None:\n img[slices] = (img[slices] - self.subtrahend[slices]) / self.divisor[slices]\n else:\n img[slices] = (img[slices] - np.mean(img[slices])) / np.std(img[slices])\n return img\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`, assuming `img` is a channel-first array if `self.channel_wise` is True,\n \"\"\"\n if self.channel_wise:\n for i, d in enumerate(img):\n img[i] = self._normalize(d)\n else:\n img = self._normalize(img)\n\n return img", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ThresholdIntensity_ThresholdIntensity.__call__.return.np_where_img_self_thres": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ThresholdIntensity_ThresholdIntensity.__call__.return.np_where_img_self_thres", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 230, "end_line": 251, "span_ids": ["ThresholdIntensity", "ThresholdIntensity.__call__", "ThresholdIntensity.__init__"], "tokens": 211}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ThresholdIntensity(Transform):\n \"\"\"\n Filter the intensity values of whole image to below threshold or above threshold.\n And fill the remaining parts of the image to the `cval` value.\n\n Args:\n threshold: the threshold to filter intensity values.\n above: filter values above the threshold or below the threshold, default is True.\n cval: value to fill the remaining parts of the image, default is 0.\n \"\"\"\n\n def __init__(self, threshold: float, above: bool = True, cval: float = 0.0) -> None:\n assert isinstance(threshold, (int, float)), \"threshold must be a float or int number.\"\n self.threshold = threshold\n self.above = above\n self.cval = cval\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n return np.where(img > self.threshold if self.above else img < self.threshold, img, self.cval).astype(img.dtype)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensityRange_ScaleIntensityRange.__init__.self.clip.clip": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensityRange_ScaleIntensityRange.__init__.self.clip.clip", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 254, "end_line": 272, "span_ids": ["ScaleIntensityRange", "ScaleIntensityRange.__init__"], "tokens": 165}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ScaleIntensityRange(Transform):\n \"\"\"\n Apply specific intensity scaling to the whole numpy array.\n Scaling from [a_min, a_max] to [b_min, b_max] with clip option.\n\n Args:\n a_min: intensity original range min.\n a_max: intensity original range max.\n b_min: intensity target range min.\n b_max: intensity target range max.\n clip: whether to perform clip after scaling.\n \"\"\"\n\n def __init__(self, a_min: float, a_max: float, b_min: float, b_max: float, clip: bool = False) -> None:\n self.a_min = a_min\n self.a_max = a_max\n self.b_min = b_min\n self.b_max = b_max\n self.clip = clip", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensityRange.__call___ScaleIntensityRange.__call__.return.img": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensityRange.__call___ScaleIntensityRange.__call__.return.img", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 274, "end_line": 287, "span_ids": ["ScaleIntensityRange.__call__"], "tokens": 132}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ScaleIntensityRange(Transform):\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n if self.a_max - self.a_min == 0.0:\n warn(\"Divide by zero (a_min == a_max)\", Warning)\n return img - self.a_min + self.b_min\n\n img = (img - self.a_min) / (self.a_max - self.a_min)\n img = img * (self.b_max - self.b_min) + self.b_min\n if self.clip:\n img = np.clip(img, self.b_min, self.b_max)\n\n return img", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_AdjustContrast_AdjustContrast.__call__.return.np_power_img_img_min_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_AdjustContrast_AdjustContrast.__call__.return.np_power_img_img_min_", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 290, "end_line": 311, "span_ids": ["AdjustContrast.__init__", "AdjustContrast", "AdjustContrast.__call__"], "tokens": 177}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AdjustContrast(Transform):\n \"\"\"\n Changes image intensity by gamma. Each pixel/voxel intensity is updated as::\n\n x = ((x - min) / intensity_range) ^ gamma * intensity_range + min\n\n Args:\n gamma: gamma value to adjust the contrast as function.\n \"\"\"\n\n def __init__(self, gamma: float) -> None:\n assert isinstance(gamma, (int, float)), \"gamma must be a float or int number.\"\n self.gamma = gamma\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n epsilon = 1e-7\n img_min = img.min()\n img_range = img.max() - img_min\n return np.power(((img - img_min) / float(img_range + epsilon)), self.gamma) * img_range + img_min", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_RandAdjustContrast_RandAdjustContrast.__call__.return.adjuster_img_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_RandAdjustContrast_RandAdjustContrast.__call__.return.adjuster_img_", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 314, "end_line": 351, "span_ids": ["RandAdjustContrast.randomize", "RandAdjustContrast", "RandAdjustContrast.__call__", "RandAdjustContrast.__init__"], "tokens": 360}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandAdjustContrast(Randomizable, Transform):\n \"\"\"\n Randomly changes image intensity by gamma. Each pixel/voxel intensity is updated as::\n\n x = ((x - min) / intensity_range) ^ gamma * intensity_range + min\n\n Args:\n prob: Probability of adjustment.\n gamma: Range of gamma values.\n If single number, value is picked from (0.5, gamma), default is (0.5, 4.5).\n \"\"\"\n\n def __init__(self, prob: float = 0.1, gamma: Union[Sequence[float], float] = (0.5, 4.5)) -> None:\n self.prob = prob\n\n if isinstance(gamma, (int, float)):\n assert gamma > 0.5, \"if gamma is single number, must greater than 0.5 and value is picked from (0.5, gamma)\"\n self.gamma = (0.5, gamma)\n else:\n assert len(gamma) == 2, \"gamma should be a number or pair of numbers.\"\n self.gamma = (min(gamma), max(gamma))\n\n self._do_transform = False\n self.gamma_value = None\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self._do_transform = self.R.random_sample() < self.prob\n self.gamma_value = self.R.uniform(low=self.gamma[0], high=self.gamma[1])\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n self.randomize()\n if not self._do_transform:\n return img\n adjuster = AdjustContrast(self.gamma_value)\n return adjuster(img)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensityRangePercentiles_ScaleIntensityRangePercentiles._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensityRangePercentiles_ScaleIntensityRangePercentiles._", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 354, "end_line": 407, "span_ids": ["ScaleIntensityRangePercentiles"], "tokens": 641}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ScaleIntensityRangePercentiles(Transform):\n \"\"\"\n Apply range scaling to a numpy array based on the intensity distribution of the input.\n\n By default this transform will scale from [lower_intensity_percentile, upper_intensity_percentile] to [b_min, b_max], where\n {lower,upper}_intensity_percentile are the intensity values at the corresponding percentiles of ``img``.\n\n The ``relative`` parameter can also be set to scale from [lower_intensity_percentile, upper_intensity_percentile] to the\n lower and upper percentiles of the output range [b_min, b_max]\n\n For example:\n\n .. code-block:: python\n :emphasize-lines: 11, 22\n\n image = np.array(\n [[[1, 2, 3, 4, 5],\n [1, 2, 3, 4, 5],\n [1, 2, 3, 4, 5],\n [1, 2, 3, 4, 5],\n [1, 2, 3, 4, 5],\n [1, 2, 3, 4, 5]]])\n\n # Scale from lower and upper image intensity percentiles\n # to output range [b_min, b_max]\n scaler = ScaleIntensityRangePercentiles(10, 90, 0, 200, False, False)\n print(scaler(image))\n [[[0., 50., 100., 150., 200.],\n [0., 50., 100., 150., 200.],\n [0., 50., 100., 150., 200.],\n [0., 50., 100., 150., 200.],\n [0., 50., 100., 150., 200.],\n [0., 50., 100., 150., 200.]]]\n\n # Scale from lower and upper image intensity percentiles\n # to lower and upper percentiles of the output range [b_min, b_max]\n rel_scaler = ScaleIntensityRangePercentiles(10, 90, 0, 200, False, True)\n print(rel_scaler(image))\n [[[20., 60., 100., 140., 180.],\n [20., 60., 100., 140., 180.],\n [20., 60., 100., 140., 180.],\n [20., 60., 100., 140., 180.],\n [20., 60., 100., 140., 180.],\n [20., 60., 100., 140., 180.]]]\n\n\n Args:\n lower: lower intensity percentile.\n upper: upper intensity percentile.\n b_min: intensity target range min.\n b_max: intensity target range max.\n clip: whether to perform clip after scaling.\n relative: whether to scale to the corresponding percentiles of [b_min, b_max].\n \"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensityRangePercentiles.__init___ScaleIntensityRangePercentiles.__init__.self.relative.relative": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensityRangePercentiles.__init___ScaleIntensityRangePercentiles.__init__.self.relative.relative", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 409, "end_line": 419, "span_ids": ["ScaleIntensityRangePercentiles.__init__"], "tokens": 146}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ScaleIntensityRangePercentiles(Transform):\n\n def __init__(\n self, lower: float, upper: float, b_min: float, b_max: float, clip: bool = False, relative: bool = False\n ) -> None:\n assert 0.0 <= lower <= 100.0, \"Percentiles must be in the range [0, 100]\"\n assert 0.0 <= upper <= 100.0, \"Percentiles must be in the range [0, 100]\"\n self.lower = lower\n self.upper = upper\n self.b_min = b_min\n self.b_max = b_max\n self.clip = clip\n self.relative = relative", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensityRangePercentiles.__call___ScaleIntensityRangePercentiles.__call__.return.img": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensityRangePercentiles.__call___ScaleIntensityRangePercentiles.__call__.return.img", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 421, "end_line": 440, "span_ids": ["ScaleIntensityRangePercentiles.__call__"], "tokens": 188}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ScaleIntensityRangePercentiles(Transform):\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n a_min = np.percentile(img, self.lower)\n a_max = np.percentile(img, self.upper)\n b_min = self.b_min\n b_max = self.b_max\n\n if self.relative:\n b_min = ((self.b_max - self.b_min) * (self.lower / 100.0)) + self.b_min\n b_max = ((self.b_max - self.b_min) * (self.upper / 100.0)) + self.b_min\n\n scalar = ScaleIntensityRange(a_min=a_min, a_max=a_max, b_min=b_min, b_max=b_max, clip=False)\n img = scalar(img)\n\n if self.clip:\n img = np.clip(img, self.b_min, self.b_max)\n\n return img", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_MaskIntensity_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_MaskIntensity_", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 443, "end_line": 467, "span_ids": ["MaskIntensity.__call__", "MaskIntensity.__init__", "MaskIntensity"], "tokens": 255}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class MaskIntensity(Transform):\n \"\"\"\n Mask the intensity values of input image with the specified mask data.\n Mask data must have the same spatial size as the input image, and all\n the intensity values of input image corresponding to `0` in the mask\n data will be set to `0`, others will keep the original value.\n\n Args:\n mask_data: if mask data is single channel, apply to evey channel\n of input image. if multiple channels, the channel number must\n match input data. mask_data will be converted to `bool` values\n by `mask_data > 0` before applying transform to input image.\n\n \"\"\"\n\n def __init__(self, mask_data: np.ndarray):\n self.mask_data = mask_data\n\n def __call__(self, img, mask_data: Optional[np.ndarray] = None):\n mask_data_ = self.mask_data > 0 if mask_data is None else mask_data > 0\n if mask_data_.shape[0] != 1 and mask_data_.shape[0] != img.shape[0]:\n raise RuntimeError(\"mask data has more than 1 channel and do not match channels of input data.\")\n\n return img * mask_data_", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_from_typing_import_Option_RandGaussianNoised.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_from_typing_import_Option_RandGaussianNoised.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 18, "end_line": 72, "span_ids": ["RandGaussianNoised.__call__", "RandGaussianNoised.__init__", "RandGaussianNoised", "RandGaussianNoised.randomize", "docstring"], "tokens": 426}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Sequence, Tuple, Union, Any\n\nimport numpy as np\n\nfrom monai.config import KeysCollection\nfrom monai.transforms.compose import MapTransform, Randomizable\nfrom monai.transforms.intensity.array import (\n NormalizeIntensity,\n ScaleIntensityRange,\n ThresholdIntensity,\n AdjustContrast,\n ShiftIntensity,\n ScaleIntensity,\n ScaleIntensityRangePercentiles,\n MaskIntensity,\n)\n\n\nclass RandGaussianNoised(Randomizable, MapTransform):\n \"\"\"\n Dictionary-based version :py:class:`monai.transforms.RandGaussianNoise`.\n Add Gaussian noise to image. This transform assumes all the expected fields have same shape.\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n prob: Probability to add Gaussian noise.\n mean: Mean or \u201ccentre\u201d of the distribution.\n std: Standard deviation (spread) of distribution.\n \"\"\"\n\n def __init__(\n self, keys: KeysCollection, prob: float = 0.1, mean: Union[Sequence[float], float] = 0.0, std: float = 0.1\n ) -> None:\n super().__init__(keys)\n self.prob = prob\n self.mean = mean\n self.std = std\n self._do_transform = False\n self._noise = None\n\n def randomize(self, im_shape: Sequence[int]) -> None:\n self._do_transform = self.R.random() < self.prob\n self._noise = self.R.normal(self.mean, self.R.uniform(0, self.std), size=im_shape)\n\n def __call__(self, data):\n d = dict(data)\n\n image_shape = d[self.keys[0]].shape # image shape from the first data key\n self.randomize(image_shape)\n if not self._do_transform:\n return d\n for key in self.keys:\n d[key] = d[key] + self._noise.astype(d[key].dtype)\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_ShiftIntensityd_ShiftIntensityd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_ShiftIntensityd_ShiftIntensityd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 75, "end_line": 94, "span_ids": ["ShiftIntensityd", "ShiftIntensityd.__call__", "ShiftIntensityd.__init__"], "tokens": 144}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ShiftIntensityd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.ShiftIntensity`.\n \"\"\"\n\n def __init__(self, keys: KeysCollection, offset: float) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n offset: offset value to shift the intensity of image.\n \"\"\"\n super().__init__(keys)\n self.shifter = ShiftIntensity(offset)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.shifter(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandShiftIntensityd_RandShiftIntensityd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandShiftIntensityd_RandShiftIntensityd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 97, "end_line": 135, "span_ids": ["RandShiftIntensityd.randomize", "RandShiftIntensityd.__init__", "RandShiftIntensityd.__call__", "RandShiftIntensityd"], "tokens": 357}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandShiftIntensityd(Randomizable, MapTransform):\n \"\"\"\n Dictionary-based version :py:class:`monai.transforms.RandShiftIntensity`.\n \"\"\"\n\n def __init__(self, keys: KeysCollection, offsets: Union[Tuple[float, float], float], prob: float = 0.1) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n offsets: offset range to randomly shift.\n if single number, offset value is picked from (-offsets, offsets).\n prob: probability of rotating.\n (Default 0.1, with 10% probability it returns a rotated array.)\n \"\"\"\n super().__init__(keys)\n\n if isinstance(offsets, (int, float)):\n self.offsets = (min(-offsets, offsets), max(-offsets, offsets))\n else:\n assert len(offsets) == 2, \"offsets should be a number or pair of numbers.\"\n self.offsets = (min(offsets), max(offsets))\n\n self.prob = prob\n self._do_transform = False\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self._offset = self.R.uniform(low=self.offsets[0], high=self.offsets[1])\n self._do_transform = self.R.random() < self.prob\n\n def __call__(self, data):\n d = dict(data)\n self.randomize()\n if not self._do_transform:\n return d\n shifter = ShiftIntensity(self._offset)\n for key in self.keys:\n d[key] = shifter(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_ScaleIntensityd_ScaleIntensityd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_ScaleIntensityd_ScaleIntensityd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 138, "end_line": 164, "span_ids": ["ScaleIntensityd", "ScaleIntensityd.__call__", "ScaleIntensityd.__init__"], "tokens": 255}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ScaleIntensityd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.ScaleIntensity`.\n Scale the intensity of input image to the given value range (minv, maxv).\n If `minv` and `maxv` not provided, use `factor` to scale image by ``v = v * (1 + factor)``.\n \"\"\"\n\n def __init__(\n self, keys: KeysCollection, minv: float = 0.0, maxv: float = 1.0, factor: Optional[float] = None\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n minv: minimum value of output data.\n maxv: maximum value of output data.\n factor: factor scale by ``v = v * (1 + factor)``.\n\n \"\"\"\n super().__init__(keys)\n self.scaler = ScaleIntensity(minv, maxv, factor)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.scaler(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandScaleIntensityd_RandScaleIntensityd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandScaleIntensityd_RandScaleIntensityd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 167, "end_line": 206, "span_ids": ["RandScaleIntensityd.__call__", "RandScaleIntensityd.__init__", "RandScaleIntensityd", "RandScaleIntensityd.randomize"], "tokens": 374}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandScaleIntensityd(Randomizable, MapTransform):\n \"\"\"\n Dictionary-based version :py:class:`monai.transforms.RandScaleIntensity`.\n \"\"\"\n\n def __init__(self, keys: KeysCollection, factors: Union[Tuple[float, float], float], prob: float = 0.1) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n factors: factor range to randomly scale by ``v = v * (1 + factor)``.\n if single number, factor value is picked from (-factors, factors).\n prob: probability of rotating.\n (Default 0.1, with 10% probability it returns a rotated array.)\n\n \"\"\"\n super().__init__(keys)\n\n if isinstance(factors, (int, float)):\n self.factors = (min(-factors, factors), max(-factors, factors))\n else:\n assert len(factors) == 2, \"factors should be a number or pair of numbers.\"\n self.factors = (min(factors), max(factors))\n\n self.prob = prob\n self._do_transform = False\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self.factor = self.R.uniform(low=self.factors[0], high=self.factors[1])\n self._do_transform = self.R.random() < self.prob\n\n def __call__(self, data):\n d = dict(data)\n self.randomize()\n if not self._do_transform:\n return d\n scaler = ScaleIntensity(minv=None, maxv=None, factor=self.factor)\n for key in self.keys:\n d[key] = scaler(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_NormalizeIntensityd_NormalizeIntensityd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_NormalizeIntensityd_NormalizeIntensityd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 209, "end_line": 240, "span_ids": ["NormalizeIntensityd.__call__", "NormalizeIntensityd.__init__", "NormalizeIntensityd"], "tokens": 266}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class NormalizeIntensityd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.NormalizeIntensity`.\n This transform can normalize only non-zero values or entire image, and can also calculate\n mean and std on each channel separately.\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: monai.transforms.MapTransform\n subtrahend: the amount to subtract by (usually the mean)\n divisor: the amount to divide by (usually the standard deviation)\n nonzero: whether only normalize non-zero values.\n channel_wise: if using calculated mean and std, calculate on each channel separately\n or calculate on the entire image directly.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n subtrahend: Optional[np.ndarray] = None,\n divisor: Optional[np.ndarray] = None,\n nonzero: bool = False,\n channel_wise: bool = False,\n ) -> None:\n super().__init__(keys)\n self.normalizer = NormalizeIntensity(subtrahend, divisor, nonzero, channel_wise)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.normalizer(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_ThresholdIntensityd_ThresholdIntensityd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_ThresholdIntensityd_ThresholdIntensityd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 243, "end_line": 263, "span_ids": ["ThresholdIntensityd.__init__", "ThresholdIntensityd", "ThresholdIntensityd.__call__"], "tokens": 189}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ThresholdIntensityd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.ThresholdIntensity`.\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: monai.transforms.MapTransform\n threshold: the threshold to filter intensity values.\n above: filter values above the threshold or below the threshold, default is True.\n cval: value to fill the remaining parts of the image, default is 0.\n \"\"\"\n\n def __init__(self, keys: KeysCollection, threshold: float, above: bool = True, cval: float = 0.0) -> None:\n super().__init__(keys)\n self.filter = ThresholdIntensity(threshold, above, cval)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.filter(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_ScaleIntensityRanged_ScaleIntensityRanged.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_ScaleIntensityRanged_ScaleIntensityRanged.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 266, "end_line": 290, "span_ids": ["ScaleIntensityRanged.__call__", "ScaleIntensityRanged.__init__", "ScaleIntensityRanged"], "tokens": 208}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ScaleIntensityRanged(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.ScaleIntensityRange`.\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: monai.transforms.MapTransform\n a_min: intensity original range min.\n a_max: intensity original range max.\n b_min: intensity target range min.\n b_max: intensity target range max.\n clip: whether to perform clip after scaling.\n \"\"\"\n\n def __init__(\n self, keys: KeysCollection, a_min: float, a_max: float, b_min: float, b_max: float, clip: bool = False\n ) -> None:\n super().__init__(keys)\n self.scaler = ScaleIntensityRange(a_min, a_max, b_min, b_max, clip)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.scaler(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_AdjustContrastd_AdjustContrastd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_AdjustContrastd_AdjustContrastd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 293, "end_line": 312, "span_ids": ["AdjustContrastd", "AdjustContrastd.__call__", "AdjustContrastd.__init__"], "tokens": 155}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AdjustContrastd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.AdjustContrast`.\n Changes image intensity by gamma. Each pixel/voxel intensity is updated as:\n\n `x = ((x - min) / intensity_range) ^ gamma * intensity_range + min`\n\n Args:\n gamma: gamma value to adjust the contrast as function.\n \"\"\"\n\n def __init__(self, keys: KeysCollection, gamma: float) -> None:\n super().__init__(keys)\n self.adjuster = AdjustContrast(gamma)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.adjuster(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandAdjustContrastd_RandAdjustContrastd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandAdjustContrastd_RandAdjustContrastd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 315, "end_line": 358, "span_ids": ["RandAdjustContrastd", "RandAdjustContrastd.randomize", "RandAdjustContrastd.__call__", "RandAdjustContrastd.__init__"], "tokens": 429}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandAdjustContrastd(Randomizable, MapTransform):\n \"\"\"\n Dictionary-based version :py:class:`monai.transforms.RandAdjustContrast`.\n Randomly changes image intensity by gamma. Each pixel/voxel intensity is updated as:\n\n `x = ((x - min) / intensity_range) ^ gamma * intensity_range + min`\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: monai.transforms.MapTransform\n prob: Probability of adjustment.\n gamma: Range of gamma values.\n If single number, value is picked from (0.5, gamma), default is (0.5, 4.5).\n \"\"\"\n\n def __init__(\n self, keys: KeysCollection, prob: float = 0.1, gamma: Union[Tuple[float, float], float] = (0.5, 4.5)\n ) -> None:\n super().__init__(keys)\n self.prob: float = prob\n\n if isinstance(gamma, (int, float)):\n assert gamma > 0.5, \"if gamma is single number, must greater than 0.5 and value is picked from (0.5, gamma)\"\n self.gamma = (0.5, gamma)\n else:\n assert len(gamma) == 2, \"gamma should be a number or pair of numbers.\"\n self.gamma = (min(gamma), max(gamma))\n\n self._do_transform = False\n self.gamma_value = None\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self._do_transform = self.R.random_sample() < self.prob\n self.gamma_value = self.R.uniform(low=self.gamma[0], high=self.gamma[1])\n\n def __call__(self, data):\n d = dict(data)\n self.randomize()\n if not self._do_transform:\n return d\n adjuster = AdjustContrast(self.gamma_value)\n for key in self.keys:\n d[key] = adjuster(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_ScaleIntensityRangePercentilesd_ScaleIntensityRangePercentilesd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_ScaleIntensityRangePercentilesd_ScaleIntensityRangePercentilesd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 361, "end_line": 393, "span_ids": ["ScaleIntensityRangePercentilesd", "ScaleIntensityRangePercentilesd.__init__", "ScaleIntensityRangePercentilesd.__call__"], "tokens": 238}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ScaleIntensityRangePercentilesd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.ScaleIntensityRangePercentiles`.\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: monai.transforms.MapTransform\n lower: lower percentile.\n upper: upper percentile.\n b_min: intensity target range min.\n b_max: intensity target range max.\n clip: whether to perform clip after scaling.\n relative: whether to scale to the corresponding percentiles of [b_min, b_max]\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n lower: float,\n upper: float,\n b_min: float,\n b_max: float,\n clip: bool = False,\n relative: bool = False,\n ) -> None:\n super().__init__(keys)\n self.scaler = ScaleIntensityRangePercentiles(lower, upper, b_min, b_max, clip, relative)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.scaler(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_MaskIntensityd_MaskIntensityd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_MaskIntensityd_MaskIntensityd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 396, "end_line": 418, "span_ids": ["MaskIntensityd", "MaskIntensityd.__call__", "MaskIntensityd.__init__"], "tokens": 188}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class MaskIntensityd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.MaskIntensity`.\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n mask_data: if mask data is single channel, apply to evey channel\n of input image. if multiple channels, the channel number must\n match input data. mask_data will be converted to `bool` values\n by `mask_data > 0` before applying transform to input image.\n\n \"\"\"\n\n def __init__(self, keys: KeysCollection, mask_data: np.ndarray):\n super().__init__(keys)\n self.converter = MaskIntensity(mask_data)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.converter(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandGaussianNoiseD_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandGaussianNoiseD_", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 421, "end_line": 433, "span_ids": ["impl"], "tokens": 176}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "RandGaussianNoiseD = RandGaussianNoiseDict = RandGaussianNoised\nShiftIntensityD = ShiftIntensityDict = ShiftIntensityd\nRandShiftIntensityD = RandShiftIntensityDict = RandShiftIntensityd\nScaleIntensityD = ScaleIntensityDict = ScaleIntensityd\nRandScaleIntensityD = RandScaleIntensityDict = RandScaleIntensityd\nNormalizeIntensityD = NormalizeIntensityDict = NormalizeIntensityd\nThresholdIntensityD = ThresholdIntensityDict = ThresholdIntensityd\nScaleIntensityRangeD = ScaleIntensityRangeDict = ScaleIntensityRanged\nAdjustContrastD = AdjustContrastDict = AdjustContrastd\nRandAdjustContrastD = RandAdjustContrastDict = RandAdjustContrastd\nScaleIntensityRangePercentilesD = ScaleIntensityRangePercentilesDict = ScaleIntensityRangePercentilesd\nMaskIntensityD = MaskIntensityDict = MaskIntensityd", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/__init__.py__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/__init__.py__", "embedding": null, "metadata": {"file_path": "monai/transforms/io/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 11, "end_line": 11, "span_ids": [], "tokens": 0}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_from_typing_import_Option_LoadNifti.__init__.self.dtype.dtype": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_from_typing_import_Option_LoadNifti.__init__.self.dtype.dtype", "embedding": null, "metadata": {"file_path": "monai/transforms/io/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 16, "end_line": 57, "span_ids": ["LoadNifti.__init__", "LoadNifti", "docstring"], "tokens": 388}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional\n\nimport numpy as np\nfrom torch.utils.data._utils.collate import np_str_obj_array_pattern\nfrom monai.config import KeysCollection\nfrom monai.data.utils import correct_nifti_header_if_necessary\nfrom monai.transforms.compose import Transform\nfrom monai.utils import optional_import, ensure_tuple\n\nnib, _ = optional_import(\"nibabel\")\nImage, _ = optional_import(\"PIL.Image\")\n\n\nclass LoadNifti(Transform):\n \"\"\"\n Load Nifti format file or files from provided path. If loading a list of\n files, stack them together and add a new dimension as first dimension, and\n use the meta data of the first image to represent the stacked result. Note\n that the affine transform of all the images should be same if ``image_only=False``.\n \"\"\"\n\n def __init__(\n self, as_closest_canonical: bool = False, image_only: bool = False, dtype: Optional[np.dtype] = np.float32\n ) -> None:\n \"\"\"\n Args:\n as_closest_canonical: if True, load the image as closest to canonical axis format.\n image_only: if True return only the image volume, otherwise return image data array and header dict.\n dtype: if not None convert the loaded image to this data type.\n\n Note:\n The transform returns image data array if `image_only` is True,\n or a tuple of two elements containing the data array, and the Nifti\n header in a dict format otherwise.\n if a dictionary header is returned:\n\n - header['affine'] stores the affine of the image.\n - header['original_affine'] will be additionally created to store the original affine.\n \"\"\"\n self.as_closest_canonical = as_closest_canonical\n self.image_only = image_only\n self.dtype = dtype", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadNifti.__call___LoadNifti.__call__.return.img_array_compatible_met": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadNifti.__call___LoadNifti.__call__.return.img_array_compatible_met", "embedding": null, "metadata": {"file_path": "monai/transforms/io/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 59, "end_line": 106, "span_ids": ["LoadNifti.__call__"], "tokens": 404}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LoadNifti(Transform):\n\n def __call__(self, filename):\n \"\"\"\n Args:\n filename (str, list, tuple, file): path file or file-like object or a list of files.\n \"\"\"\n filename = ensure_tuple(filename)\n img_array = list()\n compatible_meta = dict()\n for name in filename:\n img = nib.load(name)\n img = correct_nifti_header_if_necessary(img)\n header = dict(img.header)\n header[\"filename_or_obj\"] = name\n header[\"affine\"] = img.affine\n header[\"original_affine\"] = img.affine.copy()\n header[\"as_closest_canonical\"] = self.as_closest_canonical\n ndim = img.header[\"dim\"][0]\n spatial_rank = min(ndim, 3)\n header[\"spatial_shape\"] = img.header[\"dim\"][1 : spatial_rank + 1]\n\n if self.as_closest_canonical:\n img = nib.as_closest_canonical(img)\n header[\"affine\"] = img.affine\n\n img_array.append(np.array(img.get_fdata(dtype=self.dtype)))\n img.uncache()\n\n if self.image_only:\n continue\n\n if not compatible_meta:\n for meta_key in header:\n meta_datum = header[meta_key]\n if (\n isinstance(meta_datum, np.ndarray)\n and np_str_obj_array_pattern.search(meta_datum.dtype.str) is not None\n ):\n continue\n compatible_meta[meta_key] = meta_datum\n else:\n assert np.allclose(\n header[\"affine\"], compatible_meta[\"affine\"]\n ), \"affine data of all images should be same.\"\n\n img_array = np.stack(img_array, axis=0) if len(img_array) > 1 else img_array[0]\n if self.image_only:\n return img_array\n return img_array, compatible_meta", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadPNG_LoadPNG.__init__.self.dtype.dtype": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadPNG_LoadPNG.__init__.self.dtype.dtype", "embedding": null, "metadata": {"file_path": "monai/transforms/io/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 109, "end_line": 125, "span_ids": ["LoadPNG", "LoadPNG.__init__"], "tokens": 181}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LoadPNG(Transform):\n \"\"\"\n Load common 2D image format (PNG, JPG, etc. using PIL) file or files from provided path.\n If loading a list of files, stack them together and add a new dimension as first dimension,\n and use the meta data of the first image to represent the stacked result.\n It's based on the Image module in PIL library:\n https://pillow.readthedocs.io/en/stable/reference/Image.html\n \"\"\"\n\n def __init__(self, image_only: bool = False, dtype: Optional[np.dtype] = np.float32) -> None:\n \"\"\"\n Args:\n image_only: if True return only the image volume, otherwise return image data array and metadata.\n dtype: if not None convert the loaded image to this data type.\n \"\"\"\n self.image_only = image_only\n self.dtype = dtype", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadPNG.__call___LoadPNG.__call__.return.img_array_if_self_image_o": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadPNG.__call___LoadPNG.__call__.return.img_array_if_self_image_o", "embedding": null, "metadata": {"file_path": "monai/transforms/io/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 127, "end_line": 161, "span_ids": ["LoadPNG.__call__"], "tokens": 277}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LoadPNG(Transform):\n\n def __call__(self, filename):\n \"\"\"\n Args:\n filename (str, list, tuple, file): path file or file-like object or a list of files.\n \"\"\"\n filename = ensure_tuple(filename)\n img_array = list()\n compatible_meta = None\n for name in filename:\n img = Image.open(name)\n data = np.asarray(img)\n if self.dtype:\n data = data.astype(self.dtype)\n img_array.append(data)\n\n if self.image_only:\n continue\n\n meta = dict()\n meta[\"filename_or_obj\"] = name\n meta[\"spatial_shape\"] = data.shape[:2]\n meta[\"format\"] = img.format\n meta[\"mode\"] = img.mode\n meta[\"width\"] = img.width\n meta[\"height\"] = img.height\n meta[\"info\"] = img.info\n if not compatible_meta:\n compatible_meta = meta\n else:\n assert np.allclose(\n meta[\"spatial_shape\"], compatible_meta[\"spatial_shape\"]\n ), \"all the images in the list should have same spatial shape.\"\n\n img_array = np.stack(img_array, axis=0) if len(img_array) > 1 else img_array[0]\n return img_array if self.image_only else (img_array, compatible_meta)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadNumpy_LoadNumpy.__init__.self.npz_keys.npz_keys": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadNumpy_LoadNumpy.__init__.self.npz_keys.npz_keys", "embedding": null, "metadata": {"file_path": "monai/transforms/io/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 164, "end_line": 191, "span_ids": ["LoadNumpy.__init__", "LoadNumpy"], "tokens": 305}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LoadNumpy(Transform):\n \"\"\"\n Load arrays or pickled objects from .npy, .npz or pickled files, file or files are from provided path.\n A typical usage is to load the `mask` data for classification task.\n If loading a list of files or laoding npz file, stack results together and add a new dimension as first dimension,\n and use the meta data of the first file to represent the stacked result.\n It can load part of the npz file with specified `npz_keys`.\n It's based on the Numpy load/read API:\n https://numpy.org/doc/stable/reference/generated/numpy.load.html\n\n \"\"\"\n\n def __init__(\n self, data_only: bool = False, dtype: Optional[np.dtype] = np.float32, npz_keys: Optional[KeysCollection] = None\n ) -> None:\n \"\"\"\n Args:\n data_only: if True return only the data array, otherwise return data array and metadata.\n dtype: if not None convert the loaded data to this data type.\n npz_keys: if loading npz file, only load the specified keys, if None, load all the items.\n stack the loaded items together to construct a new first dimension.\n\n \"\"\"\n self.data_only = data_only\n self.dtype = dtype\n if npz_keys is not None:\n npz_keys = ensure_tuple(npz_keys)\n self.npz_keys = npz_keys", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadNumpy.__call___LoadNumpy.__call__._save_data_meta.return.compatible_meta": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadNumpy.__call___LoadNumpy.__call__._save_data_meta.return.compatible_meta", "embedding": null, "metadata": {"file_path": "monai/transforms/io/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 193, "end_line": 218, "span_ids": ["LoadNumpy.__call__"], "tokens": 226}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LoadNumpy(Transform):\n\n def __call__(self, filename):\n \"\"\"\n Args:\n filename (str, list, tuple, file): path file or file-like object or a list of files.\n \"\"\"\n if isinstance(filename, (tuple, list)):\n for name in filename:\n if name.endswith(\".npz\"):\n raise TypeError(\"can not load a list of npz file.\")\n filename = ensure_tuple(filename)\n data_array = list()\n compatible_meta = None\n\n def _save_data_meta(data_array, name, data, compatible_meta):\n data_array.append(data if self.dtype is None else data.astype(self.dtype))\n if not self.data_only:\n meta = dict()\n meta[\"filename_or_obj\"] = name\n meta[\"spatial_shape\"] = data.shape\n if not compatible_meta:\n compatible_meta = meta\n else:\n assert np.allclose(\n meta[\"spatial_shape\"], compatible_meta[\"spatial_shape\"]\n ), \"all the data in the list should have same shape.\"\n return compatible_meta\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadNumpy.__call__.for_name_in_filename__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_LoadNumpy.__call__.for_name_in_filename__", "embedding": null, "metadata": {"file_path": "monai/transforms/io/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 220, "end_line": 232, "span_ids": ["LoadNumpy.__call__"], "tokens": 179}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LoadNumpy(Transform):\n\n def __call__(self, filename):\n # ... other code\n\n for name in filename:\n data = np.load(name, allow_pickle=True)\n if name.endswith(\".npz\"):\n # load expected items from NPZ file\n npz_keys = [f\"arr_{i}\" for i in range(len(data))] if self.npz_keys is None else self.npz_keys\n for k in npz_keys:\n compatible_meta = _save_data_meta(data_array, name, data[k], compatible_meta)\n else:\n compatible_meta = _save_data_meta(data_array, name, data, compatible_meta)\n\n data_array = np.stack(data_array, axis=0) if len(data_array) > 1 else data_array[0]\n return data_array if self.data_only else (data_array, compatible_meta)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_from_typing_import_Option_LoadDatad.__init__.self.overwriting.overwriting": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_from_typing_import_Option_LoadDatad.__init__.self.overwriting.overwriting", "embedding": null, "metadata": {"file_path": "monai/transforms/io/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 18, "end_line": 64, "span_ids": ["LoadDatad", "LoadDatad.__init__", "docstring"], "tokens": 451}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Callable\n\nimport numpy as np\n\nfrom monai.config import KeysCollection\nfrom monai.transforms.compose import MapTransform\nfrom monai.transforms.io.array import LoadNifti, LoadPNG, LoadNumpy\n\n\nclass LoadDatad(MapTransform):\n \"\"\"\n Base class for dictionary-based wrapper of IO loader transforms.\n It must load image and metadata together. If loading a list of files in one key,\n stack them together and add a new dimension as the first dimension, and use the\n meta data of the first image to represent the stacked result. Note that the affine\n transform of all the stacked images should be same. The output metadata field will\n be created as ``key_{meta_key_postfix}``.\n \"\"\"\n\n def __init__(\n self, keys: KeysCollection, loader: Callable, meta_key_postfix: str = \"meta_dict\", overwriting: bool = False,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n loader: callable function to load data from expected source.\n typically, it's array level transform, for example: `LoadNifti`,\n `LoadPNG` and `LoadNumpy`, etc.\n meta_key_postfix: use `key_{postfix}` to store the metadata of the loaded data,\n default is `meta_dict`. The meta data is a dictionary object.\n For example, load Nifti file for `image`, store the metadata into `image_meta_dict`.\n overwriting: whether allow to overwrite existing meta data of same key.\n default is False, which will raise exception if encountering existing key.\n\n Raises:\n ValueError: meta_key_postfix must be a string.\n\n \"\"\"\n super().__init__(keys)\n if not callable(loader):\n raise ValueError(\"loader must be a Callable function or object.\")\n self.loader = loader\n if not isinstance(meta_key_postfix, str):\n raise ValueError(\"meta_key_postfix must be a string.\")\n self.meta_key_postfix = meta_key_postfix\n self.overwriting = overwriting", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_LoadDatad.__call___LoadDatad.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_LoadDatad.__call___LoadDatad.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/io/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 66, "end_line": 77, "span_ids": ["LoadDatad.__call__"], "tokens": 140}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LoadDatad(MapTransform):\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n data = self.loader(d[key])\n assert isinstance(data, (tuple, list)), \"loader must return a tuple or list.\"\n d[key] = data[0]\n assert isinstance(data[1], dict), \"metadata must be a dict.\"\n key_to_add = f\"{key}_{self.meta_key_postfix}\"\n if key_to_add in d and not self.overwriting:\n raise KeyError(f\"meta data with key {key_to_add} already exists.\")\n d[key_to_add] = data[1]\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_LoadNiftid_LoadNiftid.__init__.super___init___keys_lo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_LoadNiftid_LoadNiftid.__init__.super___init___keys_lo", "embedding": null, "metadata": {"file_path": "monai/transforms/io/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 80, "end_line": 115, "span_ids": ["LoadNiftid", "LoadNiftid.__init__"], "tokens": 386}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LoadNiftid(LoadDatad):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.LoadNifti`,\n must load image and metadata together. If loading a list of files in one key,\n stack them together and add a new dimension as the first dimension, and use the\n meta data of the first image to represent the stacked result. Note that the affine\n transform of all the stacked images should be same. The output metadata field will\n be created as ``key_{meta_key_postfix}``.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n as_closest_canonical: bool = False,\n dtype: Optional[np.dtype] = np.float32,\n meta_key_postfix: str = \"meta_dict\",\n overwriting: bool = False,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n as_closest_canonical: if True, load the image as closest to canonical axis format.\n dtype: if not None convert the loaded image data to this data type.\n meta_key_postfix: use `key_{postfix}` to store the metadata of the nifti image,\n default is `meta_dict`. The meta data is a dictionary object.\n For example, load nifti file for `image`, store the metadata into `image_meta_dict`.\n overwriting: whether allow to overwrite existing meta data of same key.\n default is False, which will raise exception if encountering existing key.\n\n Raises:\n ValueError: meta_key_postfix must be a string.\n\n \"\"\"\n loader = LoadNifti(as_closest_canonical, False, dtype)\n super().__init__(keys, loader, meta_key_postfix, overwriting)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_LoadPNGd_LoadPNGd.__init__.super___init___keys_lo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_LoadPNGd_LoadPNGd.__init__.super___init___keys_lo", "embedding": null, "metadata": {"file_path": "monai/transforms/io/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 118, "end_line": 146, "span_ids": ["LoadPNGd.__init__", "LoadPNGd"], "tokens": 256}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LoadPNGd(LoadDatad):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.LoadPNG`.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n dtype: Optional[np.dtype] = np.float32,\n meta_key_postfix: str = \"meta_dict\",\n overwriting: bool = False,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n dtype: if not None convert the loaded image data to this data type.\n meta_key_postfix: use `key_{postfix}` to store the metadata of the PNG image,\n default is `meta_dict`. The meta data is a dictionary object.\n For example, load PNG file for `image`, store the metadata into `image_meta_dict`.\n overwriting: whether allow to overwrite existing meta data of same key.\n default is False, which will raise exception if encountering existing key.\n\n Raises:\n ValueError: meta_key_postfix must be a string.\n\n \"\"\"\n loader = LoadPNG(False, dtype)\n super().__init__(keys, loader, meta_key_postfix, overwriting)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_LoadNumpyd_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_LoadNumpyd_", "embedding": null, "metadata": {"file_path": "monai/transforms/io/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 149, "end_line": 186, "span_ids": ["LoadNumpyd.__init__", "LoadNumpyd", "impl"], "tokens": 365}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LoadNumpyd(LoadDatad):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.LoadNumpy`.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n dtype: Optional[np.dtype] = np.float32,\n npz_keys: Optional[KeysCollection] = None,\n meta_key_postfix: str = \"meta_dict\",\n overwriting: bool = False,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n dtype: if not None convert the loaded data to this data type.\n npz_keys: if loading npz file, only load the specified keys, if None, load all the items.\n stack the loaded items together to construct a new first dimension.\n meta_key_postfix: use `key_{postfix}` to store the metadata of the Numpy data,\n default is `meta_dict`. The meta data is a dictionary object.\n For example, load Numpy file for `mask`, store the metadata into `mask_meta_dict`.\n overwriting: whether allow to overwrite existing meta data of same key.\n default is False, which will raise exception if encountering existing key.\n\n Raises:\n ValueError: meta_key_postfix must be a string.\n\n \"\"\"\n loader = LoadNumpy(data_only=False, dtype=dtype, npz_keys=npz_keys)\n super().__init__(keys, loader, meta_key_postfix, overwriting)\n\n\nLoadNiftiD = LoadNiftiDict = LoadNiftid\nLoadPNGD = LoadPNGDict = LoadPNGd\nLoadNumpyD = LoadNumpyDict = LoadNumpyd", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/__init__.py__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/__init__.py__", "embedding": null, "metadata": {"file_path": "monai/transforms/post/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 11, "end_line": 11, "span_ids": [], "tokens": 0}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_from_typing_import_Callab_SplitChannel.__init__.self.num_classes.num_classes": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_from_typing_import_Callab_SplitChannel.__init__.self.num_classes.num_classes", "embedding": null, "metadata": {"file_path": "monai/transforms/post/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 16, "end_line": 43, "span_ids": ["SplitChannel", "SplitChannel.__init__", "docstring"], "tokens": 260}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Optional, Sequence, Union\nimport numpy as np\nimport torch\nimport torch.nn.functional as F\n\nfrom monai.transforms.compose import Transform\nfrom monai.networks import one_hot\nfrom monai.transforms.utils import get_largest_connected_component_mask\nfrom monai.utils import ensure_tuple\n\n\nclass SplitChannel(Transform):\n \"\"\"\n Split PyTorch Tensor data according to the channel dim, if only 1 channel, convert to One-Hot\n format first based on the class number. Users can use this transform to compute metrics on every\n single class to get more details of validation/evaluation. Expected input shape:\n ``(batch_size, num_channels, [spatial_dim_1, spatial_dim_2, ...])``\n\n Args:\n to_onehot: whether to convert the data to One-Hot format first.\n Defaults to ``False``.\n num_classes: the class number used to convert to One-Hot format if `to_onehot` is True.\n Defaults to ``None``.\n \"\"\"\n\n def __init__(self, to_onehot: bool = False, num_classes: Optional[int] = None) -> None:\n self.to_onehot = to_onehot\n self.num_classes = num_classes", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_SplitChannel.__call___SplitChannel.__call__.return.outputs": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_SplitChannel.__call___SplitChannel.__call__.return.outputs", "embedding": null, "metadata": {"file_path": "monai/transforms/post/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 45, "end_line": 63, "span_ids": ["SplitChannel.__call__"], "tokens": 195}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SplitChannel(Transform):\n\n def __call__(self, img: torch.Tensor, to_onehot: Optional[bool] = None, num_classes: Optional[int] = None):\n \"\"\"\n Args:\n to_onehot: whether to convert the data to One-Hot format first.\n Defaults to ``self.to_onehot``.\n num_classes: the class number used to convert to One-Hot format if `to_onehot` is True.\n Defaults to ``self.num_classes``.\n \"\"\"\n if to_onehot or self.to_onehot:\n if num_classes is None:\n num_classes = self.num_classes\n assert isinstance(num_classes, int), \"must specify class number for One-Hot.\"\n img = one_hot(img, num_classes)\n n_classes = img.shape[1]\n outputs = list()\n for i in range(n_classes):\n outputs.append(img[:, i : i + 1])\n\n return outputs", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_Activations_Activations.__init__.self.other.other": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_Activations_Activations.__init__.self.other.other", "embedding": null, "metadata": {"file_path": "monai/transforms/post/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 66, "end_line": 83, "span_ids": ["Activations.__init__", "Activations"], "tokens": 154}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Activations(Transform):\n \"\"\"\n Add activation operations to the model output, typically `Sigmoid` or `Softmax`.\n\n Args:\n sigmoid: whether to execute sigmoid function on model output before transform.\n Defaults to ``False``.\n softmax: whether to execute softmax function on model output before transform.\n Defaults to ``False``.\n other: callable function to execute other activation layers, for example:\n `other = lambda x: torch.tanh(x)`. Defaults to ``None``.\n\n \"\"\"\n\n def __init__(self, sigmoid: bool = False, softmax: bool = False, other: Optional[Callable] = None) -> None:\n self.sigmoid = sigmoid\n self.softmax = softmax\n self.other = other", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_Activations.__call___Activations.__call__.return.img": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_Activations.__call___Activations.__call__.return.img", "embedding": null, "metadata": {"file_path": "monai/transforms/post/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 85, "end_line": 118, "span_ids": ["Activations.__call__"], "tokens": 267}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Activations(Transform):\n\n def __call__(\n self,\n img: torch.Tensor,\n sigmoid: Optional[bool] = None,\n softmax: Optional[bool] = None,\n other: Optional[Callable] = None,\n ):\n \"\"\"\n Args:\n sigmoid: whether to execute sigmoid function on model output before transform.\n Defaults to ``self.sigmoid``.\n softmax: whether to execute softmax function on model output before transform.\n Defaults to ``self.softmax``.\n other: callable function to execute other activation layers, for example:\n `other = lambda x: torch.tanh(x)`. Defaults to ``self.other``.\n\n Raises:\n ValueError: sigmoid=True and softmax=True are not compatible.\n ValueError: act_func must be a Callable function.\n\n \"\"\"\n if sigmoid is True and softmax is True:\n raise ValueError(\"sigmoid=True and softmax=True are not compatible.\")\n if sigmoid or self.sigmoid:\n img = torch.sigmoid(img)\n if softmax or self.softmax:\n img = torch.softmax(img, dim=1)\n act_func = self.other if other is None else other\n if act_func is not None:\n if not callable(act_func):\n raise ValueError(\"act_func must be a Callable function.\")\n img = act_func(img)\n\n return img", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_AsDiscrete_AsDiscrete.__init__.self.logit_thresh.logit_thresh": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_AsDiscrete_AsDiscrete.__init__.self.logit_thresh.logit_thresh", "embedding": null, "metadata": {"file_path": "monai/transforms/post/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 121, "end_line": 156, "span_ids": ["AsDiscrete.__init__", "AsDiscrete"], "tokens": 293}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AsDiscrete(Transform):\n \"\"\"\n Execute after model forward to transform model output to discrete values.\n It can complete below operations:\n\n - execute `argmax` for input logits values.\n - threshold input value to 0.0 or 1.0.\n - convert input value to One-Hot format\n\n Args:\n argmax: whether to execute argmax function on input data before transform.\n Defaults to ``False``.\n to_onehot: whether to convert input data into the one-hot format.\n Defaults to ``False``.\n n_classes: the number of classes to convert to One-Hot format.\n Defaults to ``None``.\n threshold_values: whether threshold the float value to int number 0 or 1.\n Defaults to ``False``.\n logit_thresh: the threshold value for thresholding operation..\n Defaults to ``0.5``.\n\n \"\"\"\n\n def __init__(\n self,\n argmax: bool = False,\n to_onehot: bool = False,\n n_classes: Optional[int] = None,\n threshold_values: bool = False,\n logit_thresh: float = 0.5,\n ) -> None:\n self.argmax = argmax\n self.to_onehot = to_onehot\n self.n_classes = n_classes\n self.threshold_values = threshold_values\n self.logit_thresh = logit_thresh", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_AsDiscrete.__call___AsDiscrete.__call__.return.img_float_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_AsDiscrete.__call___AsDiscrete.__call__.return.img_float_", "embedding": null, "metadata": {"file_path": "monai/transforms/post/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 158, "end_line": 192, "span_ids": ["AsDiscrete.__call__"], "tokens": 329}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AsDiscrete(Transform):\n\n def __call__(\n self,\n img: torch.Tensor,\n argmax: Optional[bool] = None,\n to_onehot: Optional[bool] = None,\n n_classes: Optional[int] = None,\n threshold_values: Optional[bool] = None,\n logit_thresh: Optional[float] = None,\n ):\n \"\"\"\n Args:\n argmax: whether to execute argmax function on input data before transform.\n Defaults to ``self.argmax``.\n to_onehot: whether to convert input data into the one-hot format.\n Defaults to ``self.to_onehot``.\n n_classes: the number of classes to convert to One-Hot format.\n Defaults to ``self.n_classes``.\n threshold_values: whether threshold the float value to int number 0 or 1.\n Defaults to ``self.threshold_values``.\n logit_thresh: the threshold value for thresholding operation..\n Defaults to ``self.logit_thresh``.\n\n \"\"\"\n if argmax or self.argmax:\n img = torch.argmax(img, dim=1, keepdim=True)\n\n if to_onehot or self.to_onehot:\n _nclasses = self.n_classes if n_classes is None else n_classes\n assert isinstance(_nclasses, int), \"One of self.n_classes or n_classes must be an integer\"\n img = one_hot(img, _nclasses)\n\n if threshold_values or self.threshold_values:\n img = img >= (self.logit_thresh if logit_thresh is None else logit_thresh)\n\n return img.float()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_KeepLargestConnectedComponent_KeepLargestConnectedComponent._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_KeepLargestConnectedComponent_KeepLargestConnectedComponent._", "embedding": null, "metadata": {"file_path": "monai/transforms/post/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 195, "end_line": 239, "span_ids": ["KeepLargestConnectedComponent"], "tokens": 782}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class KeepLargestConnectedComponent(Transform):\n \"\"\"\n Keeps only the largest connected component in the image.\n This transform can be used as a post-processing step to clean up over-segment areas in model output.\n\n The input is assumed to be a PyTorch Tensor:\n 1) With shape (batch_size, 1, spatial_dim1[, spatial_dim2, ...]) and the values correspond to expected labels.\n 2) With shape (batch_size, C, spatial_dim1[, spatial_dim2, ...]) and the values should be 0, 1 on each labels.\n\n Note:\n For single channel data, 0 will be treated as background and the over-segment pixels will be set to 0.\n For one-hot data, the over-segment pixels will be set to 0 in its channel.\n\n For example:\n Use KeepLargestConnectedComponent with applied_labels=[1], connectivity=1::\n\n [1, 0, 0] [0, 0, 0]\n [0, 1, 1] => [0, 1 ,1]\n [0, 1, 1] [0, 1, 1]\n\n Use KeepLargestConnectedComponent with applied_labels[1, 2], independent=False, connectivity=1::\n\n [0, 0, 1, 0 ,0] [0, 0, 1, 0 ,0]\n [0, 2, 1, 1 ,1] [0, 2, 1, 1 ,1]\n [1, 2, 1, 0 ,0] => [1, 2, 1, 0 ,0]\n [1, 2, 0, 1 ,0] [1, 2, 0, 0 ,0]\n [2, 2, 0, 0 ,2] [2, 2, 0, 0 ,0]\n\n Use KeepLargestConnectedComponent with applied_labels[1, 2], independent=True, connectivity=1::\n\n [0, 0, 1, 0 ,0] [0, 0, 1, 0 ,0]\n [0, 2, 1, 1 ,1] [0, 2, 1, 1 ,1]\n [1, 2, 1, 0 ,0] => [0, 2, 1, 0 ,0]\n [1, 2, 0, 1 ,0] [0, 2, 0, 0 ,0]\n [2, 2, 0, 0 ,2] [2, 2, 0, 0 ,0]\n\n Use KeepLargestConnectedComponent with applied_labels[1, 2], independent=False, connectivity=2::\n\n [0, 0, 1, 0 ,0] [0, 0, 1, 0 ,0]\n [0, 2, 1, 1 ,1] [0, 2, 1, 1 ,1]\n [1, 2, 1, 0 ,0] => [1, 2, 1, 0 ,0]\n [1, 2, 0, 1 ,0] [1, 2, 0, 1 ,0]\n [2, 2, 0, 0 ,2] [2, 2, 0, 0 ,2]\n\n \"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_KeepLargestConnectedComponent.__init___KeepLargestConnectedComponent.__init__.self.connectivity.connectivity": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_KeepLargestConnectedComponent.__init___KeepLargestConnectedComponent.__init__.self.connectivity.connectivity", "embedding": null, "metadata": {"file_path": "monai/transforms/post/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 241, "end_line": 259, "span_ids": ["KeepLargestConnectedComponent.__init__"], "tokens": 237}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class KeepLargestConnectedComponent(Transform):\n\n def __init__(\n self, applied_labels: Union[Sequence[int], int], independent: bool = True, connectivity: Optional[int] = None\n ) -> None:\n \"\"\"\n Args:\n applied_labels: Labels for applying the connected component on.\n If only one channel. The pixel whose value is not in this list will remain unchanged.\n If the data is in one-hot format, this is used to determine what channels to apply.\n independent: consider several labels as a whole or independent, default is `True`.\n Example use case would be segment label 1 is liver and label 2 is liver tumor, in that case\n you want this \"independent\" to be specified as False.\n connectivity: Maximum number of orthogonal hops to consider a pixel/voxel as a neighbor.\n Accepted values are ranging from 1 to input.ndim. If ``None``, a full\n connectivity of ``input.ndim`` is used.\n \"\"\"\n super().__init__()\n self.applied_labels = ensure_tuple(applied_labels)\n self.independent = independent\n self.connectivity = connectivity", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_KeepLargestConnectedComponent.__call___KeepLargestConnectedComponent.__call__.return.output": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_KeepLargestConnectedComponent.__call___KeepLargestConnectedComponent.__call__.return.output", "embedding": null, "metadata": {"file_path": "monai/transforms/post/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 261, "end_line": 303, "span_ids": ["KeepLargestConnectedComponent.__call__"], "tokens": 442}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class KeepLargestConnectedComponent(Transform):\n\n def __call__(self, img: torch.Tensor):\n \"\"\"\n Args:\n img: shape must be (batch_size, C, spatial_dim1[, spatial_dim2, ...]).\n\n Returns:\n A PyTorch Tensor with shape (batch_size, C, spatial_dim1[, spatial_dim2, ...]).\n \"\"\"\n channel_dim = 1\n if img.shape[channel_dim] == 1:\n\n img = torch.squeeze(img, dim=channel_dim)\n\n if self.independent:\n for i in self.applied_labels:\n foreground = (img == i).type(torch.uint8)\n mask = get_largest_connected_component_mask(foreground, self.connectivity)\n img[foreground != mask] = 0\n else:\n foreground = torch.zeros_like(img)\n for i in self.applied_labels:\n foreground += (img == i).type(torch.uint8)\n mask = get_largest_connected_component_mask(foreground, self.connectivity)\n img[foreground != mask] = 0\n output = torch.unsqueeze(img, dim=channel_dim)\n else:\n # one-hot data is assumed to have binary value in each channel\n if self.independent:\n for i in self.applied_labels:\n foreground = img[:, i, ...].type(torch.uint8)\n mask = get_largest_connected_component_mask(foreground, self.connectivity)\n img[:, i, ...][foreground != mask] = 0\n else:\n applied_img = img[:, self.applied_labels, ...].type(torch.uint8)\n foreground = torch.any(applied_img, dim=channel_dim)\n mask = get_largest_connected_component_mask(foreground, self.connectivity)\n background_mask = torch.unsqueeze(foreground != mask, dim=channel_dim)\n background_mask = torch.repeat_interleave(background_mask, len(self.applied_labels), dim=channel_dim)\n applied_img[background_mask] = 0\n img[:, self.applied_labels, ...] = applied_img.type(img.type())\n output = img\n\n return output", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_LabelToContour_LabelToContour.__init__.self.kernel_type.kernel_type": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_LabelToContour_LabelToContour.__init__.self.kernel_type.kernel_type", "embedding": null, "metadata": {"file_path": "monai/transforms/post/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 306, "end_line": 319, "span_ids": ["LabelToContour", "LabelToContour.__init__"], "tokens": 130}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LabelToContour(Transform):\n \"\"\"\n Return the contour of binary input images that only compose of 0 and 1, with Laplace kernel\n set as default for edge detection. Typical usage is to plot the edge of label or segmentation output.\n\n Args:\n kernel_type: the method applied to do edge detection, default is \"Laplace\".\n\n \"\"\"\n\n def __init__(self, kernel_type: str = \"Laplace\") -> None:\n if kernel_type != \"Laplace\":\n raise NotImplementedError(\"currently, LabelToContour only supports Laplace kernel.\")\n self.kernel_type = kernel_type", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_LabelToContour.__call___LabelToContour.__call__.return.contour_img": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_LabelToContour.__call___LabelToContour.__call__.return.contour_img", "embedding": null, "metadata": {"file_path": "monai/transforms/post/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 321, "end_line": 348, "span_ids": ["LabelToContour.__call__"], "tokens": 390}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LabelToContour(Transform):\n\n def __call__(self, img: torch.Tensor):\n \"\"\"\n Args:\n img: torch tensor data to extract the contour, with shape: [batch_size, channels, height, width[, depth]]\n\n Returns:\n A torch tensor with the same shape as img, note:\n 1. it's the binary classification result of whether a pixel is edge or not.\n 2. in order to keep the original shape of mask image, we use padding as default.\n 3. the edge detection is just approximate because it defects inherent to Laplace kernel,\n ideally the edge should be thin enough, but now it has a thickness.\n\n \"\"\"\n channels = img.shape[1]\n if img.ndim == 4:\n kernel = torch.tensor([[-1, -1, -1], [-1, 8, -1], [-1, -1, -1]], dtype=torch.float32, device=img.device)\n kernel = kernel.repeat(channels, 1, 1, 1)\n contour_img = F.conv2d(img, kernel, bias=None, stride=1, padding=1, dilation=1, groups=channels)\n elif img.ndim == 5:\n kernel = -1 * torch.ones(3, 3, 3, dtype=torch.float32, device=img.device)\n kernel[1, 1, 1] = 26\n kernel = kernel.repeat(channels, 1, 1, 1, 1)\n contour_img = F.conv3d(img, kernel, bias=None, stride=1, padding=1, dilation=1, groups=channels)\n else:\n raise RuntimeError(\"the dimensions of img should be 4 or 5.\")\n\n contour_img.clamp_(min=0.0, max=1.0)\n return contour_img", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_MeanEnsemble_MeanEnsemble.__init__.self.weights.torch_as_tensor_weights_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_MeanEnsemble_MeanEnsemble.__init__.self.weights.torch_as_tensor_weights_", "embedding": null, "metadata": {"file_path": "monai/transforms/post/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 351, "end_line": 374, "span_ids": ["MeanEnsemble", "MeanEnsemble.__init__"], "tokens": 401}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class MeanEnsemble(Transform):\n \"\"\"\n Execute mean ensemble on the input data.\n The input data can be a list or tuple of PyTorch Tensor with shape: [B, C, H, W[, D]],\n Or a single PyTorch Tensor with shape: [E, B, C, H, W[, D]], the `E` dimension represents\n the output data from different models.\n And it also can support to add `weights` for the input data.\n\n Args:\n weights: can be a list or tuple of numbers for input data with shape: [E, B, C, H, W[, D]].\n or a Numpy ndarray or a PyTorch Tensor data.\n the `weights` will be added to input data from highest dimension, for example:\n 1. if the `weights` only has 1 dimension, it will be added to the `E` dimension of input data.\n 2. if the `weights` has 3 dimensions, it will be added to `E`, `B` and `C` dimensions.\n it's a typical practice to add weights for different classes:\n to ensemble 3 segmentation model outputs, every output has 4 channels(classes),\n so the input data shape can be: [3, B, 4, H, W, D].\n and add different `weights` for different classes, so the `weights` shape can be: [3, 1, 4].\n for example: `weights = [[[1, 2, 3, 4]], [[4, 3, 2, 1]], [[1, 1, 1, 1]]]`.\n\n \"\"\"\n\n def __init__(self, weights: Optional[Union[Sequence[float], torch.Tensor, np.ndarray]] = None):\n self.weights = torch.as_tensor(weights, dtype=torch.float) if weights is not None else None", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_MeanEnsemble.__call___": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_MeanEnsemble.__call___", "embedding": null, "metadata": {"file_path": "monai/transforms/post/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 376, "end_line": 388, "span_ids": ["MeanEnsemble.__call__"], "tokens": 135}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class MeanEnsemble(Transform):\n\n def __call__(self, img: Union[Sequence[torch.Tensor], torch.Tensor]):\n img_: torch.Tensor = torch.stack(img) if isinstance(img, (tuple, list)) else torch.as_tensor(img)\n if self.weights is not None:\n self.weights = self.weights.to(img_.device)\n shape = tuple(self.weights.shape)\n for _ in range(img_.ndim - self.weights.ndim):\n shape += (1,)\n weights = self.weights.reshape(*shape)\n\n img_ = img_ * weights / weights.mean(dim=0, keepdim=True)\n\n return torch.mean(img_, dim=0)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_from_typing_import_Option_SplitChanneld.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_from_typing_import_Option_SplitChanneld.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/post/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 18, "end_line": 78, "span_ids": ["SplitChanneld.__call__", "SplitChanneld.__init__", "SplitChanneld", "docstring"], "tokens": 554}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Union, Sequence, Callable\nimport numpy as np\nimport torch\nfrom monai.config import KeysCollection\nfrom monai.utils import ensure_tuple_rep\nfrom monai.transforms.compose import MapTransform\nfrom monai.transforms.post.array import (\n SplitChannel,\n Activations,\n AsDiscrete,\n KeepLargestConnectedComponent,\n LabelToContour,\n MeanEnsemble,\n)\n\n\nclass SplitChanneld(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.SplitChannel`.\n All the input specified by `keys` should be splitted into same count of data.\n\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n output_postfixes: Sequence[str],\n to_onehot: Union[Sequence[bool], bool] = False,\n num_classes: Optional[Union[Sequence[int], int]] = None,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n output_postfixes: the postfixes to construct keys to store split data.\n for example: if the key of input data is `pred` and split 2 classes, the output\n data keys will be: pred_(output_postfixes[0]), pred_(output_postfixes[1])\n to_onehot: whether to convert the data to One-Hot format, default is False.\n it also can be a sequence of bool, each element corresponds to a key in ``keys``.\n num_classes: the class number used to convert to One-Hot format\n if `to_onehot` is True. it also can be a sequence of int, each element corresponds\n to a key in ``keys``.\n\n Raises:\n ValueError: must specify key postfixes to store splitted data.\n\n \"\"\"\n super().__init__(keys)\n self.output_postfixes = output_postfixes\n self.to_onehot = ensure_tuple_rep(to_onehot, len(self.keys))\n self.num_classes = ensure_tuple_rep(num_classes, len(self.keys))\n self.splitter = SplitChannel()\n\n def __call__(self, data):\n d = dict(data)\n for idx, key in enumerate(self.keys):\n rets = self.splitter(d[key], self.to_onehot[idx], self.num_classes[idx])\n assert len(self.output_postfixes) == len(rets), \"count of split results must match output_postfixes.\"\n for i, r in enumerate(rets):\n d[f\"{key}_{self.output_postfixes[i]}\"] = r\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_Activationsd_Activationsd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_Activationsd_Activationsd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/post/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 81, "end_line": 117, "span_ids": ["Activationsd.__call__", "Activationsd", "Activationsd.__init__"], "tokens": 363}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Activationsd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.AddActivations`.\n Add activation layers to the input data specified by `keys`.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n sigmoid: Union[Sequence[bool], bool] = False,\n softmax: Union[Sequence[bool], bool] = False,\n other: Optional[Union[Sequence[Callable], Callable]] = None,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to model output and label.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n sigmoid: whether to execute sigmoid function on model output before transform.\n it also can be a sequence of bool, each element corresponds to a key in ``keys``.\n softmax: whether to execute softmax function on model output before transform.\n it also can be a sequence of bool, each element corresponds to a key in ``keys``.\n other: callable function to execute other activation layers,\n for example: `other = lambda x: torch.tanh(x)`. it also can be a sequence of Callable, each\n element corresponds to a key in ``keys``.\n\n \"\"\"\n super().__init__(keys)\n self.sigmoid = ensure_tuple_rep(sigmoid, len(self.keys))\n self.softmax = ensure_tuple_rep(softmax, len(self.keys))\n self.other = ensure_tuple_rep(other, len(self.keys))\n self.converter = Activations()\n\n def __call__(self, data):\n d = dict(data)\n for idx, key in enumerate(self.keys):\n d[key] = self.converter(d[key], self.sigmoid[idx], self.softmax[idx], self.other[idx])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_AsDiscreted_AsDiscreted.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_AsDiscreted_AsDiscreted.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/post/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 120, "end_line": 169, "span_ids": ["AsDiscreted", "AsDiscreted.__call__", "AsDiscreted.__init__"], "tokens": 530}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AsDiscreted(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.AsDiscrete`.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n argmax: Union[Sequence[bool], bool] = False,\n to_onehot: Union[Sequence[bool], bool] = False,\n n_classes: Optional[Union[Sequence[int], int]] = None,\n threshold_values: Union[Sequence[bool], bool] = False,\n logit_thresh: Union[Sequence[float], float] = 0.5,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to model output and label.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n argmax: whether to execute argmax function on input data before transform.\n it also can be a sequence of bool, each element corresponds to a key in ``keys``.\n to_onehot: whether to convert input data into the one-hot format. Defaults to False.\n it also can be a sequence of bool, each element corresponds to a key in ``keys``.\n n_classes: the number of classes to convert to One-Hot format. it also can be a\n sequence of int, each element corresponds to a key in ``keys``.\n threshold_values: whether threshold the float value to int number 0 or 1, default is False.\n it also can be a sequence of bool, each element corresponds to a key in ``keys``.\n logit_thresh: the threshold value for thresholding operation, default is 0.5.\n it also can be a sequence of float, each element corresponds to a key in ``keys``.\n\n \"\"\"\n super().__init__(keys)\n self.argmax = ensure_tuple_rep(argmax, len(self.keys))\n self.to_onehot = ensure_tuple_rep(to_onehot, len(self.keys))\n self.n_classes = ensure_tuple_rep(n_classes, len(self.keys))\n self.threshold_values = ensure_tuple_rep(threshold_values, len(self.keys))\n self.logit_thresh = ensure_tuple_rep(logit_thresh, len(self.keys))\n self.converter = AsDiscrete()\n\n def __call__(self, data):\n d = dict(data)\n for idx, key in enumerate(self.keys):\n d[key] = self.converter(\n d[key],\n self.argmax[idx],\n self.to_onehot[idx],\n self.n_classes[idx],\n self.threshold_values[idx],\n self.logit_thresh[idx],\n )\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_KeepLargestConnectedComponentd_KeepLargestConnectedComponentd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_KeepLargestConnectedComponentd_KeepLargestConnectedComponentd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/post/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 172, "end_line": 206, "span_ids": ["KeepLargestConnectedComponentd.__init__", "KeepLargestConnectedComponentd", "KeepLargestConnectedComponentd.__call__"], "tokens": 326}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class KeepLargestConnectedComponentd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:monai.transforms.KeepLargestConnectedComponent.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n applied_labels: Union[Sequence[int], int],\n independent: bool = True,\n connectivity: Optional[int] = None,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n applied_labels: Labels for applying the connected component on.\n If only one channel. The pixel whose value is not in this list will remain unchanged.\n If the data is in one-hot format, this is the channel indexes to apply transform.\n independent: consider several labels as a whole or independent, default is `True`.\n Example use case would be segment label 1 is liver and label 2 is liver tumor, in that case\n you want this \"independent\" to be specified as False.\n connectivity: Maximum number of orthogonal hops to consider a pixel/voxel as a neighbor.\n Accepted values are ranging from 1 to input.ndim. If ``None``, a full\n connectivity of ``input.ndim`` is used.\n\n \"\"\"\n super().__init__(keys)\n self.converter = KeepLargestConnectedComponent(applied_labels, independent, connectivity)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.converter(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_LabelToContourd_LabelToContourd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_LabelToContourd_LabelToContourd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/post/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 209, "end_line": 229, "span_ids": ["LabelToContourd.__init__", "LabelToContourd", "LabelToContourd.__call__"], "tokens": 163}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LabelToContourd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:monai.transforms.LabelToContour.\n \"\"\"\n\n def __init__(self, keys: KeysCollection, kernel_type: str = \"Laplace\") -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n kernel_type: the method applied to do edge detection, default is \"Laplace\".\n\n \"\"\"\n super().__init__(keys)\n self.converter = LabelToContour(kernel_type=kernel_type)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.converter(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_MeanEnsembled_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_MeanEnsembled_", "embedding": null, "metadata": {"file_path": "monai/transforms/post/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 232, "end_line": 284, "span_ids": ["MeanEnsembled", "MeanEnsembled.__call__", "MeanEnsembled.__init__", "impl"], "tokens": 636}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class MeanEnsembled(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:monai.transforms.MeanEnsemble.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n output_key: Optional[str] = None,\n weights: Optional[Union[Sequence[float], torch.Tensor, np.ndarray]] = None,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be stack and execute ensemble.\n if only 1 key provided, suppose it's a PyTorch Tensor with data stacked on dimension `E`.\n output_key: the key to store ensemble result in the dictionary.\n if only 1 key provided in `keys`, `output_key` can be None and use `keys` as default.\n weights: can be a list or tuple of numbers for input data with shape: [E, B, C, H, W[, D]].\n or a Numpy ndarray or a PyTorch Tensor data.\n the `weights` will be added to input data from highest dimension, for example:\n 1. if the `weights` only has 1 dimension, it will be added to the `E` dimension of input data.\n 2. if the `weights` has 3 dimensions, it will be added to `E`, `B` and `C` dimensions.\n it's a typical practice to add weights for different classes:\n to ensemble 3 segmentation model outputs, every output has 4 channels(classes),\n so the input data shape can be: [3, B, 4, H, W, D].\n and add different `weights` for different classes, so the `weights` shape can be: [3, 1, 4].\n for example: `weights = [[[1, 2, 3, 4]], [[4, 3, 2, 1]], [[1, 1, 1, 1]]]`.\n\n \"\"\"\n super().__init__(keys)\n if len(self.keys) > 1 and output_key is None:\n raise ValueError(\"must provide expected key to store the output data.\")\n self.output_key = output_key if output_key is not None else self.keys[0]\n self.ensemble = MeanEnsemble(weights=weights)\n\n def __call__(self, data):\n d = dict(data)\n if len(self.keys) == 1:\n items = d[self.keys[0]]\n else:\n items = [d[key] for key in self.keys]\n d[self.output_key] = self.ensemble(items)\n\n return d\n\n\nSplitChannelD = SplitChannelDict = SplitChanneld\nActivationsD = ActivationsDict = Activationsd\nAsDiscreteD = AsDiscreteDict = AsDiscreted\nKeepLargestConnectedComponentD = KeepLargestConnectedComponentDict = KeepLargestConnectedComponentd\nLabelToContourD = LabelToContourDict = LabelToContourd\nMeanEnsembleD = MeanEnsembleDict = MeanEnsembled", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/__init__.py__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/__init__.py__", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 11, "end_line": 11, "span_ids": [], "tokens": 0}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_from_typing_import_Callab_if_get_torch_version_tupl.else_._torch_interp.torch_nn_functional_inter": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_from_typing_import_Callab_if_get_torch_version_tupl.else_._torch_interp.torch_nn_functional_inter", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 16, "end_line": 59, "span_ids": ["docstring"], "tokens": 262}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, List, Optional, Sequence, Tuple, Union, Any\n\nimport warnings\n\nimport numpy as np\nimport torch\n\nfrom monai.config import get_torch_version_tuple\nfrom monai.data.utils import compute_shape_offset, to_affine_nd, zoom_affine\nfrom monai.networks.layers import AffineTransform, GaussianFilter\nfrom monai.transforms.compose import Randomizable, Transform\nfrom monai.transforms.croppad.array import CenterSpatialCrop\nfrom monai.transforms.utils import (\n create_control_grid,\n create_grid,\n create_rotate,\n create_scale,\n create_shear,\n create_translate,\n)\nfrom monai.utils import (\n optional_import,\n GridSampleMode,\n GridSamplePadMode,\n InterpolateMode,\n NumpyPadMode,\n ensure_tuple,\n ensure_tuple_rep,\n ensure_tuple_size,\n fall_back_tuple,\n)\n\nnib, _ = optional_import(\"nibabel\")\n\n_torch_interp: Callable\n\nif get_torch_version_tuple() >= (1, 5):\n # additional argument since torch 1.5 (to avoid warnings)\n def _torch_interp(**kwargs):\n return torch.nn.functional.interpolate(recompute_scale_factor=True, **kwargs)\n\n\nelse:\n _torch_interp = torch.nn.functional.interpolate", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Spacing_Spacing.__init__.self.dtype.dtype": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Spacing_Spacing.__init__.self.dtype.dtype", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 62, "end_line": 101, "span_ids": ["Spacing.__init__", "Spacing"], "tokens": 428}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Spacing(Transform):\n \"\"\"\n Resample input image into the specified `pixdim`.\n \"\"\"\n\n def __init__(\n self,\n pixdim: Union[Sequence[float], float],\n diagonal: bool = False,\n mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,\n padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.BORDER,\n dtype: Optional[np.dtype] = None,\n ) -> None:\n \"\"\"\n Args:\n pixdim: output voxel spacing.\n diagonal: whether to resample the input to have a diagonal affine matrix.\n If True, the input data is resampled to the following affine::\n\n np.diag((pixdim_0, pixdim_1, ..., pixdim_n, 1))\n\n This effectively resets the volume to the world coordinate system (RAS+ in nibabel).\n The original orientation, rotation, shearing are not preserved.\n\n If False, this transform preserves the axes orientation, orthogonal rotation and\n translation components from the original affine. This option will not flip/swap axes\n of the original data.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``\"border\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n dtype: output array data type. Defaults to ``np.float32``.\n \"\"\"\n self.pixdim = np.array(ensure_tuple(pixdim), dtype=np.float64)\n self.diagonal = diagonal\n self.mode: GridSampleMode = GridSampleMode(mode)\n self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)\n self.dtype = dtype", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Spacing.__call___Spacing.__call__.return.output_data_affine_new_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Spacing.__call___Spacing.__call__.return.output_data_affine_new_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 103, "end_line": 175, "span_ids": ["Spacing.__call__"], "tokens": 790}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Spacing(Transform):\n\n def __call__(\n self,\n data_array: np.ndarray,\n affine=None,\n mode: Optional[Union[GridSampleMode, str]] = None,\n padding_mode: Optional[Union[GridSamplePadMode, str]] = None,\n dtype: Optional[np.dtype] = None,\n ):\n \"\"\"\n Args:\n data_array: in shape (num_channels, H[, W, ...]).\n affine (matrix): (N+1)x(N+1) original affine matrix for spatially ND `data_array`. Defaults to identity.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``self.mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``self.padding_mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n dtype: output array data type. Defaults to ``self.dtype``.\n\n Returns:\n data_array (resampled into `self.pixdim`), original pixdim, current pixdim.\n\n Raises:\n ValueError: the array should have at least one spatial dimension.\n ValueError: pixdim must be positive, got {out_d}\n\n \"\"\"\n sr = data_array.ndim - 1\n if sr <= 0:\n raise ValueError(\"the array should have at least one spatial dimension.\")\n if affine is None:\n # default to identity\n affine = np.eye(sr + 1, dtype=np.float64)\n affine_ = np.eye(sr + 1, dtype=np.float64)\n else:\n affine_ = to_affine_nd(sr, affine)\n out_d = self.pixdim[:sr]\n if out_d.size < sr:\n out_d = np.append(out_d, [1.0] * (out_d.size - sr))\n if np.any(out_d <= 0):\n raise ValueError(f\"pixdim must be positive, got {out_d}\")\n # compute output affine, shape and offset\n new_affine = zoom_affine(affine_, out_d, diagonal=self.diagonal)\n output_shape, offset = compute_shape_offset(data_array.shape[1:], affine_, new_affine)\n new_affine[:sr, -1] = offset[:sr]\n transform = np.linalg.inv(affine_) @ new_affine\n # adapt to the actual rank\n transform_ = to_affine_nd(sr, transform)\n _dtype = dtype or self.dtype or np.float32\n\n # no resampling if it's identity transform\n if np.allclose(transform_, np.diag(np.ones(len(transform_))), atol=1e-3):\n output_data = data_array.copy().astype(_dtype)\n new_affine = to_affine_nd(affine, new_affine)\n return output_data, affine, new_affine\n\n # resample\n affine_xform = AffineTransform(\n normalized=False,\n mode=mode or self.mode,\n padding_mode=padding_mode or self.padding_mode,\n align_corners=True,\n reverse_indexing=True,\n )\n output_data = affine_xform(\n torch.from_numpy((data_array.astype(np.float64))).unsqueeze(0), # AffineTransform requires a batch dim\n torch.from_numpy(transform_.astype(np.float64)),\n spatial_size=output_shape,\n )\n output_data = output_data.squeeze(0).detach().cpu().numpy().astype(_dtype)\n new_affine = to_affine_nd(affine, new_affine)\n return output_data, affine, new_affine", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Orientation_Orientation.__init__.self.labels.labels": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Orientation_Orientation.__init__.self.labels.labels", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 178, "end_line": 209, "span_ids": ["Orientation.__init__", "Orientation"], "tokens": 372}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Orientation(Transform):\n \"\"\"\n Change the input image's orientation into the specified based on `axcodes`.\n \"\"\"\n\n def __init__(\n self, axcodes: Optional[str] = None, as_closest_canonical: bool = False, labels=tuple(zip(\"LPI\", \"RAS\"))\n ) -> None:\n \"\"\"\n Args:\n axcodes: N elements sequence for spatial ND input's orientation.\n e.g. axcodes='RAS' represents 3D orientation:\n (Left, Right), (Posterior, Anterior), (Inferior, Superior).\n default orientation labels options are: 'L' and 'R' for the first dimension,\n 'P' and 'A' for the second, 'I' and 'S' for the third.\n as_closest_canonical: if True, load the image as closest to canonical axis format.\n labels: optional, None or sequence of (2,) sequences\n (2,) sequences are labels for (beginning, end) of output axis.\n Defaults to ``(('L', 'R'), ('P', 'A'), ('I', 'S'))``.\n\n Raises:\n ValueError: provide either `axcodes` or `as_closest_canonical=True`.\n\n See Also: `nibabel.orientations.ornt2axcodes`.\n \"\"\"\n if axcodes is None and not as_closest_canonical:\n raise ValueError(\"provide either `axcodes` or `as_closest_canonical=True`.\")\n if axcodes is not None and as_closest_canonical:\n warnings.warn(\"using as_closest_canonical=True, axcodes ignored.\")\n self.axcodes = axcodes\n self.as_closest_canonical = as_closest_canonical\n self.labels = labels", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Orientation.__call___Orientation.__call__.return.data_array_affine_new_a": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Orientation.__call___Orientation.__call__.return.data_array_affine_new_a", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 211, "end_line": 255, "span_ids": ["Orientation.__call__"], "tokens": 493}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Orientation(Transform):\n\n def __call__(self, data_array: np.ndarray, affine=None):\n \"\"\"\n original orientation of `data_array` is defined by `affine`.\n\n Args:\n data_array: in shape (num_channels, H[, W, ...]).\n affine (matrix): (N+1)x(N+1) original affine matrix for spatially ND `data_array`. Defaults to identity.\n\n Returns:\n data_array (reoriented in `self.axcodes`), original axcodes, current axcodes.\n\n Raises:\n ValueError: the array should have at least one spatial dimension.\n ValueError: `self.axcodes` should have at least {sr} elements\n given the data array is in spatial {sr}D, got \"{self.axcodes}\"\n\n \"\"\"\n sr = data_array.ndim - 1\n if sr <= 0:\n raise ValueError(\"the array should have at least one spatial dimension.\")\n if affine is None:\n affine = np.eye(sr + 1, dtype=np.float64)\n affine_ = np.eye(sr + 1, dtype=np.float64)\n else:\n affine_ = to_affine_nd(sr, affine)\n src = nib.io_orientation(affine_)\n if self.as_closest_canonical:\n spatial_ornt = src\n else:\n assert self.axcodes is not None\n dst = nib.orientations.axcodes2ornt(self.axcodes[:sr], labels=self.labels)\n if len(dst) < sr:\n raise ValueError(\n f\"`self.axcodes` should have at least {sr} elements\"\n f' given the data array is in spatial {sr}D, got \"{self.axcodes}\"'\n )\n spatial_ornt = nib.orientations.ornt_transform(src, dst)\n ornt = spatial_ornt.copy()\n ornt[:, 0] += 1 # skip channel dim\n ornt = np.concatenate([np.array([[0, 1]]), ornt])\n shape = data_array.shape[1:]\n data_array = nib.orientations.apply_orientation(data_array, ornt)\n new_affine = affine_ @ nib.orientations.inv_ornt_aff(spatial_ornt, shape)\n new_affine = to_affine_nd(affine, new_affine)\n return data_array, affine, new_affine", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Flip_Flip.__call__.return.np_stack_flipped_astype_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Flip_Flip.__call__.return.np_stack_flipped_astype_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 258, "end_line": 279, "span_ids": ["Flip.__init__", "Flip", "Flip.__call__"], "tokens": 181}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Flip(Transform):\n \"\"\"\n Reverses the order of elements along the given spatial axis. Preserves shape.\n Uses ``np.flip`` in practice. See numpy.flip for additional details.\n https://docs.scipy.org/doc/numpy/reference/generated/numpy.flip.html\n\n Args:\n spatial_axis: spatial axes along which to flip over. Default is None.\n \"\"\"\n\n def __init__(self, spatial_axis: Optional[Union[Sequence[int], int]]) -> None:\n self.spatial_axis = spatial_axis\n\n def __call__(self, img: np.ndarray):\n \"\"\"\n Args:\n img: channel first array, must have shape: (num_channels, H[, W, ..., ]),\n \"\"\"\n flipped = list()\n for channel in img:\n flipped.append(np.flip(channel, self.spatial_axis))\n return np.stack(flipped).astype(img.dtype)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Resize_Resize.__init__.self.align_corners.align_corners": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Resize_Resize.__init__.self.align_corners.align_corners", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 282, "end_line": 308, "span_ids": ["Resize.__init__", "Resize"], "tokens": 321}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Resize(Transform):\n \"\"\"\n Resize the input image to given spatial size.\n Implemented using :py:class:`torch.nn.functional.interpolate`.\n\n Args:\n spatial_size: expected shape of spatial dimensions after resize operation.\n if the components of the `spatial_size` are non-positive values, the transform will use the\n corresponding components of img size. For example, `spatial_size=(32, -1)` will be adapted\n to `(32, 64)` if the second spatial dimension size of img is `64`.\n mode: {``\"nearest\"``, ``\"linear\"``, ``\"bilinear\"``, ``\"bicubic\"``, ``\"trilinear\"``, ``\"area\"``}\n The interpolation mode. Defaults to ``\"area\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n align_corners: This only has an effect when mode is\n 'linear', 'bilinear', 'bicubic' or 'trilinear'. Default: None.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n \"\"\"\n\n def __init__(\n self,\n spatial_size: Union[Sequence[int], int],\n mode: Union[InterpolateMode, str] = InterpolateMode.AREA,\n align_corners: Optional[bool] = None,\n ) -> None:\n self.spatial_size = ensure_tuple(spatial_size)\n self.mode: InterpolateMode = InterpolateMode(mode)\n self.align_corners = align_corners", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Resize.__call___Resize.__call__.return.resized": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Resize.__call___Resize.__call__.return.resized", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 310, "end_line": 346, "span_ids": ["Resize.__call__"], "tokens": 449}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Resize(Transform):\n\n def __call__(\n self, img: np.ndarray, mode: Optional[Union[InterpolateMode, str]] = None, align_corners: Optional[bool] = None,\n ):\n \"\"\"\n Args:\n img: channel first array, must have shape: (num_channels, H[, W, ..., ]).\n mode: {``\"nearest\"``, ``\"linear\"``, ``\"bilinear\"``, ``\"bicubic\"``, ``\"trilinear\"``, ``\"area\"``}\n The interpolation mode. Defaults to ``self.mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n align_corners: This only has an effect when mode is\n 'linear', 'bilinear', 'bicubic' or 'trilinear'. Defaults to ``self.align_corners``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n\n Raises:\n ValueError: len(spatial_size) cannot be smaller than the image spatial dimensions,\n got {output_ndim} and {input_ndim}.\n\n \"\"\"\n input_ndim = img.ndim - 1 # spatial ndim\n output_ndim = len(self.spatial_size)\n if output_ndim > input_ndim:\n input_shape = ensure_tuple_size(img.shape, output_ndim + 1, 1)\n img = img.reshape(input_shape)\n elif output_ndim < input_ndim:\n raise ValueError(\n \"len(spatial_size) cannot be smaller than the image spatial dimensions, \"\n f\"got {output_ndim} and {input_ndim}.\"\n )\n spatial_size = fall_back_tuple(self.spatial_size, img.shape[1:])\n resized = _torch_interp(\n input=torch.as_tensor(np.ascontiguousarray(img), dtype=torch.float).unsqueeze(0),\n size=spatial_size,\n mode=self.mode.value if mode is None else InterpolateMode(mode).value,\n align_corners=self.align_corners if align_corners is None else align_corners,\n )\n resized = resized.squeeze(0).detach().cpu().numpy()\n return resized", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rotate_Rotate.__init__.self.align_corners.align_corners": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rotate_Rotate.__init__.self.align_corners.align_corners", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 349, "end_line": 380, "span_ids": ["Rotate.__init__", "Rotate"], "tokens": 377}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Rotate(Transform):\n \"\"\"\n Rotates an input image by given angle using :py:class:`monai.networks.layers.AffineTransform`.\n\n Args:\n angle: Rotation angle(s) in degrees. should a float for 2D, three floats for 3D.\n keep_size: If it is True, the output shape is kept the same as the input.\n If it is False, the output shape is adapted so that the\n input array is contained completely in the output. Default is True.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``\"border\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n align_corners: Defaults to False.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n \"\"\"\n\n def __init__(\n self,\n angle: Union[Sequence[float], float],\n keep_size: bool = True,\n mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,\n padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.BORDER,\n align_corners: bool = False,\n ) -> None:\n self.angle = angle\n self.keep_size = keep_size\n self.mode: GridSampleMode = GridSampleMode(mode)\n self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)\n self.align_corners = align_corners", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rotate.__call___Rotate.__call__.return.output": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rotate.__call___Rotate.__call__.return.output", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 382, "end_line": 439, "span_ids": ["Rotate.__call__"], "tokens": 677}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Rotate(Transform):\n\n def __call__(\n self,\n img: np.ndarray,\n mode: Optional[Union[GridSampleMode, str]] = None,\n padding_mode: Optional[Union[GridSamplePadMode, str]] = None,\n align_corners=None,\n ):\n \"\"\"\n Args:\n img: channel first array, must have shape: (num_channels, H[, W, ..., ]),\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``self.mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``self.padding_mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n align_corners: Defaults to ``self.align_corners``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n align_corners (bool): Defaults to ``self.align_corners``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n\n Raises:\n ValueError: Rotate only supports 2D and 3D: [chns, H, W] and [chns, H, W, D].\n\n \"\"\"\n im_shape = np.asarray(img.shape[1:]) # spatial dimensions\n input_ndim = len(im_shape)\n if input_ndim not in (2, 3):\n raise ValueError(\"Rotate only supports 2D and 3D: [chns, H, W] and [chns, H, W, D].\")\n _angle = ensure_tuple_rep(self.angle, 1 if input_ndim == 2 else 3)\n _rad = np.deg2rad(_angle)\n transform = create_rotate(input_ndim, _rad)\n shift = create_translate(input_ndim, (im_shape - 1) / 2)\n if self.keep_size:\n output_shape = im_shape\n else:\n corners = np.asarray(np.meshgrid(*[(0, dim) for dim in im_shape], indexing=\"ij\")).reshape(\n (len(im_shape), -1)\n )\n corners = transform[:-1, :-1] @ corners\n output_shape = (corners.ptp(axis=1) + 0.5).astype(int)\n shift_1 = create_translate(input_ndim, -(output_shape - 1) / 2)\n transform = shift @ transform @ shift_1\n _dtype = img.dtype\n xform = AffineTransform(\n normalized=False,\n mode=mode or self.mode,\n padding_mode=padding_mode or self.padding_mode,\n align_corners=self.align_corners if align_corners is None else align_corners,\n reverse_indexing=True,\n )\n output = xform(\n torch.from_numpy(img.astype(np.float64)).unsqueeze(0),\n torch.from_numpy(transform.astype(np.float64)),\n spatial_size=output_shape,\n )\n output = output.squeeze(0).detach().cpu().numpy().astype(_dtype)\n return output", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Zoom_Zoom.__init__.self.keep_size.keep_size": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Zoom_Zoom.__init__.self.keep_size.keep_size", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 442, "end_line": 473, "span_ids": ["Zoom.__init__", "Zoom"], "tokens": 360}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Zoom(Transform):\n \"\"\"\n Zooms an ND image using :py:class:`torch.nn.functional.interpolate`.\n For details, please see https://pytorch.org/docs/stable/nn.functional.html#interpolate.\n\n Different from :py:class:`monai.transforms.resize`, this transform takes scaling factors\n as input, and provides an option of preserving the input spatial size.\n\n Args:\n zoom: The zoom factor along the spatial axes.\n If a float, zoom is the same for each spatial axis.\n If a sequence, zoom should contain one value for each spatial axis.\n mode: {``\"nearest\"``, ``\"linear\"``, ``\"bilinear\"``, ``\"bicubic\"``, ``\"trilinear\"``, ``\"area\"``}\n The interpolation mode. Defaults to ``\"area\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n align_corners: This only has an effect when mode is\n 'linear', 'bilinear', 'bicubic' or 'trilinear'. Default: None.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n keep_size: Should keep original size (padding/slicing if needed), default is True.\n \"\"\"\n\n def __init__(\n self,\n zoom: Union[Sequence[float], float],\n mode: Union[InterpolateMode, str] = InterpolateMode.AREA,\n align_corners: Optional[bool] = None,\n keep_size: bool = True,\n ) -> None:\n self.zoom = zoom\n self.mode: InterpolateMode = InterpolateMode(mode)\n self.align_corners = align_corners\n self.keep_size = keep_size", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Zoom.__call___Zoom.__call__.return.zoomed_tuple_slice_vec_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Zoom.__call___Zoom.__call__.return.zoomed_tuple_slice_vec_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 475, "end_line": 510, "span_ids": ["Zoom.__call__"], "tokens": 478}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Zoom(Transform):\n\n def __call__(\n self, img: np.ndarray, mode: Optional[Union[InterpolateMode, str]] = None, align_corners: Optional[bool] = None,\n ):\n \"\"\"\n Args:\n img: channel first array, must have shape: (num_channels, H[, W, ..., ]).\n mode: {``\"nearest\"``, ``\"linear\"``, ``\"bilinear\"``, ``\"bicubic\"``, ``\"trilinear\"``, ``\"area\"``}\n The interpolation mode. Defaults to ``self.mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n align_corners: This only has an effect when mode is\n 'linear', 'bilinear', 'bicubic' or 'trilinear'. Defaults to ``self.align_corners``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n\n \"\"\"\n _zoom = ensure_tuple_rep(self.zoom, img.ndim - 1) # match the spatial image dim\n zoomed = _torch_interp(\n input=torch.as_tensor(np.ascontiguousarray(img), dtype=torch.float).unsqueeze(0),\n scale_factor=list(_zoom),\n mode=self.mode.value if mode is None else InterpolateMode(mode).value,\n align_corners=self.align_corners if align_corners is None else align_corners,\n )\n zoomed = zoomed.squeeze(0).detach().cpu().numpy()\n if not self.keep_size or np.allclose(img.shape, zoomed.shape):\n return zoomed\n\n pad_vec = [[0, 0]] * len(img.shape)\n slice_vec = [slice(None)] * len(img.shape)\n for idx, (od, zd) in enumerate(zip(img.shape, zoomed.shape)):\n diff = od - zd\n half = abs(diff) // 2\n if diff > 0: # need padding\n pad_vec[idx] = [half, diff - half]\n elif diff < 0: # need slicing\n slice_vec[idx] = slice(half, half + od)\n zoomed = np.pad(zoomed, pad_vec, mode=NumpyPadMode.EDGE.value)\n return zoomed[tuple(slice_vec)]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rotate90_Rotate90.__call__.return.np_stack_rotated_astype_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rotate90_Rotate90.__call__.return.np_stack_rotated_astype_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 513, "end_line": 536, "span_ids": ["Rotate90.__call__", "Rotate90.__init__", "Rotate90"], "tokens": 207}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Rotate90(Transform):\n \"\"\"\n Rotate an array by 90 degrees in the plane specified by `axes`.\n \"\"\"\n\n def __init__(self, k: int = 1, spatial_axes: Tuple[int, int] = (0, 1)) -> None:\n \"\"\"\n Args:\n k: number of times to rotate by 90 degrees.\n spatial_axes: 2 int numbers, defines the plane to rotate with 2 spatial axes.\n Default: (0, 1), this is the first two axis in spatial dimensions.\n \"\"\"\n self.k = k\n self.spatial_axes = spatial_axes\n\n def __call__(self, img: np.ndarray):\n \"\"\"\n Args:\n img: channel first array, must have shape: (num_channels, H[, W, ..., ]),\n \"\"\"\n rotated = list()\n for channel in img:\n rotated.append(np.rot90(channel, self.k, self.spatial_axes))\n return np.stack(rotated).astype(img.dtype)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandRotate90_RandRotate90.__call__.return.rotator_img_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandRotate90_RandRotate90.__call__.return.rotator_img_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 539, "end_line": 574, "span_ids": ["RandRotate90.randomize", "RandRotate90", "RandRotate90.__init__", "RandRotate90.__call__"], "tokens": 357}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandRotate90(Randomizable, Transform):\n \"\"\"\n With probability `prob`, input arrays are rotated by 90 degrees\n in the plane specified by `spatial_axes`.\n \"\"\"\n\n def __init__(self, prob: float = 0.1, max_k: int = 3, spatial_axes: Tuple[int, int] = (0, 1)) -> None:\n \"\"\"\n Args:\n prob: probability of rotating.\n (Default 0.1, with 10% probability it returns a rotated array)\n max_k: number of rotations will be sampled from `np.random.randint(max_k) + 1`, (Default 3).\n spatial_axes: 2 int numbers, defines the plane to rotate with 2 spatial axes.\n Default: (0, 1), this is the first two axis in spatial dimensions.\n \"\"\"\n self.prob = min(max(prob, 0.0), 1.0)\n self.max_k = max_k\n self.spatial_axes = spatial_axes\n\n self._do_transform = False\n self._rand_k = 0\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self._rand_k = self.R.randint(self.max_k) + 1\n self._do_transform = self.R.random() < self.prob\n\n def __call__(self, img: np.ndarray):\n \"\"\"\n Args:\n img: channel first array, must have shape: (num_channels, H[, W, ..., ]),\n \"\"\"\n self.randomize()\n if not self._do_transform:\n return img\n rotator = Rotate90(self._rand_k, self.spatial_axes)\n return rotator(img)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandRotate_RandRotate.randomize.self.z.self_R_uniform_low_self_r": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandRotate_RandRotate.randomize.self.z.self_R_uniform_low_self_r", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 577, "end_line": 638, "span_ids": ["RandRotate", "RandRotate.__init__", "RandRotate.randomize"], "tokens": 775}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandRotate(Randomizable, Transform):\n \"\"\"\n Randomly rotate the input arrays.\n\n Args:\n range_x: Range of rotation angle in degrees in the plane defined by the first and second axes.\n If single number, angle is uniformly sampled from (-range_x, range_x).\n range_y: Range of rotation angle in degrees in the plane defined by the first and third axes.\n If single number, angle is uniformly sampled from (-range_y, range_y).\n range_z: Range of rotation angle in degrees in the plane defined by the second and third axes.\n If single number, angle is uniformly sampled from (-range_z, range_z).\n prob: Probability of rotation.\n keep_size: If it is False, the output shape is adapted so that the\n input array is contained completely in the output.\n If it is True, the output shape is the same as the input. Default is True.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``\"border\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n align_corners: Defaults to False.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n \"\"\"\n\n def __init__(\n self,\n range_x: Union[Tuple[float, float], float] = 0.0,\n range_y: Union[Tuple[float, float], float] = 0.0,\n range_z: Union[Tuple[float, float], float] = 0.0,\n prob: float = 0.1,\n keep_size: bool = True,\n mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,\n padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.BORDER,\n align_corners: bool = False,\n ) -> None:\n self.range_x = ensure_tuple(range_x)\n if len(self.range_x) == 1:\n self.range_x = tuple(sorted([-self.range_x[0], self.range_x[0]]))\n self.range_y = ensure_tuple(range_y)\n if len(self.range_y) == 1:\n self.range_y = tuple(sorted([-self.range_y[0], self.range_y[0]]))\n self.range_z = ensure_tuple(range_z)\n if len(self.range_z) == 1:\n self.range_z = tuple(sorted([-self.range_z[0], self.range_z[0]]))\n\n self.prob = prob\n self.keep_size = keep_size\n self.mode: GridSampleMode = GridSampleMode(mode)\n self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)\n self.align_corners = align_corners\n\n self._do_transform = False\n self.x = 0.0\n self.y = 0.0\n self.z = 0.0\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self._do_transform = self.R.random_sample() < self.prob\n self.x = self.R.uniform(low=self.range_x[0], high=self.range_x[1])\n self.y = self.R.uniform(low=self.range_y[0], high=self.range_y[1])\n self.z = self.R.uniform(low=self.range_z[0], high=self.range_z[1])", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandRotate.__call___RandRotate.__call__.return.rotator_img_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandRotate.__call___RandRotate.__call__.return.rotator_img_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 640, "end_line": 669, "span_ids": ["RandRotate.__call__"], "tokens": 343}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandRotate(Randomizable, Transform):\n\n def __call__(\n self,\n img: np.ndarray,\n mode: Optional[Union[GridSampleMode, str]] = None,\n padding_mode: Optional[Union[GridSamplePadMode, str]] = None,\n align_corners=None,\n ):\n \"\"\"\n Args:\n img: channel first array, must have shape 2D: (nchannels, H, W), or 3D: (nchannels, H, W, D).\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``self.mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``self.padding_mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n align_corners (bool): Defaults to ``self.align_corners``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n \"\"\"\n self.randomize()\n if not self._do_transform:\n return img\n rotator = Rotate(\n angle=self.x if img.ndim == 3 else (self.x, self.y, self.z),\n keep_size=self.keep_size,\n mode=mode or self.mode,\n padding_mode=padding_mode or self.padding_mode,\n align_corners=self.align_corners if align_corners is None else align_corners,\n )\n return rotator(img)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandFlip_RandFlip.__call__.return.self_flipper_img_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandFlip_RandFlip.__call__.return.self_flipper_img_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 672, "end_line": 699, "span_ids": ["RandFlip", "RandFlip.__init__", "RandFlip.__call__", "RandFlip.randomize"], "tokens": 231}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandFlip(Randomizable, Transform):\n \"\"\"\n Randomly flips the image along axes. Preserves shape.\n See numpy.flip for additional details.\n https://docs.scipy.org/doc/numpy/reference/generated/numpy.flip.html\n\n Args:\n prob: Probability of flipping.\n spatial_axis: Spatial axes along which to flip over. Default is None.\n \"\"\"\n\n def __init__(self, prob: float = 0.1, spatial_axis: Optional[Union[Sequence[int], int]] = None):\n self.prob = prob\n self.flipper = Flip(spatial_axis=spatial_axis)\n self._do_transform = False\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self._do_transform = self.R.random_sample() < self.prob\n\n def __call__(self, img: np.ndarray):\n \"\"\"\n Args:\n img: channel first array, must have shape: (num_channels, H[, W, ..., ]),\n \"\"\"\n self.randomize()\n if not self._do_transform:\n return img\n return self.flipper(img)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandZoom_RandZoom.randomize.if_len_self__zoom_1_.self._zoom.self__zoom_0_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandZoom_RandZoom.randomize.if_len_self__zoom_1_.self._zoom.self__zoom_0_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 702, "end_line": 750, "span_ids": ["RandZoom.randomize", "RandZoom", "RandZoom.__init__"], "tokens": 613}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandZoom(Randomizable, Transform):\n \"\"\"\n Randomly zooms input arrays with given probability within given zoom range.\n\n Args:\n prob: Probability of zooming.\n min_zoom: Min zoom factor. Can be float or sequence same size as image.\n If a float, select a random factor from `[min_zoom, max_zoom]` then apply to all spatial dims\n to keep the original spatial shape ratio.\n If a sequence, min_zoom should contain one value for each spatial axis.\n max_zoom: Max zoom factor. Can be float or sequence same size as image.\n If a float, select a random factor from `[min_zoom, max_zoom]` then apply to all spatial dims\n to keep the original spatial shape ratio.\n If a sequence, max_zoom should contain one value for each spatial axis.\n mode: {``\"nearest\"``, ``\"linear\"``, ``\"bilinear\"``, ``\"bicubic\"``, ``\"trilinear\"``, ``\"area\"``}\n The interpolation mode. Defaults to ``\"area\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n align_corners: This only has an effect when mode is\n 'linear', 'bilinear', 'bicubic' or 'trilinear'. Default: None.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n keep_size: Should keep original size (pad if needed), default is True.\n \"\"\"\n\n def __init__(\n self,\n prob: float = 0.1,\n min_zoom: Union[Sequence[float], float] = 0.9,\n max_zoom: Union[Sequence[float], float] = 1.1,\n mode: Union[InterpolateMode, str] = InterpolateMode.AREA,\n align_corners: Optional[bool] = None,\n keep_size: bool = True,\n ) -> None:\n self.min_zoom = ensure_tuple(min_zoom)\n self.max_zoom = ensure_tuple(max_zoom)\n assert len(self.min_zoom) == len(self.max_zoom), \"min_zoom and max_zoom must have same length.\"\n self.prob = prob\n self.mode: InterpolateMode = InterpolateMode(mode)\n self.align_corners = align_corners\n self.keep_size = keep_size\n\n self._do_transform = False\n self._zoom: Union[List[float], float] = 1.0\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self._do_transform = self.R.random_sample() < self.prob\n self._zoom = [self.R.uniform(l, h) for l, h in zip(self.min_zoom, self.max_zoom)]\n if len(self._zoom) == 1:\n # to keep the spatial shape ratio, use same random zoom factor for all dims\n self._zoom = self._zoom[0]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandZoom.__call___RandZoom.__call__.return.zoomer_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandZoom.__call___RandZoom.__call__.return.zoomer_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 752, "end_line": 773, "span_ids": ["RandZoom.__call__"], "tokens": 306}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandZoom(Randomizable, Transform):\n\n def __call__(\n self, img: np.ndarray, mode: Optional[Union[InterpolateMode, str]] = None, align_corners: Optional[bool] = None,\n ):\n \"\"\"\n Args:\n img: channel first array, must have shape 2D: (nchannels, H, W), or 3D: (nchannels, H, W, D).\n mode: {``\"nearest\"``, ``\"linear\"``, ``\"bilinear\"``, ``\"bicubic\"``, ``\"trilinear\"``, ``\"area\"``}\n The interpolation mode. Defaults to ``self.mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n align_corners: This only has an effect when mode is\n 'linear', 'bilinear', 'bicubic' or 'trilinear'. Defaults to ``self.align_corners``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n \"\"\"\n # match the spatial image dim\n self.randomize()\n _dtype = np.float32\n if not self._do_transform:\n return img.astype(_dtype)\n zoomer = Zoom(self._zoom, keep_size=self.keep_size)\n return zoomer(\n img, mode=mode or self.mode, align_corners=self.align_corners if align_corners is None else align_corners,\n ).astype(_dtype)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_AffineGrid_AffineGrid.__init__.self.device.device": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_AffineGrid_AffineGrid.__init__.self.device.device", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 776, "end_line": 817, "span_ids": ["AffineGrid", "AffineGrid.__init__"], "tokens": 513}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AffineGrid(Transform):\n \"\"\"\n Affine transforms on the coordinates.\n\n Args:\n rotate_range: angle range in radians. rotate_range[0] with be used to generate the 1st rotation\n parameter from `uniform[-rotate_range[0], rotate_range[0])`. Similarly, `rotate_range[1]` and\n `rotate_range[2]` are used in 3D affine for the range of 2nd and 3rd axes.\n shear_range: shear_range[0] with be used to generate the 1st shearing parameter from\n `uniform[-shear_range[0], shear_range[0])`. Similarly, `shear_range[1]` to\n `shear_range[N]` controls the range of the uniform distribution used to generate the 2nd to\n N-th parameter.\n translate_range : translate_range[0] with be used to generate the 1st shift parameter from\n `uniform[-translate_range[0], translate_range[0])`. Similarly, `translate_range[1]`\n to `translate_range[N]` controls the range of the uniform distribution used to generate\n the 2nd to N-th parameter.\n scale_range: scaling_range[0] with be used to generate the 1st scaling factor from\n `uniform[-scale_range[0], scale_range[0]) + 1.0`. Similarly, `scale_range[1]` to\n `scale_range[N]` controls the range of the uniform distribution used to generate the 2nd to\n N-th parameter.\n as_tensor_output: whether to output tensor instead of numpy array.\n defaults to True.\n device: device to store the output grid data.\n\n \"\"\"\n\n def __init__(\n self,\n rotate_params: Optional[Union[Sequence[float], float]] = None,\n shear_params: Optional[Union[Sequence[float], float]] = None,\n translate_params: Optional[Union[Sequence[float], float]] = None,\n scale_params: Optional[Union[Sequence[float], float]] = None,\n as_tensor_output: bool = True,\n device: Optional[torch.device] = None,\n ) -> None:\n self.rotate_params = rotate_params\n self.shear_params = shear_params\n self.translate_params = translate_params\n self.scale_params = scale_params\n\n self.as_tensor_output = as_tensor_output\n self.device = device", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_AffineGrid.__call___AffineGrid.__call__.return.grid_cpu_numpy_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_AffineGrid.__call___AffineGrid.__call__.return.grid_cpu_numpy_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 819, "end_line": 853, "span_ids": ["AffineGrid.__call__"], "tokens": 364}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AffineGrid(Transform):\n\n def __call__(self, spatial_size: Optional[Sequence[int]] = None, grid: Optional[np.ndarray] = None):\n \"\"\"\n Args:\n spatial_size: output grid size.\n grid: grid to be transformed. Shape must be (3, H, W) for 2D or (4, H, W, D) for 3D.\n\n Raises:\n ValueError: Either specify a grid or a spatial size to create a grid from.\n\n \"\"\"\n if grid is None:\n if spatial_size is not None:\n grid = create_grid(spatial_size)\n else:\n raise ValueError(\"Either specify a grid or a spatial size to create a grid from.\")\n\n spatial_dims = len(grid.shape) - 1\n affine = np.eye(spatial_dims + 1)\n if self.rotate_params:\n affine = affine @ create_rotate(spatial_dims, self.rotate_params)\n if self.shear_params:\n affine = affine @ create_shear(spatial_dims, self.shear_params)\n if self.translate_params:\n affine = affine @ create_translate(spatial_dims, self.translate_params)\n if self.scale_params:\n affine = affine @ create_scale(spatial_dims, self.scale_params)\n affine = torch.as_tensor(np.ascontiguousarray(affine), device=self.device)\n\n grid = torch.tensor(grid) if not torch.is_tensor(grid) else grid.detach().clone()\n if self.device:\n grid = grid.to(self.device)\n grid = (affine.float() @ grid.reshape((grid.shape[0], -1)).float()).reshape([-1] + list(grid.shape[1:]))\n if self.as_tensor_output:\n return grid\n return grid.cpu().numpy()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandAffineGrid_RandAffineGrid.__init__.self.device.device": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandAffineGrid_RandAffineGrid.__init__.self.device.device", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 856, "end_line": 908, "span_ids": ["RandAffineGrid", "RandAffineGrid.__init__"], "tokens": 641}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandAffineGrid(Randomizable, Transform):\n \"\"\"\n Generate randomised affine grid.\n \"\"\"\n\n def __init__(\n self,\n rotate_range: Optional[Union[Sequence[float], float]] = None,\n shear_range: Optional[Union[Sequence[float], float]] = None,\n translate_range: Optional[Union[Sequence[float], float]] = None,\n scale_range: Optional[Union[Sequence[float], float]] = None,\n as_tensor_output: bool = True,\n device: Optional[torch.device] = None,\n ) -> None:\n \"\"\"\n Args:\n rotate_range: angle range in radians. rotate_range[0] with be used to generate the 1st rotation\n parameter from `uniform[-rotate_range[0], rotate_range[0])`. Similarly, `rotate_range[1]` and\n `rotate_range[2]` are used in 3D affine for the range of 2nd and 3rd axes.\n shear_range: shear_range[0] with be used to generate the 1st shearing parameter from\n `uniform[-shear_range[0], shear_range[0])`. Similarly, `shear_range[1]` to\n `shear_range[N]` controls the range of the uniform distribution used to generate the 2nd to\n N-th parameter.\n translate_range : translate_range[0] with be used to generate the 1st shift parameter from\n `uniform[-translate_range[0], translate_range[0])`. Similarly, `translate_range[1]`\n to `translate_range[N]` controls the range of the uniform distribution used to generate\n the 2nd to N-th parameter.\n scale_range: scaling_range[0] with be used to generate the 1st scaling factor from\n `uniform[-scale_range[0], scale_range[0]) + 1.0`. Similarly, `scale_range[1]` to\n `scale_range[N]` controls the range of the uniform distribution used to generate the 2nd to\n N-th parameter.\n as_tensor_output: whether to output tensor instead of numpy array.\n defaults to True.\n device: device to store the output grid data.\n\n See also:\n - :py:meth:`monai.transforms.utils.create_rotate`\n - :py:meth:`monai.transforms.utils.create_shear`\n - :py:meth:`monai.transforms.utils.create_translate`\n - :py:meth:`monai.transforms.utils.create_scale`\n \"\"\"\n self.rotate_range = ensure_tuple(rotate_range)\n self.shear_range = ensure_tuple(shear_range)\n self.translate_range = ensure_tuple(translate_range)\n self.scale_range = ensure_tuple(scale_range)\n\n self.rotate_params: Optional[List[float]] = None\n self.shear_params: Optional[List[float]] = None\n self.translate_params: Optional[List[float]] = None\n self.scale_params: Optional[List[float]] = None\n\n self.as_tensor_output = as_tensor_output\n self.device = device", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandAffineGrid.randomize_RandAffineGrid.randomize.if_self_scale_range_.self.scale_params._self_R_uniform_f_f_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandAffineGrid.randomize_RandAffineGrid.randomize.if_self_scale_range_.self.scale_params._self_R_uniform_f_f_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 910, "end_line": 918, "span_ids": ["RandAffineGrid.randomize"], "tokens": 163}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandAffineGrid(Randomizable, Transform):\n\n def randomize(self, data: Optional[Any] = None) -> None:\n if self.rotate_range:\n self.rotate_params = [self.R.uniform(-f, f) for f in self.rotate_range if f is not None]\n if self.shear_range:\n self.shear_params = [self.R.uniform(-f, f) for f in self.shear_range if f is not None]\n if self.translate_range:\n self.translate_params = [self.R.uniform(-f, f) for f in self.translate_range if f is not None]\n if self.scale_range:\n self.scale_params = [self.R.uniform(-f, f) + 1.0 for f in self.scale_range if f is not None]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandAffineGrid.__call___RandAffineGrid.__call__.return.affine_grid_spatial_size_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandAffineGrid.__call___RandAffineGrid.__call__.return.affine_grid_spatial_size_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 920, "end_line": 934, "span_ids": ["RandAffineGrid.__call__"], "tokens": 138}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandAffineGrid(Randomizable, Transform):\n\n def __call__(self, spatial_size: Optional[Sequence[int]] = None, grid: Optional[np.ndarray] = None):\n \"\"\"\n Returns:\n a 2D (3xHxW) or 3D (4xHxWxD) grid.\n \"\"\"\n self.randomize()\n affine_grid = AffineGrid(\n rotate_params=self.rotate_params,\n shear_params=self.shear_params,\n translate_params=self.translate_params,\n scale_params=self.scale_params,\n as_tensor_output=self.as_tensor_output,\n device=self.device,\n )\n return affine_grid(spatial_size, grid)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandDeformGrid_RandDeformGrid.randomize.self.rand_mag.self_R_uniform_self_magni": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandDeformGrid_RandDeformGrid.randomize.self.rand_mag.self_R_uniform_self_magni", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 937, "end_line": 971, "span_ids": ["RandDeformGrid", "RandDeformGrid.__init__", "RandDeformGrid.randomize"], "tokens": 315}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandDeformGrid(Randomizable, Transform):\n \"\"\"\n Generate random deformation grid.\n \"\"\"\n\n def __init__(\n self,\n spacing: Union[Sequence[float], float],\n magnitude_range: Tuple[float, float],\n as_tensor_output: bool = True,\n device: Optional[torch.device] = None,\n ) -> None:\n \"\"\"\n Args:\n spacing: spacing of the grid in 2D or 3D.\n e.g., spacing=(1, 1) indicates pixel-wise deformation in 2D,\n spacing=(1, 1, 1) indicates voxel-wise deformation in 3D,\n spacing=(2, 2) indicates deformation field defined on every other pixel in 2D.\n magnitude_range: the random offsets will be generated from\n `uniform[magnitude[0], magnitude[1])`.\n as_tensor_output: whether to output tensor instead of numpy array.\n defaults to True.\n device: device to store the output grid data.\n \"\"\"\n self.spacing = spacing\n self.magnitude = magnitude_range\n\n self.rand_mag = 1.0\n self.as_tensor_output = as_tensor_output\n self.random_offset = 0.0\n self.device = device\n\n def randomize(self, grid_size: Sequence[int]):\n self.random_offset = self.R.normal(size=([len(grid_size)] + list(grid_size))).astype(np.float32)\n self.rand_mag = self.R.uniform(self.magnitude[0], self.magnitude[1])", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandDeformGrid.__call___RandDeformGrid.__call__.return.control_grid": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandDeformGrid.__call___RandDeformGrid.__call__.return.control_grid", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 973, "end_line": 984, "span_ids": ["RandDeformGrid.__call__"], "tokens": 133}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandDeformGrid(Randomizable, Transform):\n\n def __call__(self, spatial_size: Sequence[int]):\n \"\"\"\n Args:\n spatial_size: spatial size of the grid.\n \"\"\"\n self.spacing = fall_back_tuple(self.spacing, (1.0,) * len(spatial_size))\n control_grid = create_control_grid(spatial_size, self.spacing)\n self.randomize(control_grid.shape[1:])\n control_grid[: len(spatial_size)] += self.rand_mag * self.random_offset\n if self.as_tensor_output:\n control_grid = torch.as_tensor(np.ascontiguousarray(control_grid), device=self.device)\n return control_grid", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Resample_Resample.__init__.self.device.device": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Resample_Resample.__init__.self.device.device", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 987, "end_line": 1012, "span_ids": ["Resample.__init__", "Resample"], "tokens": 310}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Resample(Transform):\n def __init__(\n self,\n mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,\n padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.BORDER,\n as_tensor_output: bool = False,\n device: Optional[torch.device] = None,\n ) -> None:\n \"\"\"\n computes output image using values from `img`, locations from `grid` using pytorch.\n supports spatially 2D or 3D (num_channels, H, W[, D]).\n\n Args:\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``\"border\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n as_tensor_output: whether to return a torch tensor. Defaults to False.\n device: device on which the tensor will be allocated.\n \"\"\"\n self.mode: GridSampleMode = GridSampleMode(mode)\n self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)\n self.as_tensor_output = as_tensor_output\n self.device = device", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Resample.__call___Resample.__call__.return.out_cpu_numpy_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Resample.__call___Resample.__call__.return.out_cpu_numpy_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1014, "end_line": 1056, "span_ids": ["Resample.__call__"], "tokens": 507}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Resample(Transform):\n\n def __call__(\n self,\n img: Union[np.ndarray, torch.Tensor],\n grid: Optional[Union[np.ndarray, torch.Tensor]] = None,\n mode: Optional[Union[GridSampleMode, str]] = None,\n padding_mode: Optional[Union[GridSamplePadMode, str]] = None,\n ):\n \"\"\"\n Args:\n img: shape must be (num_channels, H, W[, D]).\n grid: shape must be (3, H, W) for 2D or (4, H, W, D) for 3D.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``self.mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``self.padding_mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n \"\"\"\n\n if not torch.is_tensor(img):\n img = torch.as_tensor(np.ascontiguousarray(img))\n assert grid is not None, \"Error, grid argument must be supplied as an ndarray or tensor \"\n grid = torch.tensor(grid) if not torch.is_tensor(grid) else grid.detach().clone()\n if self.device:\n img = img.to(self.device)\n grid = grid.to(self.device)\n\n for i, dim in enumerate(img.shape[1:]):\n grid[i] = 2.0 * grid[i] / (dim - 1.0)\n grid = grid[:-1] / grid[-1:]\n index_ordering: List[int] = list(range(img.ndim - 2, -1, -1))\n grid = grid[index_ordering]\n grid = grid.permute(list(range(grid.ndim))[1:] + [0])\n out = torch.nn.functional.grid_sample(\n img.unsqueeze(0).float(),\n grid.unsqueeze(0).float(),\n mode=self.mode.value if mode is None else GridSampleMode(mode).value,\n padding_mode=self.padding_mode.value if padding_mode is None else GridSamplePadMode(padding_mode).value,\n align_corners=True,\n )[0]\n if self.as_tensor_output:\n return out\n return out.cpu().numpy()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Affine_Affine.__init__.self.padding_mode.GridSamplePadMode_padding": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Affine_Affine.__init__.self.padding_mode.GridSamplePadMode_padding", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1059, "end_line": 1113, "span_ids": ["Affine", "Affine.__init__"], "tokens": 711}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Affine(Transform):\n \"\"\"\n Transform ``img`` given the affine parameters.\n \"\"\"\n\n def __init__(\n self,\n rotate_params: Optional[Union[Sequence[float], float]] = None,\n shear_params: Optional[Union[Sequence[float], float]] = None,\n translate_params: Optional[Union[Sequence[float], float]] = None,\n scale_params: Optional[Union[Sequence[float], float]] = None,\n spatial_size: Optional[Union[Sequence[int], int]] = None,\n mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,\n padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.REFLECTION,\n as_tensor_output: bool = False,\n device: Optional[torch.device] = None,\n ) -> None:\n \"\"\"\n The affine transformations are applied in rotate, shear, translate, scale order.\n\n Args:\n rotate_params: a rotation angle in radians, a scalar for 2D image, a tuple of 3 floats for 3D.\n Defaults to no rotation.\n shear_params: a tuple of 2 floats for 2D, a tuple of 6 floats for 3D. Defaults to no shearing.\n translate_params: a tuple of 2 floats for 2D, a tuple of 3 floats for 3D. Translation is in\n pixel/voxel relative to the center of the input image. Defaults to no translation.\n scale_params: a tuple of 2 floats for 2D, a tuple of 3 floats for 3D. Defaults to no scaling.\n spatial_size: output image spatial size.\n if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,\n the transform will use the spatial size of `img`.\n if the components of the `spatial_size` are non-positive values, the transform will use the\n corresponding components of img size. For example, `spatial_size=(32, -1)` will be adapted\n to `(32, 64)` if the second spatial dimension size of img is `64`.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``\"reflection\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n as_tensor_output: the computation is implemented using pytorch tensors, this option specifies\n whether to convert it back to numpy arrays.\n device: device on which the tensor will be allocated.\n \"\"\"\n self.affine_grid = AffineGrid(\n rotate_params=rotate_params,\n shear_params=shear_params,\n translate_params=translate_params,\n scale_params=scale_params,\n as_tensor_output=True,\n device=device,\n )\n self.resampler = Resample(as_tensor_output=as_tensor_output, device=device)\n self.spatial_size = spatial_size\n self.mode: GridSampleMode = GridSampleMode(mode)\n self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Affine.__call___Affine.__call__.return.self_resampler_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Affine.__call___Affine.__call__.return.self_resampler_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1115, "end_line": 1141, "span_ids": ["Affine.__call__"], "tokens": 371}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Affine(Transform):\n\n def __call__(\n self,\n img: Union[np.ndarray, torch.Tensor],\n spatial_size: Optional[Union[Sequence[int], int]] = None,\n mode: Optional[Union[GridSampleMode, str]] = None,\n padding_mode: Optional[Union[GridSamplePadMode, str]] = None,\n ):\n \"\"\"\n Args:\n img: shape must be (num_channels, H, W[, D]),\n spatial_size: output image spatial size.\n if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,\n the transform will use the spatial size of `img`.\n if `img` has two spatial dimensions, `spatial_size` should have 2 elements [h, w].\n if `img` has three spatial dimensions, `spatial_size` should have 3 elements [h, w, d].\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``self.mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``self.padding_mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n \"\"\"\n sp_size = fall_back_tuple(spatial_size or self.spatial_size, img.shape[1:])\n grid = self.affine_grid(spatial_size=sp_size)\n return self.resampler(\n img=img, grid=grid, mode=mode or self.mode, padding_mode=padding_mode or self.padding_mode\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandAffine_RandAffine.__init__.self.prob.prob": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandAffine_RandAffine.__init__.self.prob.prob", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1144, "end_line": 1217, "span_ids": ["RandAffine", "RandAffine.__init__"], "tokens": 954}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandAffine(Randomizable, Transform):\n \"\"\"\n Random affine transform.\n \"\"\"\n\n def __init__(\n self,\n prob: float = 0.1,\n rotate_range: Optional[Union[Sequence[float], float]] = None,\n shear_range: Optional[Union[Sequence[float], float]] = None,\n translate_range: Optional[Union[Sequence[float], float]] = None,\n scale_range: Optional[Union[Sequence[float], float]] = None,\n spatial_size: Optional[Union[Sequence[float], float]] = None,\n mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,\n padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.REFLECTION,\n as_tensor_output: bool = True,\n device: Optional[torch.device] = None,\n ) -> None:\n \"\"\"\n Args:\n prob: probability of returning a randomized affine grid.\n defaults to 0.1, with 10% chance returns a randomized grid.\n rotate_range: angle range in radians. rotate_range[0] with be used to generate the 1st rotation\n parameter from `uniform[-rotate_range[0], rotate_range[0])`. Similarly, `rotate_range[1]` and\n `rotate_range[2]` are used in 3D affine for the range of 2nd and 3rd axes.\n shear_range: shear_range[0] with be used to generate the 1st shearing parameter from\n `uniform[-shear_range[0], shear_range[0])`. Similarly, `shear_range[1]` to\n `shear_range[N]` controls the range of the uniform distribution used to generate the 2nd to\n N-th parameter.\n translate_range : translate_range[0] with be used to generate the 1st shift parameter from\n `uniform[-translate_range[0], translate_range[0])`. Similarly, `translate_range[1]`\n to `translate_range[N]` controls the range of the uniform distribution used to generate\n the 2nd to N-th parameter.\n scale_range: scaling_range[0] with be used to generate the 1st scaling factor from\n `uniform[-scale_range[0], scale_range[0]) + 1.0`. Similarly, `scale_range[1]` to\n `scale_range[N]` controls the range of the uniform distribution used to generate the 2nd to\n N-th parameter.\n spatial_size: output image spatial size.\n if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,\n the transform will use the spatial size of `img`.\n if the components of the `spatial_size` are non-positive values, the transform will use the\n corresponding components of img size. For example, `spatial_size=(32, -1)` will be adapted\n to `(32, 64)` if the second spatial dimension size of img is `64`.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``\"reflection\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n as_tensor_output: the computation is implemented using pytorch tensors, this option specifies\n whether to convert it back to numpy arrays.\n device: device on which the tensor will be allocated.\n\n See also:\n - :py:class:`RandAffineGrid` for the random affine parameters configurations.\n - :py:class:`Affine` for the affine transformation parameters configurations.\n \"\"\"\n\n self.rand_affine_grid = RandAffineGrid(\n rotate_range=rotate_range,\n shear_range=shear_range,\n translate_range=translate_range,\n scale_range=scale_range,\n as_tensor_output=True,\n device=device,\n )\n self.resampler = Resample(as_tensor_output=as_tensor_output, device=device)\n\n self.spatial_size = spatial_size\n self.mode: GridSampleMode = GridSampleMode(mode)\n self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)\n\n self.do_transform = False\n self.prob = prob", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandAffine.set_random_state_RandAffine.__call__.return.self_resampler_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandAffine.set_random_state_RandAffine.__call__.return.self_resampler_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1219, "end_line": 1259, "span_ids": ["RandAffine.randomize", "RandAffine.__call__", "RandAffine.set_random_state"], "tokens": 493}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandAffine(Randomizable, Transform):\n\n def set_random_state(self, seed: Optional[int] = None, state: Optional[np.random.RandomState] = None):\n self.rand_affine_grid.set_random_state(seed, state)\n super().set_random_state(seed, state)\n return self\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self.do_transform = self.R.rand() < self.prob\n self.rand_affine_grid.randomize()\n\n def __call__(\n self,\n img: Union[np.ndarray, torch.Tensor],\n spatial_size: Optional[Union[Sequence[int], int]] = None,\n mode: Optional[Union[GridSampleMode, str]] = None,\n padding_mode: Optional[Union[GridSamplePadMode, str]] = None,\n ):\n \"\"\"\n Args:\n img: shape must be (num_channels, H, W[, D]),\n spatial_size: output image spatial size.\n if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,\n the transform will use the spatial size of `img`.\n if `img` has two spatial dimensions, `spatial_size` should have 2 elements [h, w].\n if `img` has three spatial dimensions, `spatial_size` should have 3 elements [h, w, d].\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``self.mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``self.padding_mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n \"\"\"\n self.randomize()\n\n sp_size = fall_back_tuple(spatial_size or self.spatial_size, img.shape[1:])\n if self.do_transform:\n grid = self.rand_affine_grid(spatial_size=sp_size)\n else:\n grid = create_grid(spatial_size=sp_size)\n return self.resampler(\n img=img, grid=grid, mode=mode or self.mode, padding_mode=padding_mode or self.padding_mode\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand2DElastic_Rand2DElastic.__init__.self.do_transform.False": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand2DElastic_Rand2DElastic.__init__.self.do_transform.False", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1262, "end_line": 1337, "span_ids": ["Rand2DElastic", "Rand2DElastic.__init__"], "tokens": 995}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Rand2DElastic(Randomizable, Transform):\n \"\"\"\n Random elastic deformation and affine in 2D\n \"\"\"\n\n def __init__(\n self,\n spacing: Union[Tuple[float, float], float],\n magnitude_range: Tuple[float, float],\n prob: float = 0.1,\n rotate_range: Optional[Union[Sequence[float], float]] = None,\n shear_range: Optional[Union[Sequence[float], float]] = None,\n translate_range: Optional[Union[Sequence[float], float]] = None,\n scale_range: Optional[Union[Sequence[float], float]] = None,\n spatial_size: Optional[Union[Sequence[int], int]] = None,\n mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,\n padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.REFLECTION,\n as_tensor_output: bool = False,\n device: Optional[torch.device] = None,\n ) -> None:\n \"\"\"\n Args:\n spacing : distance in between the control points.\n magnitude_range: the random offsets will be generated from ``uniform[magnitude[0], magnitude[1])``.\n prob: probability of returning a randomized affine grid.\n defaults to 0.1, with 10% chance returns a randomized grid,\n otherwise returns a ``spatial_size`` centered area extracted from the input image.\n rotate_range: angle range in radians. rotate_range[0] with be used to generate the 1st rotation\n parameter from `uniform[-rotate_range[0], rotate_range[0])`.\n shear_range: shear_range[0] with be used to generate the 1st shearing parameter from\n `uniform[-shear_range[0], shear_range[0])`. Similarly, `shear_range[1]` controls\n the range of the uniform distribution used to generate the 2nd parameter.\n translate_range : translate_range[0] with be used to generate the 1st shift parameter from\n `uniform[-translate_range[0], translate_range[0])`. Similarly, `translate_range[1]` controls\n the range of the uniform distribution used to generate the 2nd parameter.\n scale_range: scaling_range[0] with be used to generate the 1st scaling factor from\n `uniform[-scale_range[0], scale_range[0]) + 1.0`. Similarly, `scale_range[1]` controls\n the range of the uniform distribution used to generate the 2nd parameter.\n spatial_size: specifying output image spatial size [h, w].\n if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,\n the transform will use the spatial size of `img`.\n if the components of the `spatial_size` are non-positive values, the transform will use the\n corresponding components of img size. For example, `spatial_size=(32, -1)` will be adapted\n to `(32, 64)` if the second spatial dimension size of img is `64`.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``\"reflection\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n as_tensor_output: the computation is implemented using pytorch tensors, this option specifies\n whether to convert it back to numpy arrays.\n device: device on which the tensor will be allocated.\n\n See also:\n - :py:class:`RandAffineGrid` for the random affine parameters configurations.\n - :py:class:`Affine` for the affine transformation parameters configurations.\n \"\"\"\n self.deform_grid = RandDeformGrid(\n spacing=spacing, magnitude_range=magnitude_range, as_tensor_output=True, device=device\n )\n self.rand_affine_grid = RandAffineGrid(\n rotate_range=rotate_range,\n shear_range=shear_range,\n translate_range=translate_range,\n scale_range=scale_range,\n as_tensor_output=True,\n device=device,\n )\n self.resampler = Resample(as_tensor_output=as_tensor_output, device=device)\n\n self.spatial_size = spatial_size\n self.mode: GridSampleMode = GridSampleMode(mode)\n self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)\n self.prob = prob\n self.do_transform = False", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand2DElastic.set_random_state_Rand2DElastic.randomize.self_rand_affine_grid_ran": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand2DElastic.set_random_state_Rand2DElastic.randomize.self_rand_affine_grid_ran", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1339, "end_line": 1348, "span_ids": ["Rand2DElastic.randomize", "Rand2DElastic.set_random_state"], "tokens": 123}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Rand2DElastic(Randomizable, Transform):\n\n def set_random_state(self, seed: Optional[int] = None, state: Optional[np.random.RandomState] = None):\n self.deform_grid.set_random_state(seed, state)\n self.rand_affine_grid.set_random_state(seed, state)\n super().set_random_state(seed, state)\n return self\n\n def randomize(self, spatial_size: Sequence[int]) -> None:\n self.do_transform = self.R.rand() < self.prob\n self.deform_grid.randomize(spatial_size)\n self.rand_affine_grid.randomize()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand2DElastic.__call___Rand2DElastic.__call__.return.self_resampler_img_grid_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand2DElastic.__call___Rand2DElastic.__call__.return.self_resampler_img_grid_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1350, "end_line": 1384, "span_ids": ["Rand2DElastic.__call__"], "tokens": 429}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Rand2DElastic(Randomizable, Transform):\n\n def __call__(\n self,\n img: Union[np.ndarray, torch.Tensor],\n spatial_size: Optional[Union[Tuple[int, int], int]] = None,\n mode: Optional[Union[GridSampleMode, str]] = None,\n padding_mode: Optional[Union[GridSamplePadMode, str]] = None,\n ):\n \"\"\"\n Args:\n img: shape must be (num_channels, H, W),\n spatial_size: specifying output image spatial size [h, w].\n if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,\n the transform will use the spatial size of `img`.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``self.mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``self.padding_mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n \"\"\"\n sp_size = fall_back_tuple(spatial_size or self.spatial_size, img.shape[1:])\n self.randomize(spatial_size=sp_size)\n if self.do_transform:\n grid = self.deform_grid(spatial_size=sp_size)\n grid = self.rand_affine_grid(grid=grid)\n grid = _torch_interp(\n input=grid.unsqueeze(0),\n scale_factor=list(ensure_tuple(self.deform_grid.spacing)),\n mode=InterpolateMode.BICUBIC.value,\n align_corners=False,\n )\n grid = CenterSpatialCrop(roi_size=sp_size)(grid[0])\n else:\n grid = create_grid(spatial_size=sp_size)\n return self.resampler(img, grid, mode=mode or self.mode, padding_mode=padding_mode or self.padding_mode)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand3DElastic_Rand3DElastic.__init__.self.sigma.1_0": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand3DElastic_Rand3DElastic.__init__.self.sigma.1_0", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1387, "end_line": 1463, "span_ids": ["Rand3DElastic.__init__", "Rand3DElastic"], "tokens": 1100}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Rand3DElastic(Randomizable, Transform):\n \"\"\"\n Random elastic deformation and affine in 3D\n \"\"\"\n\n def __init__(\n self,\n sigma_range: Tuple[float, float],\n magnitude_range: Tuple[float, float],\n prob: float = 0.1,\n rotate_range: Optional[Union[Sequence[float], float]] = None,\n shear_range: Optional[Union[Sequence[float], float]] = None,\n translate_range: Optional[Union[Sequence[float], float]] = None,\n scale_range: Optional[Union[Sequence[float], float]] = None,\n spatial_size: Optional[Union[Sequence[int], int]] = None,\n mode: Union[GridSampleMode, str] = GridSampleMode.BILINEAR,\n padding_mode: Union[GridSamplePadMode, str] = GridSamplePadMode.REFLECTION,\n as_tensor_output: bool = False,\n device: Optional[torch.device] = None,\n ) -> None:\n \"\"\"\n Args:\n sigma_range: a Gaussian kernel with standard deviation sampled from\n ``uniform[sigma_range[0], sigma_range[1])`` will be used to smooth the random offset grid.\n magnitude_range: the random offsets on the grid will be generated from\n ``uniform[magnitude[0], magnitude[1])``.\n prob: probability of returning a randomized affine grid.\n defaults to 0.1, with 10% chance returns a randomized grid,\n otherwise returns a ``spatial_size`` centered area extracted from the input image.\n rotate_range: angle range in radians. rotate_range[0] with be used to generate the 1st rotation\n parameter from `uniform[-rotate_range[0], rotate_range[0])`. Similarly, `rotate_range[1]` and\n `rotate_range[2]` are used in 3D affine for the range of 2nd and 3rd axes.\n shear_range: shear_range[0] with be used to generate the 1st shearing parameter from\n `uniform[-shear_range[0], shear_range[0])`. Similarly, `shear_range[1]` and `shear_range[2]`\n controls the range of the uniform distribution used to generate the 2nd and 3rd parameters.\n translate_range : translate_range[0] with be used to generate the 1st shift parameter from\n `uniform[-translate_range[0], translate_range[0])`. Similarly, `translate_range[1]` and\n `translate_range[2]` controls the range of the uniform distribution used to generate\n the 2nd and 3rd parameters.\n scale_range: scaling_range[0] with be used to generate the 1st scaling factor from\n `uniform[-scale_range[0], scale_range[0]) + 1.0`. Similarly, `scale_range[1]` and `scale_range[2]`\n controls the range of the uniform distribution used to generate the 2nd and 3rd parameters.\n spatial_size: specifying output image spatial size [h, w, d].\n if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,\n the transform will use the spatial size of `img`.\n if the components of the `spatial_size` are non-positive values, the transform will use the\n corresponding components of img size. For example, `spatial_size=(32, 32, -1)` will be adapted\n to `(32, 32, 64)` if the third spatial dimension size of img is `64`.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``\"reflection\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n as_tensor_output: the computation is implemented using pytorch tensors, this option specifies\n whether to convert it back to numpy arrays.\n device: device on which the tensor will be allocated.\n\n See also:\n - :py:class:`RandAffineGrid` for the random affine parameters configurations.\n - :py:class:`Affine` for the affine transformation parameters configurations.\n \"\"\"\n self.rand_affine_grid = RandAffineGrid(rotate_range, shear_range, translate_range, scale_range, True, device)\n self.resampler = Resample(as_tensor_output=as_tensor_output, device=device)\n\n self.sigma_range = sigma_range\n self.magnitude_range = magnitude_range\n self.spatial_size = spatial_size\n self.mode: GridSampleMode = GridSampleMode(mode)\n self.padding_mode: GridSamplePadMode = GridSamplePadMode(padding_mode)\n self.device = device\n\n self.prob = prob\n self.do_transform = False\n self.rand_offset = None\n self.magnitude = 1.0\n self.sigma = 1.0", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand3DElastic.set_random_state_Rand3DElastic.randomize.self_rand_affine_grid_ran": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand3DElastic.set_random_state_Rand3DElastic.randomize.self_rand_affine_grid_ran", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1465, "end_line": 1476, "span_ids": ["Rand3DElastic.randomize", "Rand3DElastic.set_random_state"], "tokens": 175}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Rand3DElastic(Randomizable, Transform):\n\n def set_random_state(self, seed: Optional[int] = None, state: Optional[np.random.RandomState] = None):\n self.rand_affine_grid.set_random_state(seed, state)\n super().set_random_state(seed, state)\n return self\n\n def randomize(self, grid_size: Sequence[int]) -> None:\n self.do_transform = self.R.rand() < self.prob\n if self.do_transform:\n self.rand_offset = self.R.uniform(-1.0, 1.0, [3] + list(grid_size)).astype(np.float32)\n self.magnitude = self.R.uniform(self.magnitude_range[0], self.magnitude_range[1])\n self.sigma = self.R.uniform(self.sigma_range[0], self.sigma_range[1])\n self.rand_affine_grid.randomize()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand3DElastic.__call___": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Rand3DElastic.__call___", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1478, "end_line": 1509, "span_ids": ["Rand3DElastic.__call__"], "tokens": 437}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Rand3DElastic(Randomizable, Transform):\n\n def __call__(\n self,\n img: Union[np.ndarray, torch.Tensor],\n spatial_size: Optional[Union[Tuple[int, int, int], int]] = None,\n mode: Optional[Union[GridSampleMode, str]] = None,\n padding_mode: Optional[Union[GridSamplePadMode, str]] = None,\n ):\n \"\"\"\n Args:\n img: shape must be (num_channels, H, W, D),\n spatial_size: specifying spatial 3D output image spatial size [h, w, d].\n if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,\n the transform will use the spatial size of `img`.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``self.mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``self.padding_mode``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n \"\"\"\n sp_size = fall_back_tuple(spatial_size or self.spatial_size, img.shape[1:])\n self.randomize(grid_size=sp_size)\n grid = create_grid(spatial_size=sp_size)\n if self.do_transform:\n assert self.rand_offset is not None\n grid = torch.as_tensor(np.ascontiguousarray(grid), device=self.device)\n gaussian = GaussianFilter(3, self.sigma, 3.0).to(device=self.device)\n offset = torch.as_tensor(self.rand_offset, device=self.device).unsqueeze(0)\n grid[:3] += gaussian(offset)[0] * self.magnitude\n grid = self.rand_affine_grid(grid=grid)\n return self.resampler(img, grid, mode=mode or self.mode, padding_mode=padding_mode or self.padding_mode)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_from_typing_import_Option_InterpolateModeSequence.Union_Sequence_Union_Inte": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_from_typing_import_Option_InterpolateModeSequence.Union_Sequence_Union_Inte", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 18, "end_line": 52, "span_ids": ["docstring"], "tokens": 238}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Sequence, Tuple, Union, Any\n\nimport numpy as np\nimport torch\n\nfrom monai.config import KeysCollection\nfrom monai.networks.layers.simplelayers import GaussianFilter\nfrom monai.transforms.compose import MapTransform, Randomizable\nfrom monai.transforms.croppad.array import CenterSpatialCrop\nfrom monai.transforms.spatial.array import (\n Flip,\n Orientation,\n Rand2DElastic,\n Rand3DElastic,\n RandAffine,\n Resize,\n Rotate,\n Rotate90,\n Spacing,\n Zoom,\n _torch_interp,\n)\nfrom monai.transforms.utils import create_grid\nfrom monai.utils import (\n GridSampleMode,\n GridSamplePadMode,\n InterpolateMode,\n ensure_tuple,\n ensure_tuple_rep,\n fall_back_tuple,\n)\n\nGridSampleModeSequence = Union[Sequence[Union[GridSampleMode, str]], GridSampleMode, str]\nGridSamplePadModeSequence = Union[Sequence[Union[GridSamplePadMode, str]], GridSamplePadMode, str]\nInterpolateModeSequence = Union[Sequence[Union[InterpolateMode, str]], InterpolateMode, str]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Spacingd_Spacingd.__init__.self.meta_key_postfix.meta_key_postfix": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Spacingd_Spacingd.__init__.self.meta_key_postfix.meta_key_postfix", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 55, "end_line": 121, "span_ids": ["Spacingd.__init__", "Spacingd"], "tokens": 742}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Spacingd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.Spacing`.\n\n This transform assumes the ``data`` dictionary has a key for the input\n data's metadata and contains `affine` field. The key is formed by ``key_{meta_key_postfix}``.\n\n After resampling the input array, this transform will write the new affine\n to the `affine` field of metadata which is formed by ``key_{meta_key_postfix}``.\n\n see also:\n :py:class:`monai.transforms.Spacing`\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n pixdim: Sequence[float],\n diagonal: bool = False,\n mode: GridSampleModeSequence = GridSampleMode.BILINEAR,\n padding_mode: GridSamplePadModeSequence = GridSamplePadMode.BORDER,\n dtype: Optional[Union[Sequence[np.dtype], np.dtype]] = None,\n meta_key_postfix: str = \"meta_dict\",\n ) -> None:\n \"\"\"\n Args:\n pixdim: output voxel spacing.\n diagonal: whether to resample the input to have a diagonal affine matrix.\n If True, the input data is resampled to the following affine::\n\n np.diag((pixdim_0, pixdim_1, pixdim_2, 1))\n\n This effectively resets the volume to the world coordinate system (RAS+ in nibabel).\n The original orientation, rotation, shearing are not preserved.\n\n If False, the axes orientation, orthogonal rotation and\n translations components from the original affine will be\n preserved in the target affine. This option will not flip/swap\n axes against the original ones.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``\"border\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n dtype: output array data type.\n Defaults to None to use input data's dtype. It also can be a sequence of np.dtype,\n each element corresponds to a key in ``keys``.\n meta_key_postfix: use `key_{postfix}` to to fetch the meta data according to the key data,\n default is `meta_dict`, the meta data is a dictionary object.\n For example, to handle key `image`, read/write affine matrices from the\n metadata `image_meta_dict` dictionary's `affine` field.\n\n Raises:\n ValueError: meta_key_postfix must be a string.\n\n \"\"\"\n super().__init__(keys)\n self.spacing_transform = Spacing(pixdim, diagonal=diagonal)\n self.mode = ensure_tuple_rep(mode, len(self.keys))\n self.padding_mode = ensure_tuple_rep(padding_mode, len(self.keys))\n self.dtype = ensure_tuple_rep(dtype, len(self.keys))\n if not isinstance(meta_key_postfix, str):\n raise ValueError(\"meta_key_postfix must be a string.\")\n self.meta_key_postfix = meta_key_postfix", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Spacingd.__call___Spacingd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Spacingd.__call___Spacingd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 123, "end_line": 138, "span_ids": ["Spacingd.__call__"], "tokens": 145}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Spacingd(MapTransform):\n\n def __call__(self, data):\n d = dict(data)\n for idx, key in enumerate(self.keys):\n meta_data = d[f\"{key}_{self.meta_key_postfix}\"]\n # resample array of each corresponding key\n # using affine fetched from d[affine_key]\n d[key], _, new_affine = self.spacing_transform(\n data_array=d[key],\n affine=meta_data[\"affine\"],\n mode=self.mode[idx],\n padding_mode=self.padding_mode[idx],\n dtype=self.dtype[idx],\n )\n # set the 'affine' key\n meta_data[\"affine\"] = new_affine\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Orientationd_Orientationd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Orientationd_Orientationd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 141, "end_line": 194, "span_ids": ["Orientationd.__init__", "Orientationd", "Orientationd.__call__"], "tokens": 601}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Orientationd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.Orientation`.\n\n This transform assumes the ``data`` dictionary has a key for the input\n data's metadata and contains `affine` field. The key is formed by ``key_{meta_key_postfix}``.\n\n After reorienting the input array, this transform will write the new affine\n to the `affine` field of metadata which is formed by ``key_{meta_key_postfix}``.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n axcodes: Optional[str] = None,\n as_closest_canonical: bool = False,\n labels=tuple(zip(\"LPI\", \"RAS\")),\n meta_key_postfix: str = \"meta_dict\",\n ) -> None:\n \"\"\"\n Args:\n axcodes: N elements sequence for spatial ND input's orientation.\n e.g. axcodes='RAS' represents 3D orientation:\n (Left, Right), (Posterior, Anterior), (Inferior, Superior).\n default orientation labels options are: 'L' and 'R' for the first dimension,\n 'P' and 'A' for the second, 'I' and 'S' for the third.\n as_closest_canonical: if True, load the image as closest to canonical axis format.\n labels: optional, None or sequence of (2,) sequences\n (2,) sequences are labels for (beginning, end) of output axis.\n Defaults to ``(('L', 'R'), ('P', 'A'), ('I', 'S'))``.\n meta_key_postfix: use `key_{postfix}` to to fetch the meta data according to the key data,\n default is `meta_dict`, the meta data is a dictionary object.\n For example, to handle key `image`, read/write affine matrices from the\n metadata `image_meta_dict` dictionary's `affine` field.\n\n Raises:\n ValueError: meta_key_postfix must be a string.\n\n See Also:\n `nibabel.orientations.ornt2axcodes`.\n \"\"\"\n super().__init__(keys)\n self.ornt_transform = Orientation(axcodes=axcodes, as_closest_canonical=as_closest_canonical, labels=labels)\n if not isinstance(meta_key_postfix, str):\n raise ValueError(\"meta_key_postfix must be a string.\")\n self.meta_key_postfix = meta_key_postfix\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n meta_data = d[f\"{key}_{self.meta_key_postfix}\"]\n d[key], _, new_affine = self.ornt_transform(d[key], affine=meta_data[\"affine\"])\n meta_data[\"affine\"] = new_affine\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rotate90d_Rotate90d.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rotate90d_Rotate90d.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 197, "end_line": 216, "span_ids": ["Rotate90d.__call__", "Rotate90d.__init__", "Rotate90d"], "tokens": 177}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Rotate90d(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.Rotate90`.\n \"\"\"\n\n def __init__(self, keys: KeysCollection, k: int = 1, spatial_axes: Tuple[int, int] = (0, 1)) -> None:\n \"\"\"\n Args:\n k: number of times to rotate by 90 degrees.\n spatial_axes: 2 int numbers, defines the plane to rotate with 2 spatial axes.\n Default: (0, 1), this is the first two axis in spatial dimensions.\n \"\"\"\n super().__init__(keys)\n self.rotator = Rotate90(k, spatial_axes)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.rotator(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandRotate90d_RandRotate90d.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandRotate90d_RandRotate90d.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 219, "end_line": 262, "span_ids": ["RandRotate90d", "RandRotate90d.__call__", "RandRotate90d.__init__", "RandRotate90d.randomize"], "tokens": 407}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandRotate90d(Randomizable, MapTransform):\n \"\"\"\n Dictionary-based version :py:class:`monai.transforms.RandRotate90`.\n With probability `prob`, input arrays are rotated by 90 degrees\n in the plane specified by `spatial_axes`.\n \"\"\"\n\n def __init__(\n self, keys: KeysCollection, prob: float = 0.1, max_k: int = 3, spatial_axes: Tuple[int, int] = (0, 1),\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n prob: probability of rotating.\n (Default 0.1, with 10% probability it returns a rotated array.)\n max_k: number of rotations will be sampled from `np.random.randint(max_k) + 1`.\n (Default 3)\n spatial_axes: 2 int numbers, defines the plane to rotate with 2 spatial axes.\n Default: (0, 1), this is the first two axis in spatial dimensions.\n \"\"\"\n super().__init__(keys)\n\n self.prob = min(max(prob, 0.0), 1.0)\n self.max_k = max_k\n self.spatial_axes = spatial_axes\n\n self._do_transform = False\n self._rand_k = 0\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self._rand_k = self.R.randint(self.max_k) + 1\n self._do_transform = self.R.random() < self.prob\n\n def __call__(self, data):\n self.randomize()\n if not self._do_transform:\n return data\n\n rotator = Rotate90(self._rand_k, self.spatial_axes)\n d = dict(data)\n for key in self.keys:\n d[key] = rotator(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Resized_Resized.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Resized_Resized.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 265, "end_line": 302, "span_ids": ["Resized.__call__", "Resized.__init__", "Resized"], "tokens": 462}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Resized(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.Resize`.\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n spatial_size: expected shape of spatial dimensions after resize operation.\n if the components of the `spatial_size` are non-positive values, the transform will use the\n corresponding components of img size. For example, `spatial_size=(32, -1)` will be adapted\n to `(32, 64)` if the second spatial dimension size of img is `64`.\n mode: {``\"nearest\"``, ``\"linear\"``, ``\"bilinear\"``, ``\"bicubic\"``, ``\"trilinear\"``, ``\"area\"``}\n The interpolation mode. Defaults to ``\"area\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n align_corners (bool, None or sequence of bool or None): This only has an effect when mode is\n 'linear', 'bilinear', 'bicubic' or 'trilinear'. Default: None.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n It also can be a sequence of bool or None, each element corresponds to a key in ``keys``.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n spatial_size: Union[Sequence[int], int],\n mode: InterpolateModeSequence = InterpolateMode.AREA,\n align_corners=None,\n ) -> None:\n super().__init__(keys)\n self.mode = ensure_tuple_rep(mode, len(self.keys))\n self.align_corners = ensure_tuple_rep(align_corners, len(self.keys))\n self.resizer = Resize(spatial_size=spatial_size)\n\n def __call__(self, data):\n d = dict(data)\n for idx, key in enumerate(self.keys):\n d[key] = self.resizer(d[key], mode=self.mode[idx], align_corners=self.align_corners[idx])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandAffined_RandAffined.__init__.self.padding_mode.ensure_tuple_rep_padding_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandAffined_RandAffined.__init__.self.padding_mode.ensure_tuple_rep_padding_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 305, "end_line": 378, "span_ids": ["RandAffined.__init__", "RandAffined"], "tokens": 997}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandAffined(Randomizable, MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.RandAffine`.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n spatial_size: Optional[Union[Sequence[int], int]] = None,\n prob: float = 0.1,\n rotate_range: Optional[Union[Sequence[float], float]] = None,\n shear_range: Optional[Union[Sequence[float], float]] = None,\n translate_range: Optional[Union[Sequence[float], float]] = None,\n scale_range: Optional[Union[Sequence[float], float]] = None,\n mode: GridSampleModeSequence = GridSampleMode.BILINEAR,\n padding_mode: GridSamplePadModeSequence = GridSamplePadMode.REFLECTION,\n as_tensor_output: bool = True,\n device: Optional[torch.device] = None,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n spatial_size: output image spatial size.\n if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,\n the transform will use the spatial size of `img`.\n if the components of the `spatial_size` are non-positive values, the transform will use the\n corresponding components of img size. For example, `spatial_size=(32, -1)` will be adapted\n to `(32, 64)` if the second spatial dimension size of img is `64`.\n prob: probability of returning a randomized affine grid.\n defaults to 0.1, with 10% chance returns a randomized grid.\n rotate_range: angle range in radians. rotate_range[0] with be used to generate the 1st rotation\n parameter from `uniform[-rotate_range[0], rotate_range[0])`. Similarly, `rotate_range[1]` and\n `rotate_range[2]` are used in 3D affine for the range of 2nd and 3rd axes.\n shear_range: shear_range[0] with be used to generate the 1st shearing parameter from\n `uniform[-shear_range[0], shear_range[0])`. Similarly, `shear_range[1]` to\n `shear_range[N]` controls the range of the uniform distribution used to generate the 2nd to\n N-th parameter.\n translate_range : translate_range[0] with be used to generate the 1st shift parameter from\n `uniform[-translate_range[0], translate_range[0])`. Similarly, `translate_range[1]`\n to `translate_range[N]` controls the range of the uniform distribution used to generate\n the 2nd to N-th parameter.\n scale_range: scaling_range[0] with be used to generate the 1st scaling factor from\n `uniform[-scale_range[0], scale_range[0]) + 1.0`. Similarly, `scale_range[1]` to\n `scale_range[N]` controls the range of the uniform distribution used to generate the 2nd to\n N-th parameter.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``\"reflection\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n as_tensor_output: the computation is implemented using pytorch tensors, this option specifies\n whether to convert it back to numpy arrays.\n device: device on which the tensor will be allocated.\n\n See also:\n - :py:class:`monai.transforms.compose.MapTransform`\n - :py:class:`RandAffineGrid` for the random affine parameters configurations.\n \"\"\"\n super().__init__(keys)\n self.rand_affine = RandAffine(\n prob=prob,\n rotate_range=rotate_range,\n shear_range=shear_range,\n translate_range=translate_range,\n scale_range=scale_range,\n spatial_size=spatial_size,\n as_tensor_output=as_tensor_output,\n device=device,\n )\n self.mode = ensure_tuple_rep(mode, len(self.keys))\n self.padding_mode = ensure_tuple_rep(padding_mode, len(self.keys))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandAffined.set_random_state_RandAffined.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandAffined.set_random_state_RandAffined.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 380, "end_line": 400, "span_ids": ["RandAffined.__call__", "RandAffined.set_random_state", "RandAffined.randomize"], "tokens": 214}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandAffined(Randomizable, MapTransform):\n\n def set_random_state(self, seed: Optional[int] = None, state: Optional[np.random.RandomState] = None):\n self.rand_affine.set_random_state(seed, state)\n super().set_random_state(seed, state)\n return self\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self.rand_affine.randomize()\n\n def __call__(self, data):\n d = dict(data)\n self.randomize()\n\n sp_size = fall_back_tuple(self.rand_affine.spatial_size, data[self.keys[0]].shape[1:])\n if self.rand_affine.do_transform:\n grid = self.rand_affine.rand_affine_grid(spatial_size=sp_size)\n else:\n grid = create_grid(spatial_size=sp_size)\n\n for idx, key in enumerate(self.keys):\n d[key] = self.rand_affine.resampler(d[key], grid, mode=self.mode[idx], padding_mode=self.padding_mode[idx])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rand2DElasticd_Rand2DElasticd.__init__.self.padding_mode.ensure_tuple_rep_padding_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rand2DElasticd_Rand2DElasticd.__init__.self.padding_mode.ensure_tuple_rep_padding_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 403, "end_line": 480, "span_ids": ["Rand2DElasticd", "Rand2DElasticd.__init__"], "tokens": 1028}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Rand2DElasticd(Randomizable, MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.Rand2DElastic`.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n spacing: Union[Tuple[float, float], float],\n magnitude_range: Tuple[float, float],\n spatial_size: Optional[Union[Sequence[int], int]] = None,\n prob: float = 0.1,\n rotate_range: Optional[Union[Sequence[float], float]] = None,\n shear_range: Optional[Union[Sequence[float], float]] = None,\n translate_range: Optional[Union[Sequence[float], float]] = None,\n scale_range: Optional[Union[Sequence[float], float]] = None,\n mode: GridSampleModeSequence = GridSampleMode.BILINEAR,\n padding_mode: GridSamplePadModeSequence = GridSamplePadMode.REFLECTION,\n as_tensor_output: bool = False,\n device: Optional[torch.device] = None,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n spacing: distance in between the control points.\n magnitude_range: 2 int numbers, the random offsets will be generated from\n ``uniform[magnitude[0], magnitude[1])``.\n spatial_size: specifying output image spatial size [h, w].\n if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,\n the transform will use the spatial size of `img`.\n if the components of the `spatial_size` are non-positive values, the transform will use the\n corresponding components of img size. For example, `spatial_size=(32, -1)` will be adapted\n to `(32, 64)` if the second spatial dimension size of img is `64`.\n prob: probability of returning a randomized affine grid.\n defaults to 0.1, with 10% chance returns a randomized grid,\n otherwise returns a ``spatial_size`` centered area extracted from the input image.\n rotate_range: angle range in radians. rotate_range[0] with be used to generate the 1st rotation\n parameter from `uniform[-rotate_range[0], rotate_range[0])`.\n shear_range: shear_range[0] with be used to generate the 1st shearing parameter from\n `uniform[-shear_range[0], shear_range[0])`. Similarly, `shear_range[1]` controls\n the range of the uniform distribution used to generate the 2nd parameter.\n translate_range : translate_range[0] with be used to generate the 1st shift parameter from\n `uniform[-translate_range[0], translate_range[0])`. Similarly, `translate_range[1]` controls\n the range of the uniform distribution used to generate the 2nd parameter.\n scale_range: scaling_range[0] with be used to generate the 1st scaling factor from\n `uniform[-scale_range[0], scale_range[0]) + 1.0`. Similarly, `scale_range[1]` controls\n the range of the uniform distribution used to generate the 2nd parameter.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``\"reflection\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n as_tensor_output: the computation is implemented using pytorch tensors, this option specifies\n whether to convert it back to numpy arrays.\n device: device on which the tensor will be allocated.\n\n See also:\n - :py:class:`RandAffineGrid` for the random affine parameters configurations.\n - :py:class:`Affine` for the affine transformation parameters configurations.\n \"\"\"\n super().__init__(keys)\n self.rand_2d_elastic = Rand2DElastic(\n spacing=spacing,\n magnitude_range=magnitude_range,\n prob=prob,\n rotate_range=rotate_range,\n shear_range=shear_range,\n translate_range=translate_range,\n scale_range=scale_range,\n spatial_size=spatial_size,\n as_tensor_output=as_tensor_output,\n device=device,\n )\n self.mode = ensure_tuple_rep(mode, len(self.keys))\n self.padding_mode = ensure_tuple_rep(padding_mode, len(self.keys))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rand2DElasticd.set_random_state_Rand2DElasticd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rand2DElasticd.set_random_state_Rand2DElasticd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 482, "end_line": 513, "span_ids": ["Rand2DElasticd.randomize", "Rand2DElasticd.__call__", "Rand2DElasticd.set_random_state"], "tokens": 329}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Rand2DElasticd(Randomizable, MapTransform):\n\n def set_random_state(self, seed: Optional[int] = None, state: Optional[np.random.RandomState] = None):\n self.rand_2d_elastic.set_random_state(seed, state)\n super().set_random_state(seed, state)\n return self\n\n def randomize(self, spatial_size: Sequence[int]) -> None:\n self.rand_2d_elastic.randomize(spatial_size)\n\n def __call__(self, data):\n d = dict(data)\n\n sp_size = fall_back_tuple(self.rand_2d_elastic.spatial_size, data[self.keys[0]].shape[1:])\n self.randomize(spatial_size=sp_size)\n\n if self.rand_2d_elastic.do_transform:\n grid = self.rand_2d_elastic.deform_grid(spatial_size=sp_size)\n grid = self.rand_2d_elastic.rand_affine_grid(grid=grid)\n grid = _torch_interp(\n input=grid.unsqueeze(0),\n scale_factor=list(self.rand_2d_elastic.deform_grid.spacing),\n mode=InterpolateMode.BICUBIC.value,\n align_corners=False,\n )\n grid = CenterSpatialCrop(roi_size=sp_size)(grid[0])\n else:\n grid = create_grid(spatial_size=sp_size)\n\n for idx, key in enumerate(self.keys):\n d[key] = self.rand_2d_elastic.resampler(\n d[key], grid, mode=self.mode[idx], padding_mode=self.padding_mode[idx]\n )\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rand3DElasticd_Rand3DElasticd.__init__.self.padding_mode.ensure_tuple_rep_padding_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rand3DElasticd_Rand3DElasticd.__init__.self.padding_mode.ensure_tuple_rep_padding_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 516, "end_line": 596, "span_ids": ["Rand3DElasticd", "Rand3DElasticd.__init__"], "tokens": 1137}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Rand3DElasticd(Randomizable, MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.Rand3DElastic`.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n sigma_range: Tuple[float, float],\n magnitude_range: Tuple[float, float],\n spatial_size: Optional[Union[Sequence[int], int]] = None,\n prob: float = 0.1,\n rotate_range: Optional[Union[Sequence[float], float]] = None,\n shear_range: Optional[Union[Sequence[float], float]] = None,\n translate_range: Optional[Union[Sequence[float], float]] = None,\n scale_range: Optional[Union[Sequence[float], float]] = None,\n mode: GridSampleModeSequence = GridSampleMode.BILINEAR,\n padding_mode: GridSamplePadModeSequence = GridSamplePadMode.REFLECTION,\n as_tensor_output: bool = False,\n device: Optional[torch.device] = None,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n sigma_range: a Gaussian kernel with standard deviation sampled from\n ``uniform[sigma_range[0], sigma_range[1])`` will be used to smooth the random offset grid.\n magnitude_range: the random offsets on the grid will be generated from\n ``uniform[magnitude[0], magnitude[1])``.\n spatial_size: specifying output image spatial size [h, w, d].\n if `spatial_size` and `self.spatial_size` are not defined, or smaller than 1,\n the transform will use the spatial size of `img`.\n if the components of the `spatial_size` are non-positive values, the transform will use the\n corresponding components of img size. For example, `spatial_size=(32, 32, -1)` will be adapted\n to `(32, 32, 64)` if the third spatial dimension size of img is `64`.\n prob: probability of returning a randomized affine grid.\n defaults to 0.1, with 10% chance returns a randomized grid,\n otherwise returns a ``spatial_size`` centered area extracted from the input image.\n rotate_range: angle range in radians. rotate_range[0] with be used to generate the 1st rotation\n parameter from `uniform[-rotate_range[0], rotate_range[0])`. Similarly, `rotate_range[1]` and\n `rotate_range[2]` are used in 3D affine for the range of 2nd and 3rd axes.\n shear_range: shear_range[0] with be used to generate the 1st shearing parameter from\n `uniform[-shear_range[0], shear_range[0])`. Similarly, `shear_range[1]` and `shear_range[2]`\n controls the range of the uniform distribution used to generate the 2nd and 3rd parameters.\n translate_range : translate_range[0] with be used to generate the 1st shift parameter from\n `uniform[-translate_range[0], translate_range[0])`. Similarly, `translate_range[1]` and\n `translate_range[2]` controls the range of the uniform distribution used to generate\n the 2nd and 3rd parameters.\n scale_range: scaling_range[0] with be used to generate the 1st scaling factor from\n `uniform[-scale_range[0], scale_range[0]) + 1.0`. Similarly, `scale_range[1]` and `scale_range[2]`\n controls the range of the uniform distribution used to generate the 2nd and 3rd parameters.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``\"reflection\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n as_tensor_output: the computation is implemented using pytorch tensors, this option specifies\n whether to convert it back to numpy arrays.\n device: device on which the tensor will be allocated.\n\n See also:\n - :py:class:`RandAffineGrid` for the random affine parameters configurations.\n - :py:class:`Affine` for the affine transformation parameters configurations.\n \"\"\"\n super().__init__(keys)\n self.rand_3d_elastic = Rand3DElastic(\n sigma_range=sigma_range,\n magnitude_range=magnitude_range,\n prob=prob,\n rotate_range=rotate_range,\n shear_range=shear_range,\n translate_range=translate_range,\n scale_range=scale_range,\n spatial_size=spatial_size,\n as_tensor_output=as_tensor_output,\n device=device,\n )\n self.mode = ensure_tuple_rep(mode, len(self.keys))\n self.padding_mode = ensure_tuple_rep(padding_mode, len(self.keys))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rand3DElasticd.set_random_state_Rand3DElasticd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rand3DElasticd.set_random_state_Rand3DElasticd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 598, "end_line": 624, "span_ids": ["Rand3DElasticd.__call__", "Rand3DElasticd.set_random_state", "Rand3DElasticd.randomize"], "tokens": 333}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Rand3DElasticd(Randomizable, MapTransform):\n\n def set_random_state(self, seed: Optional[int] = None, state: Optional[np.random.RandomState] = None):\n self.rand_3d_elastic.set_random_state(seed, state)\n super().set_random_state(seed, state)\n return self\n\n def randomize(self, grid_size: Sequence[int]) -> None:\n self.rand_3d_elastic.randomize(grid_size)\n\n def __call__(self, data):\n d = dict(data)\n sp_size = fall_back_tuple(self.rand_3d_elastic.spatial_size, data[self.keys[0]].shape[1:])\n\n self.randomize(grid_size=sp_size)\n grid = create_grid(spatial_size=sp_size)\n if self.rand_3d_elastic.do_transform:\n device = self.rand_3d_elastic.device\n grid = torch.tensor(grid).to(device)\n gaussian = GaussianFilter(spatial_dims=3, sigma=self.rand_3d_elastic.sigma, truncated=3.0).to(device)\n offset = torch.tensor(self.rand_3d_elastic.rand_offset, device=device).unsqueeze(0)\n grid[:3] += gaussian(offset)[0] * self.rand_3d_elastic.magnitude\n grid = self.rand_3d_elastic.rand_affine_grid(grid=grid)\n\n for idx, key in enumerate(self.keys):\n d[key] = self.rand_3d_elastic.resampler(\n d[key], grid, mode=self.mode[idx], padding_mode=self.padding_mode[idx]\n )\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Flipd_Flipd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Flipd_Flipd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 627, "end_line": 647, "span_ids": ["Flipd.__init__", "Flipd", "Flipd.__call__"], "tokens": 168}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Flipd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.Flip`.\n\n See `numpy.flip` for additional details.\n https://docs.scipy.org/doc/numpy/reference/generated/numpy.flip.html\n\n Args:\n keys: Keys to pick data for transformation.\n spatial_axis: Spatial axes along which to flip over. Default is None.\n \"\"\"\n\n def __init__(self, keys: KeysCollection, spatial_axis: Optional[Union[Sequence[int], int]] = None) -> None:\n super().__init__(keys)\n self.flipper = Flip(spatial_axis=spatial_axis)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.flipper(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandFlipd_RandFlipd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandFlipd_RandFlipd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 650, "end_line": 683, "span_ids": ["RandFlipd", "RandFlipd.__init__", "RandFlipd.__call__", "RandFlipd.randomize"], "tokens": 262}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandFlipd(Randomizable, MapTransform):\n \"\"\"\n Dictionary-based version :py:class:`monai.transforms.RandFlip`.\n\n See `numpy.flip` for additional details.\n https://docs.scipy.org/doc/numpy/reference/generated/numpy.flip.html\n\n Args:\n keys: Keys to pick data for transformation.\n prob: Probability of flipping.\n spatial_axis: Spatial axes along which to flip over. Default is None.\n \"\"\"\n\n def __init__(\n self, keys: KeysCollection, prob: float = 0.1, spatial_axis: Optional[Union[Sequence[int], int]] = None,\n ) -> None:\n super().__init__(keys)\n self.spatial_axis = spatial_axis\n self.prob = prob\n\n self._do_transform = False\n self.flipper = Flip(spatial_axis=spatial_axis)\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self._do_transform = self.R.random_sample() < self.prob\n\n def __call__(self, data):\n self.randomize()\n d = dict(data)\n if not self._do_transform:\n return d\n for key in self.keys:\n d[key] = self.flipper(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rotated_Rotated.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Rotated_Rotated.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 686, "end_line": 731, "span_ids": ["Rotated.__init__", "Rotated.__call__", "Rotated"], "tokens": 510}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Rotated(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.Rotate`.\n\n Args:\n keys: Keys to pick data for transformation.\n angle: Rotation angle(s) in degrees.\n keep_size: If it is False, the output shape is adapted so that the\n input array is contained completely in the output.\n If it is True, the output shape is the same as the input. Default is True.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``\"border\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n align_corners: Defaults to False.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n It also can be a sequence of bool, each element corresponds to a key in ``keys``.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n angle: Union[Sequence[float], float],\n keep_size: bool = True,\n mode: GridSampleModeSequence = GridSampleMode.BILINEAR,\n padding_mode: GridSamplePadModeSequence = GridSamplePadMode.BORDER,\n align_corners: Union[Sequence[bool], bool] = False,\n ) -> None:\n super().__init__(keys)\n self.rotator = Rotate(angle=angle, keep_size=keep_size)\n\n self.mode = ensure_tuple_rep(mode, len(self.keys))\n self.padding_mode = ensure_tuple_rep(padding_mode, len(self.keys))\n self.align_corners = ensure_tuple_rep(align_corners, len(self.keys))\n\n def __call__(self, data):\n d = dict(data)\n for idx, key in enumerate(self.keys):\n d[key] = self.rotator(\n d[key], mode=self.mode[idx], padding_mode=self.padding_mode[idx], align_corners=self.align_corners[idx],\n )\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandRotated_RandRotated._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandRotated_RandRotated._", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 734, "end_line": 762, "span_ids": ["RandRotated"], "tokens": 421}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandRotated(Randomizable, MapTransform):\n \"\"\"\n Dictionary-based version :py:class:`monai.transforms.RandRotate`\n Randomly rotates the input arrays.\n\n Args:\n keys: Keys to pick data for transformation.\n range_x: Range of rotation angle in degrees in the plane defined by the first and second axes.\n If single number, angle is uniformly sampled from (-range_x, range_x).\n range_y: Range of rotation angle in degrees in the plane defined by the first and third axes.\n If single number, angle is uniformly sampled from (-range_y, range_y).\n range_z: Range of rotation angle in degrees in the plane defined by the second and third axes.\n If single number, angle is uniformly sampled from (-range_z, range_z).\n prob: Probability of rotation.\n keep_size: If it is False, the output shape is adapted so that the\n input array is contained completely in the output.\n If it is True, the output shape is the same as the input. Default is True.\n mode: {``\"bilinear\"``, ``\"nearest\"``}\n Interpolation mode to calculate output values. Defaults to ``\"bilinear\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n padding_mode: {``\"zeros\"``, ``\"border\"``, ``\"reflection\"``}\n Padding mode for outside grid values. Defaults to ``\"border\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n align_corners: Defaults to False.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n It also can be a sequence of bool, each element corresponds to a key in ``keys``.\n \"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandRotated.__init___RandRotated.randomize.self.z.self_R_uniform_low_self_r": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandRotated.__init___RandRotated.randomize.self.z.self_R_uniform_low_self_r", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 764, "end_line": 802, "span_ids": ["RandRotated.randomize", "RandRotated.__init__"], "tokens": 472}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandRotated(Randomizable, MapTransform):\n\n def __init__(\n self,\n keys: KeysCollection,\n range_x: Union[Tuple[float, float], float] = 0.0,\n range_y: Union[Tuple[float, float], float] = 0.0,\n range_z: Union[Tuple[float, float], float] = 0.0,\n prob: float = 0.1,\n keep_size: bool = True,\n mode: GridSampleModeSequence = GridSampleMode.BILINEAR,\n padding_mode: GridSamplePadModeSequence = GridSamplePadMode.BORDER,\n align_corners: Union[Sequence[bool], bool] = False,\n ) -> None:\n super().__init__(keys)\n self.range_x = ensure_tuple(range_x)\n if len(self.range_x) == 1:\n self.range_x = tuple(sorted([-self.range_x[0], self.range_x[0]]))\n self.range_y = ensure_tuple(range_y)\n if len(self.range_y) == 1:\n self.range_y = tuple(sorted([-self.range_y[0], self.range_y[0]]))\n self.range_z = ensure_tuple(range_z)\n if len(self.range_z) == 1:\n self.range_z = tuple(sorted([-self.range_z[0], self.range_z[0]]))\n\n self.prob = prob\n self.keep_size = keep_size\n self.mode = ensure_tuple_rep(mode, len(self.keys))\n self.padding_mode = ensure_tuple_rep(padding_mode, len(self.keys))\n self.align_corners = ensure_tuple_rep(align_corners, len(self.keys))\n\n self._do_transform = False\n self.x = 0.0\n self.y = 0.0\n self.z = 0.0\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self._do_transform = self.R.random_sample() < self.prob\n self.x = self.R.uniform(low=self.range_x[0], high=self.range_x[1])\n self.y = self.R.uniform(low=self.range_y[0], high=self.range_y[1])\n self.z = self.R.uniform(low=self.range_z[0], high=self.range_z[1])", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandRotated.__call___RandRotated.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandRotated.__call___RandRotated.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 804, "end_line": 816, "span_ids": ["RandRotated.__call__"], "tokens": 129}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandRotated(Randomizable, MapTransform):\n\n def __call__(self, data):\n self.randomize()\n d = dict(data)\n if not self._do_transform:\n return d\n rotator = Rotate(\n angle=self.x if d[self.keys[0]].ndim == 3 else (self.x, self.y, self.z), keep_size=self.keep_size,\n )\n for idx, key in enumerate(self.keys):\n d[key] = rotator(\n d[key], mode=self.mode[idx], padding_mode=self.padding_mode[idx], align_corners=self.align_corners[idx],\n )\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Zoomd_Zoomd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Zoomd_Zoomd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 819, "end_line": 856, "span_ids": ["Zoomd.__call__", "Zoomd.__init__", "Zoomd"], "tokens": 433}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Zoomd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.Zoom`.\n\n Args:\n keys: Keys to pick data for transformation.\n zoom: The zoom factor along the spatial axes.\n If a float, zoom is the same for each spatial axis.\n If a sequence, zoom should contain one value for each spatial axis.\n mode: {``\"nearest\"``, ``\"linear\"``, ``\"bilinear\"``, ``\"bicubic\"``, ``\"trilinear\"``, ``\"area\"``}\n The interpolation mode. Defaults to ``\"area\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n align_corners (bool, None or sequence of bool or None): This only has an effect when mode is\n 'linear', 'bilinear', 'bicubic' or 'trilinear'. Default: None.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n It also can be a sequence of bool or None, each element corresponds to a key in ``keys``.\n keep_size: Should keep original size (pad if needed), default is True.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n zoom: Union[Sequence[float], float],\n mode: InterpolateModeSequence = InterpolateMode.AREA,\n align_corners=None,\n keep_size: bool = True,\n ) -> None:\n super().__init__(keys)\n self.mode = ensure_tuple_rep(mode, len(self.keys))\n self.align_corners = ensure_tuple_rep(align_corners, len(self.keys))\n self.zoomer = Zoom(zoom=zoom, keep_size=keep_size)\n\n def __call__(self, data):\n d = dict(data)\n for idx, key in enumerate(self.keys):\n d[key] = self.zoomer(d[key], mode=self.mode[idx], align_corners=self.align_corners[idx])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandZoomd_RandZoomd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_RandZoomd_RandZoomd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 859, "end_line": 924, "span_ids": ["RandZoomd.__init__", "RandZoomd.randomize", "RandZoomd.__call__", "RandZoomd"], "tokens": 777}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandZoomd(Randomizable, MapTransform):\n \"\"\"\n Dict-based version :py:class:`monai.transforms.RandZoom`.\n\n Args:\n keys: Keys to pick data for transformation.\n prob: Probability of zooming.\n min_zoom: Min zoom factor. Can be float or sequence same size as image.\n If a float, select a random factor from `[min_zoom, max_zoom]` then apply to all spatial dims\n to keep the original spatial shape ratio.\n If a sequence, min_zoom should contain one value for each spatial axis.\n max_zoom: Max zoom factor. Can be float or sequence same size as image.\n If a float, select a random factor from `[min_zoom, max_zoom]` then apply to all spatial dims\n to keep the original spatial shape ratio.\n If a sequence, max_zoom should contain one value for each spatial axis.\n mode: {``\"nearest\"``, ``\"linear\"``, ``\"bilinear\"``, ``\"bicubic\"``, ``\"trilinear\"``, ``\"area\"``}\n The interpolation mode. Defaults to ``\"area\"``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n align_corners (bool, None or sequence of bool or None): This only has an effect when mode is\n 'linear', 'bilinear', 'bicubic' or 'trilinear'. Default: None.\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n It also can be a sequence of bool or None, each element corresponds to a key in ``keys``.\n keep_size: Should keep original size (pad if needed), default is True.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n prob: float = 0.1,\n min_zoom: Union[Sequence[float], float] = 0.9,\n max_zoom: Union[Sequence[float], float] = 1.1,\n mode: InterpolateModeSequence = InterpolateMode.AREA,\n align_corners=None,\n keep_size: bool = True,\n ) -> None:\n super().__init__(keys)\n self.min_zoom = ensure_tuple(min_zoom)\n self.max_zoom = ensure_tuple(max_zoom)\n assert len(self.min_zoom) == len(self.max_zoom), \"min_zoom and max_zoom must have same length.\"\n self.prob = prob\n\n self.mode = ensure_tuple_rep(mode, len(self.keys))\n self.align_corners = ensure_tuple_rep(align_corners, len(self.keys))\n self.keep_size = keep_size\n\n self._do_transform = False\n self._zoom: Union[Sequence[float], float]\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self._do_transform = self.R.random_sample() < self.prob\n self._zoom = [self.R.uniform(l, h) for l, h in zip(self.min_zoom, self.max_zoom)]\n if len(self._zoom) == 1:\n # to keep the spatial shape ratio, use same random zoom factor for all dims\n self._zoom = self._zoom[0]\n\n def __call__(self, data):\n # match the spatial dim of first item\n self.randomize()\n d = dict(data)\n if not self._do_transform:\n return d\n zoomer = Zoom(self._zoom, keep_size=self.keep_size)\n for idx, key in enumerate(self.keys):\n d[key] = zoomer(d[key], mode=self.mode[idx], align_corners=self.align_corners[idx])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_SpacingD_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_SpacingD_", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 927, "end_line": 941, "span_ids": ["impl:7"], "tokens": 168}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "SpacingD = SpacingDict = Spacingd\nOrientationD = OrientationDict = Orientationd\nRotate90D = Rotate90Dict = Rotate90d\nRandRotate90D = RandRotate90Dict = RandRotate90d\nResizeD = ResizeDict = Resized\nRandAffineD = RandAffineDict = RandAffined\nRand2DElasticD = Rand2DElasticDict = Rand2DElasticd\nRand3DElasticD = Rand3DElasticDict = Rand3DElasticd\nFlipD = FlipDict = Flipd\nRandFlipD = RandFlipDict = RandFlipd\nRotateD = RotateDict = Rotated\nRandRotateD = RandRotateDict = RandRotated\nZoomD = ZoomDict = Zoomd\nRandZoomD = RandZoomDict = RandZoomd", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/__init__.py__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/__init__.py__", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 11, "end_line": 11, "span_ids": [], "tokens": 0}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_from_typing_import_Callab_Identity.__call__.return.np_asanyarray_img_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_from_typing_import_Callab_Identity.__call__.return.np_asanyarray_img_", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 16, "end_line": 40, "span_ids": ["Identity.__call__", "Identity", "docstring"], "tokens": 133}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Optional, Union, Sequence\n\nimport time\nimport logging\n\nimport numpy as np\nimport torch\n\nfrom monai.transforms.compose import Transform\nfrom monai.utils import ensure_tuple\n\n\nclass Identity(Transform):\n \"\"\"\n Convert the input to an np.ndarray, if input data is np.ndarray or subclasses, return unchanged data.\n As the output value is same as input, it can be used as a testing tool to verify the transform chain,\n Compose or transform adaptor, etc.\n\n \"\"\"\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n return np.asanyarray(img)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_AsChannelFirst_AsChannelFirst.__call__.return.np_moveaxis_img_self_cha": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_AsChannelFirst_AsChannelFirst.__call__.return.np_moveaxis_img_self_cha", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 43, "end_line": 67, "span_ids": ["AsChannelFirst.__init__", "AsChannelFirst", "AsChannelFirst.__call__"], "tokens": 234}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AsChannelFirst(Transform):\n \"\"\"\n Change the channel dimension of the image to the first dimension.\n\n Most of the image transformations in ``monai.transforms``\n assume the input image is in the channel-first format, which has the shape\n (num_channels, spatial_dim_1[, spatial_dim_2, ...]).\n\n This transform could be used to convert, for example, a channel-last image array in shape\n (spatial_dim_1[, spatial_dim_2, ...], num_channels) into the channel-first format,\n so that the multidimensional image array can be correctly interpreted by the other transforms.\n\n Args:\n channel_dim: which dimension of input image is the channel, default is the last dimension.\n \"\"\"\n\n def __init__(self, channel_dim: int = -1) -> None:\n assert isinstance(channel_dim, int) and channel_dim >= -1, \"invalid channel dimension.\"\n self.channel_dim = channel_dim\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n return np.moveaxis(img, self.channel_dim, 0)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_AsChannelLast_AsChannelLast.__call__.return.np_moveaxis_img_self_cha": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_AsChannelLast_AsChannelLast.__call__.return.np_moveaxis_img_self_cha", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 70, "end_line": 93, "span_ids": ["AsChannelLast.__init__", "AsChannelLast.__call__", "AsChannelLast"], "tokens": 228}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AsChannelLast(Transform):\n \"\"\"\n Change the channel dimension of the image to the last dimension.\n\n Some of other 3rd party transforms assume the input image is in the channel-last format with shape\n (spatial_dim_1[, spatial_dim_2, ...], num_channels).\n\n This transform could be used to convert, for example, a channel-first image array in shape\n (num_channels, spatial_dim_1[, spatial_dim_2, ...]) into the channel-last format,\n so that MONAI transforms can construct a chain with other 3rd party transforms together.\n\n Args:\n channel_dim: which dimension of input image is the channel, default is the first dimension.\n \"\"\"\n\n def __init__(self, channel_dim: int = 0) -> None:\n assert isinstance(channel_dim, int) and channel_dim >= -1, \"invalid channel dimension.\"\n self.channel_dim = channel_dim\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n return np.moveaxis(img, self.channel_dim, -1)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_AddChannel_AddChannel.__call__.return.img_None_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_AddChannel_AddChannel.__call__.return.img_None_", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 96, "end_line": 114, "span_ids": ["AddChannel.__call__", "AddChannel"], "tokens": 151}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AddChannel(Transform):\n \"\"\"\n Adds a 1-length channel dimension to the input image.\n\n Most of the image transformations in ``monai.transforms``\n assumes the input image is in the channel-first format, which has the shape\n (num_channels, spatial_dim_1[, spatial_dim_2, ...]).\n\n This transform could be used, for example, to convert a (spatial_dim_1[, spatial_dim_2, ...])\n spatial image into the channel-first format so that the\n multidimensional image array can be correctly interpreted by the other\n transforms.\n \"\"\"\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n return img[None]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_RepeatChannel_RepeatChannel.__call__.return.np_repeat_img_self_repea": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_RepeatChannel_RepeatChannel.__call__.return.np_repeat_img_self_repea", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 117, "end_line": 135, "span_ids": ["RepeatChannel.__call__", "RepeatChannel.__init__", "RepeatChannel"], "tokens": 186}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RepeatChannel(Transform):\n \"\"\"\n Repeat channel data to construct expected input shape for models.\n The `repeats` count includes the origin data, for example:\n ``RepeatChannel(repeats=2)([[1, 2], [3, 4]])`` generates: ``[[1, 2], [1, 2], [3, 4], [3, 4]]``\n\n Args:\n repeats: the number of repetitions for each element.\n \"\"\"\n\n def __init__(self, repeats: int) -> None:\n assert repeats > 0, \"repeats count must be greater than 0.\"\n self.repeats = repeats\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`, assuming `img` is a \"channel-first\" array.\n \"\"\"\n return np.repeat(img, self.repeats, 0)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_CastToType_CastToType.__call__.return.img_astype_self_dtype_if_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_CastToType_CastToType.__call__.return.img_astype_self_dtype_if_", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 138, "end_line": 155, "span_ids": ["CastToType.__call__", "CastToType", "CastToType.__init__"], "tokens": 140}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CastToType(Transform):\n \"\"\"\n Cast the image data to specified numpy data type.\n \"\"\"\n\n def __init__(self, dtype: np.dtype = np.float32) -> None:\n \"\"\"\n Args:\n dtype: convert image to this data type, default is `np.float32`.\n \"\"\"\n self.dtype = dtype\n\n def __call__(self, img: np.ndarray, dtype: Optional[np.dtype] = None):\n \"\"\"\n Apply the transform to `img`, assuming `img` is a numpy array.\n \"\"\"\n assert isinstance(img, np.ndarray), \"image must be numpy array.\"\n return img.astype(self.dtype if dtype is None else dtype)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_ToTensor_Transpose.__call__.return.img_transpose_self_indice": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_ToTensor_Transpose.__call__.return.img_transpose_self_indice", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 158, "end_line": 198, "span_ids": ["ToTensor.__call__", "Transpose.__init__", "ToNumpy.__call__", "Transpose", "ToTensor", "ToNumpy", "Transpose.__call__"], "tokens": 217}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ToTensor(Transform):\n \"\"\"\n Converts the input image to a tensor without applying any other transformations.\n \"\"\"\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img` and make it contiguous.\n \"\"\"\n if torch.is_tensor(img):\n return img.contiguous()\n return torch.as_tensor(np.ascontiguousarray(img))\n\n\nclass ToNumpy(Transform):\n \"\"\"\n Converts the input Tensor data to numpy array.\n \"\"\"\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img` and make it contiguous.\n \"\"\"\n if torch.is_tensor(img):\n img = img.detach().cpu().numpy()\n return np.ascontiguousarray(img)\n\n\nclass Transpose(Transform):\n \"\"\"\n Transposes the input image based on the given `indices` dimension ordering.\n \"\"\"\n\n def __init__(self, indices) -> None:\n self.indices = indices\n\n def __call__(self, img):\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n return img.transpose(self.indices)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_SqueezeDim_SqueezeDim.__call__.return.img_squeeze_self_dim_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_SqueezeDim_SqueezeDim.__call__.return.img_squeeze_self_dim_", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 201, "end_line": 225, "span_ids": ["SqueezeDim.__call__", "SqueezeDim.__init__", "SqueezeDim"], "tokens": 150}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SqueezeDim(Transform):\n \"\"\"\n Squeeze a unitary dimension.\n \"\"\"\n\n def __init__(self, dim: Optional[int] = 0) -> None:\n \"\"\"\n Args:\n dim: dimension to be squeezed. Default = 0\n \"None\" works when the input is numpy array.\n\n Raises:\n ValueError: Invalid channel dimension {dim}\n\n \"\"\"\n if dim is not None and not isinstance(dim, int):\n raise ValueError(f\"Invalid channel dimension {dim}\")\n self.dim = dim\n\n def __call__(self, img: np.ndarray):\n \"\"\"\n Args:\n img: numpy arrays with required dimension `dim` removed\n \"\"\"\n return img.squeeze(self.dim)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_DataStats_DataStats.__init__.if_logger_handler_is_not_.self__logger_addHandler_l": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_DataStats_DataStats.__init__.if_logger_handler_is_not_.self__logger_addHandler_l", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 228, "end_line": 272, "span_ids": ["DataStats", "DataStats.__init__"], "tokens": 418}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DataStats(Transform):\n \"\"\"\n Utility transform to show the statistics of data for debug or analysis.\n It can be inserted into any place of a transform chain and check results of previous transforms.\n It support both `numpy.ndarray` and `torch.tensor` as input data,\n so it can be used in pre-processing and post-processing.\n \"\"\"\n\n def __init__(\n self,\n prefix: str = \"Data\",\n data_shape: bool = True,\n value_range: bool = True,\n data_value: bool = False,\n additional_info: Optional[Callable] = None,\n logger_handler: Optional[logging.Handler] = None,\n ) -> None:\n \"\"\"\n Args:\n prefix: will be printed in format: \"{prefix} statistics\".\n data_shape: whether to show the shape of input data.\n value_range: whether to show the value range of input data.\n data_value: whether to show the raw value of input data.\n a typical example is to print some properties of Nifti image: affine, pixdim, etc.\n additional_info: user can define callable function to extract additional info from input data.\n logger_handler: add additional handler to output data: save to file, etc.\n add existing python logging handlers: https://docs.python.org/3/library/logging.handlers.html\n\n Raises:\n ValueError: argument `additional_info` must be a callable.\n\n \"\"\"\n assert isinstance(prefix, str), \"prefix must be a string.\"\n self.prefix = prefix\n self.data_shape = data_shape\n self.value_range = value_range\n self.data_value = data_value\n if additional_info is not None and not callable(additional_info):\n raise ValueError(\"argument `additional_info` must be a callable.\")\n self.additional_info = additional_info\n self.output: Optional[str] = None\n logging.basicConfig(level=logging.NOTSET)\n self._logger = logging.getLogger(\"DataStats\")\n if logger_handler is not None:\n self._logger.addHandler(logger_handler)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_DataStats.__call___DataStats.__call__.return.img": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_DataStats.__call___DataStats.__call__.return.img", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 274, "end_line": 306, "span_ids": ["DataStats.__call__"], "tokens": 310}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DataStats(Transform):\n\n def __call__(\n self,\n img,\n prefix: Optional[str] = None,\n data_shape: Optional[bool] = None,\n value_range: Optional[bool] = None,\n data_value: Optional[bool] = None,\n additional_info=None,\n ):\n \"\"\"\n Apply the transform to `img`, optionally take arguments similar to the class constructor.\n \"\"\"\n lines = [f\"{prefix or self.prefix} statistics:\"]\n\n if self.data_shape if data_shape is None else data_shape:\n lines.append(f\"Shape: {img.shape}\")\n if self.value_range if value_range is None else value_range:\n if isinstance(img, np.ndarray):\n lines.append(f\"Value range: ({np.min(img)}, {np.max(img)})\")\n elif torch.is_tensor(img):\n lines.append(f\"Value range: ({torch.min(img)}, {torch.max(img)})\")\n else:\n lines.append(f\"Value range: (not a PyTorch or Numpy array, type: {type(img)})\")\n if self.data_value if data_value is None else data_value:\n lines.append(f\"Value: {img}\")\n additional_info = self.additional_info if additional_info is None else additional_info\n if additional_info is not None:\n lines.append(f\"Additional info: {additional_info(img)}\")\n separator = \"\\n\"\n self.output = f\"{separator.join(lines)}\"\n self._logger.debug(self.output)\n\n return img", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_SimulateDelay_SimulateDelay.__call__.return.img": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_SimulateDelay_SimulateDelay.__call__.return.img", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 309, "end_line": 338, "span_ids": ["SimulateDelay.__call__", "SimulateDelay.__init__", "SimulateDelay"], "tokens": 247}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SimulateDelay(Transform):\n \"\"\"\n This is a pass through transform to be used for testing purposes. It allows\n adding fake behaviors that are useful for testing purposes to simulate\n how large datasets behave without needing to test on large data sets.\n\n For example, simulating slow NFS data transfers, or slow network transfers\n in testing by adding explicit timing delays. Testing of small test data\n can lead to incomplete understanding of real world issues, and may lead\n to sub-optimal design choices.\n \"\"\"\n\n def __init__(self, delay_time: float = 0.0) -> None:\n \"\"\"\n Args:\n delay_time: The minimum amount of time, in fractions of seconds,\n to accomplish this delay task.\n \"\"\"\n super().__init__()\n self.delay_time: float = delay_time\n\n def __call__(self, img, delay_time: Optional[float] = None):\n \"\"\"\n Args:\n img: data remain unchanged throughout this transform.\n delay_time: The minimum amount of time, in fractions of seconds,\n to accomplish this delay task.\n \"\"\"\n time.sleep(self.delay_time if delay_time is None else delay_time)\n return img", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_Lambda_Lambda.__call__.if_self_func_is_not_None_.else_.raise_RuntimeError_neith": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_Lambda_Lambda.__call__.if_self_func_is_not_None_.else_.raise_RuntimeError_neith", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 341, "end_line": 375, "span_ids": ["Lambda", "Lambda.__init__", "Lambda.__call__"], "tokens": 234}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Lambda(Transform):\n \"\"\"\n Apply a user-defined lambda as a transform.\n\n For example:\n\n .. code-block:: python\n :emphasize-lines: 2\n\n image = np.ones((10, 2, 2))\n lambd = Lambda(func=lambda x: x[:4, :, :])\n print(lambd(image).shape)\n (4, 2, 2)\n\n Args:\n func: Lambda/function to be applied.\n \"\"\"\n\n def __init__(self, func: Optional[Callable] = None) -> None:\n if func is not None and not callable(func):\n raise ValueError(\"func must be callable.\")\n self.func = func\n\n def __call__(self, img, func: Optional[Callable] = None):\n \"\"\"\n Apply `self.func` to `img`.\n \"\"\"\n if func is not None:\n if not callable(func):\n raise ValueError(\"func must be callable.\")\n return func(img)\n if self.func is not None:\n return self.func(img)\n else:\n raise RuntimeError(\"neither func or self.func is callable.\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_LabelToMask_LabelToMask.__init__.self.merge_channels.merge_channels": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_LabelToMask_LabelToMask.__init__.self.merge_channels.merge_channels", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 378, "end_line": 399, "span_ids": ["LabelToMask.__init__", "LabelToMask"], "tokens": 265}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LabelToMask(Transform):\n \"\"\"\n Convert labels to mask for other tasks. A typical usage is to convert segmentation labels\n to mask data to pre-process images and then feed the images into classification network.\n It can support single channel labels or One-Hot labels with specified `select_labels`.\n For example, users can select `label value = [2, 3]` to construct mask data, or select the\n second and the third channels of labels to construct mask data.\n The output mask data can be a multiple channels binary data or a single channel binary\n data that merges all the channels.\n\n Args:\n select_labels: labels to generate mask from. for 1 channel label, the `select_labels`\n is the expected label values, like: [1, 2, 3]. for One-Hot format label, the\n `select_labels` is the expected channel indexes.\n merge_channels: whether to use `np.any()` to merge the result on channel dim. if yes,\n will return a single channel mask with binary data.\n\n \"\"\"\n\n def __init__(self, select_labels: Union[Sequence[int], int], merge_channels: bool = False):\n self.select_labels = ensure_tuple(select_labels)\n self.merge_channels = merge_channels", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_LabelToMask.__call___": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_LabelToMask.__call___", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 401, "end_line": 417, "span_ids": ["LabelToMask.__call__"], "tokens": 150}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LabelToMask(Transform):\n\n def __call__(\n self, img, select_labels: Optional[Union[Sequence[int], int]] = None, merge_channels: Optional[bool] = None\n ):\n if select_labels is None:\n select_labels = self.select_labels\n else:\n select_labels = ensure_tuple(select_labels)\n if merge_channels is None:\n merge_channels = self.merge_channels\n\n if img.shape[0] > 1:\n data = img[[*(select_labels)]]\n else:\n data = np.where(np.in1d(img, select_labels), True, False).reshape(img.shape)\n\n return np.any(data, axis=0, keepdims=True) if merge_channels else data", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_from_typing_import_Option_from_monai_transforms_uti": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_from_typing_import_Option_from_monai_transforms_uti", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 18, "end_line": 43, "span_ids": ["docstring"], "tokens": 120}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Callable, Union, Sequence\n\nimport logging\nimport copy\n\nimport torch\nimport numpy as np\n\nfrom monai.config import KeysCollection\nfrom monai.transforms.compose import MapTransform\nfrom monai.utils import ensure_tuple, ensure_tuple_rep\nfrom monai.transforms.utility.array import (\n AddChannel,\n AsChannelFirst,\n ToTensor,\n ToNumpy,\n AsChannelLast,\n CastToType,\n RepeatChannel,\n SqueezeDim,\n DataStats,\n SimulateDelay,\n Identity,\n Lambda,\n LabelToMask,\n)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_Identityd_Identityd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_Identityd_Identityd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 46, "end_line": 65, "span_ids": ["Identityd.__init__", "Identityd", "Identityd.__call__"], "tokens": 121}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Identityd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.Identity`.\n \"\"\"\n\n def __init__(self, keys: KeysCollection) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n\n \"\"\"\n super().__init__(keys)\n self.identity = Identity()\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.identity(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_AsChannelFirstd_AsChannelFirstd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_AsChannelFirstd_AsChannelFirstd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 68, "end_line": 87, "span_ids": ["AsChannelFirstd.__init__", "AsChannelFirstd.__call__", "AsChannelFirstd"], "tokens": 159}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AsChannelFirstd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.AsChannelFirst`.\n \"\"\"\n\n def __init__(self, keys: KeysCollection, channel_dim: int = -1) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n channel_dim: which dimension of input image is the channel, default is the last dimension.\n \"\"\"\n super().__init__(keys)\n self.converter = AsChannelFirst(channel_dim=channel_dim)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.converter(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_AsChannelLastd_AsChannelLastd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_AsChannelLastd_AsChannelLastd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 90, "end_line": 109, "span_ids": ["AsChannelLastd.__call__", "AsChannelLastd.__init__", "AsChannelLastd"], "tokens": 159}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AsChannelLastd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.AsChannelLast`.\n \"\"\"\n\n def __init__(self, keys: KeysCollection, channel_dim: int = 0) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n channel_dim: which dimension of input image is the channel, default is the first dimension.\n \"\"\"\n super().__init__(keys)\n self.converter = AsChannelLast(channel_dim=channel_dim)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.converter(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_AddChanneld_AddChanneld.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_AddChanneld_AddChanneld.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 112, "end_line": 130, "span_ids": ["AddChanneld.__call__", "AddChanneld.__init__", "AddChanneld"], "tokens": 127}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AddChanneld(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.AddChannel`.\n \"\"\"\n\n def __init__(self, keys: KeysCollection) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n \"\"\"\n super().__init__(keys)\n self.adder = AddChannel()\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.adder(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_RepeatChanneld_RepeatChanneld.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_RepeatChanneld_RepeatChanneld.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 133, "end_line": 152, "span_ids": ["RepeatChanneld.__init__", "RepeatChanneld", "RepeatChanneld.__call__"], "tokens": 145}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RepeatChanneld(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.RepeatChannel`.\n \"\"\"\n\n def __init__(self, keys: KeysCollection, repeats: int) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n repeats: the number of repetitions for each element.\n \"\"\"\n super().__init__(keys)\n self.repeater = RepeatChannel(repeats)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.repeater(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_CastToTyped_CastToTyped.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_CastToTyped_CastToTyped.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 155, "end_line": 178, "span_ids": ["CastToTyped", "CastToTyped.__init__", "CastToTyped.__call__"], "tokens": 202}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CastToTyped(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.CastToType`.\n \"\"\"\n\n def __init__(self, keys: KeysCollection, dtype: Union[Sequence[np.dtype], np.dtype] = np.float32):\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n dtype: convert image to this data type, default is `np.float32`.\n it also can be a sequence of np.dtype, each element corresponds to a key in ``keys``.\n\n \"\"\"\n MapTransform.__init__(self, keys)\n self.dtype = ensure_tuple_rep(dtype, len(self.keys))\n self.converter = CastToType()\n\n def __call__(self, data):\n d = dict(data)\n for idx, key in enumerate(self.keys):\n d[key] = self.converter(d[key], dtype=self.dtype[idx])\n\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_ToTensord_ToTensord.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_ToTensord_ToTensord.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 181, "end_line": 199, "span_ids": ["ToTensord", "ToTensord.__call__", "ToTensord.__init__"], "tokens": 125}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ToTensord(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.ToTensor`.\n \"\"\"\n\n def __init__(self, keys: KeysCollection) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n \"\"\"\n super().__init__(keys)\n self.converter = ToTensor()\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.converter(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_ToNumpyd_ToNumpyd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_ToNumpyd_ToNumpyd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 202, "end_line": 220, "span_ids": ["ToNumpyd.__init__", "ToNumpyd", "ToNumpyd.__call__"], "tokens": 127}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ToNumpyd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.ToNumpy`.\n \"\"\"\n\n def __init__(self, keys: KeysCollection) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n \"\"\"\n super().__init__(keys)\n self.converter = ToNumpy()\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.converter(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_DeleteItemsd_DeleteItemsd.__call__.return._key_val_for_key_val_in": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_DeleteItemsd_DeleteItemsd.__call__.return._key_val_for_key_val_in", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 223, "end_line": 238, "span_ids": ["DeleteItemsd.__init__", "DeleteItemsd.__call__", "DeleteItemsd"], "tokens": 125}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DeleteItemsd(MapTransform):\n \"\"\"\n Delete specified items from data dictionary to release memory.\n It will remove the key-values and copy the others to construct a new dictionary.\n \"\"\"\n\n def __init__(self, keys: KeysCollection) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n \"\"\"\n super().__init__(keys)\n\n def __call__(self, data):\n return {key: val for key, val in data.items() if key not in self.keys}", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_SqueezeDimd_SqueezeDimd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_SqueezeDimd_SqueezeDimd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 241, "end_line": 260, "span_ids": ["SqueezeDimd.__init__", "SqueezeDimd", "SqueezeDimd.__call__"], "tokens": 154}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SqueezeDimd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.SqueezeDim`.\n \"\"\"\n\n def __init__(self, keys: KeysCollection, dim: int = 0) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n dim: dimension to be squeezed. Default: 0 (the first dimension)\n \"\"\"\n super().__init__(keys)\n self.converter = SqueezeDim(dim=dim)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.converter(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_DataStatsd_DataStatsd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_DataStatsd_DataStatsd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 263, "end_line": 318, "span_ids": ["DataStatsd.__call__", "DataStatsd", "DataStatsd.__init__"], "tokens": 579}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DataStatsd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.DataStats`.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n prefix: Union[Sequence[str], str] = \"Data\",\n data_shape: Union[Sequence[bool], bool] = True,\n value_range: Union[Sequence[bool], bool] = True,\n data_value: Union[Sequence[bool], bool] = False,\n additional_info: Optional[Union[Sequence[Callable], Callable]] = None,\n logger_handler: Optional[logging.Handler] = None,\n ) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n prefix: will be printed in format: \"{prefix} statistics\".\n it also can be a sequence of string, each element corresponds to a key in ``keys``.\n data_shape: whether to show the shape of input data.\n it also can be a sequence of bool, each element corresponds to a key in ``keys``.\n value_range: whether to show the value range of input data.\n it also can be a sequence of bool, each element corresponds to a key in ``keys``.\n data_value: whether to show the raw value of input data.\n it also can be a sequence of bool, each element corresponds to a key in ``keys``.\n a typical example is to print some properties of Nifti image: affine, pixdim, etc.\n additional_info: user can define callable function to extract\n additional info from input data. it also can be a sequence of string, each element\n corresponds to a key in ``keys``.\n logger_handler: add additional handler to output data: save to file, etc.\n add existing python logging handlers: https://docs.python.org/3/library/logging.handlers.html\n\n \"\"\"\n super().__init__(keys)\n self.prefix = ensure_tuple_rep(prefix, len(self.keys))\n self.data_shape = ensure_tuple_rep(data_shape, len(self.keys))\n self.value_range = ensure_tuple_rep(value_range, len(self.keys))\n self.data_value = ensure_tuple_rep(data_value, len(self.keys))\n self.additional_info = ensure_tuple_rep(additional_info, len(self.keys))\n self.logger_handler = logger_handler\n self.printer = DataStats(logger_handler=logger_handler)\n\n def __call__(self, data):\n d = dict(data)\n for idx, key in enumerate(self.keys):\n d[key] = self.printer(\n d[key],\n self.prefix[idx],\n self.data_shape[idx],\n self.value_range[idx],\n self.data_value[idx],\n self.additional_info[idx],\n )\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_SimulateDelayd_SimulateDelayd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_SimulateDelayd_SimulateDelayd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 321, "end_line": 343, "span_ids": ["SimulateDelayd.__init__", "SimulateDelayd.__call__", "SimulateDelayd"], "tokens": 212}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SimulateDelayd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:monai.transforms.utility.array.SimulateDelay.\n \"\"\"\n\n def __init__(self, keys: KeysCollection, delay_time: Union[Sequence[float], float] = 0.0):\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n delay_time: The minimum amount of time, in fractions of seconds, to accomplish this identity task.\n It also can be a sequence of string, each element corresponds to a key in ``keys``.\n\n \"\"\"\n super().__init__(keys)\n self.delay_time = ensure_tuple_rep(delay_time, len(self.keys))\n self.delayer = SimulateDelay()\n\n def __call__(self, data):\n d = dict(data)\n for idx, key in enumerate(self.keys):\n d[key] = self.delayer(d[key], delay_time=self.delay_time[idx])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_CopyItemsd_CopyItemsd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_CopyItemsd_CopyItemsd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 346, "end_line": 384, "span_ids": ["CopyItemsd.__call__", "CopyItemsd", "CopyItemsd.__init__"], "tokens": 374}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CopyItemsd(MapTransform):\n \"\"\"\n Copy specified items from data dictionary and save with different key names.\n It can copy several items together and copy several times.\n\n \"\"\"\n\n def __init__(self, keys: KeysCollection, times: int, names: KeysCollection):\n \"\"\"\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n times: expected copy times, for example, if keys is \"img\", times is 3,\n it will add 3 copies of \"img\" data to the dictionary.\n names: the names coresponding to the newly copied data,\n the length should match `len(keys) x times`. for example, if keys is [\"img\", \"seg\"]\n and times is 2, names can be: [\"img_1\", \"seg_1\", \"img_2\", \"seg_2\"].\n\n Raises:\n ValueError: times must be greater than 0.\n ValueError: length of names does not match `len(keys) x times`.\n\n \"\"\"\n super().__init__(keys)\n if times < 1:\n raise ValueError(\"times must be greater than 0.\")\n self.times = times\n names = ensure_tuple(names)\n if len(names) != (len(self.keys) * times):\n raise ValueError(\"length of names does not match `len(keys) x times`.\")\n self.names = names\n\n def __call__(self, data):\n d = dict(data)\n for key, new_key in zip(self.keys * self.times, self.names):\n if new_key in d:\n raise KeyError(f\"key {new_key} already exists in dictionary.\")\n d[new_key] = copy.deepcopy(d[key])\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_ConcatItemsd_ConcatItemsd.__init__.self.dim.dim": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_ConcatItemsd_ConcatItemsd.__init__.self.dim.dim", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 387, "end_line": 410, "span_ids": ["ConcatItemsd", "ConcatItemsd.__init__"], "tokens": 196}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ConcatItemsd(MapTransform):\n \"\"\"\n Concatenate specified items from data dictionary together on the first dim to construct a big array.\n Expect all the items are numpy array or PyTorch Tensor.\n\n \"\"\"\n\n def __init__(self, keys: KeysCollection, name: str, dim: int = 0) -> None:\n \"\"\"\n Args:\n keys: keys of the corresponding items to be concatenated together.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n name: the name coresponding to the key to store the concatenated data.\n dim: on which dimension to concatenate the items, default is 0.\n\n Raises:\n ValueError: must provide must than 1 items to concat.\n\n \"\"\"\n super().__init__(keys)\n if len(self.keys) < 2:\n raise ValueError(\"must provide must than 1 items to concat.\")\n self.name = name\n self.dim = dim", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_ConcatItemsd.__call___ConcatItemsd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_ConcatItemsd.__call___ConcatItemsd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 412, "end_line": 428, "span_ids": ["ConcatItemsd.__call__"], "tokens": 151}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ConcatItemsd(MapTransform):\n\n def __call__(self, data):\n d = dict(data)\n output = list()\n data_type = None\n for key in self.keys:\n if data_type is None:\n data_type = type(d[key])\n elif not isinstance(d[key], data_type):\n raise TypeError(\"not all the items are with same data type.\")\n output.append(d[key])\n if data_type == np.ndarray:\n d[self.name] = np.concatenate(output, axis=self.dim)\n elif data_type == torch.Tensor:\n d[self.name] = torch.cat(output, dim=self.dim)\n else:\n raise TypeError(f\"unsupported data type to concat: {data_type}.\")\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_Lambdad_Lambdad.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_Lambdad_Lambdad.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 431, "end_line": 462, "span_ids": ["Lambdad", "Lambdad.__init__", "Lambdad.__call__"], "tokens": 278}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Lambdad(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.Lambda`.\n\n For example:\n\n .. code-block:: python\n :emphasize-lines: 2\n\n input_data={'image': np.zeros((10, 2, 2)), 'label': np.ones((10, 2, 2))}\n lambd = Lambdad(keys='label', func=lambda x: x[:4, :, :])\n print(lambd(input_data)['label'].shape)\n (4, 2, 2)\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n func: Lambda/function to be applied. It also can be a sequence of Callable,\n each element corresponds to a key in ``keys``.\n \"\"\"\n\n def __init__(self, keys: KeysCollection, func: Union[Sequence[Callable], Callable]) -> None:\n super().__init__(keys)\n self.func = ensure_tuple_rep(func, len(self.keys))\n self.lambd = Lambda()\n\n def __call__(self, data):\n d = dict(data)\n for idx, key in enumerate(self.keys):\n d[key] = self.lambd(d[key], func=self.func[idx])\n\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_LabelToMaskd_LabelToMaskd.__call__.return.d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_LabelToMaskd_LabelToMaskd.__call__.return.d", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 465, "end_line": 491, "span_ids": ["LabelToMaskd", "LabelToMaskd.__init__", "LabelToMaskd.__call__"], "tokens": 240}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class LabelToMaskd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.LabelToMask`.\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n select_labels: labels to generate mask from. for 1 channel label, the `select_labels`\n is the expected label values, like: [1, 2, 3]. for One-Hot format label, the\n `select_labels` is the expected channel indexes.\n merge_channels: whether to use `np.any()` to merge the result on channel dim.\n if yes, will return a single channel mask with binary data.\n\n \"\"\"\n\n def __init__(\n self, keys: KeysCollection, select_labels: Union[Sequence[int], int], merge_channels: bool = False\n ) -> None:\n super().__init__(keys)\n self.converter = LabelToMask(select_labels, merge_channels)\n\n def __call__(self, data):\n d = dict(data)\n for key in self.keys:\n d[key] = self.converter(d[key])\n\n return d", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_IdentityD_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_IdentityD_", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 494, "end_line": 509, "span_ids": ["impl"], "tokens": 193}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "IdentityD = IdentityDict = Identityd\nAsChannelFirstD = AsChannelFirstDict = AsChannelFirstd\nAsChannelLastD = AsChannelLastDict = AsChannelLastd\nAddChannelD = AddChannelDict = AddChanneld\nRepeatChannelD = RepeatChannelDict = RepeatChanneld\nCastToTypeD = CastToTypeDict = CastToTyped\nToTensorD = ToTensorDict = ToTensord\nDeleteItemsD = DeleteItemsDict = DeleteItemsd\nSqueezeDimD = SqueezeDimDict = SqueezeDimd\nDataStatsD = DataStatsDict = DataStatsd\nSimulateDelayD = SimulateDelayDict = SimulateDelayd\nCopyItemsD = CopyItemsDict = CopyItemsd\nConcatItemsD = ConcatItemsDict = ConcatItemsd\nLambdaD = LambdaDict = Lambdad\nLabelToMaskD = LabelToMaskDict = LabelToMaskd", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_from_typing_import_Callab_zero_margins.return.True": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_from_typing_import_Callab_zero_margins.return.True", "embedding": null, "metadata": {"file_path": "monai/transforms/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 66, "span_ids": ["zero_margins", "docstring", "img_bounds", "is_empty", "rand_choice", "in_bounds"], "tokens": 455}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Callable, Optional, Sequence, Union\n\nimport random\nimport warnings\n\nimport torch\nimport numpy as np\n\nfrom monai.config import IndexSelection\nfrom monai.utils import ensure_tuple, ensure_tuple_size, fall_back_tuple, optional_import, min_version\n\nmeasure, _ = optional_import(\"skimage.measure\", \"0.14.2\", min_version)\n\n\ndef rand_choice(prob: float = 0.5) -> bool:\n \"\"\"\n Returns True if a randomly chosen number is less than or equal to `prob`, by default this is a 50/50 chance.\n \"\"\"\n return bool(random.random() <= prob)\n\n\ndef img_bounds(img):\n \"\"\"\n Returns the minimum and maximum indices of non-zero lines in axis 0 of `img`, followed by that for axis 1.\n \"\"\"\n ax0 = np.any(img, axis=0)\n ax1 = np.any(img, axis=1)\n return np.concatenate((np.where(ax0)[0][[0, -1]], np.where(ax1)[0][[0, -1]]))\n\n\ndef in_bounds(x, y, margin, maxx, maxy) -> bool:\n \"\"\"\n Returns True if (x,y) is within the rectangle (margin, margin, maxx-margin, maxy-margin).\n \"\"\"\n return bool(margin <= x < (maxx - margin) and margin <= y < (maxy - margin))\n\n\ndef is_empty(img) -> bool:\n \"\"\"\n Returns True if `img` is empty, that is its maximum value is not greater than its minimum.\n \"\"\"\n return not (img.max() > img.min()) # use > instead of <= so that an image full of NaNs will result in True\n\n\ndef zero_margins(img, margin) -> bool:\n \"\"\"\n Returns True if the values within `margin` indices of the edges of `img` in dimensions 1 and 2 are 0.\n \"\"\"\n if np.any(img[:, :, :margin]) or np.any(img[:, :, -margin:]):\n return False\n\n if np.any(img[:, :margin, :]) or np.any(img[:, -margin:, :]):\n return False\n\n return True", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_rescale_array_rescale_array._rescale_by_minv_and_max": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_rescale_array_rescale_array._rescale_by_minv_and_max", "embedding": null, "metadata": {"file_path": "monai/transforms/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 69, "end_line": 83, "span_ids": ["rescale_array"], "tokens": 160}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def rescale_array(arr, minv=0.0, maxv=1.0, dtype: Optional[np.dtype] = np.float32):\n \"\"\"\n Rescale the values of numpy array `arr` to be from `minv` to `maxv`.\n \"\"\"\n if dtype is not None:\n arr = arr.astype(dtype)\n\n mina = np.min(arr)\n maxa = np.max(arr)\n\n if mina == maxa:\n return arr * minv\n\n norm = (arr - mina) / (maxa - mina) # normalize the array first\n return (norm * (maxv - minv)) + minv # rescale by minv and maxv, which is the normalized array by default", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_rescale_instance_array_rescale_array_int_max.return.rescale_array_arr_info_m": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_rescale_instance_array_rescale_array_int_max.return.rescale_array_arr_info_m", "embedding": null, "metadata": {"file_path": "monai/transforms/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 86, "end_line": 102, "span_ids": ["rescale_instance_array", "rescale_array_int_max"], "tokens": 179}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def rescale_instance_array(arr: np.ndarray, minv: float = 0.0, maxv: float = 1.0, dtype: np.dtype = np.float32):\n \"\"\"\n Rescale each array slice along the first dimension of `arr` independently.\n \"\"\"\n out: np.ndarray = np.zeros(arr.shape, dtype)\n for i in range(arr.shape[0]):\n out[i] = rescale_array(arr[i], minv, maxv, dtype)\n\n return out\n\n\ndef rescale_array_int_max(arr: np.ndarray, dtype: np.dtype = np.uint16):\n \"\"\"\n Rescale the array `arr` to be between the minimum and maximum values of the type `dtype`.\n \"\"\"\n info: np.iinfo = np.iinfo(dtype)\n return rescale_array(arr, info.min, info.max).astype(dtype)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_copypaste_arrays_copypaste_arrays.return.tuple_srcslices_tuple_d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_copypaste_arrays_copypaste_arrays.return.tuple_srcslices_tuple_d", "embedding": null, "metadata": {"file_path": "monai/transforms/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 105, "end_line": 151, "span_ids": ["copypaste_arrays"], "tokens": 593}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def copypaste_arrays(src, dest, srccenter, destcenter, dims):\n \"\"\"\n Calculate the slices to copy a sliced area of array `src` into array `dest`. The area has dimensions `dims` (use 0\n or None to copy everything in that dimension), the source area is centered at `srccenter` index in `src` and copied\n into area centered at `destcenter` in `dest`. The dimensions of the copied area will be clipped to fit within the\n source and destination arrays so a smaller area may be copied than expected. Return value is the tuples of slice\n objects indexing the copied area in `src`, and those indexing the copy area in `dest`.\n\n Example\n\n .. code-block:: python\n\n src = np.random.randint(0,10,(6,6))\n dest = np.zeros_like(src)\n srcslices, destslices = copypaste_arrays(src, dest, (3, 2),(2, 1),(3, 4))\n dest[destslices] = src[srcslices]\n print(src)\n print(dest)\n\n >>> [[9 5 6 6 9 6]\n [4 3 5 6 1 2]\n [0 7 3 2 4 1]\n [3 0 0 1 5 1]\n [9 4 7 1 8 2]\n [6 6 5 8 6 7]]\n [[0 0 0 0 0 0]\n [7 3 2 4 0 0]\n [0 0 1 5 0 0]\n [4 7 1 8 0 0]\n [0 0 0 0 0 0]\n [0 0 0 0 0 0]]\n\n \"\"\"\n srcslices = [slice(None)] * src.ndim\n destslices = [slice(None)] * dest.ndim\n\n for i, ss, ds, sc, dc, dim in zip(range(src.ndim), src.shape, dest.shape, srccenter, destcenter, dims):\n if dim:\n # dimension before midpoint, clip to size fitting in both arrays\n d1 = np.clip(dim // 2, 0, min(sc, dc))\n # dimension after midpoint, clip to size fitting in both arrays\n d2 = np.clip(dim // 2 + 1, 0, min(ss - sc, ds - dc))\n\n srcslices[i] = slice(sc - d1, sc + d2)\n destslices[i] = slice(dc - d1, dc + d2)\n\n return tuple(srcslices), tuple(destslices)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_resize_center_resize_center.return.dest": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_resize_center_resize_center.return.dest", "embedding": null, "metadata": {"file_path": "monai/transforms/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 154, "end_line": 170, "span_ids": ["resize_center"], "tokens": 230}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def resize_center(img, *resize_dims, fill_value=0):\n \"\"\"\n Resize `img` by cropping or expanding the image from the center. The `resize_dims` values are the output dimensions\n (or None to use original dimension of `img`). If a dimension is smaller than that of `img` then the result will be\n cropped and if larger padded with zeros, in both cases this is done relative to the center of `img`. The result is\n a new image with the specified dimensions and values from `img` copied into its center.\n \"\"\"\n resize_dims = tuple(resize_dims[i] or img.shape[i] for i in range(len(resize_dims)))\n\n dest = np.full(resize_dims, fill_value, img.dtype)\n half_img_shape = np.asarray(img.shape) // 2\n half_dest_shape = np.asarray(dest.shape) // 2\n\n srcslices, destslices = copypaste_arrays(img, dest, half_img_shape, half_dest_shape, resize_dims)\n dest[destslices] = img[srcslices]\n\n return dest", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_generate_pos_neg_label_crop_centers_generate_pos_neg_label_crop_centers.return.centers": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_generate_pos_neg_label_crop_centers_generate_pos_neg_label_crop_centers.return.centers", "embedding": null, "metadata": {"file_path": "monai/transforms/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 173, "end_line": 254, "span_ids": ["generate_pos_neg_label_crop_centers"], "tokens": 863}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def generate_pos_neg_label_crop_centers(\n label: np.ndarray,\n spatial_size: Union[Sequence[int], int],\n num_samples: int,\n pos_ratio: float,\n image: Optional[np.ndarray] = None,\n image_threshold: float = 0.0,\n rand_state: np.random.RandomState = np.random,\n):\n \"\"\"Generate valid sample locations based on image with option for specifying foreground ratio\n Valid: samples sitting entirely within image, expected input shape: [C, H, W, D] or [C, H, W]\n\n Args:\n label: use the label data to get the foreground/background information.\n spatial_size: spatial size of the ROIs to be sampled.\n num_samples: total sample centers to be generated.\n pos_ratio: ratio of total locations generated that have center being foreground.\n image: if image is not None, use ``label = 0 & image > image_threshold``\n to select background. so the crop center will only exist on valid image area.\n image_threshold: if enabled image_key, use ``image > image_threshold`` to\n determine the valid image content area.\n rand_state: numpy randomState object to align with other modules.\n\n Raises:\n ValueError: no sampling location available.\n\n \"\"\"\n max_size = label.shape[1:]\n spatial_size = fall_back_tuple(spatial_size, default=max_size)\n if not (np.subtract(max_size, spatial_size) >= 0).all():\n raise ValueError(\"proposed roi is larger than image itself.\")\n\n # Select subregion to assure valid roi\n valid_start = np.floor_divide(spatial_size, 2)\n valid_end = np.subtract(max_size + np.array(1), spatial_size / np.array(2)).astype(np.uint16) # add 1 for random\n # int generation to have full range on upper side, but subtract unfloored size/2 to prevent rounded range\n # from being too high\n for i in range(len(valid_start)): # need this because np.random.randint does not work with same start and end\n if valid_start[i] == valid_end[i]:\n valid_end[i] += 1\n\n def _correct_centers(center_ori, valid_start, valid_end):\n for i, c in enumerate(center_ori):\n center_i = c\n if c < valid_start[i]:\n center_i = valid_start[i]\n if c >= valid_end[i]:\n center_i = valid_end[i] - 1\n center_ori[i] = center_i\n return center_ori\n\n centers = []\n # Prepare fg/bg indices\n if label.shape[0] > 1:\n label = label[1:] # for One-Hot format data, remove the background channel\n label_flat = np.any(label, axis=0).ravel() # in case label has multiple dimensions\n fg_indices = np.nonzero(label_flat)[0]\n if image is not None:\n img_flat = np.any(image > image_threshold, axis=0).ravel()\n bg_indices = np.nonzero(np.logical_and(img_flat, ~label_flat))[0]\n else:\n bg_indices = np.nonzero(~label_flat)[0]\n\n if not len(fg_indices) or not len(bg_indices):\n if not len(fg_indices) and not len(bg_indices):\n raise ValueError(\"no sampling location available.\")\n warnings.warn(\n f\"N foreground {len(fg_indices)}, N background {len(bg_indices)},\"\n \"unable to generate class balanced samples.\"\n )\n pos_ratio = 0 if not len(fg_indices) else 1\n\n for _ in range(num_samples):\n indices_to_use = fg_indices if rand_state.rand() < pos_ratio else bg_indices\n random_int = rand_state.randint(len(indices_to_use))\n center = np.unravel_index(indices_to_use[random_int], label.shape)\n center = center[1:]\n # shift center to range of valid centers\n center_ori = list(center)\n centers.append(_correct_centers(center_ori, valid_start, valid_end))\n\n return centers", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_apply_transform_apply_transform.try_.except_Exception_as_e_.raise_type_e_f_applying_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_apply_transform_apply_transform.try_.except_Exception_as_e_.raise_type_e_f_applying_", "embedding": null, "metadata": {"file_path": "monai/transforms/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 257, "end_line": 279, "span_ids": ["apply_transform"], "tokens": 214}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def apply_transform(transform: Callable, data: object, map_items: bool = True):\n \"\"\"\n Transform `data` with `transform`.\n If `data` is a list or tuple and `map_data` is True, each item of `data` will be transformed\n and this method returns a list of outcomes.\n otherwise transform will be applied once with `data` as the argument.\n\n Args:\n transform: a callable to be used to transform `data`\n data: an object to be transformed.\n map_items: whether to apply transform to each item in `data`,\n if `data` is a list or tuple. Defaults to True.\n\n Raises:\n with_traceback: applying transform {transform}.\n\n \"\"\"\n try:\n if isinstance(data, (list, tuple)) and map_items:\n return [transform(item) for item in data]\n return transform(data)\n except Exception as e:\n raise type(e)(f\"applying transform {transform}.\").with_traceback(e.__traceback__)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_create_grid_create_grid.return.np_concatenate_coords_n": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_create_grid_create_grid.return.np_concatenate_coords_n", "embedding": null, "metadata": {"file_path": "monai/transforms/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 282, "end_line": 302, "span_ids": ["create_grid"], "tokens": 215}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def create_grid(\n spatial_size: Sequence[int],\n spacing: Optional[Sequence[float]] = None,\n homogeneous: bool = True,\n dtype: np.dtype = float,\n):\n \"\"\"\n compute a `spatial_size` mesh.\n\n Args:\n spatial_size: spatial size of the grid.\n spacing: same len as ``spatial_size``, defaults to 1.0 (dense grid).\n homogeneous: whether to make homogeneous coordinates.\n dtype: output grid data type.\n \"\"\"\n spacing = spacing or tuple(1.0 for _ in spatial_size)\n ranges = [np.linspace(-(d - 1.0) / 2.0 * s, (d - 1.0) / 2.0 * s, int(d)) for d, s in zip(spatial_size, spacing)]\n coords = np.asarray(np.meshgrid(*ranges, indexing=\"ij\"), dtype=dtype)\n if not homogeneous:\n return coords\n return np.concatenate([coords, np.ones_like(coords[:1])])", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_create_control_grid_create_control_grid.return.create_grid_grid_shape_s": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_create_control_grid_create_control_grid.return.create_grid_grid_shape_s", "embedding": null, "metadata": {"file_path": "monai/transforms/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 305, "end_line": 318, "span_ids": ["create_control_grid"], "tokens": 170}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def create_control_grid(\n spatial_shape: Sequence[int], spacing: Sequence[float], homogeneous: bool = True, dtype: Optional[np.dtype] = float\n):\n \"\"\"\n control grid with two additional point in each direction\n \"\"\"\n grid_shape = []\n for d, s in zip(spatial_shape, spacing):\n d = int(d)\n if d % 2 == 0:\n grid_shape.append(np.ceil((d - 1.0) / (2.0 * s) + 0.5) * 2.0 + 2.0)\n else:\n grid_shape.append(np.ceil((d - 1.0) / (2.0 * s)) * 2.0 + 3.0)\n return create_grid(grid_shape, spacing, homogeneous, dtype)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_create_rotate_create_rotate.raise_ValueError_f_create": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_create_rotate_create_rotate.raise_ValueError_f_create", "embedding": null, "metadata": {"file_path": "monai/transforms/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 321, "end_line": 360, "span_ids": ["create_rotate"], "tokens": 572}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def create_rotate(spatial_dims: int, radians: Union[Sequence[float], float]):\n \"\"\"\n create a 2D or 3D rotation matrix\n\n Args:\n spatial_dims: {``2``, ``3``} spatial rank\n radians: rotation radians\n when spatial_dims == 3, the `radians` sequence corresponds to\n rotation in the 1st, 2nd, and 3rd dim respectively.\n\n Raises:\n ValueError: create_rotate got spatial_dims={spatial_dims}, radians={radians}.\n\n \"\"\"\n radians = ensure_tuple(radians)\n if spatial_dims == 2:\n if len(radians) >= 1:\n sin_, cos_ = np.sin(radians[0]), np.cos(radians[0])\n return np.array([[cos_, -sin_, 0.0], [sin_, cos_, 0.0], [0.0, 0.0, 1.0]])\n\n if spatial_dims == 3:\n affine = None\n if len(radians) >= 1:\n sin_, cos_ = np.sin(radians[0]), np.cos(radians[0])\n affine = np.array(\n [[1.0, 0.0, 0.0, 0.0], [0.0, cos_, -sin_, 0.0], [0.0, sin_, cos_, 0.0], [0.0, 0.0, 0.0, 1.0]]\n )\n if len(radians) >= 2:\n sin_, cos_ = np.sin(radians[1]), np.cos(radians[1])\n affine = affine @ np.array(\n [[cos_, 0.0, sin_, 0.0], [0.0, 1.0, 0.0, 0.0], [-sin_, 0.0, cos_, 0.0], [0.0, 0.0, 0.0, 1.0]]\n )\n if len(radians) >= 3:\n sin_, cos_ = np.sin(radians[2]), np.cos(radians[2])\n affine = affine @ np.array(\n [[cos_, -sin_, 0.0, 0.0], [sin_, cos_, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]\n )\n return affine\n\n raise ValueError(f\"create_rotate got spatial_dims={spatial_dims}, radians={radians}.\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_create_shear_create_shear.raise_NotImplementedError": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_create_shear_create_shear.raise_NotImplementedError", "embedding": null, "metadata": {"file_path": "monai/transforms/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 363, "end_line": 388, "span_ids": ["create_shear"], "tokens": 288}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def create_shear(spatial_dims: int, coefs: Union[Sequence[float], float]):\n \"\"\"\n create a shearing matrix\n\n Args:\n spatial_dims: spatial rank\n coefs: shearing factors, defaults to 0.\n\n Raises:\n NotImplementedError: spatial_dims must be 2 or 3\n\n \"\"\"\n if spatial_dims == 2:\n coefs = ensure_tuple_size(coefs, dim=2, pad_val=0.0)\n return np.array([[1, coefs[0], 0.0], [coefs[1], 1.0, 0.0], [0.0, 0.0, 1.0]])\n if spatial_dims == 3:\n coefs = ensure_tuple_size(coefs, dim=6, pad_val=0.0)\n return np.array(\n [\n [1.0, coefs[0], coefs[1], 0.0],\n [coefs[2], 1.0, coefs[3], 0.0],\n [coefs[4], coefs[5], 1.0, 0.0],\n [0.0, 0.0, 0.0, 1.0],\n ]\n )\n raise NotImplementedError(\"spatial_dims must be 2 or 3\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_create_scale_create_translate.return.affine": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_create_scale_create_translate.return.affine", "embedding": null, "metadata": {"file_path": "monai/transforms/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 391, "end_line": 415, "span_ids": ["create_scale", "create_translate"], "tokens": 188}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def create_scale(spatial_dims: int, scaling_factor: Union[Sequence[float], float]):\n \"\"\"\n create a scaling matrix\n\n Args:\n spatial_dims: spatial rank\n scaling_factor: scaling factors, defaults to 1.\n \"\"\"\n scaling_factor = ensure_tuple_size(scaling_factor, dim=spatial_dims, pad_val=1.0)\n return np.diag(scaling_factor[:spatial_dims] + (1.0,))\n\n\ndef create_translate(spatial_dims: int, shift: Union[Sequence[float], float]):\n \"\"\"\n create a translation matrix\n\n Args:\n spatial_dims: spatial rank\n shift: translate factors, defaults to 0.\n \"\"\"\n shift = ensure_tuple(shift)\n affine = np.eye(spatial_dims + 1)\n for i, a in enumerate(shift[:spatial_dims]):\n affine[i, spatial_dims] = a\n return affine", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_generate_spatial_bounding_box_generate_spatial_bounding_box.return.box_start_box_end": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_generate_spatial_bounding_box_generate_spatial_bounding_box.return.box_start_box_end", "embedding": null, "metadata": {"file_path": "monai/transforms/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 418, "end_line": 447, "span_ids": ["generate_spatial_bounding_box"], "tokens": 326}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def generate_spatial_bounding_box(\n img: np.ndarray,\n select_fn: Callable = lambda x: x > 0,\n channel_indexes: Optional[IndexSelection] = None,\n margin: int = 0,\n):\n \"\"\"\n generate the spatial bounding box of foreground in the image with start-end positions.\n Users can define arbitrary function to select expected foreground from the whole image or specified channels.\n And it can also add margin to every dim of the bounding box.\n\n Args:\n img: source image to generate bounding box from.\n select_fn: function to select expected foreground, default is to select values > 0.\n channel_indexes: if defined, select foreground only on the specified channels\n of image. if None, select foreground on the whole image.\n margin: add margin to all dims of the bounding box.\n \"\"\"\n assert isinstance(margin, int), \"margin must be int type.\"\n data = img[[*(ensure_tuple(channel_indexes))]] if channel_indexes is not None else img\n data = np.any(select_fn(data), axis=0)\n nonzero_idx = np.nonzero(data)\n\n box_start = list()\n box_end = list()\n for i in range(data.ndim):\n assert len(nonzero_idx[i]) > 0, f\"did not find nonzero index at spatial dim {i}\"\n box_start.append(max(0, np.min(nonzero_idx[i]) - margin))\n box_end.append(min(data.shape[i], np.max(nonzero_idx[i]) + margin + 1))\n return box_start, box_end", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_get_largest_connected_component_mask_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_get_largest_connected_component_mask_", "embedding": null, "metadata": {"file_path": "monai/transforms/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 450, "end_line": 467, "span_ids": ["get_largest_connected_component_mask"], "tokens": 207}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def get_largest_connected_component_mask(img, connectivity: Optional[int] = None):\n \"\"\"\n Gets the largest connected component mask of an image.\n\n Args:\n img: Image to get largest connected component from. Shape is (batch_size, spatial_dim1 [, spatial_dim2, ...])\n connectivity: Maximum number of orthogonal hops to consider a pixel/voxel as a neighbor.\n Accepted values are ranging from 1 to input.ndim. If ``None``, a full\n connectivity of ``input.ndim`` is used.\n \"\"\"\n img_arr = img.detach().cpu().numpy()\n largest_cc = np.zeros(shape=img_arr.shape, dtype=img_arr.dtype)\n for i, item in enumerate(img_arr):\n item = measure.label(item, connectivity=connectivity)\n if item.max() != 0:\n largest_cc[i, ...] = item == (np.argmax(np.bincount(item.flat)[1:]) + 1)\n return torch.as_tensor(largest_cc, device=img.device)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/__init__.py_from_aliases_import__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/__init__.py_from_aliases_import__", "embedding": null, "metadata": {"file_path": "monai/utils/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 13, "end_line": 18, "span_ids": ["docstring"], "tokens": 34}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from .aliases import *\nfrom .decorators import *\nfrom .enums import *\nfrom .misc import *\nfrom .module import export, optional_import, min_version, exact_version", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/aliases.py_threading_alias.return._outer": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/aliases.py_threading_alias.return._outer", "embedding": null, "metadata": {"file_path": "monai/utils/aliases.py", "file_name": "aliases.py", "file_type": "text/x-python", "category": "implementation", "start_line": 16, "end_line": 42, "span_ids": ["alias", "docstring"], "tokens": 150}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import threading\nimport sys\nimport inspect\nimport importlib\n\n\nalias_lock = threading.RLock()\nGlobalAliases = {}\n\n\ndef alias(*names):\n \"\"\"\n Stores the decorated function or class in the global aliases table under the given names and as the `__aliases__`\n member of the decorated object. This new member will contain all alias names declared for that object.\n \"\"\"\n\n def _outer(obj):\n for n in names:\n with alias_lock:\n GlobalAliases[n] = obj\n\n # set the member list __aliases__ to contain the alias names defined by the decorator for `obj`\n obj.__aliases__ = getattr(obj, \"__aliases__\", ()) + tuple(names)\n\n return obj\n\n return _outer", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/aliases.py_resolve_name_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/aliases.py_resolve_name_", "embedding": null, "metadata": {"file_path": "monai/utils/aliases.py", "file_name": "aliases.py", "file_type": "text/x-python", "category": "implementation", "start_line": 45, "end_line": 105, "span_ids": ["resolve_name"], "tokens": 632}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def resolve_name(name):\n \"\"\"\n Search for the declaration (function or class) with the given name. This will first search the list of aliases to\n see if it was declared with this aliased name, then search treating `name` as a fully qualified name, then search\n the loaded modules for one having a declaration with the given name. If no declaration is found, raise ValueError.\n\n Raises:\n ValueError: Module {modname!r} not found\n ValueError: Module {modname!r} does not have member {declname!r}\n ValueError: Multiple modules (%r) with declaration name %r found, resolution is ambiguous\n ValueError: No module with member {name!r} found\n\n \"\"\"\n # attempt to resolve an alias\n with alias_lock:\n obj = GlobalAliases.get(name, None)\n\n assert name not in GlobalAliases or obj is not None\n\n # attempt to resolve a qualified name\n if obj is None and \".\" in name:\n modname, declname = name.rsplit(\".\", 1)\n\n try:\n mod = importlib.import_module(modname)\n obj = getattr(mod, declname, None)\n except ModuleNotFoundError:\n raise ValueError(f\"Module {modname!r} not found\")\n\n if obj is None:\n raise ValueError(f\"Module {modname!r} does not have member {declname!r}\")\n\n # attempt to resolve a simple name\n if obj is None:\n # Get all modules having the declaration/import, need to check here that getattr returns something which doesn't\n # equate to False since in places __getattr__ returns 0 incorrectly:\n # https://github.com/tensorflow/tensorboard/blob/a22566561d2b4fea408755a951ac9eaf3a156f8e/tensorboard/compat/tensorflow_stub/pywrap_tensorflow.py#L35 # noqa: B950\n mods = [m for m in list(sys.modules.values()) if getattr(m, name, None)]\n\n if len(mods) > 0: # found modules with this declaration or import\n if len(mods) > 1: # found multiple modules, need to determine if ambiguous or just multiple imports\n foundmods = {inspect.getmodule(getattr(m, name)) for m in mods} # resolve imports\n foundmods = {m for m in foundmods if m is not None}\n\n if len(foundmods) > 1: # found multiple declarations with the same name\n modnames = [m.__name__ for m in foundmods]\n msg = \"Multiple modules (%r) with declaration name %r found, resolution is ambiguous\" % (\n modnames,\n name,\n )\n raise ValueError(msg)\n else:\n mods = list(foundmods)\n\n obj = getattr(mods[0], name)\n\n if obj is None:\n raise ValueError(f\"No module with member {name!r} found\")\n\n return obj", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/decorators.py_time_RestartGenerator.__iter__.return.self_create_gen_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/decorators.py_time_RestartGenerator.__iter__.return.self_create_gen_", "embedding": null, "metadata": {"file_path": "monai/utils/decorators.py", "file_name": "decorators.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 44, "span_ids": ["RestartGenerator.__iter__", "RestartGenerator.__init__", "timing", "docstring", "RestartGenerator"], "tokens": 215}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import time\nfrom functools import wraps\n\n\ndef timing(func):\n \"\"\"\n This simple timing function decorator prints to stdout/logfile (it uses printFlush) how many seconds a call to the\n original function took to execute, as well as the name before and after the call.\n \"\"\"\n\n @wraps(func)\n def timingwrap(*args, **kwargs):\n print(func.__name__, flush=True)\n start = time.time()\n res = func(*args, **kwargs)\n end = time.time()\n print(func.__name__, \"dT (s) =\", (end - start), flush=True)\n return res\n\n return timingwrap\n\n\nclass RestartGenerator:\n \"\"\"\n Wraps a generator callable which will be called whenever this class is iterated and its result returned. This is\n used to create an iterator which can start iteration over the given generator multiple times.\n \"\"\"\n\n def __init__(self, create_gen):\n self.create_gen = create_gen\n\n def __iter__(self):\n return self.create_gen()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/decorators.py_MethodReplacer_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/decorators.py_MethodReplacer_", "embedding": null, "metadata": {"file_path": "monai/utils/decorators.py", "file_name": "decorators.py", "file_type": "text/x-python", "category": "implementation", "start_line": 47, "end_line": 96, "span_ids": ["MethodReplacer.replace_method", "MethodReplacer.__init__", "MethodReplacer", "MethodReplacer.__set_name__"], "tokens": 413}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class MethodReplacer(object):\n \"\"\"\n Base class for method decorators which can be used to replace methods pass to replace_method() with wrapped versions.\n \"\"\"\n\n replace_list_name = \"__replacemethods__\"\n\n def __init__(self, meth):\n self.meth = meth\n\n def replace_method(self, meth):\n \"\"\"\n Return a new method to replace `meth` in the instantiated object, or `meth` to do nothing.\n \"\"\"\n return meth\n\n def __set_name__(self, owner, name):\n \"\"\"\n Add the (name,self.replace_method) pair to the list named by replace_list_name in `owner`, creating the list and\n replacing the constructor of `owner` if necessary. The replaced constructor will call the old one then do the\n replacing operation of substituting, for each (name,self.replace_method) pair, the named method with the returned\n value from self.replace_method.\n \"\"\"\n entry = (name, owner, self.replace_method)\n\n if not hasattr(owner, self.replace_list_name):\n oldinit = owner.__init__\n\n # replace the constructor with a new one which calls the old then replaces methods\n @wraps(oldinit)\n def newinit(_self, *args, **kwargs):\n oldinit(_self, *args, **kwargs)\n\n # replace each listed method of this newly constructed object\n for m, owner, replacer in getattr(_self, self.replace_list_name):\n if isinstance(_self, owner):\n meth = getattr(_self, m)\n newmeth = replacer(meth)\n setattr(_self, m, newmeth)\n\n owner.__init__ = newinit\n setattr(owner, self.replace_list_name, [entry])\n else:\n namelist = getattr(owner, self.replace_list_name)\n\n if not any(nl[0] == name for nl in namelist):\n namelist.append(entry)\n\n setattr(owner, name, self.meth)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/enums.py_from_enum_import_Enum_NumpyPadMode.EMPTY._empty_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/enums.py_from_enum_import_Enum_NumpyPadMode.EMPTY._empty_", "embedding": null, "metadata": {"file_path": "monai/utils/enums.py", "file_name": "enums.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 30, "span_ids": ["NumpyPadMode", "docstring"], "tokens": 117}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from enum import Enum\n\n\nclass NumpyPadMode(Enum):\n \"\"\"\n See also: https://numpy.org/doc/1.18/reference/generated/numpy.pad.html\n \"\"\"\n\n CONSTANT = \"constant\"\n EDGE = \"edge\"\n LINEAR_RAMP = \"linear_ramp\"\n MAXIMUM = \"maximum\"\n MEAN = \"mean\"\n MEDIAN = \"median\"\n MINIMUM = \"minimum\"\n REFLECT = \"reflect\"\n SYMMETRIC = \"symmetric\"\n WRAP = \"wrap\"\n EMPTY = \"empty\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/enums.py_GridSampleMode_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/enums.py_GridSampleMode_", "embedding": null, "metadata": {"file_path": "monai/utils/enums.py", "file_name": "enums.py", "file_type": "text/x-python", "category": "implementation", "start_line": 33, "end_line": 187, "span_ids": ["ChannelMatching", "Average", "LossReduction", "GridSampleMode", "BlendMode", "Normalisation", "MetricReduction", "Weight", "Activation", "InterpolateMode", "Method", "GridSamplePadMode", "PytorchPadMode", "UpsampleMode"], "tokens": 871}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class GridSampleMode(Enum):\n \"\"\"\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n \"\"\"\n\n BILINEAR = \"bilinear\"\n NEAREST = \"nearest\"\n\n\nclass InterpolateMode(Enum):\n \"\"\"\n See also: https://pytorch.org/docs/stable/nn.functional.html#interpolate\n \"\"\"\n\n NEAREST = \"nearest\"\n LINEAR = \"linear\"\n BILINEAR = \"bilinear\"\n BICUBIC = \"bicubic\"\n TRILINEAR = \"trilinear\"\n AREA = \"area\"\n\n\nclass UpsampleMode(Enum):\n \"\"\"\n See also: https://pytorch.org/docs/stable/nn.html#upsample\n \"\"\"\n\n NEAREST = \"nearest\"\n LINEAR = \"linear\"\n BILINEAR = \"bilinear\"\n BICUBIC = \"bicubic\"\n TRILINEAR = \"trilinear\"\n\n\nclass BlendMode(Enum):\n \"\"\"\n See also: :py:class:`monai.data.utils.compute_importance_map`\n \"\"\"\n\n CONSTANT = \"constant\"\n GAUSSIAN = \"gaussian\"\n\n\nclass PytorchPadMode(Enum):\n \"\"\"\n See also: https://pytorch.org/docs/stable/nn.functional.html#pad\n \"\"\"\n\n CONSTANT = \"constant\"\n REFLECT = \"reflect\"\n REPLICATE = \"replicate\"\n CIRCULAR = \"circular\"\n\n\nclass GridSamplePadMode(Enum):\n \"\"\"\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n \"\"\"\n\n ZEROS = \"zeros\"\n BORDER = \"border\"\n REFLECTION = \"reflection\"\n\n\nclass Average(Enum):\n \"\"\"\n See also: :py:class:`monai.metrics.rocauc.compute_roc_auc`\n \"\"\"\n\n MACRO = \"macro\"\n WEIGHTED = \"weighted\"\n MICRO = \"micro\"\n NONE = \"none\"\n\n\nclass MetricReduction(Enum):\n \"\"\"\n See also: :py:class:`monai.metrics.meandice.DiceMetric`\n \"\"\"\n\n NONE = \"none\"\n MEAN = \"mean\"\n SUM = \"sum\"\n MEAN_BATCH = \"mean_batch\"\n SUM_BATCH = \"sum_batch\"\n MEAN_CHANNEL = \"mean_channel\"\n SUM_CHANNEL = \"sum_channel\"\n\n\nclass LossReduction(Enum):\n \"\"\"\n See also:\n - :py:class:`monai.losses.dice.DiceLoss`\n - :py:class:`monai.losses.dice.GeneralizedDiceLoss`\n - :py:class:`monai.losses.focal_loss.FocalLoss`\n - :py:class:`monai.losses.tversky.TverskyLoss`\n \"\"\"\n\n NONE = \"none\"\n MEAN = \"mean\"\n SUM = \"sum\"\n\n\nclass Weight(Enum):\n \"\"\"\n See also: :py:class:`monai.losses.dice.GeneralizedDiceLoss`\n \"\"\"\n\n SQUARE = \"square\"\n SIMPLE = \"simple\"\n UNIFORM = \"uniform\"\n\n\nclass Normalisation(Enum):\n \"\"\"\n See also:\n - :py:class:`monai.networks.nets.ConvNormActi`\n - :py:class:`monai.networks.nets.HighResBlock`\n - :py:class:`monai.networks.nets.HighResNet`\n \"\"\"\n\n BATCH = \"batch\"\n INSTANCE = \"instance\"\n\n\nclass Activation(Enum):\n \"\"\"\n See also:\n - :py:class:`monai.networks.nets.ConvNormActi`\n - :py:class:`monai.networks.nets.HighResBlock`\n - :py:class:`monai.networks.nets.HighResNet`\n \"\"\"\n\n RELU = \"relu\"\n PRELU = \"prelu\"\n RELU6 = \"relu6\"\n\n\nclass ChannelMatching(Enum):\n \"\"\"\n See also: :py:class:`monai.networks.nets.HighResBlock`\n \"\"\"\n\n PAD = \"pad\"\n PROJECT = \"project\"\n\n\nclass Method(Enum):\n \"\"\"\n See also: :py:class:`monai.transforms.croppad.array.SpatialPad`\n \"\"\"\n\n SYMMETRIC = \"symmetric\"\n END = \"end\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_from_typing_import_Any_C_ensure_tuple_size.return.tuple_tup_dim_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_from_typing_import_Any_C_ensure_tuple_size.return.tuple_tup_dim_", "embedding": null, "metadata": {"file_path": "monai/utils/misc.py", "file_name": "misc.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 69, "span_ids": ["zip_with", "ensure_tuple_size", "first", "docstring", "ensure_tuple", "star_zip_with", "issequenceiterable"], "tokens": 345}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Any, Callable, Optional, Sequence, Tuple, Union\n\nimport random\nimport itertools\nfrom collections.abc import Iterable\n\nimport numpy as np\nimport torch\n\n_seed = None\n\n\ndef zip_with(op, *vals, mapfunc=map):\n \"\"\"\n Map `op`, using `mapfunc`, to each tuple derived from zipping the iterables in `vals`.\n \"\"\"\n return mapfunc(op, zip(*vals))\n\n\ndef star_zip_with(op, *vals):\n \"\"\"\n Use starmap as the mapping function in zipWith.\n \"\"\"\n return zip_with(op, *vals, mapfunc=itertools.starmap)\n\n\ndef first(iterable, default=None):\n \"\"\"\n Returns the first item in the given iterable or `default` if empty, meaningful mostly with 'for' expressions.\n \"\"\"\n for i in iterable:\n return i\n return default\n\n\ndef issequenceiterable(obj) -> bool:\n \"\"\"\n Determine if the object is an iterable sequence and is not a string.\n \"\"\"\n return isinstance(obj, Iterable) and not isinstance(obj, str)\n\n\ndef ensure_tuple(vals: Any) -> Tuple:\n \"\"\"\n Returns a tuple of `vals`.\n \"\"\"\n if not issequenceiterable(vals):\n vals = (vals,)\n\n return tuple(vals)\n\n\ndef ensure_tuple_size(tup, dim: int, pad_val=0) -> Tuple:\n \"\"\"\n Returns a copy of `tup` with `dim` values by either shortened or padded with `pad_val` as necessary.\n \"\"\"\n tup = ensure_tuple(tup) + (pad_val,) * dim\n return tuple(tup[:dim])", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_ensure_tuple_rep_ensure_tuple_rep.raise_ValueError_f_sequen": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_ensure_tuple_rep_ensure_tuple_rep.raise_ValueError_f_sequen", "embedding": null, "metadata": {"file_path": "monai/utils/misc.py", "file_name": "misc.py", "file_type": "text/x-python", "category": "implementation", "start_line": 72, "end_line": 100, "span_ids": ["ensure_tuple_rep"], "tokens": 254}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def ensure_tuple_rep(tup: Any, dim: int):\n \"\"\"\n Returns a copy of `tup` with `dim` values by either shortened or duplicated input.\n\n Examples::\n\n >>> ensure_tuple_rep(1, 3)\n (1, 1, 1)\n >>> ensure_tuple_rep(None, 3)\n (None, None, None)\n >>> ensure_tuple_rep('test', 3)\n ('test', 'test', 'test')\n >>> ensure_tuple_rep([1, 2, 3], 3)\n (1, 2, 3)\n >>> ensure_tuple_rep(range(3), 3)\n (0, 1, 2)\n >>> ensure_tuple_rep([1, 2], 3)\n ValueError: sequence must have length 3, got length 2.\n\n Raises:\n ValueError: sequence must have length {dim}, got length {len(tup)}.\n\n \"\"\"\n if not issequenceiterable(tup):\n return (tup,) * dim\n elif len(tup) == dim:\n return tuple(tup)\n\n raise ValueError(f\"sequence must have length {dim}, got length {len(tup)}.\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_fall_back_tuple_fall_back_tuple.return.tuple_use_the_default": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_fall_back_tuple_fall_back_tuple.return.tuple_use_the_default", "embedding": null, "metadata": {"file_path": "monai/utils/misc.py", "file_name": "misc.py", "file_type": "text/x-python", "category": "implementation", "start_line": 103, "end_line": 144, "span_ids": ["fall_back_tuple"], "tokens": 455}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def fall_back_tuple(user_provided: Any, default: Sequence, func: Callable = lambda x: x and x > 0) -> Tuple:\n \"\"\"\n Refine `user_provided` according to the `default`, and returns as a validated tuple.\n\n The validation is done for each element in `user_provided` using `func`.\n If `func(user_provided[idx])` returns False, the corresponding `default[idx]` will be used\n as the fallback.\n\n Typically used when `user_provided` is a tuple of window size provided by the user,\n `default` is defined by data, this function returns an updated `user_provided` with its non-positive\n components replaced by the corresponding components from `default`.\n\n Args:\n user_provided: item to be validated.\n default: a sequence used to provided the fallbacks.\n func: a Callable to validate every components of `user_provided`.\n\n Examples::\n\n >>> fall_back_tuple((1, 2), (32, 32))\n (1, 2)\n >>> fall_back_tuple(None, (32, 32))\n (32, 32)\n >>> fall_back_tuple((-1, 10), (32, 32))\n (32, 10)\n >>> fall_back_tuple((-1, None), (32, 32))\n (32, 32)\n >>> fall_back_tuple((1, None), (32, 32))\n (1, 32)\n >>> fall_back_tuple(0, (32, 32))\n (32, 32)\n >>> fall_back_tuple(range(3), (32, 64, 48))\n (32, 1, 2)\n >>> fall_back_tuple([0], (32, 32))\n ValueError: sequence must have length 2, got length 1.\n\n \"\"\"\n ndim = len(default)\n user = ensure_tuple_rep(user_provided, ndim)\n return tuple( # use the default values if user provided is not valid\n user_c if func(user_c) else default_c for default_c, user_c in zip(default, user)\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_is_scalar_tensor_get_seed.return._seed": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_is_scalar_tensor_get_seed.return._seed", "embedding": null, "metadata": {"file_path": "monai/utils/misc.py", "file_name": "misc.py", "file_type": "text/x-python", "category": "implementation", "start_line": 147, "end_line": 179, "span_ids": ["is_scalar", "is_scalar_tensor", "progress_bar", "get_seed"], "tokens": 285}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def is_scalar_tensor(val) -> bool:\n if torch.is_tensor(val) and val.ndim == 0:\n return True\n return False\n\n\ndef is_scalar(val) -> bool:\n if torch.is_tensor(val) and val.ndim == 0:\n return True\n return bool(np.isscalar(val))\n\n\ndef progress_bar(index: int, count: int, desc: str = None, bar_len: int = 30, newline: bool = False) -> None:\n \"\"\"print a progress bar to track some time consuming task.\n\n Args:\n index: current satus in progress.\n count: total steps of the progress.\n desc: description of the progress bar, if not None, show before the progress bar.\n bar_len: the total length of the bar on screen, default is 30 char.\n newline: whether to print in a new line for every index.\n \"\"\"\n end = \"\\r\" if newline is False else \"\\r\\n\"\n filled_len = int(bar_len * index // count)\n bar = f\"{desc} \" if desc is not None else \"\"\n bar += \"[\" + \"=\" * filled_len + \" \" * (bar_len - filled_len) + \"]\"\n print(f\"{index}/{count} {bar}\", end=end)\n if index == count:\n print(\"\")\n\n\ndef get_seed():\n return _seed", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_set_determinism_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_set_determinism_", "embedding": null, "metadata": {"file_path": "monai/utils/misc.py", "file_name": "misc.py", "file_type": "text/x-python", "category": "implementation", "start_line": 182, "end_line": 221, "span_ids": ["set_determinism"], "tokens": 376}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def set_determinism(\n seed: Optional[int] = np.iinfo(np.int32).max,\n additional_settings: Optional[Union[Sequence[Callable], Callable]] = None,\n) -> None:\n \"\"\"\n Set random seed for modules to enable or disable deterministic training.\n\n Args:\n seed: the random seed to use, default is np.iinfo(np.int32).max.\n It is recommended to set a large seed, i.e. a number that has a good balance\n of 0 and 1 bits. Avoid having many 0 bits in the seed.\n if set to None, will disable deterministic training.\n additional_settings: additional settings\n that need to set random seed.\n\n \"\"\"\n if seed is None:\n # cast to 32 bit seed for CUDA\n seed_ = torch.default_generator.seed() % (np.iinfo(np.int32).max + 1) # type: ignore # Module has no attribute\n if not torch.cuda._is_in_bad_fork(): # type: ignore # Module has no attribute\n torch.cuda.manual_seed_all(seed_) # type: ignore # Module has no attribute\n else:\n torch.manual_seed(seed)\n\n global _seed\n _seed = seed\n random.seed(seed)\n np.random.seed(seed)\n\n if additional_settings is not None:\n additional_settings = ensure_tuple(additional_settings)\n for func in additional_settings:\n func(seed)\n\n if seed is not None:\n torch.backends.cudnn.deterministic = True # type: ignore # Module has no attribute\n torch.backends.cudnn.benchmark = False # type: ignore # Module has no attribute\n else:\n torch.backends.cudnn.deterministic = False # type: ignore # Module has no attribute", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/module.py_from_importlib_import_imp_export.return._inner": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/module.py_from_importlib_import_imp_export.return._inner", "embedding": null, "metadata": {"file_path": "monai/utils/module.py", "file_name": "module.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 39, "span_ids": ["export", "docstring"], "tokens": 198}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from importlib import import_module\nfrom pkgutil import walk_packages\nfrom re import match\nfrom typing import Any, Callable, Tuple\n\nOPTIONAL_IMPORT_MSG_FMT = \"{}\"\n\n\ndef export(modname):\n \"\"\"\n Make the decorated object a member of the named module. This will also add the object under its aliases if it has\n a `__aliases__` member, thus this decorator should be before the `alias` decorator to pick up those names. Alias\n names which conflict with package names or existing members will be ignored.\n \"\"\"\n\n def _inner(obj):\n mod = import_module(modname)\n if not hasattr(mod, obj.__name__):\n setattr(mod, obj.__name__, obj)\n\n # add the aliases for `obj` to the target module\n for alias in getattr(obj, \"__aliases__\", ()):\n if not hasattr(mod, alias):\n setattr(mod, alias, obj)\n\n return obj\n\n return _inner", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/module.py_load_submodules_load_submodules.return.submodules": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/module.py_load_submodules_load_submodules.return.submodules", "embedding": null, "metadata": {"file_path": "monai/utils/module.py", "file_name": "module.py", "file_type": "text/x-python", "category": "implementation", "start_line": 42, "end_line": 55, "span_ids": ["load_submodules"], "tokens": 170}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def load_submodules(basemod, load_all: bool = True, exclude_pattern: str = \"(.*[tT]est.*)|(_.*)\"):\n \"\"\"\n Traverse the source of the module structure starting with module `basemod`, loading all packages plus all files if\n `loadAll` is True, excluding anything whose name matches `excludePattern`.\n \"\"\"\n submodules = []\n\n for importer, name, is_pkg in walk_packages(basemod.__path__):\n if (is_pkg or load_all) and match(exclude_pattern, name) is None:\n mod = import_module(basemod.__name__ + \".\" + name) # why do I need to do this first?\n importer.find_module(name).load_module(name)\n submodules.append(mod)\n\n return submodules", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/module.py_get_full_type_name_exact_version.return.bool_the_module___version": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/module.py_get_full_type_name_exact_version.return.bool_the_module___version", "embedding": null, "metadata": {"file_path": "monai/utils/module.py", "file_name": "module.py", "file_type": "text/x-python", "category": "implementation", "start_line": 58, "end_line": 85, "span_ids": ["exact_version", "min_version", "get_full_type_name"], "tokens": 237}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "@export(\"monai.utils\")\ndef get_full_type_name(typeobj):\n module = typeobj.__module__\n if module is None or module == str.__class__.__module__:\n return typeobj.__name__ # Avoid reporting __builtin__\n else:\n return module + \".\" + typeobj.__name__\n\n\ndef min_version(the_module, min_version_str: str = \"\") -> bool:\n \"\"\"\n Convert version strings into tuples of int and compare them.\n\n Returns True if the module's version is greater or equal to the 'min_version'.\n When min_version_str is not provided, it always returns True.\n \"\"\"\n if min_version_str:\n mod_version = tuple(int(x) for x in the_module.__version__.split(\".\")[:2])\n required = tuple(int(x) for x in min_version_str.split(\".\")[:2])\n return mod_version >= required\n return True # always valid version\n\n\ndef exact_version(the_module, version_str: str = \"\") -> bool:\n \"\"\"\n Returns True if the module's __version__ matches version_str\n \"\"\"\n return bool(the_module.__version__ == version_str)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/module.py_optional_import_optional_import.msg.descriptor_format_actual_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/module.py_optional_import_optional_import.msg.descriptor_format_actual_", "embedding": null, "metadata": {"file_path": "monai/utils/module.py", "file_name": "module.py", "file_type": "text/x-python", "category": "implementation", "start_line": 88, "end_line": 166, "span_ids": ["optional_import"], "tokens": 770}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def optional_import(\n module: str,\n version: str = \"\",\n version_checker: Callable = min_version,\n name: str = \"\",\n descriptor: str = OPTIONAL_IMPORT_MSG_FMT,\n version_args=None,\n allow_namespace_pkg: bool = False,\n) -> Tuple[Any, bool]:\n \"\"\"\n Imports an optional module specified by `module` string.\n Any importing related exceptions will be stored, and exceptions raise lazily\n when attempting to use the failed-to-import module.\n\n Args:\n module: name of the module to be imported.\n version: version string used by the version_checker.\n version_checker: a callable to check the module version, Defaults to monai.utils.min_version.\n name: a non-module attribute (such as method/class) to import from the imported module.\n descriptor: a format string for the final error message when using a not imported module.\n version_args: additional parameters to the version checker.\n allow_namespace_pkg: whether importing a namespace package is allowed. Defaults to False.\n\n Returns:\n The imported module and a boolean flag indicating whether the import is successful.\n\n Raises:\n _exception: Optional import: {msg}.\n\n Examples::\n\n >>> torch, flag = optional_import('torch', '1.1')\n >>> print(torch, flag)\n True\n\n >>> the_module, flag = optional_import('unknown_module')\n >>> print(flag)\n False\n >>> the_module.method # trying to access a module which is not imported\n AttributeError: Optional import: import unknown_module (No module named 'unknown_module').\n\n >>> torch, flag = optional_import('torch', '42', exact_version)\n >>> torch.nn # trying to access a module for which there isn't a proper version imported\n AttributeError: Optional import: import torch (requires version '42' by 'exact_version').\n\n >>> conv, flag = optional_import('torch.nn.functional', '1.0', name='conv1d')\n >>> print(conv)\n \n\n >>> conv, flag = optional_import('torch.nn.functional', '42', name='conv1d')\n >>> conv() # trying to use a function from the not successfully imported module (due to unmatched version)\n AttributeError: Optional import: from torch.nn.functional import conv1d (requires version '42' by 'min_version').\n \"\"\"\n\n tb = None\n exception_str = \"\"\n if name:\n actual_cmd = f\"from {module} import {name}\"\n else:\n actual_cmd = f\"import {module}\"\n try:\n pkg = __import__(module) # top level module\n the_module = import_module(module)\n if not allow_namespace_pkg:\n is_namespace = getattr(the_module, \"__file__\", None) is None and hasattr(the_module, \"__path__\")\n assert not is_namespace\n if name: # user specified to load class/function/... from the module\n the_module = getattr(the_module, name)\n except Exception as import_exception: # any exceptions during import\n tb = import_exception.__traceback__\n exception_str = f\"{import_exception}\"\n else: # found the module\n if version_args and version_checker(pkg, f\"{version}\", version_args):\n return the_module, True\n if not version_args and version_checker(pkg, f\"{version}\"):\n return the_module, True\n\n # preparing lazy error message\n msg = descriptor.format(actual_cmd)\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/module.py_optional_import.if_version_and_tb_is_None_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/module.py_optional_import.if_version_and_tb_is_None_", "embedding": null, "metadata": {"file_path": "monai/utils/module.py", "file_name": "module.py", "file_type": "text/x-python", "category": "implementation", "start_line": 167, "end_line": 191, "span_ids": ["optional_import"], "tokens": 274}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def optional_import(\n module: str,\n version: str = \"\",\n version_checker: Callable = min_version,\n name: str = \"\",\n descriptor: str = OPTIONAL_IMPORT_MSG_FMT,\n version_args=None,\n allow_namespace_pkg: bool = False,\n) -> Tuple[Any, bool]:\n # ... other code\n if version and tb is None: # a pure version issue\n msg += f\" (requires '{module} {version}' by '{version_checker.__name__}')\"\n if exception_str:\n msg += f\" ({exception_str})\"\n\n class _LazyRaise:\n def __init__(self, *_args, **_kwargs):\n _default_msg = (\n f\"Optional import: {msg}.\"\n + \"\\n\\nFor details about installing the optional dependencies, please visit:\"\n + \"\\n https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\"\n )\n if tb is None:\n self._exception = AttributeError(_default_msg)\n else:\n self._exception = AttributeError(_default_msg).with_traceback(tb)\n\n def __getattr__(self, name):\n raise self._exception\n\n def __call__(self, *_args, **_kwargs):\n raise self._exception\n\n return _LazyRaise(), False", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/__init__.py_from_img2tensorboard_imp_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/__init__.py_from_img2tensorboard_imp_", "embedding": null, "metadata": {"file_path": "monai/visualize/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 13, "span_ids": ["docstring"], "tokens": 8}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from .img2tensorboard import *", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py_from_typing_import_Option_if_TYPE_CHECKING_.else_.SummaryWriter___option": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py_from_typing_import_Option_if_TYPE_CHECKING_.else_.SummaryWriter___option", "embedding": null, "metadata": {"file_path": "monai/visualize/img2tensorboard.py", "file_name": "img2tensorboard.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 26, "span_ids": ["docstring"], "tokens": 122}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from typing import Optional, Sequence, Union, TYPE_CHECKING\n\nimport numpy as np\nimport torch\n\nfrom monai.transforms import rescale_array\nfrom monai.utils import optional_import\n\nPIL, _ = optional_import(\"PIL\")\nGifImage, _ = optional_import(\"PIL.GifImagePlugin\", name=\"Image\")\nsummary_pb2, _ = optional_import(\"tensorboard.compat.proto.summary_pb2\")\nif TYPE_CHECKING:\n from torch.utils.tensorboard import SummaryWriter\nelse:\n SummaryWriter, _ = optional_import(\"torch.utils.tensorboard\", name=\"SummaryWriter\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py__image3_animated_gif__image3_animated_gif.return.summary_pb2_Summary_value": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py__image3_animated_gif__image3_animated_gif.return.summary_pb2_Summary_value", "embedding": null, "metadata": {"file_path": "monai/visualize/img2tensorboard.py", "file_name": "img2tensorboard.py", "file_type": "text/x-python", "category": "implementation", "start_line": 29, "end_line": 52, "span_ids": ["_image3_animated_gif"], "tokens": 366}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def _image3_animated_gif(tag: str, image: Union[np.ndarray, torch.Tensor], scale_factor: float = 1.0):\n \"\"\"Function to actually create the animated gif.\n\n Args:\n tag: Data identifier\n image: 3D image tensors expected to be in `HWD` format\n scale_factor: amount to multiply values by. if the image data is between 0 and 1, using 255 for this value will\n scale it to displayable range\n \"\"\"\n assert len(image.shape) == 3, \"3D image tensors expected to be in `HWD` format, len(image.shape) != 3\"\n\n ims = [(np.asarray((image[:, :, i])) * scale_factor).astype(np.uint8) for i in range(image.shape[2])]\n ims = [GifImage.fromarray(im) for im in ims]\n img_str = b\"\"\n for b_data in PIL.GifImagePlugin.getheader(ims[0])[0]:\n img_str += b_data\n img_str += b\"\\x21\\xFF\\x0B\\x4E\\x45\\x54\\x53\\x43\\x41\\x50\" b\"\\x45\\x32\\x2E\\x30\\x03\\x01\\x00\\x00\\x00\"\n for i in ims:\n for b_data in PIL.GifImagePlugin.getdata(i):\n img_str += b_data\n img_str += b\"\\x3B\"\n summary_image_str = summary_pb2.Summary.Image(height=10, width=10, colorspace=1, encoded_image_string=img_str)\n image_summary = summary_pb2.Summary.Value(tag=tag, image=summary_image_str)\n return summary_pb2.Summary(value=[image_summary])", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py_make_animated_gif_summary_make_animated_gif_summary.return.summary_op": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py_make_animated_gif_summary_make_animated_gif_summary.return.summary_op", "embedding": null, "metadata": {"file_path": "monai/visualize/img2tensorboard.py", "file_name": "img2tensorboard.py", "file_type": "text/x-python", "category": "implementation", "start_line": 55, "end_line": 99, "span_ids": ["make_animated_gif_summary"], "tokens": 410}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def make_animated_gif_summary(\n tag: str,\n image: Union[np.ndarray, torch.Tensor],\n max_out: int = 3,\n animation_axes: Sequence[int] = (3,),\n image_axes: Sequence[int] = (1, 2),\n other_indices=None,\n scale_factor: float = 1.0,\n):\n \"\"\"Creates an animated gif out of an image tensor in 'CHWD' format and returns Summary.\n\n Args:\n tag: Data identifier\n image: The image, expected to be in CHWD format\n max_out: maximum number of slices to animate through\n animation_axes: axis to animate on (not currently used)\n image_axes: axes of image (not currently used)\n other_indices: (not currently used)\n scale_factor: amount to multiply values by.\n if the image data is between 0 and 1, using 255 for this value will scale it to displayable range\n \"\"\"\n\n if max_out == 1:\n suffix = \"/image\"\n else:\n suffix = \"/image/{}\"\n if other_indices is None:\n other_indices = {}\n axis_order = [0] + list(animation_axes) + list(image_axes)\n\n slicing = []\n for i in range(len(image.shape)):\n if i in axis_order:\n slicing.append(slice(None))\n else:\n other_ind = other_indices.get(i, 0)\n slicing.append(slice(other_ind, other_ind + 1))\n image = image[tuple(slicing)]\n\n for it_i in range(min(max_out, list(image.shape)[0])):\n one_channel_img: Union[torch.Tensor, np.ndarray] = image[it_i, :, :, :].squeeze(dim=0) if torch.is_tensor(\n image\n ) else image[it_i, :, :, :]\n summary_op = _image3_animated_gif(tag + suffix.format(it_i), one_channel_img, scale_factor)\n return summary_op", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py_add_animated_gif_add_animated_gif.writer__get_file_writer_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py_add_animated_gif_add_animated_gif.writer__get_file_writer_", "embedding": null, "metadata": {"file_path": "monai/visualize/img2tensorboard.py", "file_name": "img2tensorboard.py", "file_type": "text/x-python", "category": "implementation", "start_line": 102, "end_line": 126, "span_ids": ["add_animated_gif"], "tokens": 236}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def add_animated_gif(\n writer: SummaryWriter,\n tag: str,\n image_tensor: Union[np.ndarray, torch.Tensor],\n max_out: int,\n scale_factor: float,\n global_step: Optional[int] = None,\n) -> None:\n \"\"\"Creates an animated gif out of an image tensor in 'CHWD' format and writes it with SummaryWriter.\n\n Args:\n writer: Tensorboard SummaryWriter to write to\n tag: Data identifier\n image_tensor: tensor for the image to add, expected to be in CHWD format\n max_out: maximum number of slices to animate through\n scale_factor: amount to multiply values by. If the image data is between 0 and 1, using 255 for this value will\n scale it to displayable range\n global_step: Global step value to record\n \"\"\"\n writer._get_file_writer().add_summary(\n make_animated_gif_summary(\n tag, image_tensor, max_out=max_out, animation_axes=[1], image_axes=[2, 3], scale_factor=scale_factor\n ),\n global_step,\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py_add_animated_gif_no_channels_add_animated_gif_no_channels.writer__get_file_writer_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py_add_animated_gif_no_channels_add_animated_gif_no_channels.writer__get_file_writer_", "embedding": null, "metadata": {"file_path": "monai/visualize/img2tensorboard.py", "file_name": "img2tensorboard.py", "file_type": "text/x-python", "category": "implementation", "start_line": 129, "end_line": 155, "span_ids": ["add_animated_gif_no_channels"], "tokens": 268}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def add_animated_gif_no_channels(\n writer: SummaryWriter,\n tag: str,\n image_tensor: Union[np.ndarray, torch.Tensor],\n max_out: int,\n scale_factor: float,\n global_step: Optional[int] = None,\n) -> None:\n \"\"\"Creates an animated gif out of an image tensor in 'HWD' format that does not have\n a channel dimension and writes it with SummaryWriter. This is similar to the \"add_animated_gif\"\n after inserting a channel dimension of 1.\n\n Args:\n writer: Tensorboard SummaryWriter to write to\n tag: Data identifier\n image_tensor: tensor for the image to add, expected to be in CHWD format\n max_out: maximum number of slices to animate through\n scale_factor: amount to multiply values by. If the image data is between 0 and 1,\n using 255 for this value will scale it to displayable range\n global_step: Global step value to record\n \"\"\"\n writer._get_file_writer().add_summary(\n make_animated_gif_summary(\n tag, image_tensor, max_out=max_out, animation_axes=[1], image_axes=[1, 2], scale_factor=scale_factor\n ),\n global_step,\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py_plot_2d_or_3d_image_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py_plot_2d_or_3d_image_", "embedding": null, "metadata": {"file_path": "monai/visualize/img2tensorboard.py", "file_name": "img2tensorboard.py", "file_type": "text/x-python", "category": "implementation", "start_line": 158, "end_line": 209, "span_ids": ["plot_2d_or_3d_image"], "tokens": 529}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def plot_2d_or_3d_image(\n data: Union[torch.Tensor, np.ndarray],\n step: int,\n writer: SummaryWriter,\n index: int = 0,\n max_channels: int = 1,\n max_frames: int = 64,\n tag: str = \"output\",\n) -> None:\n \"\"\"Plot 2D or 3D image on the TensorBoard, 3D image will be converted to GIF image.\n\n Note:\n Plot 3D or 2D image(with more than 3 channels) as separate images.\n\n Args:\n data: target data to be plotted as image on the TensorBoard.\n The data is expected to have 'NCHW[D]' dimensions, and only plot the first in the batch.\n step: current step to plot in a chart.\n writer: specify TensorBoard SummaryWriter to plot the image.\n index: plot which element in the input data batch, default is the first element.\n max_channels: number of channels to plot.\n max_frames: number of frames for 2D-t plot.\n tag: tag of the plotted image on TensorBoard.\n \"\"\"\n d = data[index]\n if torch.is_tensor(d):\n d = d.detach().cpu().numpy()\n\n if d.ndim == 2:\n d = rescale_array(d, 0, 1)\n dataformats = \"HW\"\n writer.add_image(f\"{tag}_{dataformats}\", d, step, dataformats=dataformats)\n return\n\n if d.ndim == 3:\n if d.shape[0] == 3 and max_channels == 3: # RGB\n dataformats = \"CHW\"\n writer.add_image(f\"{tag}_{dataformats}\", d, step, dataformats=dataformats)\n return\n for j, d2 in enumerate(d[:max_channels]):\n d2 = rescale_array(d2, 0, 1)\n dataformats = \"HW\"\n writer.add_image(f\"{tag}_{dataformats}_{j}\", d2, step, dataformats=dataformats)\n return\n\n if d.ndim >= 4:\n spatial = d.shape[-3:]\n for j, d3 in enumerate(d.reshape([-1] + list(spatial))[:max_channels]):\n d3 = rescale_array(d3, 0, 255)\n add_animated_gif(writer, f\"{tag}_HWD_{j}\", d3[None], max_frames, 1.0, step)\n return", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/__init__.py__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/__init__.py__", "embedding": null, "metadata": {"file_path": "research/coplenet-pneumonia-lesion-segmentation/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 11, "end_line": 11, "span_ids": [], "tokens": 0}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/coplenet.py_torch_ConvBNActBlock.forward.return.self_conv_conv_se_x_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/coplenet.py_torch_ConvBNActBlock.forward.return.self_conv_conv_se_x_", "embedding": null, "metadata": {"file_path": "research/coplenet-pneumonia-lesion-segmentation/coplenet.py", "file_name": "coplenet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 21, "end_line": 42, "span_ids": ["ConvBNActBlock.forward", "ConvBNActBlock", "ConvBNActBlock.__init__", "docstring"], "tokens": 233}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import torch\nimport torch.nn as nn\n\nfrom monai.networks.blocks import Convolution, MaxAvgPool, ResidualSELayer, SimpleASPP, UpSample\nfrom monai.networks.layers.factories import Act, Norm\nfrom monai.utils import ensure_tuple_rep\n\n\nclass ConvBNActBlock(nn.Module):\n \"\"\"Two convolution layers with batch norm, leaky relu, dropout and SE block\"\"\"\n\n def __init__(self, in_channels, out_channels, dropout_p, spatial_dims: int = 2):\n super().__init__()\n self.conv_conv_se = nn.Sequential(\n Convolution(spatial_dims, in_channels, out_channels, kernel_size=3, norm=Norm.BATCH, act=Act.LEAKYRELU),\n nn.Dropout(dropout_p),\n Convolution(spatial_dims, out_channels, out_channels, kernel_size=3, norm=Norm.BATCH, act=Act.LEAKYRELU),\n ResidualSELayer(spatial_dims=spatial_dims, in_channels=out_channels, r=2),\n )\n\n def forward(self, x):\n return self.conv_conv_se(x)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/coplenet.py_DownBlock_DownBlock.forward.return.self_conv_x_pool_x_poo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/coplenet.py_DownBlock_DownBlock.forward.return.self_conv_x_pool_x_poo", "embedding": null, "metadata": {"file_path": "research/coplenet-pneumonia-lesion-segmentation/coplenet.py", "file_name": "coplenet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 45, "end_line": 57, "span_ids": ["DownBlock", "DownBlock.__init__", "DownBlock.forward"], "tokens": 138}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DownBlock(nn.Module):\n \"\"\"\n Downsampling with a concatenation of max-pool and avg-pool, followed by ConvBNActBlock\n \"\"\"\n\n def __init__(self, in_channels, out_channels, dropout_p, spatial_dims: int = 2):\n super().__init__()\n self.max_avg_pool = MaxAvgPool(spatial_dims=spatial_dims, kernel_size=2)\n self.conv = ConvBNActBlock(2 * in_channels, out_channels, dropout_p, spatial_dims=spatial_dims)\n\n def forward(self, x):\n x_pool = self.max_avg_pool(x)\n return self.conv(x_pool) + x_pool", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/coplenet.py_UpBlock_UpBlock.forward.return.self_conv_x_cat_x_cat": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/coplenet.py_UpBlock_UpBlock.forward.return.self_conv_x_cat_x_cat", "embedding": null, "metadata": {"file_path": "research/coplenet-pneumonia-lesion-segmentation/coplenet.py", "file_name": "coplenet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 60, "end_line": 70, "span_ids": ["UpBlock.forward", "UpBlock", "UpBlock.__init__"], "tokens": 158}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class UpBlock(nn.Module):\n \"\"\"Upssampling followed by ConvBNActBlock\"\"\"\n\n def __init__(self, in_channels1, in_channels2, out_channels, bilinear=True, dropout_p=0.5, spatial_dims: int = 2):\n super().__init__()\n self.up = UpSample(spatial_dims, in_channels1, in_channels2, scale_factor=2, with_conv=not bilinear)\n self.conv = ConvBNActBlock(in_channels2 * 2, out_channels, dropout_p, spatial_dims=spatial_dims)\n\n def forward(self, x1, x2):\n x_cat = torch.cat([x2, self.up(x1)], dim=1)\n return self.conv(x_cat) + x_cat", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/coplenet.py_CopleNet_CopleNet.__init__.self.out_conv.Convolution_spatial_dims_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/coplenet.py_CopleNet_CopleNet.__init__.self.out_conv.Convolution_spatial_dims_", "embedding": null, "metadata": {"file_path": "research/coplenet-pneumonia-lesion-segmentation/coplenet.py", "file_name": "coplenet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 73, "end_line": 125, "span_ids": ["CopleNet", "CopleNet.__init__"], "tokens": 912}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CopleNet(nn.Module):\n def __init__(\n self,\n spatial_dims: int = 2,\n in_channels: int = 1,\n out_channels: int = 2,\n feature_channels=(32, 64, 128, 256, 512),\n dropout=(0.0, 0.0, 0.3, 0.4, 0.5),\n bilinear: bool = True,\n ):\n \"\"\"\n Args:\n spatial_dims: dimension of the operators. Defaults to 2, i.e., using 2D operators\n for all operators, for example, using Conv2D for all the convolutions.\n It should be 2 for 3D images\n in_channels: number of channels of the input image. Defaults to 1.\n out_channels: number of segmentation classes (2 for foreground/background segmentation).\n Defaults to 2.\n feature_channels: number of intermediate feature channels\n (must have 5 elements corresponding to five conv. stages).\n Defaults to (32, 64, 128, 256, 512).\n dropout: a sequence of 5 dropout ratios. Defaults to (0.0, 0.0, 0.3, 0.4, 0.5).\n bilinear: whether to use bilinear upsampling. Defaults to True.\n \"\"\"\n super().__init__()\n ft_chns = ensure_tuple_rep(feature_channels, 5)\n\n f0_half = int(ft_chns[0] / 2)\n f1_half = int(ft_chns[1] / 2)\n f2_half = int(ft_chns[2] / 2)\n f3_half = int(ft_chns[3] / 2)\n\n self.in_conv = ConvBNActBlock(in_channels, ft_chns[0], dropout[0], spatial_dims)\n self.down1 = DownBlock(ft_chns[0], ft_chns[1], dropout[1], spatial_dims)\n self.down2 = DownBlock(ft_chns[1], ft_chns[2], dropout[2], spatial_dims)\n self.down3 = DownBlock(ft_chns[2], ft_chns[3], dropout[3], spatial_dims)\n self.down4 = DownBlock(ft_chns[3], ft_chns[4], dropout[4], spatial_dims)\n\n self.bridge0 = Convolution(spatial_dims, ft_chns[0], f0_half, kernel_size=1, norm=Norm.BATCH, act=Act.LEAKYRELU)\n self.bridge1 = Convolution(spatial_dims, ft_chns[1], f1_half, kernel_size=1, norm=Norm.BATCH, act=Act.LEAKYRELU)\n self.bridge2 = Convolution(spatial_dims, ft_chns[2], f2_half, kernel_size=1, norm=Norm.BATCH, act=Act.LEAKYRELU)\n self.bridge3 = Convolution(spatial_dims, ft_chns[3], f3_half, kernel_size=1, norm=Norm.BATCH, act=Act.LEAKYRELU)\n\n self.up1 = UpBlock(ft_chns[4], f3_half, ft_chns[3], bilinear, dropout[3], spatial_dims)\n self.up2 = UpBlock(ft_chns[3], f2_half, ft_chns[2], bilinear, dropout[2], spatial_dims)\n self.up3 = UpBlock(ft_chns[2], f1_half, ft_chns[1], bilinear, dropout[1], spatial_dims)\n self.up4 = UpBlock(ft_chns[1], f0_half, ft_chns[0], bilinear, dropout[0], spatial_dims)\n\n self.aspp = SimpleASPP(\n spatial_dims, ft_chns[4], int(ft_chns[4] / 4), kernel_sizes=[1, 3, 3, 3], dilations=[1, 2, 4, 6]\n )\n\n self.out_conv = Convolution(spatial_dims, ft_chns[0], out_channels, conv_only=True)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/coplenet.py_CopleNet.forward_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/coplenet.py_CopleNet.forward_", "embedding": null, "metadata": {"file_path": "research/coplenet-pneumonia-lesion-segmentation/coplenet.py", "file_name": "coplenet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 127, "end_line": 160, "span_ids": ["CopleNet.forward"], "tokens": 330}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class CopleNet(nn.Module):\n\n def forward(self, x):\n x_shape = list(x.shape)\n if len(x_shape) == 5:\n [batch, chns, dim1, dim2, dim3] = x_shape\n new_shape = [batch * dim1, chns, dim2, dim3]\n x = torch.transpose(x, 1, 2)\n x = torch.reshape(x, new_shape)\n elif len(x_shape) == 3:\n raise NotImplementedError(\"spatial dimension = 1 not supported.\")\n\n x0 = self.in_conv(x)\n x0b = self.bridge0(x0)\n x1 = self.down1(x0)\n x1b = self.bridge1(x1)\n x2 = self.down2(x1)\n x2b = self.bridge2(x2)\n x3 = self.down3(x2)\n x3b = self.bridge3(x3)\n x4 = self.down4(x3)\n\n x4 = self.aspp(x4)\n\n x = self.up1(x4, x3b)\n x = self.up2(x, x2b)\n x = self.up3(x, x1b)\n x = self.up4(x, x0b)\n output = self.out_conv(x)\n\n if len(x_shape) == 5:\n new_shape = [batch, dim1] + list(output.shape)[1:]\n output = torch.reshape(output, new_shape)\n output = torch.transpose(output, 1, 2)\n return output", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/run_inference.py_os_OUTPUT_FOLDER.os_path_join_output": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/run_inference.py_os_OUTPUT_FOLDER.os_path_join_output", "embedding": null, "metadata": {"file_path": "research/coplenet-pneumonia-lesion-segmentation/run_inference.py", "file_name": "run_inference.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 26, "span_ids": ["docstring"], "tokens": 119}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nfrom glob import glob\n\nimport monai\nimport numpy as np\nimport torch\nfrom monai.data import NiftiSaver\nfrom monai.inferers import sliding_window_inference\nfrom monai.transforms import AddChanneld, Compose, LoadNiftid, Orientationd, ToTensord\n\nfrom coplenet import CopleNet\n\nIMAGE_FOLDER = os.path.join(\".\", \"images\")\nMODEL_FILE = os.path.join(\".\", \"model\", \"coplenet_pretrained_monai_dict.pt\")\nOUTPUT_FOLDER = os.path.join(\".\", \"output\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/run_inference.py__writer_will_create_this_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/run_inference.py__writer_will_create_this_", "embedding": null, "metadata": {"file_path": "research/coplenet-pneumonia-lesion-segmentation/run_inference.py", "file_name": "run_inference.py", "file_type": "text/x-python", "category": "implementation", "start_line": 26, "end_line": 73, "span_ids": ["main", "impl:7", "docstring"], "tokens": 454}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": " # writer will create this folder if it doesn't exist.\n\n\ndef main():\n images = sorted(glob(os.path.join(IMAGE_FOLDER, \"case*.nii.gz\")))\n val_files = [{\"img\": img} for img in images]\n\n # define transforms for image and segmentation\n infer_transforms = Compose(\n [\n LoadNiftid(\"img\"),\n AddChanneld(\"img\"),\n Orientationd(\"img\", \"SPL\"), # coplenet works on the plane defined by the last two axes\n ToTensord(\"img\"),\n ]\n )\n test_ds = monai.data.Dataset(data=val_files, transform=infer_transforms)\n # sliding window inference need to input 1 image in every iteration\n data_loader = torch.utils.data.DataLoader(\n test_ds, batch_size=1, num_workers=0, pin_memory=torch.cuda.is_available()\n )\n\n device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n model = CopleNet().to(device)\n\n model.load_state_dict(torch.load(MODEL_FILE)[\"model_state_dict\"])\n model.eval()\n\n with torch.no_grad():\n saver = NiftiSaver(output_dir=OUTPUT_FOLDER)\n for idx, val_data in enumerate(data_loader):\n print(f\"Inference on {idx+1} of {len(data_loader)}\")\n val_images = val_data[\"img\"].to(device)\n # define sliding window size and batch size for windows inference\n slice_shape = np.ceil(np.asarray(val_images.shape[3:]) / 32) * 32\n roi_size = (20, int(slice_shape[0]), int(slice_shape[1]))\n sw_batch_size = 2\n val_outputs = sliding_window_inference(\n val_images, roi_size, sw_batch_size, model, 0.0, padding_mode=\"circular\"\n )\n # val_outputs = (val_outputs.sigmoid() >= 0.5).float()\n val_outputs = val_outputs.argmax(dim=1, keepdim=True)\n saver.save_batch(val_outputs, val_data[\"img_meta_dict\"])\n\n\nif __name__ == \"__main__\":\n main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/test_coplenet.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/coplenet-pneumonia-lesion-segmentation/test_coplenet.py_unittest_", "embedding": null, "metadata": {"file_path": "research/coplenet-pneumonia-lesion-segmentation/test_coplenet.py", "file_name": "test_coplenet.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 55, "span_ids": ["impl:3", "TestCopleNET", "TestCopleNET.test_shape", "docstring"], "tokens": 461}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom coplenet import CopleNet\n\nTEST_CASES = [\n [{\"spatial_dims\": 2}, torch.randn(16, 1, 32, 32), (16, 2, 32, 32)], # single channel 2D, batch 16, no residual\n [\n {\"spatial_dims\": 2, \"in_channels\": 5, \"out_channels\": 4},\n torch.randn(16, 5, 32, 32),\n (16, 4, 32, 32),\n ], # 5-channel 2D, batch 16\n [{\"spatial_dims\": 2}, torch.randn(16, 1, 32, 48, 48), (16, 2, 32, 48, 48)], # 1-channel 3D, batch 16\n [\n {\"spatial_dims\": 2, \"bilinear\": False},\n torch.randn(16, 1, 32, 64, 48),\n (16, 2, 32, 64, 48),\n ], # 1-channel 3D, batch 16\n [\n {\"spatial_dims\": 2, \"in_channels\": 2, \"out_channels\": 3, \"bilinear\": False},\n torch.randn(16, 2, 32, 64, 48),\n (16, 3, 32, 64, 48),\n ], # 4-channel 3D, batch 16, batch normalisation\n]\n\n\nclass TestCopleNET(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_shape(self, input_param, input_data, expected_shape):\n net = CopleNet(**input_param)\n if torch.cuda.is_available():\n net = net.to(torch.device(\"cuda\"))\n input_data = input_data.to(torch.device(\"cuda\"))\n net.eval()\n with torch.no_grad():\n result = net.forward(input_data.float())\n self.assertEqual(result.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/__init__.py__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/__init__.py__", "embedding": null, "metadata": {"file_path": "research/lamp-automated-model-parallelism/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 11, "end_line": 11, "span_ids": [], "tokens": 0}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/data_utils.py_os_get_filenames.return.os_path_join_path_img_c": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/data_utils.py_os_get_filenames.return.os_path_join_path_img_c", "embedding": null, "metadata": {"file_path": "research/lamp-automated-model-parallelism/data_utils.py", "file_name": "data_utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 44, "span_ids": ["get_filenames", "docstring"], "tokens": 228}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport numpy as np\nfrom monai.transforms import DivisiblePad\n\nSTRUCTURES = (\n \"BrainStem\",\n \"Chiasm\",\n \"Mandible\",\n \"OpticNerve_L\",\n \"OpticNerve_R\",\n \"Parotid_L\",\n \"Parotid_R\",\n \"Submandibular_L\",\n \"Submandibular_R\",\n)\n\n\ndef get_filenames(path, maskname=STRUCTURES):\n \"\"\"\n create file names according to the predefined folder structure.\n\n Args:\n path: data folder name\n maskname: target structure names\n \"\"\"\n maskfiles = []\n for seg in maskname:\n if os.path.exists(os.path.join(path, \"./structures/\" + seg + \"_crp_v2.npy\")):\n maskfiles.append(os.path.join(path, \"./structures/\" + seg + \"_crp_v2.npy\"))\n else:\n # the corresponding mask is missing seg, path.split(\"/\")[-1]\n maskfiles.append(None)\n return os.path.join(path, \"img_crp_v2.npy\"), maskfiles", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/data_utils.py_load_data_and_mask_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/data_utils.py_load_data_and_mask_", "embedding": null, "metadata": {"file_path": "research/lamp-automated-model-parallelism/data_utils.py", "file_name": "data_utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 47, "end_line": 67, "span_ids": ["load_data_and_mask"], "tokens": 201}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def load_data_and_mask(data, mask_data):\n \"\"\"\n Load data filename and mask_data (list of file names)\n into a dictionary of {'image': array, \"label\": list of arrays, \"name\": str}.\n \"\"\"\n pad_xform = DivisiblePad(k=32)\n img = np.load(data) # z y x\n img = pad_xform(img[None])[0]\n item = dict(image=img, label=[])\n for maskfnm in mask_data:\n if maskfnm is None:\n ms = np.zeros(img.shape, np.uint8)\n else:\n ms = np.load(maskfnm).astype(np.uint8)\n assert ms.min() == 0 and ms.max() == 1\n mask = pad_xform(ms[None])[0]\n item[\"label\"].append(mask)\n assert len(item[\"label\"]) == 9\n item[\"name\"] = str(data)\n return item", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/test_unet_pipe.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/test_unet_pipe.py_unittest_", "embedding": null, "metadata": {"file_path": "research/lamp-automated-model-parallelism/test_unet_pipe.py", "file_name": "test_unet_pipe.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 53, "span_ids": ["TestUNETPipe", "impl:3", "TestUNETPipe.test_shape", "docstring"], "tokens": 383}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom unet_pipe import UNetPipe\n\nTEST_CASES = [\n [ # 1-channel 3D, batch 12\n {\"spatial_dims\": 3, \"out_channels\": 2, \"in_channels\": 1, \"depth\": 3, \"n_feat\": 8},\n torch.randn(12, 1, 32, 64, 48),\n (12, 2, 32, 64, 48),\n ],\n [ # 1-channel 3D, batch 16\n {\"spatial_dims\": 3, \"out_channels\": 2, \"in_channels\": 1, \"depth\": 3},\n torch.randn(16, 1, 32, 64, 48),\n (16, 2, 32, 64, 48),\n ],\n [ # 4-channel 3D, batch 16, batch normalisation\n {\"spatial_dims\": 3, \"out_channels\": 3, \"in_channels\": 2},\n torch.randn(16, 2, 64, 64, 64),\n (16, 3, 64, 64, 64),\n ],\n]\n\n\nclass TestUNETPipe(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_shape(self, input_param, input_data, expected_shape):\n net = UNetPipe(**input_param)\n if torch.cuda.is_available():\n net = net.to(torch.device(\"cuda\"))\n input_data = input_data.to(torch.device(\"cuda\"))\n net.eval()\n with torch.no_grad():\n result = net.forward(input_data.float())\n self.assertEqual(result.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_time_torch.backends.cudnn.enabled.True": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_time_torch.backends.cudnn.enabled.True", "embedding": null, "metadata": {"file_path": "research/lamp-automated-model-parallelism/train.py", "file_name": "train.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 33, "span_ids": ["docstring"], "tokens": 179}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import time\nfrom argparse import ArgumentParser\nimport os\n\nimport numpy as np\nimport torch\nfrom monai.transforms import AddChannelDict, Compose, RandCropByPosNegLabeld, Rand3DElasticd, SpatialPadd\nfrom monai.losses import DiceLoss, FocalLoss\nfrom monai.metrics import compute_meandice\nfrom monai.data import Dataset, list_data_collate\nfrom monai.utils import first\nfrom torchgpipe import GPipe\nfrom torchgpipe.balance import balance_by_size\n\nfrom unet_pipe import UNetPipe, flatten_sequential\nfrom data_utils import get_filenames, load_data_and_mask\n\nN_CLASSES = 10\nTRAIN_PATH = \"./data/HaN/train/\" # training data folder\nVAL_PATH = \"./data/HaN/test/\" # validation data folder\n\ntorch.backends.cudnn.enabled = True", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_ImageLabelDataset_ImageLabelDataset.__len__.return.len_self_data_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_ImageLabelDataset_ImageLabelDataset.__len__.return.len_self_data_", "embedding": null, "metadata": {"file_path": "research/lamp-automated-model-parallelism/train.py", "file_name": "train.py", "file_type": "text/x-python", "category": "implementation", "start_line": 36, "end_line": 71, "span_ids": ["ImageLabelDataset.__init__", "ImageLabelDataset", "ImageLabelDataset.__getitem__", "ImageLabelDataset.__len__"], "tokens": 350}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ImageLabelDataset:\n \"\"\"\n Load image and multi-class labels based on the predefined folder structure.\n \"\"\"\n\n def __init__(self, path, n_class=10):\n self.path = path\n self.data = sorted(os.listdir(path))\n self.n_class = n_class\n\n def __getitem__(self, index):\n data = os.path.join(self.path, self.data[index])\n train_data, train_masks_data = get_filenames(data)\n data = load_data_and_mask(train_data, train_masks_data) # read into a data dict\n # loading image\n data[\"image\"] = data[\"image\"].astype(np.float32) # shape (H W D)\n # loading labels\n class_shape = (1,) + data[\"image\"].shape\n mask0 = np.zeros(class_shape)\n mask_list = []\n flagvect = np.ones((self.n_class,), np.float32)\n for i, mask in enumerate(data[\"label\"]):\n if mask is None:\n mask = np.zeros(class_shape)\n flagvect[0] = 0\n flagvect[i + 1] = 0\n mask0 = np.logical_or(mask0, mask)\n mask_list.append(mask.reshape(class_shape))\n mask0 = 1 - mask0\n data[\"label\"] = np.concatenate([mask0] + mask_list, axis=0).astype(np.uint8) # shape (C H W D)\n # setting flags\n data[\"with_complete_groundtruth\"] = flagvect # flagvec is a boolean indicator for complete annotation\n return data\n\n def __len__(self):\n return len(self.data)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_train_train.val_dataset.Dataset_ImageLabelDataset": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_train_train.val_dataset.Dataset_ImageLabelDataset", "embedding": null, "metadata": {"file_path": "research/lamp-automated-model-parallelism/train.py", "file_name": "train.py", "file_type": "text/x-python", "category": "implementation", "start_line": 74, "end_line": 138, "span_ids": ["train"], "tokens": 777}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def train(n_feat, crop_size, bs, ep, optimizer=\"rmsprop\", lr=5e-4, pretrain=None):\n model_name = f\"./HaN_{n_feat}_{bs}_{ep}_{crop_size}_{lr}_\"\n print(f\"save the best model as '{model_name}' during training.\")\n\n crop_size = [int(cz) for cz in crop_size.split(\",\")]\n print(f\"input image crop_size: {crop_size}\")\n\n # starting training set loader\n train_images = ImageLabelDataset(path=TRAIN_PATH, n_class=N_CLASSES)\n if np.any([cz == -1 for cz in crop_size]): # using full image\n train_transform = Compose(\n [\n AddChannelDict(keys=\"image\"),\n Rand3DElasticd(\n keys=(\"image\", \"label\"),\n spatial_size=crop_size,\n sigma_range=(10, 50), # 30\n magnitude_range=(600, 1200), # 1000\n prob=0.8,\n rotate_range=(np.pi / 12, np.pi / 12, np.pi / 12),\n shear_range=(np.pi / 18, np.pi / 18, np.pi / 18),\n translate_range=tuple(sz * 0.05 for sz in crop_size),\n scale_range=(0.2, 0.2, 0.2),\n mode=(\"bilinear\", \"nearest\"),\n padding_mode=(\"border\", \"zeros\"),\n ),\n ]\n )\n train_dataset = Dataset(train_images, transform=train_transform)\n # when bs > 1, the loader assumes that the full image sizes are the same across the dataset\n train_dataloader = torch.utils.data.DataLoader(train_dataset, num_workers=4, batch_size=bs, shuffle=True)\n else:\n # draw balanced foreground/background window samples according to the ground truth label\n train_transform = Compose(\n [\n AddChannelDict(keys=\"image\"),\n SpatialPadd(keys=(\"image\", \"label\"), spatial_size=crop_size), # ensure image size >= crop_size\n RandCropByPosNegLabeld(\n keys=(\"image\", \"label\"), label_key=\"label\", spatial_size=crop_size, num_samples=bs\n ),\n Rand3DElasticd(\n keys=(\"image\", \"label\"),\n spatial_size=crop_size,\n sigma_range=(10, 50), # 30\n magnitude_range=(600, 1200), # 1000\n prob=0.8,\n rotate_range=(np.pi / 12, np.pi / 12, np.pi / 12),\n shear_range=(np.pi / 18, np.pi / 18, np.pi / 18),\n translate_range=tuple(sz * 0.05 for sz in crop_size),\n scale_range=(0.2, 0.2, 0.2),\n mode=(\"bilinear\", \"nearest\"),\n padding_mode=(\"border\", \"zeros\"),\n ),\n ]\n )\n train_dataset = Dataset(train_images, transform=train_transform) # each dataset item is a list of windows\n train_dataloader = torch.utils.data.DataLoader( # stack each dataset item into a single tensor\n train_dataset, num_workers=4, batch_size=1, shuffle=True, collate_fn=list_data_collate\n )\n first_sample = first(train_dataloader)\n print(first_sample[\"image\"].shape)\n\n # starting validation set loader\n val_transform = Compose([AddChannelDict(keys=\"image\")])\n val_dataset = Dataset(ImageLabelDataset(VAL_PATH, n_class=N_CLASSES), transform=val_transform)\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_train.val_dataloader_train._foreground": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_train.val_dataloader_train._foreground", "embedding": null, "metadata": {"file_path": "research/lamp-automated-model-parallelism/train.py", "file_name": "train.py", "file_type": "text/x-python", "category": "implementation", "start_line": 139, "end_line": 178, "span_ids": ["train"], "tokens": 558}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def train(n_feat, crop_size, bs, ep, optimizer=\"rmsprop\", lr=5e-4, pretrain=None):\n # ... other code\n val_dataloader = torch.utils.data.DataLoader(val_dataset, num_workers=1, batch_size=1)\n print(val_dataset[0][\"image\"].shape)\n print(f\"training images: {len(train_dataloader)}, validation images: {len(val_dataloader)}\")\n\n model = UNetPipe(spatial_dims=3, in_channels=1, out_channels=N_CLASSES, n_feat=n_feat)\n model = flatten_sequential(model)\n lossweight = torch.from_numpy(np.array([2.22, 1.31, 1.99, 1.13, 1.93, 1.93, 1.0, 1.0, 1.90, 1.98], np.float32))\n\n if optimizer.lower() == \"rmsprop\":\n optimizer = torch.optim.RMSprop(model.parameters(), lr=lr) # lr = 5e-4\n elif optimizer.lower() == \"momentum\":\n optimizer = torch.optim.SGD(model.parameters(), lr=lr, momentum=0.9) # lr = 1e-4 for finetuning\n else:\n raise ValueError(f\"Unknown optimizer type {optimizer}. (options are 'rmsprop' and 'momentum').\")\n\n # config GPipe\n x = first_sample[\"image\"].float()\n x = torch.autograd.Variable(x.cuda())\n partitions = torch.cuda.device_count()\n print(f\"partition: {partitions}, input: {x.size()}\")\n balance = balance_by_size(partitions, model, x)\n model = GPipe(model, balance, chunks=4, checkpoint=\"always\")\n\n # config loss functions\n dice_loss_func = DiceLoss(softmax=True, reduction=\"none\")\n # use the same pipeline and loss in\n # AnatomyNet: Deep learning for fast and fully automated whole\u2010volume segmentation of head and neck anatomy,\n # Medical Physics, 2018.\n focal_loss_func = FocalLoss(reduction=\"none\")\n\n if pretrain:\n print(f\"loading from {pretrain}.\")\n pretrained_dict = torch.load(pretrain)[\"weight\"]\n model_dict = model.state_dict()\n pretrained_dict = {k: v for k, v in pretrained_dict.items() if k in model_dict}\n model_dict.update(pretrained_dict)\n model.load_state_dict(pretrained_dict)\n\n b_time = time.time()\n best_val_loss = [0] * (N_CLASSES - 1) # foreground\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_train.for_epoch_in_range_ep__train.print_total_time_time_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_train.for_epoch_in_range_ep__train.print_total_time_time_", "embedding": null, "metadata": {"file_path": "research/lamp-automated-model-parallelism/train.py", "file_name": "train.py", "file_type": "text/x-python", "category": "implementation", "start_line": 179, "end_line": 225, "span_ids": ["train"], "tokens": 687}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def train(n_feat, crop_size, bs, ep, optimizer=\"rmsprop\", lr=5e-4, pretrain=None):\n # ... other code\n for epoch in range(ep):\n model.train()\n trainloss = 0\n for b_idx, data_dict in enumerate(train_dataloader):\n x_train = data_dict[\"image\"]\n y_train = data_dict[\"label\"]\n flagvec = data_dict[\"with_complete_groundtruth\"]\n\n x_train = torch.autograd.Variable(x_train.cuda())\n y_train = torch.autograd.Variable(y_train.cuda().float())\n optimizer.zero_grad()\n o = model(x_train).to(0, non_blocking=True).float()\n\n loss = (dice_loss_func(o, y_train.to(o)) * flagvec.to(o) * lossweight.to(o)).mean()\n loss += 0.5 * (focal_loss_func(o, y_train.to(o)) * flagvec.to(o) * lossweight.to(o)).mean()\n loss.backward()\n optimizer.step()\n trainloss += loss.item()\n\n if b_idx % 20 == 0:\n print(f\"Train Epoch: {epoch} [{b_idx}/{len(train_dataloader)}] \\tLoss: {loss.item()}\")\n print(f\"epoch {epoch} TRAIN loss {trainloss / len(train_dataloader)}\")\n\n if epoch % 10 == 0:\n model.eval()\n # check validation dice\n val_loss = [0] * (N_CLASSES - 1)\n n_val = [0] * (N_CLASSES - 1)\n for data_dict in val_dataloader:\n x_val = data_dict[\"image\"]\n y_val = data_dict[\"label\"]\n with torch.no_grad():\n x_val = torch.autograd.Variable(x_val.cuda())\n o = model(x_val).to(0, non_blocking=True)\n loss = compute_meandice(o, y_val.to(o), mutually_exclusive=True, include_background=False)\n val_loss = [l.item() + tl if l == l else tl for l, tl in zip(loss[0], val_loss)]\n n_val = [n + 1 if l == l else n for l, n in zip(loss[0], n_val)]\n val_loss = [l / n for l, n in zip(val_loss, n_val)]\n print(\"validation scores %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f\" % tuple(val_loss))\n for c in range(1, 10):\n if best_val_loss[c - 1] < val_loss[c - 1]:\n best_val_loss[c - 1] = val_loss[c - 1]\n state = {\"epoch\": epoch, \"weight\": model.state_dict(), \"score_\" + str(c): best_val_loss[c - 1]}\n torch.save(state, f\"{model_name}\" + str(c))\n print(\"best validation scores %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f\" % tuple(best_val_loss))\n\n print(\"total time\", time.time() - b_time)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_if___name_____main____": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_if___name_____main____", "embedding": null, "metadata": {"file_path": "research/lamp-automated-model-parallelism/train.py", "file_name": "train.py", "file_type": "text/x-python", "category": "implementation", "start_line": 228, "end_line": 242, "span_ids": ["impl:9"], "tokens": 200}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "if __name__ == \"__main__\":\n parser = ArgumentParser()\n parser.add_argument(\"--n_feat\", type=int, default=32, dest=\"n_feat\")\n parser.add_argument(\"--crop_size\", type=str, default=\"-1,-1,-1\", dest=\"crop_size\")\n parser.add_argument(\"--bs\", type=int, default=1, dest=\"bs\") # batch size\n parser.add_argument(\"--ep\", type=int, default=150, dest=\"ep\") # number of epochs\n parser.add_argument(\"--lr\", type=float, default=5e-4, dest=\"lr\") # learning rate\n parser.add_argument(\"--optimizer\", type=str, default=\"rmsprop\", dest=\"optimizer\") # type of optimizer\n parser.add_argument(\"--pretrain\", type=str, default=None, dest=\"pretrain\")\n args = parser.parse_args()\n\n input_dict = vars(args)\n print(input_dict)\n train(**input_dict)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/unet_pipe.py_from_collections_import_O_PopCat.forward.return.input": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/unet_pipe.py_from_collections_import_O_PopCat.forward.return.input", "embedding": null, "metadata": {"file_path": "research/lamp-automated-model-parallelism/unet_pipe.py", "file_name": "unet_pipe.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 35, "span_ids": ["Stash.forward", "Stash", "PopCat.forward", "PopCat", "docstring"], "tokens": 170}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from collections import OrderedDict\nfrom typing import List\n\nimport torch\nfrom monai.networks.blocks import Convolution, UpSample\nfrom monai.networks.layers.factories import Act, Conv, Norm\nfrom torch import nn\nfrom torchgpipe.skip import Namespace, pop, skippable, stash\n\n\n@skippable(stash=[\"skip\"], pop=[])\nclass Stash(nn.Module):\n def forward(self, input: torch.Tensor):\n yield stash(\"skip\", input)\n return input # noqa using yield together with return\n\n\n@skippable(stash=[], pop=[\"skip\"])\nclass PopCat(nn.Module):\n def forward(self, input: torch.Tensor):\n skip = yield pop(\"skip\")\n if skip is not None:\n input = torch.cat([input, skip], dim=1)\n return input", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/unet_pipe.py_flatten_sequential_flatten_sequential.return.nn_Sequential_OrderedDict": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/unet_pipe.py_flatten_sequential_flatten_sequential.return.nn_Sequential_OrderedDict", "embedding": null, "metadata": {"file_path": "research/lamp-automated-model-parallelism/unet_pipe.py", "file_name": "unet_pipe.py", "file_type": "text/x-python", "category": "implementation", "start_line": 38, "end_line": 56, "span_ids": ["flatten_sequential"], "tokens": 123}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def flatten_sequential(module: nn.Sequential):\n \"\"\"\n Recursively make all the submodules sequential.\n\n Args:\n module: a torch sequential model.\n \"\"\"\n if not isinstance(module, nn.Sequential):\n raise TypeError(\"module must be a nn.Sequential instance.\")\n\n def _flatten(module):\n for name, child in module.named_children():\n if isinstance(child, nn.Sequential):\n for sub_name, sub_child in _flatten(child):\n yield f\"{name}_{sub_name}\", sub_child\n else:\n yield name, child\n\n return nn.Sequential(OrderedDict(_flatten(module)))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/unet_pipe.py_DoubleConv_DoubleConv.forward.return.self_conv_x_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/unet_pipe.py_DoubleConv_DoubleConv.forward.return.self_conv_x_", "embedding": null, "metadata": {"file_path": "research/lamp-automated-model-parallelism/unet_pipe.py", "file_name": "unet_pipe.py", "file_type": "text/x-python", "category": "implementation", "start_line": 59, "end_line": 97, "span_ids": ["DoubleConv.forward", "DoubleConv.__init__", "DoubleConv"], "tokens": 389}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class DoubleConv(nn.Module):\n def __init__(\n self,\n spatial_dims,\n in_channels,\n out_channels,\n stride=2,\n act_1=Act.LEAKYRELU,\n norm_1=Norm.BATCH,\n act_2=Act.LEAKYRELU,\n norm_2=Norm.BATCH,\n conv_only=True,\n ):\n \"\"\"\n A sequence of Conv_1 + Norm_1 + Act_1 + Conv_2 (+ Norm_2 + Act_2).\n\n `norm_2` and `act_2` are ignored when `conv_only` is True.\n `stride` is for `Conv_1`, typically stride=2 for 2x spatial downsampling.\n\n Args:\n spatial_dims: number of the input spatial dimension.\n in_channels: number of input channels.\n out_channels: number of output channels.\n stride: stride of the first conv., mainly used for 2x downsampling when stride=2.\n act_1: activation type of the first convolution.\n norm_1: normalization type of the first convolution.\n act_2: activation type of the second convolution.\n norm_2: normalization type of the second convolution.\n conv_only: whether the second conv is convolution layer only. Default to True,\n indicates that `act_2` and `norm_2` are not in use.\n \"\"\"\n super(DoubleConv, self).__init__()\n self.conv = nn.Sequential(\n Convolution(spatial_dims, in_channels, out_channels, strides=stride, act=act_1, norm=norm_1, bias=False,),\n Convolution(spatial_dims, out_channels, out_channels, act=act_2, norm=norm_2, conv_only=conv_only),\n )\n\n def forward(self, x):\n return self.conv(x)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/unet_pipe.py_UNetPipe_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/unet_pipe.py_UNetPipe_", "embedding": null, "metadata": {"file_path": "research/lamp-automated-model-parallelism/unet_pipe.py", "file_name": "unet_pipe.py", "file_type": "text/x-python", "category": "implementation", "start_line": 100, "end_line": 172, "span_ids": ["UNetPipe", "UNetPipe.__init__"], "tokens": 798}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class UNetPipe(nn.Sequential):\n def __init__(self, spatial_dims: int, in_channels: int, out_channels: int, n_feat: int = 32, depth: int = 4):\n \"\"\"\n A UNet-like architecture for model parallelism.\n\n Args:\n spatial_dims: number of input spatial dimensions,\n 2 for (B, in_channels, H, W), 3 for (B, in_channels, H, W, D).\n in_channels: number of input channels.\n out_channels: number of output channels.\n n_feat: number of features in the first convolution.\n depth: number of downsampling stages.\n \"\"\"\n super(UNetPipe, self).__init__()\n n_enc_filter: List[int] = [n_feat]\n for _ in range(depth):\n n_enc_filter.append(min(n_enc_filter[-1] * 2, 1024))\n namespaces = [Namespace() for _ in range(depth)]\n\n # construct the encoder\n encoder_layers: List[nn.Module] = []\n init_conv = Convolution(\n spatial_dims, in_channels, n_enc_filter[0], strides=2, act=Act.LEAKYRELU, norm=Norm.BATCH, bias=False,\n )\n encoder_layers.append(\n nn.Sequential(OrderedDict([(\"Conv\", init_conv,), (\"skip\", Stash().isolate(namespaces[0]))]))\n )\n for i in range(1, depth + 1):\n down_conv = DoubleConv(spatial_dims, n_enc_filter[i - 1], n_enc_filter[i])\n if i == depth:\n layer_dict = OrderedDict([(\"Down\", down_conv)])\n else:\n layer_dict = OrderedDict([(\"Down\", down_conv), (\"skip\", Stash().isolate(namespaces[i]))])\n encoder_layers.append(nn.Sequential(layer_dict))\n encoder = nn.Sequential(*encoder_layers)\n\n # construct the decoder\n decoder_layers: List[nn.Module] = []\n for i in reversed(range(1, depth + 1)):\n in_ch, out_ch = n_enc_filter[i], n_enc_filter[i - 1]\n layer_dict = OrderedDict(\n [\n (\"Up\", UpSample(spatial_dims, in_ch, out_ch, 2, True)),\n (\"skip\", PopCat().isolate(namespaces[i - 1])),\n (\"Conv1x1x1\", Conv[Conv.CONV, spatial_dims](out_ch * 2, in_ch, kernel_size=1)),\n (\"Conv\", DoubleConv(spatial_dims, in_ch, out_ch, stride=1, conv_only=True)),\n ]\n )\n decoder_layers.append(nn.Sequential(layer_dict))\n in_ch = min(n_enc_filter[0] // 2, 32)\n layer_dict = OrderedDict(\n [\n (\"Up\", UpSample(spatial_dims, n_feat, in_ch, 2, True)),\n (\"RELU\", Act[Act.LEAKYRELU](inplace=False)),\n (\"out\", Conv[Conv.CONV, spatial_dims](in_ch, out_channels, kernel_size=3, padding=1),),\n ]\n )\n decoder_layers.append(nn.Sequential(layer_dict))\n decoder = nn.Sequential(*decoder_layers)\n\n # making a sequential model\n self.add_module(\"encoder\", encoder)\n self.add_module(\"decoder\", decoder)\n\n for m in self.modules():\n if isinstance(m, Conv[Conv.CONV, spatial_dims]):\n nn.init.kaiming_normal_(m.weight)\n elif isinstance(m, Norm[Norm.BATCH, spatial_dims]):\n nn.init.constant_(m.weight, 1)\n nn.init.constant_(m.bias, 0)\n elif isinstance(m, Conv[Conv.CONVTRANS, spatial_dims]):\n nn.init.kaiming_normal_(m.weight)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/setup.py_from_setuptools_import_fi_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/setup.py_from_setuptools_import_fi_", "embedding": null, "metadata": {"file_path": "setup.py", "file_name": "setup.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 24, "span_ids": ["docstring"], "tokens": 79}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from setuptools import find_packages, setup\n\nimport versioneer\n\nif __name__ == \"__main__\":\n setup(\n version=versioneer.get_version(),\n cmdclass=versioneer.get_cmdclass(),\n packages=find_packages(exclude=(\"docs\", \"examples\", \"tests\", \"research\")),\n zip_safe=False,\n package_data={\"monai\": [\"py.typed\"]},\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/__init__.py_sys_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/__init__.py_sys_", "embedding": null, "metadata": {"file_path": "tests/__init__.py", "file_name": "__init__.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 38, "span_ids": ["_enter_pr_4800", "impl", "docstring"], "tokens": 200}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import sys\nimport unittest\nimport warnings\n\n\ndef _enter_pr_4800(self):\n \"\"\"\n code from https://github.com/python/cpython/pull/4800\n \"\"\"\n # The __warningregistry__'s need to be in a pristine state for tests\n # to work properly.\n for v in list(sys.modules.values()):\n if getattr(v, \"__warningregistry__\", None):\n v.__warningregistry__ = {}\n self.warnings_manager = warnings.catch_warnings(record=True)\n self.warnings = self.warnings_manager.__enter__()\n warnings.simplefilter(\"always\", self.expected)\n return self\n\n\n# workaround for https://bugs.python.org/issue29620\ntry:\n # Suppression for issue #494: tests/__init__.py:34: error: Cannot assign to a method\n unittest.case._AssertWarnsContext.__enter__ = _enter_pr_4800 # type: ignore\nexcept AttributeError:\n pass", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/min_tests.py_glob_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/min_tests.py_glob_", "embedding": null, "metadata": {"file_path": "tests/min_tests.py", "file_name": "min_tests.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 92, "span_ids": ["run_testsuit", "impl", "docstring"], "tokens": 547}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import glob\nimport os\nimport sys\nimport unittest\n\n\ndef run_testsuit():\n exclude_cases = [ # these cases use external dependencies\n \"test_arraydataset\",\n \"test_cachedataset\",\n \"test_cachedataset_parallel\",\n \"test_check_md5\",\n \"test_dataset\",\n \"test_handler_checkpoint_loader\",\n \"test_handler_checkpoint_saver\",\n \"test_handler_classification_saver\",\n \"test_handler_lr_scheduler\",\n \"test_handler_mean_dice\",\n \"test_handler_rocauc\",\n \"test_handler_segmentation_saver\",\n \"test_handler_stats\",\n \"test_handler_tb_image\",\n \"test_handler_tb_stats\",\n \"test_handler_validation\",\n \"test_header_correct\",\n \"test_img2tensorboard\",\n \"test_integration_segmentation_3d\",\n \"test_integration_sliding_window\",\n \"test_integration_unet_2d\",\n \"test_integration_workflows\",\n \"test_keep_largest_connected_component\",\n \"test_keep_largest_connected_componentd\",\n \"test_load_nifti\",\n \"test_load_niftid\",\n \"test_load_png\",\n \"test_load_pngd\",\n \"test_load_spacing_orientation\",\n \"test_nifti_dataset\",\n \"test_nifti_header_revise\",\n \"test_nifti_rw\",\n \"test_nifti_saver\",\n \"test_orientation\",\n \"test_orientationd\",\n \"test_parallel_execution\",\n \"test_persistentdataset\",\n \"test_plot_2d_or_3d_image\",\n \"test_png_rw\",\n \"test_png_saver\",\n \"test_rand_rotate\",\n \"test_rand_rotated\",\n \"test_rand_zoom\",\n \"test_rand_zoomd\",\n \"test_resize\",\n \"test_resized\",\n \"test_rotate\",\n \"test_rotated\",\n \"test_spacing\",\n \"test_spacingd\",\n \"test_zoom\",\n \"test_zoom_affine\",\n \"test_zoomd\",\n ]\n\n files = glob.glob(os.path.join(os.path.dirname(__file__), \"test_*.py\"))\n\n cases = []\n for case in files:\n test_module = os.path.basename(case)[:-3]\n if test_module in exclude_cases:\n print(f\"skipping test {test_module}.\")\n else:\n cases.append(f\"tests.{test_module}\")\n test_suite = unittest.TestLoader().loadTestsFromNames(cases)\n return test_suite\n\n\nif __name__ == \"__main__\":\n test_runner = unittest.TextTestRunner(stream=sys.stdout, verbosity=2)\n result = test_runner.run(run_testsuit())\n exit(int(not result.wasSuccessful()))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_activations.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_activations.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_activations.py", "file_name": "test_activations.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 49, "span_ids": ["TestActivations.test_value_shape", "impl:7", "TestActivations", "docstring"], "tokens": 398}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport torch\nfrom parameterized import parameterized\nfrom monai.transforms import Activations\n\nTEST_CASE_1 = [\n {\"sigmoid\": True, \"softmax\": False, \"other\": None},\n torch.tensor([[[[0.0, 1.0], [2.0, 3.0]]]]),\n torch.tensor([[[[0.5000, 0.7311], [0.8808, 0.9526]]]]),\n (1, 1, 2, 2),\n]\n\nTEST_CASE_2 = [\n {\"sigmoid\": False, \"softmax\": True, \"other\": None},\n torch.tensor([[[[0.0, 1.0]], [[2.0, 3.0]]]]),\n torch.tensor([[[[0.1192, 0.1192]], [[0.8808, 0.8808]]]]),\n (1, 2, 1, 2),\n]\n\nTEST_CASE_3 = [\n {\"sigmoid\": False, \"softmax\": False, \"other\": lambda x: torch.tanh(x)},\n torch.tensor([[[[0.0, 1.0], [2.0, 3.0]]]]),\n torch.tensor([[[[0.0000, 0.7616], [0.9640, 0.9951]]]]),\n (1, 1, 2, 2),\n]\n\n\nclass TestActivations(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_value_shape(self, input_param, img, out, expected_shape):\n result = Activations(**input_param)(img)\n torch.testing.assert_allclose(result, out)\n self.assertTupleEqual(result.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_activationsd.py_unittest_TEST_CASE_3._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_activationsd.py_unittest_TEST_CASE_3._", "embedding": null, "metadata": {"file_path": "tests/test_activationsd.py", "file_name": "test_activationsd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 42, "span_ids": ["docstring"], "tokens": 490}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport torch\nfrom parameterized import parameterized\nfrom monai.transforms import Activationsd\n\nTEST_CASE_1 = [\n {\"keys\": [\"pred\", \"label\"], \"sigmoid\": False, \"softmax\": [True, False], \"other\": None},\n {\"pred\": torch.tensor([[[[0.0, 1.0]], [[2.0, 3.0]]]]), \"label\": torch.tensor([[[[0.0, 1.0]], [[2.0, 3.0]]]])},\n {\n \"pred\": torch.tensor([[[[0.1192, 0.1192]], [[0.8808, 0.8808]]]]),\n \"label\": torch.tensor([[[[0.0, 1.0]], [[2.0, 3.0]]]]),\n },\n (1, 2, 1, 2),\n]\n\nTEST_CASE_2 = [\n {\"keys\": [\"pred\", \"label\"], \"sigmoid\": False, \"softmax\": False, \"other\": [lambda x: torch.tanh(x), None]},\n {\"pred\": torch.tensor([[[[0.0, 1.0], [2.0, 3.0]]]]), \"label\": torch.tensor([[[[0.0, 1.0], [2.0, 3.0]]]])},\n {\n \"pred\": torch.tensor([[[[0.0000, 0.7616], [0.9640, 0.9951]]]]),\n \"label\": torch.tensor([[[[0.0, 1.0], [2.0, 3.0]]]]),\n },\n (1, 1, 2, 2),\n]\n\nTEST_CASE_3 = [\n {\"keys\": \"pred\", \"sigmoid\": False, \"softmax\": False, \"other\": lambda x: torch.tanh(x)},\n {\"pred\": torch.tensor([[[[0.0, 1.0], [2.0, 3.0]]]])},\n {\"pred\": torch.tensor([[[[0.0000, 0.7616], [0.9640, 0.9951]]]])},\n (1, 1, 2, 2),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_activationsd.py_TestActivationsd_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_activationsd.py_TestActivationsd_", "embedding": null, "metadata": {"file_path": "tests/test_activationsd.py", "file_name": "test_activationsd.py", "file_type": "text/x-python", "category": "test", "start_line": 45, "end_line": 58, "span_ids": ["TestActivationsd.test_value_shape", "TestActivationsd", "impl:7"], "tokens": 136}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestActivationsd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_value_shape(self, input_param, test_input, output, expected_shape):\n result = Activationsd(**input_param)(test_input)\n torch.testing.assert_allclose(result[\"pred\"], output[\"pred\"])\n self.assertTupleEqual(result[\"pred\"].shape, expected_shape)\n if \"label\" in result:\n torch.testing.assert_allclose(result[\"label\"], output[\"label\"])\n self.assertTupleEqual(result[\"label\"].shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adaptors.py_unittest_TestAdaptors.test_single_in_single_out.None_4": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adaptors.py_unittest_TestAdaptors.test_single_in_single_out.None_4", "embedding": null, "metadata": {"file_path": "tests/test_adaptors.py", "file_name": "test_adaptors.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 54, "span_ids": ["TestAdaptors.test_function_signature", "TestAdaptors.test_single_in_single_out", "TestAdaptors", "docstring"], "tokens": 338}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport itertools\n\n\nfrom monai.transforms.adaptors import adaptor, apply_alias, to_kwargs, FunctionSignature\n\n\nclass TestAdaptors(unittest.TestCase):\n def test_function_signature(self):\n def foo(image, label=None, *a, **kw):\n pass\n\n f = FunctionSignature(foo)\n\n def test_single_in_single_out(self):\n def foo(image):\n return image * 2\n\n it = itertools.product([\"image\", [\"image\"]], [None, \"image\", [\"image\"], {\"image\": \"image\"}])\n for i in it:\n d = {\"image\": 2}\n dres = adaptor(foo, i[0], i[1])(d)\n self.assertEqual(dres[\"image\"], 4)\n\n d = {\"image\": 2}\n dres = adaptor(foo, \"image\")(d)\n self.assertEqual(dres[\"image\"], 4)\n\n d = {\"image\": 2}\n dres = adaptor(foo, \"image\", \"image\")(d)\n self.assertEqual(dres[\"image\"], 4)\n\n d = {\"image\": 2}\n dres = adaptor(foo, \"image\", {\"image\": \"image\"})(d)\n self.assertEqual(dres[\"image\"], 4)\n\n d = {\"img\": 2}\n dres = adaptor(foo, \"img\", {\"img\": \"image\"})(d)\n self.assertEqual(dres[\"img\"], 4)\n\n d = {\"img\": 2}\n dres = adaptor(foo, [\"img\"], {\"img\": \"image\"})(d)\n self.assertEqual(dres[\"img\"], 4)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adaptors.py_TestAdaptors.test_multi_in_single_out_TestAdaptors.test_multi_in_single_out.None_2.self_assertEqual_dres_lb": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adaptors.py_TestAdaptors.test_multi_in_single_out_TestAdaptors.test_multi_in_single_out.None_2.self_assertEqual_dres_lb", "embedding": null, "metadata": {"file_path": "tests/test_adaptors.py", "file_name": "test_adaptors.py", "file_type": "text/x-python", "category": "test", "start_line": 56, "end_line": 85, "span_ids": ["TestAdaptors.test_multi_in_single_out"], "tokens": 320}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAdaptors(unittest.TestCase):\n\n def test_multi_in_single_out(self):\n def foo(image, label):\n return image * label\n\n it = itertools.product([\"image\", [\"image\"]], [None, [\"image\", \"label\"], {\"image\": \"image\", \"label\": \"label\"}])\n\n for i in it:\n d = {\"image\": 2, \"label\": 3}\n dres = adaptor(foo, i[0], i[1])(d)\n self.assertEqual(dres[\"image\"], 6)\n self.assertEqual(dres[\"label\"], 3)\n\n it = itertools.product(\n [\"newimage\", [\"newimage\"]], [None, [\"image\", \"label\"], {\"image\": \"image\", \"label\": \"label\"}]\n )\n\n for i in it:\n d = {\"image\": 2, \"label\": 3}\n dres = adaptor(foo, i[0], i[1])(d)\n self.assertEqual(dres[\"image\"], 2)\n self.assertEqual(dres[\"label\"], 3)\n self.assertEqual(dres[\"newimage\"], 6)\n\n it = itertools.product([\"img\", [\"img\"]], [{\"img\": \"image\", \"lbl\": \"label\"}])\n\n for i in it:\n d = {\"img\": 2, \"lbl\": 3}\n dres = adaptor(foo, i[0], i[1])(d)\n self.assertEqual(dres[\"img\"], 6)\n self.assertEqual(dres[\"lbl\"], 3)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adaptors.py_TestAdaptors.test_default_arg_single_out_TestAdaptors.test_dict_out.self_assertEqual_dres_b_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adaptors.py_TestAdaptors.test_default_arg_single_out_TestAdaptors.test_dict_out.self_assertEqual_dres_b_", "embedding": null, "metadata": {"file_path": "tests/test_adaptors.py", "file_name": "test_adaptors.py", "file_type": "text/x-python", "category": "test", "start_line": 87, "end_line": 118, "span_ids": ["TestAdaptors.test_multi_out", "TestAdaptors.test_dict_out", "TestAdaptors.test_default_arg_single_out"], "tokens": 270}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAdaptors(unittest.TestCase):\n\n def test_default_arg_single_out(self):\n def foo(a, b=2):\n return a * b\n\n d = {\"a\": 5}\n dres = adaptor(foo, \"c\")(d)\n self.assertEqual(dres[\"c\"], 10)\n\n d = {\"b\": 5}\n with self.assertRaises(TypeError):\n dres = adaptor(foo, \"c\")(d)\n\n def test_multi_out(self):\n def foo(a, b):\n return a * b, a / b\n\n d = {\"a\": 3, \"b\": 4}\n dres = adaptor(foo, [\"c\", \"d\"])(d)\n self.assertEqual(dres[\"c\"], 12)\n self.assertEqual(dres[\"d\"], 3 / 4)\n\n def test_dict_out(self):\n def foo(a):\n return {\"a\": a * 2}\n\n d = {\"a\": 2}\n dres = adaptor(foo, {\"a\": \"a\"})(d)\n self.assertEqual(dres[\"a\"], 4)\n\n d = {\"b\": 2}\n dres = adaptor(foo, {\"a\": \"b\"}, {\"b\": \"a\"})(d)\n self.assertEqual(dres[\"b\"], 4)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adaptors.py_TestApplyAlias_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adaptors.py_TestApplyAlias_", "embedding": null, "metadata": {"file_path": "tests/test_adaptors.py", "file_name": "test_adaptors.py", "file_type": "text/x-python", "category": "test", "start_line": 121, "end_line": 149, "span_ids": ["TestToKwargs", "TestToKwargs.test_to_kwargs", "TestApplyAlias", "TestApplyAlias.test_apply_alias"], "tokens": 203}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestApplyAlias(unittest.TestCase):\n def test_apply_alias(self):\n def foo(d):\n d[\"x\"] *= 2\n return d\n\n d = {\"a\": 1, \"b\": 3}\n result = apply_alias(foo, {\"b\": \"x\"})(d)\n self.assertDictEqual({\"a\": 1, \"b\": 6}, result)\n\n\nclass TestToKwargs(unittest.TestCase):\n def test_to_kwargs(self):\n def foo(**kwargs):\n results = {k: v * 2 for k, v in kwargs.items()}\n return results\n\n def compose_like(fn, data):\n data = fn(data)\n return data\n\n d = {\"a\": 1, \"b\": 2}\n\n actual = compose_like(to_kwargs(foo), d)\n self.assertDictEqual(actual, {\"a\": 2, \"b\": 4})\n\n with self.assertRaises(TypeError):\n actual = compose_like(foo, d)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_add_channeld.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_add_channeld.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_add_channeld.py", "file_name": "test_add_channeld.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 34, "span_ids": ["TestAddChanneld.test_shape", "TestAddChanneld", "impl:3", "docstring"], "tokens": 175}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import AddChanneld\n\nTEST_CASE_1 = [\n {\"keys\": [\"img\", \"seg\"]},\n {\"img\": np.array([[0, 1], [1, 2]]), \"seg\": np.array([[0, 1], [1, 2]])},\n (1, 2, 2),\n]\n\n\nclass TestAddChanneld(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1])\n def test_shape(self, input_param, input_data, expected_shape):\n result = AddChanneld(**input_param)(input_data)\n self.assertEqual(result[\"img\"].shape, expected_shape)\n self.assertEqual(result[\"seg\"].shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adjust_contrast.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adjust_contrast.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_adjust_contrast.py", "file_name": "test_adjust_contrast.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 42, "span_ids": ["TestAdjustContrast.test_correct_results", "impl:7", "TestAdjustContrast", "docstring"], "tokens": 237}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import AdjustContrast\nfrom tests.utils import NumpyImageTestCase2D\n\nTEST_CASE_1 = [1.0]\n\nTEST_CASE_2 = [0.5]\n\nTEST_CASE_3 = [4.5]\n\n\nclass TestAdjustContrast(NumpyImageTestCase2D):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_correct_results(self, gamma):\n adjuster = AdjustContrast(gamma=gamma)\n result = adjuster(self.imt)\n if gamma == 1.0:\n expected = self.imt\n else:\n epsilon = 1e-7\n img_min = self.imt.min()\n img_range = self.imt.max() - img_min\n expected = np.power(((self.imt - img_min) / float(img_range + epsilon)), gamma) * img_range + img_min\n np.testing.assert_allclose(expected, result, rtol=1e-05)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adjust_contrastd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adjust_contrastd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_adjust_contrastd.py", "file_name": "test_adjust_contrastd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 42, "span_ids": ["TestAdjustContrastd.test_correct_results", "TestAdjustContrastd", "impl:7", "docstring"], "tokens": 247}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import AdjustContrastd\nfrom tests.utils import NumpyImageTestCase2D\n\nTEST_CASE_1 = [1.0]\n\nTEST_CASE_2 = [0.5]\n\nTEST_CASE_3 = [4.5]\n\n\nclass TestAdjustContrastd(NumpyImageTestCase2D):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_correct_results(self, gamma):\n adjuster = AdjustContrastd(\"img\", gamma=gamma)\n result = adjuster({\"img\": self.imt})\n if gamma == 1.0:\n expected = self.imt\n else:\n epsilon = 1e-7\n img_min = self.imt.min()\n img_range = self.imt.max() - img_min\n expected = np.power(((self.imt - img_min) / float(img_range + epsilon)), gamma) * img_range + img_min\n np.testing.assert_allclose(expected, result[\"img\"], rtol=1e-05)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine.py_unittest_TEST_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine.py_unittest_TEST_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_affine.py", "file_name": "test_affine.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 74, "span_ids": ["docstring"], "tokens": 1300}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import Affine\n\nTEST_CASES = [\n [\n dict(padding_mode=\"zeros\", as_tensor_output=False, device=None),\n {\"img\": np.arange(9).reshape((1, 3, 3)), \"spatial_size\": (-1, 0)},\n np.arange(9).reshape(1, 3, 3),\n ],\n [\n dict(padding_mode=\"zeros\", as_tensor_output=False, device=None),\n {\"img\": np.arange(4).reshape((1, 2, 2))},\n np.arange(4).reshape(1, 2, 2),\n ],\n [\n dict(padding_mode=\"zeros\", as_tensor_output=False, device=None),\n {\"img\": np.arange(4).reshape((1, 2, 2)), \"spatial_size\": (4, 4)},\n np.array([[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 2.0, 3.0, 0.0], [0.0, 0.0, 0.0, 0.0]]]),\n ],\n [\n dict(rotate_params=[np.pi / 2], padding_mode=\"zeros\", as_tensor_output=False, device=None),\n {\"img\": np.arange(4).reshape((1, 2, 2)), \"spatial_size\": (4, 4)},\n np.array([[[0.0, 0.0, 0.0, 0.0], [0.0, 2.0, 0.0, 0.0], [0.0, 3.0, 1.0, 0.0], [0.0, 0.0, 0.0, 0.0]]]),\n ],\n [\n dict(padding_mode=\"zeros\", as_tensor_output=False, device=None),\n {\"img\": np.arange(27).reshape((1, 3, 3, 3)), \"spatial_size\": (-1, 0, 0)},\n np.arange(27).reshape(1, 3, 3, 3),\n ],\n [\n dict(padding_mode=\"zeros\", as_tensor_output=False, device=None),\n {\"img\": np.arange(8).reshape((1, 2, 2, 2)), \"spatial_size\": (4, 4, 4)},\n np.array(\n [\n [\n [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]],\n [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 2.0, 3.0, 0.0], [0.0, 0.0, 0.0, 0.0]],\n [[0.0, 0.0, 0.0, 0.0], [0.0, 4.0, 5.0, 0.0], [0.0, 6.0, 7.0, 0.0], [0.0, 0.0, 0.0, 0.0]],\n [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]],\n ]\n ]\n ),\n ],\n [\n dict(rotate_params=[np.pi / 2], padding_mode=\"zeros\", as_tensor_output=False, device=None),\n {\"img\": np.arange(8).reshape((1, 2, 2, 2)), \"spatial_size\": (4, 4, 4)},\n np.array(\n [\n [\n [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]],\n [[0.0, 0.0, 0.0, 0.0], [0.0, 2.0, 0.0, 0.0], [0.0, 3.0, 1.0, 0.0], [0.0, 0.0, 0.0, 0.0]],\n [[0.0, 0.0, 0.0, 0.0], [0.0, 6.0, 4.0, 0.0], [0.0, 7.0, 5.0, 0.0], [0.0, 0.0, 0.0, 0.0]],\n [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]],\n ]\n ]\n ),\n ],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine.py_TestAffine_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine.py_TestAffine_", "embedding": null, "metadata": {"file_path": "tests/test_affine.py", "file_name": "test_affine.py", "file_type": "text/x-python", "category": "test", "start_line": 77, "end_line": 91, "span_ids": ["TestAffine", "impl:3", "TestAffine.test_affine"], "tokens": 143}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAffine(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_affine(self, input_param, input_data, expected_val):\n g = Affine(**input_param)\n result = g(**input_data)\n self.assertEqual(torch.is_tensor(result), torch.is_tensor(expected_val))\n if torch.is_tensor(result):\n np.testing.assert_allclose(result.cpu().numpy(), expected_val.cpu().numpy(), rtol=1e-4, atol=1e-4)\n else:\n np.testing.assert_allclose(result, expected_val, rtol=1e-4, atol=1e-4)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_grid.py_unittest_TEST_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_grid.py_unittest_TEST_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_affine_grid.py", "file_name": "test_affine_grid.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 88, "span_ids": ["docstring"], "tokens": 1413}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import AffineGrid\n\nTEST_CASES = [\n [\n {\"as_tensor_output\": False, \"device\": torch.device(\"cpu:0\")},\n {\"spatial_size\": (2, 2)},\n np.array([[[-0.5, -0.5], [0.5, 0.5]], [[-0.5, 0.5], [-0.5, 0.5]], [[1.0, 1.0], [1.0, 1.0]]]),\n ],\n [\n {\"as_tensor_output\": True, \"device\": None},\n {\"spatial_size\": (2, 2)},\n torch.tensor([[[-0.5, -0.5], [0.5, 0.5]], [[-0.5, 0.5], [-0.5, 0.5]], [[1.0, 1.0], [1.0, 1.0]]]),\n ],\n [{\"as_tensor_output\": False, \"device\": None}, {\"grid\": np.ones((3, 3, 3))}, np.ones((3, 3, 3))],\n [{\"as_tensor_output\": True, \"device\": torch.device(\"cpu:0\")}, {\"grid\": np.ones((3, 3, 3))}, torch.ones((3, 3, 3))],\n [{\"as_tensor_output\": False, \"device\": None}, {\"grid\": torch.ones((3, 3, 3))}, np.ones((3, 3, 3))],\n [\n {\"as_tensor_output\": True, \"device\": torch.device(\"cpu:0\")},\n {\"grid\": torch.ones((3, 3, 3))},\n torch.ones((3, 3, 3)),\n ],\n [\n {\n \"rotate_params\": (1.0, 1.0),\n \"scale_params\": (-20, 10),\n \"as_tensor_output\": True,\n \"device\": torch.device(\"cpu:0\"),\n },\n {\"grid\": torch.ones((3, 3, 3))},\n torch.tensor(\n [\n [[-19.2208, -19.2208, -19.2208], [-19.2208, -19.2208, -19.2208], [-19.2208, -19.2208, -19.2208]],\n [[-11.4264, -11.4264, -11.4264], [-11.4264, -11.4264, -11.4264], [-11.4264, -11.4264, -11.4264]],\n [[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]],\n ]\n ),\n ],\n [\n {\n \"rotate_params\": (1.0, 1.0, 1.0),\n \"scale_params\": (-20, 10),\n \"as_tensor_output\": True,\n \"device\": torch.device(\"cpu:0\"),\n },\n {\"grid\": torch.ones((4, 3, 3, 3))},\n torch.tensor(\n [\n [\n [[-9.5435, -9.5435, -9.5435], [-9.5435, -9.5435, -9.5435], [-9.5435, -9.5435, -9.5435]],\n [[-9.5435, -9.5435, -9.5435], [-9.5435, -9.5435, -9.5435], [-9.5435, -9.5435, -9.5435]],\n [[-9.5435, -9.5435, -9.5435], [-9.5435, -9.5435, -9.5435], [-9.5435, -9.5435, -9.5435]],\n ],\n [\n [[-20.2381, -20.2381, -20.2381], [-20.2381, -20.2381, -20.2381], [-20.2381, -20.2381, -20.2381]],\n [[-20.2381, -20.2381, -20.2381], [-20.2381, -20.2381, -20.2381], [-20.2381, -20.2381, -20.2381]],\n [[-20.2381, -20.2381, -20.2381], [-20.2381, -20.2381, -20.2381], [-20.2381, -20.2381, -20.2381]],\n ],\n [\n [[-0.5844, -0.5844, -0.5844], [-0.5844, -0.5844, -0.5844], [-0.5844, -0.5844, -0.5844]],\n [[-0.5844, -0.5844, -0.5844], [-0.5844, -0.5844, -0.5844], [-0.5844, -0.5844, -0.5844]],\n [[-0.5844, -0.5844, -0.5844], [-0.5844, -0.5844, -0.5844], [-0.5844, -0.5844, -0.5844]],\n ],\n [\n [[1.0000, 1.0000, 1.0000], [1.0000, 1.0000, 1.0000], [1.0000, 1.0000, 1.0000]],\n [[1.0000, 1.0000, 1.0000], [1.0000, 1.0000, 1.0000], [1.0000, 1.0000, 1.0000]],\n [[1.0000, 1.0000, 1.0000], [1.0000, 1.0000, 1.0000], [1.0000, 1.0000, 1.0000]],\n ],\n ]\n ),\n ],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_grid.py_TestAffineGrid_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_grid.py_TestAffineGrid_", "embedding": null, "metadata": {"file_path": "tests/test_affine_grid.py", "file_name": "test_affine_grid.py", "file_type": "text/x-python", "category": "test", "start_line": 91, "end_line": 105, "span_ids": ["TestAffineGrid", "impl:3", "TestAffineGrid.test_affine_grid"], "tokens": 146}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAffineGrid(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_affine_grid(self, input_param, input_data, expected_val):\n g = AffineGrid(**input_param)\n result = g(**input_data)\n self.assertEqual(torch.is_tensor(result), torch.is_tensor(expected_val))\n if torch.is_tensor(result):\n np.testing.assert_allclose(result.cpu().numpy(), expected_val.cpu().numpy(), rtol=1e-4, atol=1e-4)\n else:\n np.testing.assert_allclose(result, expected_val, rtol=1e-4, atol=1e-4)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_unittest_TEST_NORM_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_unittest_TEST_NORM_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 30, "span_ids": ["docstring"], "tokens": 341}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.networks.layers import AffineTransform\nfrom monai.networks import normalize_transform, to_norm_affine\n\nTEST_NORM_CASES = [\n [(4, 5), True, [[[0.666667, 0, -1], [0, 0.5, -1], [0, 0, 1]]]],\n [\n (2, 4, 5),\n True,\n [[[2.0, 0.0, 0.0, -1.0], [0.0, 0.6666667, 0.0, -1.0], [0.0, 0.0, 0.5, -1.0], [0.0, 0.0, 0.0, 1.0]]],\n ],\n [(4, 5), False, [[[0.5, 0.0, -0.75], [0.0, 0.4, -0.8], [0.0, 0.0, 1.0]]]],\n [(2, 4, 5), False, [[[1.0, 0.0, 0.0, -0.5], [0.0, 0.5, 0.0, -0.75], [0.0, 0.0, 0.4, -0.8], [0.0, 0.0, 0.0, 1.0]]]],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TEST_TO_NORM_AFFINE_CASES_TEST_ILL_TO_NORM_AFFINE_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TEST_TO_NORM_AFFINE_CASES_TEST_ILL_TO_NORM_AFFINE_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 32, "end_line": 67, "span_ids": ["impl:5", "docstring"], "tokens": 720}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_TO_NORM_AFFINE_CASES = [\n [\n [[[1, 0, 0], [0, 1, 0], [0, 0, 1]]],\n (4, 6),\n (5, 3),\n True,\n [[[1.3333334, 0.0, 0.33333337], [0.0, 0.4, -0.6], [0.0, 0.0, 1.0]]],\n ],\n [\n [[[1, 0, 0], [0, 1, 0], [0, 0, 1]]],\n (4, 6),\n (5, 3),\n False,\n [[[1.25, 0.0, 0.25], [0.0, 0.5, -0.5], [0.0, 0.0, 1.0]]],\n ],\n [\n [[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]],\n (2, 4, 6),\n (3, 5, 3),\n True,\n [[[2.0, 0.0, 0.0, 1.0], [0.0, 1.3333334, 0.0, 0.33333337], [0.0, 0.0, 0.4, -0.6], [0.0, 0.0, 0.0, 1.0]]],\n ],\n [\n [[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]],\n (2, 4, 6),\n (3, 5, 3),\n False,\n [[[1.5, 0.0, 0.0, 0.5], [0.0, 1.25, 0.0, 0.25], [0.0, 0.0, 0.5, -0.5], [0.0, 0.0, 0.0, 1.0]]],\n ],\n]\n\nTEST_ILL_TO_NORM_AFFINE_CASES = [\n [[[[1, 0, 0], [0, 1, 0], [0, 0, 1]]], (3, 4, 6), (3, 5, 3), False],\n [[[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]], (4, 6), (3, 5, 3), True],\n [[[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]]], (4, 6), (3, 5, 3), True],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestNormTransform_TestNormTransform.test_norm_xform.if_torch_cuda_is_availabl.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestNormTransform_TestNormTransform.test_norm_xform.if_torch_cuda_is_availabl.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 70, "end_line": 83, "span_ids": ["TestNormTransform.test_norm_xform", "TestNormTransform"], "tokens": 157}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestNormTransform(unittest.TestCase):\n @parameterized.expand(TEST_NORM_CASES)\n def test_norm_xform(self, input_shape, align_corners, expected):\n norm = normalize_transform(\n input_shape, device=torch.device(\"cpu:0\"), dtype=torch.float32, align_corners=align_corners\n )\n norm = norm.detach().cpu().numpy()\n np.testing.assert_allclose(norm, expected, atol=1e-6)\n if torch.cuda.is_available():\n norm = normalize_transform(\n input_shape, device=torch.device(\"cuda:0\"), dtype=torch.float32, align_corners=align_corners\n )\n norm = norm.detach().cpu().numpy()\n np.testing.assert_allclose(norm, expected, atol=1e-4)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestToNormAffine_TestToNormAffine.test_to_norm_affine.if_torch_cuda_is_availabl.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestToNormAffine_TestToNormAffine.test_to_norm_affine.if_torch_cuda_is_availabl.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 86, "end_line": 98, "span_ids": ["TestToNormAffine.test_to_norm_affine", "TestToNormAffine"], "tokens": 209}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestToNormAffine(unittest.TestCase):\n @parameterized.expand(TEST_TO_NORM_AFFINE_CASES)\n def test_to_norm_affine(self, affine, src_size, dst_size, align_corners, expected):\n affine = torch.as_tensor(affine, device=torch.device(\"cpu:0\"), dtype=torch.float32)\n new_affine = to_norm_affine(affine, src_size, dst_size, align_corners)\n new_affine = new_affine.detach().cpu().numpy()\n np.testing.assert_allclose(new_affine, expected, atol=1e-6)\n\n if torch.cuda.is_available():\n affine = torch.as_tensor(affine, device=torch.device(\"cuda:0\"), dtype=torch.float32)\n new_affine = to_norm_affine(affine, src_size, dst_size, align_corners)\n new_affine = new_affine.detach().cpu().numpy()\n np.testing.assert_allclose(new_affine, expected, atol=1e-4)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestToNormAffine.test_to_norm_affine_ill_TestToNormAffine.test_to_norm_affine_ill.None_1.to_norm_affine_affine_sr": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestToNormAffine.test_to_norm_affine_ill_TestToNormAffine.test_to_norm_affine_ill.None_1.to_norm_affine_affine_sr", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 100, "end_line": 106, "span_ids": ["TestToNormAffine.test_to_norm_affine_ill"], "tokens": 119}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestToNormAffine(unittest.TestCase):\n\n @parameterized.expand(TEST_ILL_TO_NORM_AFFINE_CASES)\n def test_to_norm_affine_ill(self, affine, src_size, dst_size, align_corners):\n with self.assertRaises(ValueError):\n to_norm_affine(affine, src_size, dst_size, align_corners)\n with self.assertRaises(ValueError):\n affine = torch.as_tensor(affine, device=torch.device(\"cpu:0\"), dtype=torch.float32)\n to_norm_affine(affine, src_size, dst_size, align_corners)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform_TestAffineTransform.test_affine_shift.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform_TestAffineTransform.test_affine_shift.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 109, "end_line": 116, "span_ids": ["TestAffineTransform", "TestAffineTransform.test_affine_shift"], "tokens": 197}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAffineTransform(unittest.TestCase):\n def test_affine_shift(self):\n affine = torch.as_tensor([[1.0, 0.0, 0.0], [0.0, 1.0, -1.0]])\n image = torch.as_tensor([[[[4.0, 1.0, 3.0, 2.0], [7.0, 6.0, 8.0, 5.0], [3.0, 5.0, 3.0, 6.0]]]])\n out = AffineTransform()(image, affine)\n out = out.detach().cpu().numpy()\n expected = [[[[0, 4, 1, 3], [0, 7, 6, 8], [0, 3, 5, 3]]]]\n np.testing.assert_allclose(out, expected, atol=1e-5)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_shift_1_TestAffineTransform.test_affine_shift_1.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_shift_1_TestAffineTransform.test_affine_shift_1.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 118, "end_line": 124, "span_ids": ["TestAffineTransform.test_affine_shift_1"], "tokens": 199}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAffineTransform(unittest.TestCase):\n\n def test_affine_shift_1(self):\n affine = torch.as_tensor([[1.0, 0.0, -1.0], [0.0, 1.0, -1.0]])\n image = torch.as_tensor([[[[4.0, 1.0, 3.0, 2.0], [7.0, 6.0, 8.0, 5.0], [3.0, 5.0, 3.0, 6.0]]]])\n out = AffineTransform()(image, affine)\n out = out.detach().cpu().numpy()\n expected = [[[[0, 0, 0, 0], [0, 4, 1, 3], [0, 7, 6, 8]]]]\n np.testing.assert_allclose(out, expected, atol=1e-5)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_shift_2_TestAffineTransform.test_affine_shift_2.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_shift_2_TestAffineTransform.test_affine_shift_2.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 126, "end_line": 132, "span_ids": ["TestAffineTransform.test_affine_shift_2"], "tokens": 199}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAffineTransform(unittest.TestCase):\n\n def test_affine_shift_2(self):\n affine = torch.as_tensor([[1.0, 0.0, -1.0], [0.0, 1.0, 0.0]])\n image = torch.as_tensor([[[[4.0, 1.0, 3.0, 2.0], [7.0, 6.0, 8.0, 5.0], [3.0, 5.0, 3.0, 6.0]]]])\n out = AffineTransform()(image, affine)\n out = out.detach().cpu().numpy()\n expected = [[[[0, 0, 0, 0], [4, 1, 3, 2], [7, 6, 8, 5]]]]\n np.testing.assert_allclose(out, expected, atol=1e-5)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_zoom_TestAffineTransform.test_zoom.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_zoom_TestAffineTransform.test_zoom.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 134, "end_line": 139, "span_ids": ["TestAffineTransform.test_zoom"], "tokens": 140}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAffineTransform(unittest.TestCase):\n\n def test_zoom(self):\n affine = torch.as_tensor([[1.0, 0.0, 0.0], [0.0, 2.0, 0.0]])\n image = torch.arange(1.0, 13.0).view(1, 1, 3, 4).to(device=torch.device(\"cpu:0\"))\n out = AffineTransform((3, 2))(image, affine)\n expected = [[[[1, 3], [5, 7], [9, 11]]]]\n np.testing.assert_allclose(out, expected, atol=1e-5)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_zoom_1_TestAffineTransform.test_zoom_1.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_zoom_1_TestAffineTransform.test_zoom_1.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 141, "end_line": 146, "span_ids": ["TestAffineTransform.test_zoom_1"], "tokens": 137}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAffineTransform(unittest.TestCase):\n\n def test_zoom_1(self):\n affine = torch.as_tensor([[2.0, 0.0, 0.0], [0.0, 1.0, 0.0]])\n image = torch.arange(1.0, 13.0).view(1, 1, 3, 4).to(device=torch.device(\"cpu:0\"))\n out = AffineTransform()(image, affine, (1, 4))\n expected = [[[[1, 2, 3, 4]]]]\n np.testing.assert_allclose(out, expected, atol=1e-5)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_zoom_2_TestAffineTransform.test_zoom_2.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_zoom_2_TestAffineTransform.test_zoom_2.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 148, "end_line": 153, "span_ids": ["TestAffineTransform.test_zoom_2"], "tokens": 135}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAffineTransform(unittest.TestCase):\n\n def test_zoom_2(self):\n affine = torch.as_tensor([[2.0, 0.0, 0.0], [0.0, 2.0, 0.0]], dtype=torch.float32)\n image = torch.arange(1.0, 13.0).view(1, 1, 3, 4).to(device=torch.device(\"cpu:0\"))\n out = AffineTransform((1, 2))(image, affine)\n expected = [[[[1, 3]]]]\n np.testing.assert_allclose(out, expected, atol=1e-5)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_transform_minimum_TestAffineTransform.test_affine_transform_minimum.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_transform_minimum_TestAffineTransform.test_affine_transform_minimum.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 155, "end_line": 172, "span_ids": ["TestAffineTransform.test_affine_transform_minimum"], "tokens": 305}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAffineTransform(unittest.TestCase):\n\n def test_affine_transform_minimum(self):\n t = np.pi / 3\n affine = [[np.cos(t), -np.sin(t), 0], [np.sin(t), np.cos(t), 0], [0, 0, 1]]\n affine = torch.as_tensor(affine, device=torch.device(\"cpu:0\"), dtype=torch.float32)\n image = torch.arange(24.0).view(1, 1, 4, 6).to(device=torch.device(\"cpu:0\"))\n out = AffineTransform()(image, affine)\n out = out.detach().cpu().numpy()\n expected = [\n [\n [\n [0.0, 0.06698727, 0.0, 0.0, 0.0, 0.0],\n [3.8660254, 0.86602557, 0.0, 0.0, 0.0, 0.0],\n [7.732051, 3.035899, 0.73205125, 0.0, 0.0, 0.0],\n [11.598076, 6.901923, 2.7631402, 0.0, 0.0, 0.0],\n ]\n ]\n ]\n np.testing.assert_allclose(out, expected, atol=1e-5)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_transform_2d_TestAffineTransform.test_affine_transform_2d.if_torch_cuda_is_availabl.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_transform_2d_TestAffineTransform.test_affine_transform_2d.if_torch_cuda_is_availabl.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 174, "end_line": 208, "span_ids": ["TestAffineTransform.test_affine_transform_2d"], "tokens": 558}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAffineTransform(unittest.TestCase):\n\n def test_affine_transform_2d(self):\n t = np.pi / 3\n affine = [[np.cos(t), -np.sin(t), 0], [np.sin(t), np.cos(t), 0], [0, 0, 1]]\n affine = torch.as_tensor(affine, device=torch.device(\"cpu:0\"), dtype=torch.float32)\n image = torch.arange(24.0).view(1, 1, 4, 6).to(device=torch.device(\"cpu:0\"))\n xform = AffineTransform((3, 4), padding_mode=\"border\", align_corners=True, mode=\"bilinear\")\n out = xform(image, affine)\n out = out.detach().cpu().numpy()\n expected = [\n [\n [\n [7.1525574e-07, 4.9999994e-01, 1.0000000e00, 1.4999999e00],\n [3.8660259e00, 1.3660253e00, 1.8660252e00, 2.3660252e00],\n [7.7320518e00, 3.0358994e00, 2.7320509e00, 3.2320507e00],\n ]\n ]\n ]\n np.testing.assert_allclose(out, expected, atol=1e-5)\n\n if torch.cuda.is_available():\n affine = torch.as_tensor(affine, device=torch.device(\"cuda:0\"), dtype=torch.float32)\n image = torch.arange(24.0).view(1, 1, 4, 6).to(device=torch.device(\"cuda:0\"))\n xform = AffineTransform(padding_mode=\"border\", align_corners=True, mode=\"bilinear\")\n out = xform(image, affine, (3, 4))\n out = out.detach().cpu().numpy()\n expected = [\n [\n [\n [7.1525574e-07, 4.9999994e-01, 1.0000000e00, 1.4999999e00],\n [3.8660259e00, 1.3660253e00, 1.8660252e00, 2.3660252e00],\n [7.7320518e00, 3.0358994e00, 2.7320509e00, 3.2320507e00],\n ]\n ]\n ]\n np.testing.assert_allclose(out, expected, atol=1e-4)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_transform_3d_TestAffineTransform.test_affine_transform_3d.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_transform_3d_TestAffineTransform.test_affine_transform_3d.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 210, "end_line": 234, "span_ids": ["TestAffineTransform.test_affine_transform_3d"], "tokens": 519}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAffineTransform(unittest.TestCase):\n\n def test_affine_transform_3d(self):\n t = np.pi / 3\n affine = [[1, 0, 0, 0], [0.0, np.cos(t), -np.sin(t), 0], [0, np.sin(t), np.cos(t), 0], [0, 0, 0, 1]]\n affine = torch.as_tensor(affine, device=torch.device(\"cpu:0\"), dtype=torch.float32)\n image = torch.arange(48.0).view(2, 1, 4, 2, 3).to(device=torch.device(\"cpu:0\"))\n xform = AffineTransform((3, 4, 2), padding_mode=\"border\", align_corners=False, mode=\"bilinear\")\n out = xform(image, affine)\n out = out.detach().cpu().numpy()\n expected = [\n [\n [\n [[0.00000006, 0.5000001], [2.3660254, 1.3660254], [4.732051, 2.4019241], [5.0, 3.9019237]],\n [[6.0, 6.5], [8.366026, 7.3660254], [10.732051, 8.401924], [11.0, 9.901924]],\n [[12.0, 12.5], [14.366026, 13.366025], [16.732052, 14.401924], [17.0, 15.901923]],\n ]\n ],\n [\n [\n [[24.0, 24.5], [26.366024, 25.366024], [28.732052, 26.401924], [29.0, 27.901924]],\n [[30.0, 30.5], [32.366028, 31.366026], [34.732048, 32.401924], [35.0, 33.901924]],\n [[36.0, 36.5], [38.366024, 37.366024], [40.73205, 38.401924], [41.0, 39.901924]],\n ]\n ],\n ]\n np.testing.assert_allclose(out, expected, atol=1e-4)\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_transform_3d.if_torch_cuda_is_availabl_TestAffineTransform.test_affine_transform_3d.if_torch_cuda_is_availabl.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_affine_transform_3d.if_torch_cuda_is_availabl_TestAffineTransform.test_affine_transform_3d.if_torch_cuda_is_availabl.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 236, "end_line": 258, "span_ids": ["TestAffineTransform.test_affine_transform_3d"], "tokens": 460}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAffineTransform(unittest.TestCase):\n\n def test_affine_transform_3d(self):\n # ... other code\n\n if torch.cuda.is_available():\n affine = torch.as_tensor(affine, device=torch.device(\"cuda:0\"), dtype=torch.float32)\n image = torch.arange(48.0).view(2, 1, 4, 2, 3).to(device=torch.device(\"cuda:0\"))\n xform = AffineTransform(padding_mode=\"border\", align_corners=False, mode=\"bilinear\")\n out = xform(image, affine, (3, 4, 2))\n out = out.detach().cpu().numpy()\n expected = [\n [\n [\n [[0.00000006, 0.5000001], [2.3660254, 1.3660254], [4.732051, 2.4019241], [5.0, 3.9019237]],\n [[6.0, 6.5], [8.366026, 7.3660254], [10.732051, 8.401924], [11.0, 9.901924]],\n [[12.0, 12.5], [14.366026, 13.366025], [16.732052, 14.401924], [17.0, 15.901923]],\n ]\n ],\n [\n [\n [[24.0, 24.5], [26.366024, 25.366024], [28.732052, 26.401924], [29.0, 27.901924]],\n [[30.0, 30.5], [32.366028, 31.366026], [34.732048, 32.401924], [35.0, 33.901924]],\n [[36.0, 36.5], [38.366024, 37.366024], [40.73205, 38.401924], [41.0, 39.901924]],\n ]\n ],\n ]\n np.testing.assert_allclose(out, expected, atol=1e-4)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_ill_affine_transform_TestAffineTransform.test_ill_affine_transform.None_3.xform_image_affine_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_ill_affine_transform_TestAffineTransform.test_ill_affine_transform.None_3.xform_image_affine_", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 260, "end_line": 293, "span_ids": ["TestAffineTransform.test_ill_affine_transform"], "tokens": 720}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAffineTransform(unittest.TestCase):\n\n def test_ill_affine_transform(self):\n with self.assertRaises(ValueError): # image too small\n t = np.pi / 3\n affine = [[1, 0, 0, 0], [0.0, np.cos(t), -np.sin(t), 0], [0, np.sin(t), np.cos(t), 0], [0, 0, 0, 1]]\n affine = torch.as_tensor(affine, device=torch.device(\"cpu:0\"), dtype=torch.float32)\n xform = AffineTransform((3, 4, 2), padding_mode=\"border\", align_corners=False, mode=\"bilinear\")\n xform(torch.as_tensor([1.0, 2.0, 3.0]), affine)\n\n with self.assertRaises(ValueError): # output shape too small\n t = np.pi / 3\n affine = [[1, 0, 0, 0], [0.0, np.cos(t), -np.sin(t), 0], [0, np.sin(t), np.cos(t), 0], [0, 0, 0, 1]]\n affine = torch.as_tensor(affine, device=torch.device(\"cpu:0\"), dtype=torch.float32)\n image = torch.arange(48).view(2, 1, 4, 2, 3).to(device=torch.device(\"cpu:0\"))\n xform = AffineTransform((3, 4), padding_mode=\"border\", align_corners=False, mode=\"bilinear\")\n xform(image, affine)\n\n with self.assertRaises(ValueError): # incorrect affine\n t = np.pi / 3\n affine = [[1, 0, 0, 0], [0.0, np.cos(t), -np.sin(t), 0], [0, np.sin(t), np.cos(t), 0], [0, 0, 0, 1]]\n affine = torch.as_tensor(affine, device=torch.device(\"cpu:0\"), dtype=torch.float32)\n affine = affine.unsqueeze(0).unsqueeze(0)\n image = torch.arange(48).view(2, 1, 4, 2, 3).to(device=torch.device(\"cpu:0\"))\n xform = AffineTransform((2, 3, 4), padding_mode=\"border\", align_corners=False, mode=\"bilinear\")\n xform(image, affine)\n\n with self.assertRaises(ValueError): # batch doesn't match\n t = np.pi / 3\n affine = [[1, 0, 0, 0], [0.0, np.cos(t), -np.sin(t), 0], [0, np.sin(t), np.cos(t), 0], [0, 0, 0, 1]]\n affine = torch.as_tensor(affine, device=torch.device(\"cpu:0\"), dtype=torch.float32)\n affine = affine.unsqueeze(0)\n affine = affine.repeat(3, 1, 1)\n image = torch.arange(48).view(2, 1, 4, 2, 3).to(device=torch.device(\"cpu:0\"))\n xform = AffineTransform((2, 3, 4), padding_mode=\"border\", align_corners=False, mode=\"bilinear\")\n xform(image, affine)\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_ill_affine_transform.with_self_assertRaises_Ru_TestAffineTransform.test_ill_affine_transform.None_6.out.AffineTransform_1_2_i": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_ill_affine_transform.with_self_assertRaises_Ru_TestAffineTransform.test_ill_affine_transform.None_6.out.AffineTransform_1_2_i", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 295, "end_line": 314, "span_ids": ["TestAffineTransform.test_ill_affine_transform"], "tokens": 439}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAffineTransform(unittest.TestCase):\n\n def test_ill_affine_transform(self):\n # ... other code\n\n with self.assertRaises(RuntimeError): # input grid dtypes different\n t = np.pi / 3\n affine = [[1, 0, 0, 0], [0.0, np.cos(t), -np.sin(t), 0], [0, np.sin(t), np.cos(t), 0], [0, 0, 0, 1]]\n affine = torch.as_tensor(affine, device=torch.device(\"cpu:0\"), dtype=torch.float32)\n affine = affine.unsqueeze(0)\n affine = affine.repeat(2, 1, 1)\n image = torch.arange(48).view(2, 1, 4, 2, 3).to(device=torch.device(\"cpu:0\"), dtype=torch.int32)\n xform = AffineTransform((2, 3, 4), padding_mode=\"border\", mode=\"bilinear\", normalized=True)\n xform(image, affine)\n\n with self.assertRaises(ValueError): # wrong affine\n affine = torch.as_tensor([[1, 0, 0, 0], [0, 0, 0, 1]])\n image = torch.arange(48).view(2, 1, 4, 2, 3).to(device=torch.device(\"cpu:0\"))\n xform = AffineTransform((2, 3, 4), padding_mode=\"border\", align_corners=False, mode=\"bilinear\")\n xform(image, affine)\n\n with self.assertRaises(RuntimeError): # dtype doesn't match\n affine = torch.as_tensor([[2.0, 0.0, 0.0], [0.0, 2.0, 0.0]], dtype=torch.float64)\n image = torch.arange(1.0, 13.0).view(1, 1, 3, 4).to(device=torch.device(\"cpu:0\"))\n out = AffineTransform((1, 2))(image, affine)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_forward_2d_TestAffineTransform.test_forward_2d.None_5": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_forward_2d_TestAffineTransform.test_forward_2d.None_5", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 316, "end_line": 338, "span_ids": ["TestAffineTransform.test_forward_2d"], "tokens": 328}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAffineTransform(unittest.TestCase):\n\n def test_forward_2d(self):\n x = torch.rand(2, 1, 4, 4)\n theta = torch.Tensor([[[0, -1, 0], [1, 0, 0]]]).repeat(2, 1, 1)\n grid = torch.nn.functional.affine_grid(theta, x.size(), align_corners=False)\n expected = torch.nn.functional.grid_sample(x, grid, align_corners=False)\n expected = expected.detach().cpu().numpy()\n\n actual = AffineTransform(normalized=True, reverse_indexing=False)(x, theta)\n actual = actual.detach().cpu().numpy()\n np.testing.assert_allclose(actual, expected)\n np.testing.assert_allclose(list(theta.shape), [2, 2, 3])\n\n theta = torch.Tensor([[0, -1, 0], [1, 0, 0]])\n actual = AffineTransform(normalized=True, reverse_indexing=False)(x, theta)\n actual = actual.detach().cpu().numpy()\n np.testing.assert_allclose(actual, expected)\n np.testing.assert_allclose(list(theta.shape), [2, 3])\n\n theta = torch.Tensor([[[0, -1, 0], [1, 0, 0]]])\n actual = AffineTransform(normalized=True, reverse_indexing=False)(x, theta)\n actual = actual.detach().cpu().numpy()\n np.testing.assert_allclose(actual, expected)\n np.testing.assert_allclose(list(theta.shape), [1, 2, 3])", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_forward_3d_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_affine_transform.py_TestAffineTransform.test_forward_3d_", "embedding": null, "metadata": {"file_path": "tests/test_affine_transform.py", "file_name": "test_affine_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 340, "end_line": 367, "span_ids": ["TestAffineTransform.test_forward_3d", "impl:7"], "tokens": 397}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAffineTransform(unittest.TestCase):\n\n def test_forward_3d(self):\n x = torch.rand(2, 1, 4, 4, 4)\n theta = torch.Tensor([[[0, 0, -1, 0], [1, 0, 0, 0], [0, 0, 1, 0]]]).repeat(2, 1, 1)\n grid = torch.nn.functional.affine_grid(theta, x.size(), align_corners=False)\n expected = torch.nn.functional.grid_sample(x, grid, align_corners=False)\n expected = expected.detach().cpu().numpy()\n\n actual = AffineTransform(normalized=True, reverse_indexing=False)(x, theta)\n actual = actual.detach().cpu().numpy()\n np.testing.assert_allclose(actual, expected)\n np.testing.assert_allclose(list(theta.shape), [2, 3, 4])\n\n theta = torch.Tensor([[0, 0, -1, 0], [1, 0, 0, 0], [0, 0, 1, 0]])\n actual = AffineTransform(normalized=True, reverse_indexing=False)(x, theta)\n actual = actual.detach().cpu().numpy()\n np.testing.assert_allclose(actual, expected)\n np.testing.assert_allclose(list(theta.shape), [3, 4])\n\n theta = torch.Tensor([[[0, 0, -1, 0], [1, 0, 0, 0], [0, 0, 1, 0]]])\n actual = AffineTransform(normalized=True, reverse_indexing=False)(x, theta)\n actual = actual.detach().cpu().numpy()\n np.testing.assert_allclose(actual, expected)\n np.testing.assert_allclose(list(theta.shape), [1, 3, 4])\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_arraydataset.py_os_TEST_CASE_4._Compose_LoadNifti_image": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_arraydataset.py_os_TEST_CASE_4._Compose_LoadNifti_image", "embedding": null, "metadata": {"file_path": "tests/test_arraydataset.py", "file_name": "test_arraydataset.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 55, "span_ids": ["impl:5", "TestCompose", "TestCompose.__call__", "docstring"], "tokens": 448}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport shutil\nimport tempfile\nimport unittest\n\nimport nibabel as nib\nimport numpy as np\nfrom parameterized import parameterized\nfrom torch.utils.data import DataLoader\n\nfrom monai.data import ArrayDataset\nfrom monai.transforms import AddChannel, Compose, LoadNifti, RandAdjustContrast, RandGaussianNoise, Spacing\n\nTEST_CASE_1 = [\n Compose([LoadNifti(image_only=True), AddChannel(), RandGaussianNoise(prob=1.0)]),\n Compose([LoadNifti(image_only=True), AddChannel(), RandGaussianNoise(prob=1.0)]),\n (0, 1),\n (1, 128, 128, 128),\n]\n\nTEST_CASE_2 = [\n Compose([LoadNifti(image_only=True), AddChannel(), RandAdjustContrast(prob=1.0)]),\n Compose([LoadNifti(image_only=True), AddChannel(), RandAdjustContrast(prob=1.0)]),\n (0, 1),\n (1, 128, 128, 128),\n]\n\n\nclass TestCompose(Compose):\n def __call__(self, input_):\n img, metadata = self.transforms[0](input_)\n img = self.transforms[1](img)\n img, _, _ = self.transforms[2](img, metadata[\"affine\"])\n return self.transforms[3](img), metadata\n\n\nTEST_CASE_3 = [\n TestCompose([LoadNifti(image_only=False), AddChannel(), Spacing(pixdim=(2, 2, 4)), RandAdjustContrast(prob=1.0)]),\n TestCompose([LoadNifti(image_only=False), AddChannel(), Spacing(pixdim=(2, 2, 4)), RandAdjustContrast(prob=1.0)]),\n (0, 2),\n (1, 64, 64, 33),\n]\n\nTEST_CASE_4 = [Compose([LoadNifti(image_only=True), AddChannel(), RandGaussianNoise(prob=1.0)]), (1, 128, 128, 128)]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_arraydataset.py_TestArrayDataset_TestArrayDataset.test_shape.shutil_rmtree_tempdir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_arraydataset.py_TestArrayDataset_TestArrayDataset.test_shape.shutil_rmtree_tempdir_", "embedding": null, "metadata": {"file_path": "tests/test_arraydataset.py", "file_name": "test_arraydataset.py", "file_type": "text/x-python", "category": "test", "start_line": 58, "end_line": 92, "span_ids": ["TestArrayDataset", "TestArrayDataset.test_shape"], "tokens": 484}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestArrayDataset(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_shape(self, img_transform, label_transform, indexes, expected_shape):\n test_image = nib.Nifti1Image(np.random.randint(0, 2, size=(128, 128, 128)), np.eye(4))\n tempdir = tempfile.mkdtemp()\n test_image1 = os.path.join(tempdir, \"test_image1.nii.gz\")\n test_seg1 = os.path.join(tempdir, \"test_seg1.nii.gz\")\n test_image2 = os.path.join(tempdir, \"test_image2.nii.gz\")\n test_seg2 = os.path.join(tempdir, \"test_seg2.nii.gz\")\n nib.save(test_image, test_image1)\n nib.save(test_image, test_seg1)\n nib.save(test_image, test_image2)\n nib.save(test_image, test_seg2)\n test_images = [test_image1, test_image2]\n test_segs = [test_seg1, test_seg2]\n test_labels = [1, 1]\n dataset = ArrayDataset(test_images, img_transform, test_segs, label_transform, test_labels, None)\n self.assertEqual(len(dataset), 2)\n dataset.set_random_state(1234)\n data1 = dataset[0]\n data2 = dataset[1]\n\n self.assertTupleEqual(data1[indexes[0]].shape, expected_shape)\n self.assertTupleEqual(data1[indexes[1]].shape, expected_shape)\n np.testing.assert_allclose(data1[indexes[0]], data1[indexes[1]])\n self.assertTupleEqual(data2[indexes[0]].shape, expected_shape)\n self.assertTupleEqual(data2[indexes[1]].shape, expected_shape)\n np.testing.assert_allclose(data2[indexes[0]], data2[indexes[0]])\n\n dataset = ArrayDataset(test_images, img_transform, test_segs, label_transform, test_labels, None)\n dataset.set_random_state(1234)\n _ = dataset[0]\n data2_new = dataset[1]\n np.testing.assert_allclose(data2[indexes[0]], data2_new[indexes[0]], atol=1e-3)\n shutil.rmtree(tempdir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_arraydataset.py_TestArrayDataset.test_default_none_TestArrayDataset.test_default_none.shutil_rmtree_tempdir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_arraydataset.py_TestArrayDataset.test_default_none_TestArrayDataset.test_default_none.shutil_rmtree_tempdir_", "embedding": null, "metadata": {"file_path": "tests/test_arraydataset.py", "file_name": "test_arraydataset.py", "file_type": "text/x-python", "category": "test", "start_line": 94, "end_line": 116, "span_ids": ["TestArrayDataset.test_default_none"], "tokens": 274}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestArrayDataset(unittest.TestCase):\n\n @parameterized.expand([TEST_CASE_4])\n def test_default_none(self, img_transform, expected_shape):\n test_image = nib.Nifti1Image(np.random.randint(0, 2, size=(128, 128, 128)), np.eye(4))\n tempdir = tempfile.mkdtemp()\n test_image1 = os.path.join(tempdir, \"test_image1.nii.gz\")\n test_image2 = os.path.join(tempdir, \"test_image2.nii.gz\")\n nib.save(test_image, test_image1)\n nib.save(test_image, test_image2)\n test_images = [test_image1, test_image2]\n dataset = ArrayDataset(test_images, img_transform)\n self.assertEqual(len(dataset), 2)\n dataset.set_random_state(1234)\n data1 = dataset[0]\n data2 = dataset[1]\n self.assertTupleEqual(data1.shape, expected_shape)\n self.assertTupleEqual(data2.shape, expected_shape)\n\n dataset = ArrayDataset(test_images, img_transform)\n dataset.set_random_state(1234)\n _ = dataset[0]\n data2_new = dataset[1]\n np.testing.assert_allclose(data2, data2_new, atol=1e-3)\n shutil.rmtree(tempdir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_arraydataset.py_TestArrayDataset.test_dataloading_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_arraydataset.py_TestArrayDataset.test_dataloading_", "embedding": null, "metadata": {"file_path": "tests/test_arraydataset.py", "file_name": "test_arraydataset.py", "file_type": "text/x-python", "category": "test", "start_line": 118, "end_line": 141, "span_ids": ["impl:9", "TestArrayDataset.test_dataloading"], "tokens": 273}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestArrayDataset(unittest.TestCase):\n\n @parameterized.expand([TEST_CASE_4])\n def test_dataloading(self, img_transform, expected_shape):\n test_image = nib.Nifti1Image(np.random.randint(0, 2, size=(128, 128, 128)), np.eye(4))\n tempdir = tempfile.mkdtemp()\n test_image1 = os.path.join(tempdir, \"test_image1.nii.gz\")\n test_image2 = os.path.join(tempdir, \"test_image2.nii.gz\")\n nib.save(test_image, test_image1)\n nib.save(test_image, test_image2)\n test_images = [test_image1, test_image2]\n dataset = ArrayDataset(test_images, img_transform)\n self.assertEqual(len(dataset), 2)\n dataset.set_random_state(1234)\n loader = DataLoader(dataset, batch_size=10, num_workers=1)\n imgs = next(iter(loader)) # test batching\n np.testing.assert_allclose(imgs.shape, [2] + list(expected_shape))\n\n dataset.set_random_state(1234)\n new_imgs = next(iter(loader)) # test batching\n np.testing.assert_allclose(imgs, new_imgs, atol=1e-3)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_first.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_first.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_as_channel_first.py", "file_name": "test_as_channel_first.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 34, "span_ids": ["TestAsChannelFirst.test_shape", "TestAsChannelFirst", "impl:7", "docstring"], "tokens": 200}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import AsChannelFirst\n\nTEST_CASE_1 = [{\"channel_dim\": -1}, (4, 1, 2, 3)]\n\nTEST_CASE_2 = [{\"channel_dim\": 3}, (4, 1, 2, 3)]\n\nTEST_CASE_3 = [{\"channel_dim\": 2}, (3, 1, 2, 4)]\n\n\nclass TestAsChannelFirst(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_shape(self, input_param, expected_shape):\n test_data = np.random.randint(0, 2, size=[1, 2, 3, 4])\n result = AsChannelFirst(**input_param)(test_data)\n self.assertTupleEqual(result.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_firstd.py_unittest_TEST_CASE_3._keys_image_labe": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_firstd.py_unittest_TEST_CASE_3._keys_image_labe", "embedding": null, "metadata": {"file_path": "tests/test_as_channel_firstd.py", "file_name": "test_as_channel_firstd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 21, "span_ids": ["docstring"], "tokens": 133}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import AsChannelFirstd\n\nTEST_CASE_1 = [{\"keys\": [\"image\", \"label\", \"extra\"], \"channel_dim\": -1}, (4, 1, 2, 3)]\n\nTEST_CASE_2 = [{\"keys\": [\"image\", \"label\", \"extra\"], \"channel_dim\": 3}, (4, 1, 2, 3)]\n\nTEST_CASE_3 = [{\"keys\": [\"image\", \"label\", \"extra\"], \"channel_dim\": 2}, (3, 1, 2, 4)]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_firstd.py_TestAsChannelFirstd_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_firstd.py_TestAsChannelFirstd_", "embedding": null, "metadata": {"file_path": "tests/test_as_channel_firstd.py", "file_name": "test_as_channel_firstd.py", "file_type": "text/x-python", "category": "test", "start_line": 24, "end_line": 40, "span_ids": ["TestAsChannelFirstd", "TestAsChannelFirstd.test_shape", "impl:7"], "tokens": 195}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAsChannelFirstd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_shape(self, input_param, expected_shape):\n test_data = {\n \"image\": np.random.randint(0, 2, size=[1, 2, 3, 4]),\n \"label\": np.random.randint(0, 2, size=[1, 2, 3, 4]),\n \"extra\": np.random.randint(0, 2, size=[1, 2, 3, 4]),\n }\n result = AsChannelFirstd(**input_param)(test_data)\n self.assertTupleEqual(result[\"image\"].shape, expected_shape)\n self.assertTupleEqual(result[\"label\"].shape, expected_shape)\n self.assertTupleEqual(result[\"extra\"].shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_last.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_last.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_as_channel_last.py", "file_name": "test_as_channel_last.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 34, "span_ids": ["TestAsChannelLast", "TestAsChannelLast.test_shape", "impl:7", "docstring"], "tokens": 200}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import AsChannelLast\n\nTEST_CASE_1 = [{\"channel_dim\": 0}, (2, 3, 4, 1)]\n\nTEST_CASE_2 = [{\"channel_dim\": 1}, (1, 3, 4, 2)]\n\nTEST_CASE_3 = [{\"channel_dim\": 3}, (1, 2, 3, 4)]\n\n\nclass TestAsChannelLast(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_shape(self, input_param, expected_shape):\n test_data = np.random.randint(0, 2, size=[1, 2, 3, 4])\n result = AsChannelLast(**input_param)(test_data)\n self.assertTupleEqual(result.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_lastd.py_unittest_TEST_CASE_3._keys_image_labe": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_lastd.py_unittest_TEST_CASE_3._keys_image_labe", "embedding": null, "metadata": {"file_path": "tests/test_as_channel_lastd.py", "file_name": "test_as_channel_lastd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 21, "span_ids": ["docstring"], "tokens": 133}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import AsChannelLastd\n\nTEST_CASE_1 = [{\"keys\": [\"image\", \"label\", \"extra\"], \"channel_dim\": 0}, (2, 3, 4, 1)]\n\nTEST_CASE_2 = [{\"keys\": [\"image\", \"label\", \"extra\"], \"channel_dim\": 1}, (1, 3, 4, 2)]\n\nTEST_CASE_3 = [{\"keys\": [\"image\", \"label\", \"extra\"], \"channel_dim\": 3}, (1, 2, 3, 4)]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_lastd.py_TestAsChannelLastd_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_channel_lastd.py_TestAsChannelLastd_", "embedding": null, "metadata": {"file_path": "tests/test_as_channel_lastd.py", "file_name": "test_as_channel_lastd.py", "file_type": "text/x-python", "category": "test", "start_line": 24, "end_line": 40, "span_ids": ["TestAsChannelLastd.test_shape", "TestAsChannelLastd", "impl:7"], "tokens": 195}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAsChannelLastd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_shape(self, input_param, expected_shape):\n test_data = {\n \"image\": np.random.randint(0, 2, size=[1, 2, 3, 4]),\n \"label\": np.random.randint(0, 2, size=[1, 2, 3, 4]),\n \"extra\": np.random.randint(0, 2, size=[1, 2, 3, 4]),\n }\n result = AsChannelLastd(**input_param)(test_data)\n self.assertTupleEqual(result[\"image\"].shape, expected_shape)\n self.assertTupleEqual(result[\"label\"].shape, expected_shape)\n self.assertTupleEqual(result[\"extra\"].shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_discrete.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_discrete.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_as_discrete.py", "file_name": "test_as_discrete.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 49, "span_ids": ["TestAsDiscrete", "TestAsDiscrete.test_value_shape", "impl:7", "docstring"], "tokens": 434}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport torch\nfrom parameterized import parameterized\nfrom monai.transforms import AsDiscrete\n\nTEST_CASE_1 = [\n {\"argmax\": True, \"to_onehot\": False, \"n_classes\": None, \"threshold_values\": False, \"logit_thresh\": 0.5},\n torch.tensor([[[[0.0, 1.0]], [[2.0, 3.0]]]]),\n torch.tensor([[[[1.0, 1.0]]]]),\n (1, 1, 1, 2),\n]\n\nTEST_CASE_2 = [\n {\"argmax\": True, \"to_onehot\": True, \"n_classes\": 2, \"threshold_values\": False, \"logit_thresh\": 0.5},\n torch.tensor([[[[0.0, 1.0]], [[2.0, 3.0]]]]),\n torch.tensor([[[[0.0, 0.0]], [[1.0, 1.0]]]]),\n (1, 2, 1, 2),\n]\n\nTEST_CASE_3 = [\n {\"argmax\": False, \"to_onehot\": False, \"n_classes\": None, \"threshold_values\": True, \"logit_thresh\": 0.6},\n torch.tensor([[[[0.0, 1.0], [2.0, 3.0]]]]),\n torch.tensor([[[[0.0, 1.0], [1.0, 1.0]]]]),\n (1, 1, 2, 2),\n]\n\n\nclass TestAsDiscrete(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_value_shape(self, input_param, img, out, expected_shape):\n result = AsDiscrete(**input_param)(img)\n torch.testing.assert_allclose(result, out)\n self.assertTupleEqual(result.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_discreted.py_unittest_TEST_CASE_3._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_discreted.py_unittest_TEST_CASE_3._", "embedding": null, "metadata": {"file_path": "tests/test_as_discreted.py", "file_name": "test_as_discreted.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 57, "span_ids": ["impl:5", "docstring"], "tokens": 524}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport torch\nfrom parameterized import parameterized\nfrom monai.transforms import AsDiscreted\n\nTEST_CASE_1 = [\n {\n \"keys\": [\"pred\", \"label\"],\n \"argmax\": [True, False],\n \"to_onehot\": True,\n \"n_classes\": 2,\n \"threshold_values\": False,\n \"logit_thresh\": 0.5,\n },\n {\"pred\": torch.tensor([[[[0.0, 1.0]], [[2.0, 3.0]]]]), \"label\": torch.tensor([[[[0, 1]]]])},\n {\"pred\": torch.tensor([[[[0.0, 0.0]], [[1.0, 1.0]]]]), \"label\": torch.tensor([[[[1.0, 0.0]], [[0.0, 1.0]]]])},\n (1, 2, 1, 2),\n]\n\nTEST_CASE_2 = [\n {\n \"keys\": [\"pred\", \"label\"],\n \"argmax\": False,\n \"to_onehot\": False,\n \"n_classes\": None,\n \"threshold_values\": [True, False],\n \"logit_thresh\": 0.6,\n },\n {\"pred\": torch.tensor([[[[0.0, 1.0], [2.0, 3.0]]]]), \"label\": torch.tensor([[[[0, 1], [1, 1]]]])},\n {\"pred\": torch.tensor([[[[0.0, 1.0], [1.0, 1.0]]]]), \"label\": torch.tensor([[[[0.0, 1.0], [1.0, 1.0]]]])},\n (1, 1, 2, 2),\n]\n\nTEST_CASE_3 = [\n {\n \"keys\": [\"pred\"],\n \"argmax\": True,\n \"to_onehot\": True,\n \"n_classes\": 2,\n \"threshold_values\": False,\n \"logit_thresh\": 0.5,\n },\n {\"pred\": torch.tensor([[[[0.0, 1.0]], [[2.0, 3.0]]]])},\n {\"pred\": torch.tensor([[[[0.0, 0.0]], [[1.0, 1.0]]]])},\n (1, 2, 1, 2),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_discreted.py_TestAsDiscreted_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_as_discreted.py_TestAsDiscreted_", "embedding": null, "metadata": {"file_path": "tests/test_as_discreted.py", "file_name": "test_as_discreted.py", "file_type": "text/x-python", "category": "test", "start_line": 60, "end_line": 73, "span_ids": ["TestAsDiscreted.test_value_shape", "impl:7", "TestAsDiscreted"], "tokens": 138}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestAsDiscreted(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_value_shape(self, input_param, test_input, output, expected_shape):\n result = AsDiscreted(**input_param)(test_input)\n torch.testing.assert_allclose(result[\"pred\"], output[\"pred\"])\n self.assertTupleEqual(result[\"pred\"].shape, expected_shape)\n if \"label\" in result:\n torch.testing.assert_allclose(result[\"label\"], output[\"label\"])\n self.assertTupleEqual(result[\"label\"].shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_border_pad.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_border_pad.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_border_pad.py", "file_name": "test_border_pad.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 55, "span_ids": ["impl:9", "TestBorderPad.test_pad_shape", "TestBorderPad", "docstring"], "tokens": 395}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import BorderPad\nfrom monai.utils import NumpyPadMode\n\nTEST_CASE_1 = [\n {\"spatial_border\": 2, \"mode\": \"constant\"},\n np.zeros((3, 8, 8, 4)),\n np.zeros((3, 12, 12, 8)),\n]\n\nTEST_CASE_2 = [\n {\"spatial_border\": [1, 2, 3], \"mode\": \"constant\"},\n np.zeros((3, 8, 8, 4)),\n np.zeros((3, 10, 12, 10)),\n]\n\nTEST_CASE_3 = [\n {\"spatial_border\": [1, 2, 3, 4, 5, 6], \"mode\": \"constant\"},\n np.zeros((3, 8, 8, 4)),\n np.zeros((3, 11, 15, 15)),\n]\n\nTEST_CASE_4 = [\n {\"spatial_border\": [1, 2, 3, 4, 5, 6], \"mode\": NumpyPadMode.CONSTANT},\n np.zeros((3, 8, 8, 4)),\n np.zeros((3, 11, 15, 15)),\n]\n\n\nclass TestBorderPad(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4])\n def test_pad_shape(self, input_param, input_data, expected_val):\n padder = BorderPad(**input_param)\n result = padder(input_data)\n self.assertAlmostEqual(result.shape, expected_val.shape)\n result = padder(input_data, mode=input_param[\"mode\"])\n self.assertAlmostEqual(result.shape, expected_val.shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_border_padd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_border_padd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_border_padd.py", "file_name": "test_border_padd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 59, "span_ids": ["TestBorderPadd.test_pad_shape", "impl:11", "TestBorderPadd", "docstring"], "tokens": 548}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import BorderPadd\nfrom monai.utils import NumpyPadMode\n\nTEST_CASE_1 = [\n {\"keys\": [\"img\", \"seg\"], \"spatial_border\": 2, \"mode\": [\"constant\", \"edge\"]},\n {\"img\": np.zeros((3, 8, 8, 4)), \"seg\": np.zeros((3, 8, 8, 4))},\n np.zeros((3, 12, 12, 8)),\n]\n\nTEST_CASE_2 = [\n {\"keys\": \"img\", \"spatial_border\": [1, 2, 3], \"mode\": \"constant\"},\n {\"img\": np.zeros((3, 8, 8, 4))},\n np.zeros((3, 10, 12, 10)),\n]\n\nTEST_CASE_3 = [\n {\"keys\": \"img\", \"spatial_border\": [1, 2, 3, 4, 5, 6], \"mode\": \"constant\"},\n {\"img\": np.zeros((3, 8, 8, 4))},\n np.zeros((3, 11, 15, 15)),\n]\n\nTEST_CASE_4 = [\n {\"keys\": [\"img\", \"seg\"], \"spatial_border\": 2, \"mode\": [\"constant\", NumpyPadMode.EDGE]},\n {\"img\": np.zeros((3, 8, 8, 4)), \"seg\": np.zeros((3, 8, 8, 4))},\n np.zeros((3, 12, 12, 8)),\n]\n\nTEST_CASE_5 = [\n {\"keys\": [\"img\", \"seg\"], \"spatial_border\": 2, \"mode\": [NumpyPadMode.CONSTANT, NumpyPadMode.EDGE]},\n {\"img\": np.zeros((3, 8, 8, 4)), \"seg\": np.zeros((3, 8, 8, 4))},\n np.zeros((3, 12, 12, 8)),\n]\n\n\nclass TestBorderPadd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5])\n def test_pad_shape(self, input_param, input_data, expected_val):\n padder = BorderPadd(**input_param)\n result = padder(input_data)\n self.assertAlmostEqual(result[\"img\"].shape, expected_val.shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cachedataset.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cachedataset.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_cachedataset.py", "file_name": "test_cachedataset.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 68, "span_ids": ["impl:5", "TestCacheDataset.test_shape", "TestCacheDataset", "docstring"], "tokens": 605}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport os\nimport shutil\nimport numpy as np\nimport tempfile\nimport nibabel as nib\nfrom parameterized import parameterized\nfrom monai.data import CacheDataset\nfrom monai.transforms import Compose, LoadNiftid\n\nTEST_CASE_1 = [Compose([LoadNiftid(keys=[\"image\", \"label\", \"extra\"])]), (128, 128, 128)]\n\nTEST_CASE_2 = [None, (128, 128, 128)]\n\n\nclass TestCacheDataset(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2])\n def test_shape(self, transform, expected_shape):\n test_image = nib.Nifti1Image(np.random.randint(0, 2, size=[128, 128, 128]), np.eye(4))\n tempdir = tempfile.mkdtemp()\n nib.save(test_image, os.path.join(tempdir, \"test_image1.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_label1.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_extra1.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_image2.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_label2.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_extra2.nii.gz\"))\n test_data = [\n {\n \"image\": os.path.join(tempdir, \"test_image1.nii.gz\"),\n \"label\": os.path.join(tempdir, \"test_label1.nii.gz\"),\n \"extra\": os.path.join(tempdir, \"test_extra1.nii.gz\"),\n },\n {\n \"image\": os.path.join(tempdir, \"test_image2.nii.gz\"),\n \"label\": os.path.join(tempdir, \"test_label2.nii.gz\"),\n \"extra\": os.path.join(tempdir, \"test_extra2.nii.gz\"),\n },\n ]\n dataset = CacheDataset(data=test_data, transform=transform, cache_rate=0.5)\n data1 = dataset[0]\n data2 = dataset[1]\n shutil.rmtree(tempdir)\n if transform is None:\n self.assertEqual(data1[\"image\"], os.path.join(tempdir, \"test_image1.nii.gz\"))\n self.assertEqual(data2[\"label\"], os.path.join(tempdir, \"test_label2.nii.gz\"))\n else:\n self.assertTupleEqual(data1[\"image\"].shape, expected_shape)\n self.assertTupleEqual(data1[\"label\"].shape, expected_shape)\n self.assertTupleEqual(data1[\"extra\"].shape, expected_shape)\n self.assertTupleEqual(data2[\"image\"].shape, expected_shape)\n self.assertTupleEqual(data2[\"label\"].shape, expected_shape)\n self.assertTupleEqual(data2[\"extra\"].shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cachedataset_parallel.py_unittest_TEST_CASE_3._4_100_None_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cachedataset_parallel.py_unittest_TEST_CASE_3._4_100_None_", "embedding": null, "metadata": {"file_path": "tests/test_cachedataset_parallel.py", "file_name": "test_cachedataset_parallel.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 26, "span_ids": ["docstring"], "tokens": 124}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport os\nimport shutil\nimport numpy as np\nimport tempfile\nimport nibabel as nib\nfrom parameterized import parameterized\nfrom monai.data import CacheDataset\nfrom monai.transforms import Compose, LoadNiftid\n\nTEST_CASE_1 = [0, 100, Compose([LoadNiftid(keys=[\"image\", \"label\", \"extra\"])])]\n\nTEST_CASE_2 = [4, 100, Compose([LoadNiftid(keys=[\"image\", \"label\", \"extra\"])])]\n\nTEST_CASE_3 = [4, 100, None]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cachedataset_parallel.py_TestCacheDatasetParallel_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cachedataset_parallel.py_TestCacheDatasetParallel_", "embedding": null, "metadata": {"file_path": "tests/test_cachedataset_parallel.py", "file_name": "test_cachedataset_parallel.py", "file_type": "text/x-python", "category": "test", "start_line": 29, "end_line": 53, "span_ids": ["TestCacheDatasetParallel", "impl:7", "TestCacheDatasetParallel.test_shape"], "tokens": 280}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCacheDatasetParallel(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_shape(self, num_workers, dataset_size, transform):\n test_image = nib.Nifti1Image(np.random.randint(0, 2, size=[128, 128, 128]), np.eye(4))\n tempdir = tempfile.mkdtemp()\n nib.save(test_image, os.path.join(tempdir, \"test_image1.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_label1.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_extra1.nii.gz\"))\n test_data = [\n {\n \"image\": os.path.join(tempdir, \"test_image1.nii.gz\"),\n \"label\": os.path.join(tempdir, \"test_label1.nii.gz\"),\n \"extra\": os.path.join(tempdir, \"test_extra1.nii.gz\"),\n }\n ] * dataset_size\n dataset = CacheDataset(data=test_data, transform=transform, cache_rate=1, num_workers=num_workers,)\n shutil.rmtree(tempdir)\n self.assertEqual(len(dataset._cache), dataset.cache_num)\n for i in range(dataset.cache_num):\n self.assertIsNotNone(dataset._cache[i])\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cast_to_type.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cast_to_type.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_cast_to_type.py", "file_name": "test_cast_to_type.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 29, "span_ids": ["TestCastToType.test_type", "impl:3", "TestCastToType", "docstring"], "tokens": 127}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import CastToType\n\nTEST_CASE_1 = [{\"dtype\": np.float64}, np.array([[0, 1], [1, 2]], dtype=np.float32), np.float64]\n\n\nclass TestCastToType(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1])\n def test_type(self, input_param, input_data, expected_type):\n result = CastToType(**input_param)(input_data)\n self.assertEqual(result.dtype, expected_type)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cast_to_typed.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cast_to_typed.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_cast_to_typed.py", "file_name": "test_cast_to_typed.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 34, "span_ids": ["TestCastToTyped", "impl:3", "TestCastToTyped.test_type", "docstring"], "tokens": 183}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import CastToTyped\n\nTEST_CASE_1 = [\n {\"keys\": [\"img\"], \"dtype\": np.float64},\n {\"img\": np.array([[0, 1], [1, 2]], dtype=np.float32), \"seg\": np.array([[0, 1], [1, 2]], dtype=np.int8)},\n {\"img\": np.float64, \"seg\": np.int8},\n]\n\n\nclass TestCastToTyped(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1])\n def test_type(self, input_param, input_data, expected_type):\n result = CastToTyped(**input_param)(input_data)\n for k, v in result.items():\n self.assertEqual(v.dtype, expected_type[k])\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_center_spatial_crop.py_unittest_TEST_CASE_2._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_center_spatial_crop.py_unittest_TEST_CASE_2._", "embedding": null, "metadata": {"file_path": "tests/test_center_spatial_crop.py", "file_name": "test_center_spatial_crop.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 25, "span_ids": ["docstring"], "tokens": 243}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import CenterSpatialCrop\n\nTEST_CASE_0 = [{\"roi_size\": [2, 2, -1]}, np.random.randint(0, 2, size=[3, 3, 3, 3]), (3, 2, 2, 3)]\n\nTEST_CASE_1 = [{\"roi_size\": [2, 2, 2]}, np.random.randint(0, 2, size=[3, 3, 3, 3]), (3, 2, 2, 2)]\n\nTEST_CASE_2 = [\n {\"roi_size\": [2, 2]},\n np.array([[[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 3, 2, 0], [0, 1, 2, 1, 0], [0, 0, 0, 0, 0]]]),\n np.array([[[1, 2], [2, 3]]]),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_center_spatial_crop.py_TestCenterSpatialCrop_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_center_spatial_crop.py_TestCenterSpatialCrop_", "embedding": null, "metadata": {"file_path": "tests/test_center_spatial_crop.py", "file_name": "test_center_spatial_crop.py", "file_type": "text/x-python", "category": "test", "start_line": 28, "end_line": 42, "span_ids": ["TestCenterSpatialCrop.test_shape", "TestCenterSpatialCrop", "TestCenterSpatialCrop.test_value", "impl:7"], "tokens": 126}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCenterSpatialCrop(unittest.TestCase):\n @parameterized.expand([TEST_CASE_0, TEST_CASE_1])\n def test_shape(self, input_param, input_data, expected_shape):\n result = CenterSpatialCrop(**input_param)(input_data)\n np.testing.assert_allclose(result.shape, expected_shape)\n\n @parameterized.expand([TEST_CASE_2])\n def test_value(self, input_param, input_data, expected_value):\n result = CenterSpatialCrop(**input_param)(input_data)\n np.testing.assert_allclose(result, expected_value)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_center_spatial_cropd.py_unittest_TEST_CASE_2._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_center_spatial_cropd.py_unittest_TEST_CASE_2._", "embedding": null, "metadata": {"file_path": "tests/test_center_spatial_cropd.py", "file_name": "test_center_spatial_cropd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 33, "span_ids": ["docstring"], "tokens": 284}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import CenterSpatialCropd\n\nTEST_CASE_0 = [\n {\"keys\": \"img\", \"roi_size\": [2, -1, -1]},\n {\"img\": np.random.randint(0, 2, size=[3, 3, 3, 3])},\n (3, 2, 3, 3),\n]\n\nTEST_CASE_1 = [\n {\"keys\": \"img\", \"roi_size\": [2, 2, 2]},\n {\"img\": np.random.randint(0, 2, size=[3, 3, 3, 3])},\n (3, 2, 2, 2),\n]\n\nTEST_CASE_2 = [\n {\"keys\": \"img\", \"roi_size\": [2, 2]},\n {\"img\": np.array([[[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 3, 2, 0], [0, 1, 2, 1, 0], [0, 0, 0, 0, 0]]])},\n np.array([[[1, 2], [2, 3]]]),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_center_spatial_cropd.py_TestCenterSpatialCropd_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_center_spatial_cropd.py_TestCenterSpatialCropd_", "embedding": null, "metadata": {"file_path": "tests/test_center_spatial_cropd.py", "file_name": "test_center_spatial_cropd.py", "file_type": "text/x-python", "category": "test", "start_line": 36, "end_line": 50, "span_ids": ["TestCenterSpatialCropd", "TestCenterSpatialCropd.test_value", "impl:7", "TestCenterSpatialCropd.test_shape"], "tokens": 133}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCenterSpatialCropd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_0, TEST_CASE_1])\n def test_shape(self, input_param, input_data, expected_shape):\n result = CenterSpatialCropd(**input_param)(input_data)\n self.assertTupleEqual(result[\"img\"].shape, expected_shape)\n\n @parameterized.expand([TEST_CASE_2])\n def test_value(self, input_param, input_data, expected_value):\n result = CenterSpatialCropd(**input_param)(input_data)\n np.testing.assert_allclose(result[\"img\"], expected_value)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_check_md5.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_check_md5.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_check_md5.py", "file_name": "test_check_md5.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 44, "span_ids": ["TestCheckMD5", "TestCheckMD5.test_shape", "impl:7", "docstring"], "tokens": 237}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport os\nimport shutil\nimport numpy as np\nimport tempfile\nfrom PIL import Image\nfrom parameterized import parameterized\nfrom monai.apps import check_md5\n\nTEST_CASE_1 = [\"f38e9e043c8e902321e827b24ce2e5ec\", True]\n\nTEST_CASE_2 = [\"12c730d4e7427e00ad1c5526a6677535\", False]\n\nTEST_CASE_3 = [None, True]\n\n\nclass TestCheckMD5(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_shape(self, md5_value, expected_result):\n test_image = np.ones((64, 64, 3))\n tempdir = tempfile.mkdtemp()\n filename = os.path.join(tempdir, \"test_file.png\")\n Image.fromarray(test_image.astype(\"uint8\")).save(filename)\n\n result = check_md5(filename, md5_value)\n self.assertTrue(result == expected_result)\n\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compose.py_unittest_TestCompose.test_dict_compose.self_assertDictEqual_c_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compose.py_unittest_TestCompose.test_dict_compose.self_assertDictEqual_c_", "embedding": null, "metadata": {"file_path": "tests/test_compose.py", "file_name": "test_compose.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 45, "span_ids": ["TestCompose", "TestCompose.test_empty_compose", "TestCompose.test_non_dict_compose", "docstring", "TestCompose.test_dict_compose"], "tokens": 210}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nfrom monai.transforms import Compose, Randomizable, AddChannel\n\n\nclass TestCompose(unittest.TestCase):\n def test_empty_compose(self):\n c = Compose()\n i = 1\n self.assertEqual(c(i), 1)\n\n def test_non_dict_compose(self):\n def a(i):\n return i + \"a\"\n\n def b(i):\n return i + \"b\"\n\n c = Compose([a, b, a, b])\n self.assertEqual(c(\"\"), \"abab\")\n\n def test_dict_compose(self):\n def a(d):\n d = dict(d)\n d[\"a\"] += 1\n return d\n\n def b(d):\n d = dict(d)\n d[\"b\"] += 1\n return d\n\n c = Compose([a, b, a, b, a])\n self.assertDictEqual(c({\"a\": 0, \"b\": 0}), {\"a\": 3, \"b\": 2})", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compose.py_TestCompose.test_list_dict_compose_TestCompose.test_list_dict_compose.for_item_in_value_.self_assertDictEqual_item": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compose.py_TestCompose.test_list_dict_compose_TestCompose.test_list_dict_compose.for_item_in_value_.self_assertDictEqual_item", "embedding": null, "metadata": {"file_path": "tests/test_compose.py", "file_name": "test_compose.py", "file_type": "text/x-python", "category": "test", "start_line": 47, "end_line": 67, "span_ids": ["TestCompose.test_list_dict_compose"], "tokens": 193}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCompose(unittest.TestCase):\n\n def test_list_dict_compose(self):\n def a(d): # transform to handle dict data\n d = dict(d)\n d[\"a\"] += 1\n return d\n\n def b(d): # transform to generate a batch list of data\n d = dict(d)\n d[\"b\"] += 1\n d = [d] * 5\n return d\n\n def c(d): # transform to handle dict data\n d = dict(d)\n d[\"c\"] += 1\n return d\n\n transforms = Compose([a, a, b, c, c])\n value = transforms({\"a\": 0, \"b\": 0, \"c\": 0})\n for item in value:\n self.assertDictEqual(item, {\"a\": 2, \"b\": 1, \"c\": 2})", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compose.py_TestCompose.test_random_compose_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compose.py_TestCompose.test_random_compose_", "embedding": null, "metadata": {"file_path": "tests/test_compose.py", "file_name": "test_compose.py", "file_type": "text/x-python", "category": "test", "start_line": 69, "end_line": 105, "span_ids": ["TestCompose.test_err_msg", "TestCompose.test_randomize_warn", "impl", "TestCompose.test_random_compose"], "tokens": 250}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCompose(unittest.TestCase):\n\n def test_random_compose(self):\n class _Acc(Randomizable):\n self.rand = 0.0\n\n def randomize(self, data=None):\n self.rand = self.R.rand()\n\n def __call__(self, data):\n self.randomize()\n return self.rand + data\n\n c = Compose([_Acc(), _Acc()])\n self.assertNotAlmostEqual(c(0), c(0))\n c.set_random_state(123)\n self.assertAlmostEqual(c(1), 2.39293837)\n c.set_random_state(223)\n c.randomize()\n self.assertAlmostEqual(c(1), 2.57673391)\n\n def test_randomize_warn(self):\n class _RandomClass(Randomizable):\n def randomize(self, foo1, foo2):\n pass\n\n c = Compose([_RandomClass(), _RandomClass()])\n with self.assertWarns(Warning):\n c.randomize()\n\n def test_err_msg(self):\n transforms = Compose([abs, AddChannel(), round])\n with self.assertRaisesRegex(Exception, \"AddChannel\"):\n transforms(42.1)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_meandice.py_unittest_TEST_CASE_3._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_meandice.py_unittest_TEST_CASE_3._", "embedding": null, "metadata": {"file_path": "tests/test_compute_meandice.py", "file_name": "test_compute_meandice.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 61, "span_ids": ["docstring:13", "docstring"], "tokens": 633}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.metrics import DiceMetric, compute_meandice\n\n# keep background\nTEST_CASE_1 = [ # y (1, 1, 2, 2), y_pred (1, 1, 2, 2), expected out (1, 1)\n {\n \"y_pred\": torch.tensor([[[[1.0, -1.0], [-1.0, 1.0]]]]),\n \"y\": torch.tensor([[[[1.0, 0.0], [1.0, 1.0]]]]),\n \"include_background\": True,\n \"to_onehot_y\": False,\n \"mutually_exclusive\": False,\n \"logit_thresh\": 0.5,\n \"sigmoid\": True,\n },\n [[0.8]],\n]\n\n# remove background and not One-Hot target\nTEST_CASE_2 = [ # y (2, 1, 2, 2), y_pred (2, 3, 2, 2), expected out (2, 2) (no background)\n {\n \"y_pred\": torch.tensor(\n [\n [[[-1.0, 3.0], [2.0, -4.0]], [[0.0, -1.0], [3.0, 2.0]], [[0.0, 1.0], [2.0, -1.0]]],\n [[[-2.0, 0.0], [3.0, 1.0]], [[0.0, 2.0], [1.0, -2.0]], [[-1.0, 2.0], [4.0, 0.0]]],\n ]\n ),\n \"y\": torch.tensor([[[[1.0, 2.0], [1.0, 0.0]]], [[[1.0, 1.0], [2.0, 0.0]]]]),\n \"include_background\": False,\n \"to_onehot_y\": True,\n \"mutually_exclusive\": True,\n },\n [[0.5000, 0.0000], [0.6666, 0.6666]],\n]\n\n# should return Nan for all labels=0 case and skip for MeanDice\nTEST_CASE_3 = [\n {\n \"y_pred\": torch.zeros(2, 3, 2, 2),\n \"y\": torch.tensor([[[[0.0, 0.0], [0.0, 0.0]]], [[[1.0, 0.0], [0.0, 1.0]]]]),\n \"include_background\": True,\n \"to_onehot_y\": True,\n \"mutually_exclusive\": True,\n },\n [[False, True, True], [False, False, True]],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_meandice.py_TEST_CASE_4_TEST_CASE_6._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_meandice.py_TEST_CASE_4_TEST_CASE_6._", "embedding": null, "metadata": {"file_path": "tests/test_compute_meandice.py", "file_name": "test_compute_meandice.py", "file_type": "text/x-python", "category": "test", "start_line": 63, "end_line": 103, "span_ids": ["impl:11", "docstring:13"], "tokens": 713}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_4 = [\n {\"include_background\": True, \"to_onehot_y\": True, \"reduction\": \"mean_batch\"},\n {\n \"y_pred\": torch.tensor(\n [\n [[[1.0, 1.0], [1.0, 0.0]], [[0.0, 1.0], [0.0, 0.0]], [[0.0, 1.0], [1.0, 1.0]]],\n [[[1.0, 0.0], [1.0, 1.0]], [[0.0, 1.0], [1.0, 1.0]], [[0.0, 1.0], [1.0, 0.0]]],\n ]\n ),\n \"y\": torch.tensor([[[[0.0, 0.0], [0.0, 0.0]]], [[[1.0, 1.0], [2.0, 0.0]]]]),\n },\n [0.6786, 0.4000, 0.6667],\n]\n\nTEST_CASE_5 = [\n {\"include_background\": True, \"to_onehot_y\": True, \"reduction\": \"mean\"},\n {\n \"y_pred\": torch.tensor(\n [\n [[[1.0, 1.0], [1.0, 0.0]], [[0.0, 1.0], [0.0, 0.0]], [[0.0, 1.0], [1.0, 1.0]]],\n [[[1.0, 0.0], [1.0, 1.0]], [[0.0, 1.0], [1.0, 1.0]], [[0.0, 1.0], [1.0, 0.0]]],\n ]\n ),\n \"y\": torch.tensor([[[[0.0, 0.0], [0.0, 0.0]]], [[[1.0, 1.0], [2.0, 0.0]]]]),\n },\n 0.689683,\n]\n\nTEST_CASE_6 = [\n {\"include_background\": True, \"to_onehot_y\": True, \"reduction\": \"sum_batch\"},\n {\n \"y_pred\": torch.tensor(\n [\n [[[1.0, 1.0], [1.0, 0.0]], [[0.0, 1.0], [0.0, 0.0]], [[0.0, 1.0], [1.0, 1.0]]],\n [[[1.0, 0.0], [1.0, 1.0]], [[0.0, 1.0], [1.0, 1.0]], [[0.0, 1.0], [1.0, 0.0]]],\n ]\n ),\n \"y\": torch.tensor([[[[0.0, 0.0], [0.0, 0.0]]], [[[0.0, 0.0], [0.0, 0.0]]]]),\n },\n [1.7143, 0.0000, 0.0000],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_meandice.py_TEST_CASE_7_TEST_CASE_9._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_meandice.py_TEST_CASE_7_TEST_CASE_9._", "embedding": null, "metadata": {"file_path": "tests/test_compute_meandice.py", "file_name": "test_compute_meandice.py", "file_type": "text/x-python", "category": "test", "start_line": 105, "end_line": 136, "span_ids": ["impl:11", "impl:17"], "tokens": 540}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_7 = [\n {\"include_background\": True, \"to_onehot_y\": True, \"reduction\": \"mean\"},\n {\n \"y_pred\": torch.tensor(\n [\n [[[1.0, 1.0], [1.0, 0.0]], [[0.0, 1.0], [0.0, 0.0]], [[0.0, 1.0], [1.0, 1.0]]],\n [[[1.0, 0.0], [1.0, 1.0]], [[0.0, 1.0], [1.0, 1.0]], [[0.0, 1.0], [1.0, 0.0]]],\n ]\n ),\n \"y\": torch.tensor([[[[0.0, 0.0], [0.0, 0.0]]], [[[0.0, 0.0], [0.0, 0.0]]]]),\n },\n 0.857143,\n]\n\nTEST_CASE_8 = [\n {\"to_onehot_y\": True, \"include_background\": False, \"reduction\": \"sum_batch\"},\n {\n \"y_pred\": torch.tensor(\n [\n [[[1.0, 1.0], [1.0, 0.0]], [[0.0, 1.0], [0.0, 0.0]], [[0.0, 1.0], [1.0, 1.0]]],\n [[[1.0, 0.0], [1.0, 1.0]], [[0.0, 1.0], [1.0, 1.0]], [[0.0, 1.0], [1.0, 0.0]]],\n ]\n ),\n \"y\": torch.tensor([[[[0.0, 0.0], [0.0, 0.0]]], [[[0.0, 0.0], [0.0, 0.0]]]]),\n },\n [0.0000, 0.0000],\n]\n\nTEST_CASE_9 = [\n {\"y\": torch.from_numpy(np.ones((2, 2, 3, 3))), \"y_pred\": torch.from_numpy(np.ones((2, 2, 3, 3)))},\n [[1.0000, 1.0000], [1.0000, 1.0000]],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_meandice.py_TestComputeMeanDice_TestComputeMeanDice._DiceMetric_class_tests": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_meandice.py_TestComputeMeanDice_TestComputeMeanDice._DiceMetric_class_tests", "embedding": null, "metadata": {"file_path": "tests/test_compute_meandice.py", "file_name": "test_compute_meandice.py", "file_type": "text/x-python", "category": "test", "start_line": 139, "end_line": 150, "span_ids": ["TestComputeMeanDice.test_value", "TestComputeMeanDice", "TestComputeMeanDice.test_nans"], "tokens": 130}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestComputeMeanDice(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_9])\n def test_value(self, input_data, expected_value):\n result = compute_meandice(**input_data)\n np.testing.assert_allclose(result.cpu().numpy(), expected_value, atol=1e-4)\n\n @parameterized.expand([TEST_CASE_3])\n def test_nans(self, input_data, expected_value):\n result = compute_meandice(**input_data)\n self.assertTrue(np.allclose(np.isnan(result.cpu().numpy()), expected_value))\n\n # DiceMetric class tests", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_meandice.py_TestComputeMeanDice.test_value_class_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_meandice.py_TestComputeMeanDice.test_value_class_", "embedding": null, "metadata": {"file_path": "tests/test_compute_meandice.py", "file_name": "test_compute_meandice.py", "file_type": "text/x-python", "category": "test", "start_line": 151, "end_line": 172, "span_ids": ["TestComputeMeanDice.test_value_class", "impl:19", "TestComputeMeanDice.test_nans_class"], "tokens": 220}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestComputeMeanDice(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2])\n def test_value_class(self, input_data, expected_value):\n\n # same test as for compute_meandice\n vals = dict()\n vals[\"y_pred\"] = input_data.pop(\"y_pred\")\n vals[\"y\"] = input_data.pop(\"y\")\n dice_metric = DiceMetric(**input_data, reduction=\"none\")\n result = dice_metric(**vals)\n np.testing.assert_allclose(result.cpu().numpy(), expected_value, atol=1e-4)\n\n @parameterized.expand([TEST_CASE_4, TEST_CASE_5, TEST_CASE_6, TEST_CASE_7, TEST_CASE_8])\n def test_nans_class(self, params, input_data, expected_value):\n\n dice_metric = DiceMetric(**params)\n result = dice_metric(**input_data)\n np.testing.assert_allclose(result.cpu().numpy(), expected_value, atol=1e-4)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_roc_auc.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_roc_auc.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_compute_roc_auc.py", "file_name": "test_compute_roc_auc.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 77, "span_ids": ["impl:11", "TestComputeROCAUC", "docstring", "TestComputeROCAUC.test_value", "impl:15"], "tokens": 757}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.metrics import compute_roc_auc\n\nTEST_CASE_1 = [\n {\n \"y_pred\": torch.tensor([[0.1, 0.9], [0.3, 1.4], [0.2, 0.1], [0.1, 0.5]]),\n \"y\": torch.tensor([[0], [1], [0], [1]]),\n \"to_onehot_y\": True,\n \"softmax\": True,\n },\n 0.75,\n]\n\nTEST_CASE_2 = [{\"y_pred\": torch.tensor([[0.5], [0.5], [0.2], [8.3]]), \"y\": torch.tensor([[0], [1], [0], [1]])}, 0.875]\n\nTEST_CASE_3 = [{\"y_pred\": torch.tensor([[0.5], [0.5], [0.2], [8.3]]), \"y\": torch.tensor([0, 1, 0, 1])}, 0.875]\n\nTEST_CASE_4 = [{\"y_pred\": torch.tensor([0.5, 0.5, 0.2, 8.3]), \"y\": torch.tensor([0, 1, 0, 1])}, 0.875]\n\nTEST_CASE_5 = [\n {\n \"y_pred\": torch.tensor([[0.1, 0.9], [0.3, 1.4], [0.2, 0.1], [0.1, 0.5]]),\n \"y\": torch.tensor([[0], [1], [0], [1]]),\n \"to_onehot_y\": True,\n \"softmax\": True,\n \"average\": \"none\",\n },\n [0.75, 0.75],\n]\n\nTEST_CASE_6 = [\n {\n \"y_pred\": torch.tensor([[0.1, 0.9], [0.3, 1.4], [0.2, 0.1], [0.1, 0.5], [0.1, 0.5]]),\n \"y\": torch.tensor([[1, 0], [0, 1], [0, 0], [1, 1], [0, 1]]),\n \"softmax\": True,\n \"average\": \"weighted\",\n },\n 0.56667,\n]\n\nTEST_CASE_7 = [\n {\n \"y_pred\": torch.tensor([[0.1, 0.9], [0.3, 1.4], [0.2, 0.1], [0.1, 0.5], [0.1, 0.5]]),\n \"y\": torch.tensor([[1, 0], [0, 1], [0, 0], [1, 1], [0, 1]]),\n \"softmax\": True,\n \"average\": \"micro\",\n },\n 0.62,\n]\n\n\nclass TestComputeROCAUC(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5, TEST_CASE_6, TEST_CASE_7])\n def test_value(self, input_data, expected_value):\n result = compute_roc_auc(**input_data)\n np.testing.assert_allclose(expected_value, result, rtol=1e-5)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_concat_itemsd.py_unittest_TestConcatItemsd.test_tensor_values.None_2": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_concat_itemsd.py_unittest_TestConcatItemsd.test_tensor_values.None_2", "embedding": null, "metadata": {"file_path": "tests/test_concat_itemsd.py", "file_name": "test_concat_itemsd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 29, "span_ids": ["TestConcatItemsd.test_tensor_values", "TestConcatItemsd", "docstring"], "tokens": 221}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport torch\nimport numpy as np\nfrom monai.transforms import ConcatItemsd\n\n\nclass TestConcatItemsd(unittest.TestCase):\n def test_tensor_values(self):\n device = torch.device(\"cuda:0\") if torch.cuda.is_available() else torch.device(\"cpu:0\")\n input_data = {\n \"img1\": torch.tensor([[0, 1], [1, 2]], device=device),\n \"img2\": torch.tensor([[0, 1], [1, 2]], device=device),\n }\n result = ConcatItemsd(keys=[\"img1\", \"img2\"], name=\"cat_img\")(input_data)\n self.assertTrue(\"cat_img\" in result)\n result[\"cat_img\"] += 1\n torch.testing.assert_allclose(result[\"img1\"], torch.tensor([[0, 1], [1, 2]], device=device))\n torch.testing.assert_allclose(result[\"cat_img\"], torch.tensor([[1, 2], [2, 3], [1, 2], [2, 3]], device=device))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_concat_itemsd.py_TestConcatItemsd.test_numpy_values_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_concat_itemsd.py_TestConcatItemsd.test_numpy_values_", "embedding": null, "metadata": {"file_path": "tests/test_concat_itemsd.py", "file_name": "test_concat_itemsd.py", "file_type": "text/x-python", "category": "test", "start_line": 31, "end_line": 42, "span_ids": ["impl", "TestConcatItemsd.test_numpy_values"], "tokens": 176}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestConcatItemsd(unittest.TestCase):\n\n def test_numpy_values(self):\n input_data = {\"img1\": np.array([[0, 1], [1, 2]]), \"img2\": np.array([[0, 1], [1, 2]])}\n result = ConcatItemsd(keys=[\"img1\", \"img2\"], name=\"cat_img\")(input_data)\n self.assertTrue(\"cat_img\" in result)\n result[\"cat_img\"] += 1\n np.testing.assert_allclose(result[\"img1\"], np.array([[0, 1], [1, 2]]))\n np.testing.assert_allclose(result[\"cat_img\"], np.array([[1, 2], [2, 3], [1, 2], [2, 3]]))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_convolutions.py_from_tests_utils_import_T_TestConvolution2D.test_transpose2.self_assertEqual_out_shap": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_convolutions.py_from_tests_utils_import_T_TestConvolution2D.test_transpose2.self_assertEqual_out_shap", "embedding": null, "metadata": {"file_path": "tests/test_convolutions.py", "file_name": "test_convolutions.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 64, "span_ids": ["TestConvolution2D.test_conv1", "TestConvolution2D.test_conv_only1", "TestConvolution2D.test_transpose2", "TestConvolution2D.test_dilation1", "TestConvolution2D.test_dropout1", "TestConvolution2D", "TestConvolution2D.test_transpose1", "docstring", "TestConvolution2D.test_stride1", "TestConvolution2D.test_conv1_no_acti"], "tokens": 599}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from tests.utils import TorchImageTestCase2D\n\nfrom monai.networks.blocks import Convolution, ResidualUnit\n\n\nclass TestConvolution2D(TorchImageTestCase2D):\n def test_conv1(self):\n conv = Convolution(2, self.input_channels, self.output_channels)\n out = conv(self.imt)\n expected_shape = (1, self.output_channels, self.im_shape[0], self.im_shape[1])\n self.assertEqual(out.shape, expected_shape)\n\n def test_conv1_no_acti(self):\n conv = Convolution(2, self.input_channels, self.output_channels, act=None)\n out = conv(self.imt)\n expected_shape = (1, self.output_channels, self.im_shape[0], self.im_shape[1])\n self.assertEqual(out.shape, expected_shape)\n\n def test_conv_only1(self):\n conv = Convolution(2, self.input_channels, self.output_channels, conv_only=True)\n out = conv(self.imt)\n expected_shape = (1, self.output_channels, self.im_shape[0], self.im_shape[1])\n self.assertEqual(out.shape, expected_shape)\n\n def test_stride1(self):\n conv = Convolution(2, self.input_channels, self.output_channels, strides=2)\n out = conv(self.imt)\n expected_shape = (1, self.output_channels, self.im_shape[0] // 2, self.im_shape[1] // 2)\n self.assertEqual(out.shape, expected_shape)\n\n def test_dilation1(self):\n conv = Convolution(2, self.input_channels, self.output_channels, dilation=3)\n out = conv(self.imt)\n expected_shape = (1, self.output_channels, self.im_shape[0], self.im_shape[1])\n self.assertEqual(out.shape, expected_shape)\n\n def test_dropout1(self):\n conv = Convolution(2, self.input_channels, self.output_channels, dropout=0.15)\n out = conv(self.imt)\n expected_shape = (1, self.output_channels, self.im_shape[0], self.im_shape[1])\n self.assertEqual(out.shape, expected_shape)\n\n def test_transpose1(self):\n conv = Convolution(2, self.input_channels, self.output_channels, is_transposed=True)\n out = conv(self.imt)\n expected_shape = (1, self.output_channels, self.im_shape[0], self.im_shape[1])\n self.assertEqual(out.shape, expected_shape)\n\n def test_transpose2(self):\n conv = Convolution(2, self.input_channels, self.output_channels, strides=2, is_transposed=True)\n out = conv(self.imt)\n expected_shape = (1, self.output_channels, self.im_shape[0] * 2, self.im_shape[1] * 2)\n self.assertEqual(out.shape, expected_shape)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_convolutions.py_TestResidualUnit2D_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_convolutions.py_TestResidualUnit2D_", "embedding": null, "metadata": {"file_path": "tests/test_convolutions.py", "file_name": "test_convolutions.py", "file_type": "text/x-python", "category": "test", "start_line": 67, "end_line": 91, "span_ids": ["TestResidualUnit2D.test_conv_only1", "TestResidualUnit2D", "TestResidualUnit2D.test_stride1", "TestResidualUnit2D.test_dropout1", "TestResidualUnit2D.test_dilation1"], "tokens": 290}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestResidualUnit2D(TorchImageTestCase2D):\n def test_conv_only1(self):\n conv = ResidualUnit(2, 1, self.output_channels)\n out = conv(self.imt)\n expected_shape = (1, self.output_channels, self.im_shape[0], self.im_shape[1])\n self.assertEqual(out.shape, expected_shape)\n\n def test_stride1(self):\n conv = ResidualUnit(2, 1, self.output_channels, strides=2)\n out = conv(self.imt)\n expected_shape = (1, self.output_channels, self.im_shape[0] // 2, self.im_shape[1] // 2)\n self.assertEqual(out.shape, expected_shape)\n\n def test_dilation1(self):\n conv = ResidualUnit(2, 1, self.output_channels, dilation=3)\n out = conv(self.imt)\n expected_shape = (1, self.output_channels, self.im_shape[0], self.im_shape[1])\n self.assertEqual(out.shape, expected_shape)\n\n def test_dropout1(self):\n conv = ResidualUnit(2, 1, self.output_channels, dropout=0.15)\n out = conv(self.imt)\n expected_shape = (1, self.output_channels, self.im_shape[0], self.im_shape[1])\n self.assertEqual(out.shape, expected_shape)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_copy_itemsd.py_unittest_TEST_CASE_4._img_seg_2_img": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_copy_itemsd.py_unittest_TEST_CASE_4._img_seg_2_img", "embedding": null, "metadata": {"file_path": "tests/test_copy_itemsd.py", "file_name": "test_copy_itemsd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 25, "span_ids": ["docstring"], "tokens": 132}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport torch\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import CopyItemsd\nfrom monai.utils import ensure_tuple\n\nTEST_CASE_1 = [\"img\", 1, \"img_1\"]\n\nTEST_CASE_2 = [[\"img\", \"seg\"], 1, [\"img_1\", \"seg_1\"]]\n\nTEST_CASE_3 = [\"img\", 2, [\"img_1\", \"img_2\"]]\n\nTEST_CASE_4 = [[\"img\", \"seg\"], 2, [\"img_1\", \"seg_1\", \"img_2\", \"seg_2\"]]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_copy_itemsd.py_TestCopyItemsd_TestCopyItemsd.test_numpy_values.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_copy_itemsd.py_TestCopyItemsd_TestCopyItemsd.test_numpy_values.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_copy_itemsd.py", "file_name": "test_copy_itemsd.py", "file_type": "text/x-python", "category": "test", "start_line": 28, "end_line": 37, "span_ids": ["TestCopyItemsd", "TestCopyItemsd.test_numpy_values"], "tokens": 180}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCopyItemsd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4])\n def test_numpy_values(self, keys, times, names):\n input_data = {\"img\": np.array([[0, 1], [1, 2]]), \"seg\": np.array([[0, 1], [1, 2]])}\n result = CopyItemsd(keys=keys, times=times, names=names)(input_data)\n for name in ensure_tuple(names):\n self.assertTrue(name in result)\n result[name] += 1\n np.testing.assert_allclose(result[name], np.array([[1, 2], [2, 3]]))\n np.testing.assert_allclose(result[\"img\"], np.array([[0, 1], [1, 2]]))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_copy_itemsd.py_TestCopyItemsd.test_tensor_values_TestCopyItemsd.test_tensor_values.None_2": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_copy_itemsd.py_TestCopyItemsd.test_tensor_values_TestCopyItemsd.test_tensor_values.None_2", "embedding": null, "metadata": {"file_path": "tests/test_copy_itemsd.py", "file_name": "test_copy_itemsd.py", "file_type": "text/x-python", "category": "test", "start_line": 39, "end_line": 49, "span_ids": ["TestCopyItemsd.test_tensor_values"], "tokens": 189}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCopyItemsd(unittest.TestCase):\n\n def test_tensor_values(self):\n device = torch.device(\"cuda:0\") if torch.cuda.is_available() else torch.device(\"cpu:0\")\n input_data = {\n \"img\": torch.tensor([[0, 1], [1, 2]], device=device),\n \"seg\": torch.tensor([[0, 1], [1, 2]], device=device),\n }\n result = CopyItemsd(keys=\"img\", times=1, names=\"img_1\")(input_data)\n self.assertTrue(\"img_1\" in result)\n result[\"img_1\"] += 1\n torch.testing.assert_allclose(result[\"img\"], torch.tensor([[0, 1], [1, 2]], device=device))\n torch.testing.assert_allclose(result[\"img_1\"], torch.tensor([[1, 2], [2, 3]], device=device))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_copy_itemsd.py_TestCopyItemsd.test_array_values_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_copy_itemsd.py_TestCopyItemsd.test_array_values_", "embedding": null, "metadata": {"file_path": "tests/test_copy_itemsd.py", "file_name": "test_copy_itemsd.py", "file_type": "text/x-python", "category": "test", "start_line": 51, "end_line": 62, "span_ids": ["impl:9", "TestCopyItemsd.test_array_values"], "tokens": 158}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCopyItemsd(unittest.TestCase):\n\n def test_array_values(self):\n input_data = {\"img\": [[0, 1], [1, 2]], \"seg\": [[0, 1], [1, 2]]}\n result = CopyItemsd(keys=\"img\", times=1, names=\"img_1\")(input_data)\n self.assertTrue(\"img_1\" in result)\n result[\"img_1\"][0][0] += 1\n np.testing.assert_allclose(result[\"img\"], [[0, 1], [1, 2]])\n np.testing.assert_allclose(result[\"img_1\"], [[1, 1], [1, 2]])\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_unittest_TestCreateGrid.test_create_grid.g_13.create_grid_2_2_2_sp": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_unittest_TestCreateGrid.test_create_grid.g_13.create_grid_2_2_2_sp", "embedding": null, "metadata": {"file_path": "tests/test_create_grid_and_affine.py", "file_name": "test_create_grid_and_affine.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 69, "span_ids": ["TestCreateGrid", "TestCreateGrid.test_create_grid", "docstring"], "tokens": 685}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\n\nfrom monai.transforms import (\n create_control_grid,\n create_grid,\n create_rotate,\n create_scale,\n create_shear,\n create_translate,\n)\n\n\nclass TestCreateGrid(unittest.TestCase):\n def test_create_grid(self):\n with self.assertRaisesRegex(TypeError, \"\"):\n create_grid(None)\n with self.assertRaisesRegex(TypeError, \"\"):\n create_grid((1, 1), spacing=2.0)\n with self.assertRaisesRegex(TypeError, \"\"):\n create_grid((1, 1), spacing=2.0)\n\n g = create_grid((1, 1))\n expected = np.array([[[0.0]], [[0.0]], [[1.0]]])\n np.testing.assert_allclose(g, expected)\n\n g = create_grid((1, 1), homogeneous=False)\n expected = np.array([[[0.0]], [[0.0]]])\n np.testing.assert_allclose(g, expected)\n\n g = create_grid((1, 1), spacing=(1.2, 1.3))\n expected = np.array([[[0.0]], [[0.0]], [[1.0]]])\n np.testing.assert_allclose(g, expected)\n\n g = create_grid((1, 1, 1), spacing=(1.2, 1.3, 1.0))\n expected = np.array([[[[0.0]]], [[[0.0]]], [[[0.0]]], [[[1.0]]]])\n np.testing.assert_allclose(g, expected)\n\n g = create_grid((1, 1, 1), spacing=(1.2, 1.3, 1.0), homogeneous=False)\n expected = np.array([[[[0.0]]], [[[0.0]]], [[[0.0]]]])\n np.testing.assert_allclose(g, expected)\n\n g = create_grid((1, 1, 1), spacing=(1.2, 1.3, 1.0), dtype=np.int32)\n np.testing.assert_equal(g.dtype, np.int32)\n\n g = create_grid((2, 2, 2))\n expected = np.array(\n [\n [[[-0.5, -0.5], [-0.5, -0.5]], [[0.5, 0.5], [0.5, 0.5]]],\n [[[-0.5, -0.5], [0.5, 0.5]], [[-0.5, -0.5], [0.5, 0.5]]],\n [[[-0.5, 0.5], [-0.5, 0.5]], [[-0.5, 0.5], [-0.5, 0.5]]],\n [[[1.0, 1.0], [1.0, 1.0]], [[1.0, 1.0], [1.0, 1.0]]],\n ]\n )\n np.testing.assert_allclose(g, expected)\n\n g = create_grid((2, 2, 2), spacing=(1.2, 1.3, 1.0))\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateGrid.test_create_grid.expected_14_TestCreateGrid.test_create_grid.None_7": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateGrid.test_create_grid.expected_14_TestCreateGrid.test_create_grid.None_7", "embedding": null, "metadata": {"file_path": "tests/test_create_grid_and_affine.py", "file_name": "test_create_grid_and_affine.py", "file_type": "text/x-python", "category": "test", "start_line": 70, "end_line": 78, "span_ids": ["TestCreateGrid.test_create_grid"], "tokens": 215}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCreateGrid(unittest.TestCase):\n def test_create_grid(self):\n # ... other code\n expected = np.array(\n [\n [[[-0.6, -0.6], [-0.6, -0.6]], [[0.6, 0.6], [0.6, 0.6]]],\n [[[-0.65, -0.65], [0.65, 0.65]], [[-0.65, -0.65], [0.65, 0.65]]],\n [[[-0.5, 0.5], [-0.5, 0.5]], [[-0.5, 0.5], [-0.5, 0.5]]],\n [[[1.0, 1.0], [1.0, 1.0]], [[1.0, 1.0], [1.0, 1.0]]],\n ]\n )\n np.testing.assert_allclose(g, expected)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateGrid.test_create_control_grid_TestCreateGrid.test_create_control_grid.g_6.create_control_grid_2_0_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateGrid.test_create_control_grid_TestCreateGrid.test_create_control_grid.g_6.create_control_grid_2_0_", "embedding": null, "metadata": {"file_path": "tests/test_create_grid_and_affine.py", "file_name": "test_create_grid_and_affine.py", "file_type": "text/x-python", "category": "test", "start_line": 80, "end_line": 116, "span_ids": ["TestCreateGrid.test_create_control_grid"], "tokens": 756}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCreateGrid(unittest.TestCase):\n\n def test_create_control_grid(self):\n with self.assertRaisesRegex(TypeError, \"\"):\n create_control_grid(None, None)\n with self.assertRaisesRegex(TypeError, \"\"):\n create_control_grid((1, 1), 2.0)\n\n g = create_control_grid((1.0, 1.0), (1.0, 1.0))\n expected = np.array(\n [\n [[-1.0, -1.0, -1.0], [0.0, 0.0, 0.0], [1.0, 1.0, 1.0]],\n [[-1.0, 0.0, 1.0], [-1.0, 0.0, 1.0], [-1.0, 0.0, 1.0]],\n [[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]],\n ]\n )\n np.testing.assert_allclose(g, expected)\n\n g = create_control_grid((1.0, 1.0), (2.0, 2.0))\n expected = np.array(\n [\n [[-2.0, -2.0, -2.0], [0.0, 0.0, 0.0], [2.0, 2.0, 2.0]],\n [[-2.0, 0.0, 2.0], [-2.0, 0.0, 2.0], [-2.0, 0.0, 2.0]],\n [[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]],\n ]\n )\n np.testing.assert_allclose(g, expected)\n\n g = create_control_grid((2.0, 2.0), (1.0, 1.0))\n expected = np.array(\n [\n [[-1.5, -1.5, -1.5, -1.5], [-0.5, -0.5, -0.5, -0.5], [0.5, 0.5, 0.5, 0.5], [1.5, 1.5, 1.5, 1.5]],\n [[-1.5, -0.5, 0.5, 1.5], [-1.5, -0.5, 0.5, 1.5], [-1.5, -0.5, 0.5, 1.5], [-1.5, -0.5, 0.5, 1.5]],\n [[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]],\n ]\n )\n np.testing.assert_allclose(g, expected)\n\n g = create_control_grid((2.0, 2.0), (2.0, 2.0))\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateGrid.test_create_control_grid.expected_7_TestCreateGrid.test_create_control_grid.g_8.create_control_grid_1_0_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateGrid.test_create_control_grid.expected_7_TestCreateGrid.test_create_control_grid.g_8.create_control_grid_1_0_", "embedding": null, "metadata": {"file_path": "tests/test_create_grid_and_affine.py", "file_name": "test_create_grid_and_affine.py", "file_type": "text/x-python", "category": "test", "start_line": 117, "end_line": 126, "span_ids": ["TestCreateGrid.test_create_control_grid"], "tokens": 332}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCreateGrid(unittest.TestCase):\n\n def test_create_control_grid(self):\n # ... other code\n expected = np.array(\n [\n [[-3.0, -3.0, -3.0, -3.0], [-1.0, -1.0, -1.0, -1.0], [1.0, 1.0, 1.0, 1.0], [3.0, 3.0, 3.0, 3.0]],\n [[-3.0, -1.0, 1.0, 3.0], [-3.0, -1.0, 1.0, 3.0], [-3.0, -1.0, 1.0, 3.0], [-3.0, -1.0, 1.0, 3.0]],\n [[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]],\n ]\n )\n np.testing.assert_allclose(g, expected)\n\n g = create_control_grid((1.0, 1.0, 1.0), (2.0, 2.0, 2.0), homogeneous=False)\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateGrid.test_create_control_grid.expected_9_test_assert.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateGrid.test_create_control_grid.expected_9_test_assert.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_create_grid_and_affine.py", "file_name": "test_create_grid_and_affine.py", "file_type": "text/x-python", "category": "test", "start_line": 127, "end_line": 151, "span_ids": ["test_assert", "TestCreateGrid.test_create_control_grid"], "tokens": 509}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCreateGrid(unittest.TestCase):\n\n def test_create_control_grid(self):\n # ... other code\n expected = np.array(\n [\n [\n [[-2.0, -2.0, -2.0], [-2.0, -2.0, -2.0], [-2.0, -2.0, -2.0]],\n [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]],\n [[2.0, 2.0, 2.0], [2.0, 2.0, 2.0], [2.0, 2.0, 2.0]],\n ],\n [\n [[-2.0, -2.0, -2.0], [0.0, 0.0, 0.0], [2.0, 2.0, 2.0]],\n [[-2.0, -2.0, -2.0], [0.0, 0.0, 0.0], [2.0, 2.0, 2.0]],\n [[-2.0, -2.0, -2.0], [0.0, 0.0, 0.0], [2.0, 2.0, 2.0]],\n ],\n [\n [[-2.0, 0.0, 2.0], [-2.0, 0.0, 2.0], [-2.0, 0.0, 2.0]],\n [[-2.0, 0.0, 2.0], [-2.0, 0.0, 2.0], [-2.0, 0.0, 2.0]],\n [[-2.0, 0.0, 2.0], [-2.0, 0.0, 2.0], [-2.0, 0.0, 2.0]],\n ],\n ]\n )\n np.testing.assert_allclose(g, expected)\n\n\ndef test_assert(func, params, expected):\n m = func(*params)\n np.testing.assert_allclose(m, expected, atol=1e-7)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateAffine_TestCreateAffine.test_create_rotate.None_4": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateAffine_TestCreateAffine.test_create_rotate.None_4", "embedding": null, "metadata": {"file_path": "tests/test_create_grid_and_affine.py", "file_name": "test_create_grid_and_affine.py", "file_type": "text/x-python", "category": "test", "start_line": 154, "end_line": 207, "span_ids": ["TestCreateAffine", "TestCreateAffine.test_create_rotate"], "tokens": 626}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCreateAffine(unittest.TestCase):\n def test_create_rotate(self):\n with self.assertRaisesRegex(TypeError, \"\"):\n create_rotate(2, None)\n\n with self.assertRaisesRegex(ValueError, \"\"):\n create_rotate(5, 1)\n\n test_assert(\n create_rotate,\n (2, 1.1),\n np.array([[0.45359612, -0.89120736, 0.0], [0.89120736, 0.45359612, 0.0], [0.0, 0.0, 1.0]]),\n )\n test_assert(\n create_rotate,\n (3, 1.1),\n np.array(\n [\n [1.0, 0.0, 0.0, 0.0],\n [0.0, 0.45359612, -0.89120736, 0.0],\n [0.0, 0.89120736, 0.45359612, 0.0],\n [0.0, 0.0, 0.0, 1.0],\n ]\n ),\n )\n test_assert(\n create_rotate,\n (3, (1.1, 1)),\n np.array(\n [\n [0.54030231, 0.0, 0.84147098, 0.0],\n [0.74992513, 0.45359612, -0.48152139, 0.0],\n [-0.38168798, 0.89120736, 0.24507903, 0.0],\n [0.0, 0.0, 0.0, 1.0],\n ]\n ),\n )\n test_assert(\n create_rotate,\n (3, (1, 1, 1.1)),\n np.array(\n [\n [0.24507903, -0.48152139, 0.84147098, 0.0],\n [0.80270075, -0.38596121, -0.45464871, 0.0],\n [0.54369824, 0.78687425, 0.29192658, 0.0],\n [0.0, 0.0, 0.0, 1.0],\n ]\n ),\n )\n test_assert(\n create_rotate,\n (3, (0, 0, np.pi / 2)),\n np.array([[0.0, -1.0, 0.0, 0.0], [1.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]),\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateAffine.test_create_shear_TestCreateAffine.test_create_shear.test_assert_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateAffine.test_create_shear_TestCreateAffine.test_create_shear.test_assert_", "embedding": null, "metadata": {"file_path": "tests/test_create_grid_and_affine.py", "file_name": "test_create_grid_and_affine.py", "file_type": "text/x-python", "category": "test", "start_line": 209, "end_line": 216, "span_ids": ["TestCreateAffine.test_create_shear"], "tokens": 251}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCreateAffine(unittest.TestCase):\n\n def test_create_shear(self):\n test_assert(create_shear, (2, 1.0), np.array([[1.0, 1.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]))\n test_assert(create_shear, (2, (2.0, 3.0)), np.array([[1.0, 2.0, 0.0], [3.0, 1.0, 0.0], [0.0, 0.0, 1.0]]))\n test_assert(\n create_shear,\n (3, 1.0),\n np.array([[1.0, 1.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]),\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateAffine.test_create_scale_TestCreateAffine.test_create_scale.None_4": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateAffine.test_create_scale_TestCreateAffine.test_create_scale.None_4", "embedding": null, "metadata": {"file_path": "tests/test_create_grid_and_affine.py", "file_name": "test_create_grid_and_affine.py", "file_type": "text/x-python", "category": "test", "start_line": 218, "end_line": 235, "span_ids": ["TestCreateAffine.test_create_scale"], "tokens": 465}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCreateAffine(unittest.TestCase):\n\n def test_create_scale(self):\n test_assert(create_scale, (2, 2), np.array([[2.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]))\n test_assert(create_scale, (2, [2, 2, 2]), np.array([[2.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 1.0]]))\n test_assert(\n create_scale,\n (3, [1.5, 2.4]),\n np.array([[1.5, 0.0, 0.0, 0.0], [0.0, 2.4, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]),\n )\n test_assert(\n create_scale,\n (3, 1.5),\n np.array([[1.5, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]),\n )\n test_assert(\n create_scale,\n (3, [1, 2, 3, 4, 5]),\n np.array([[1.0, 0.0, 0.0, 0.0], [0.0, 2.0, 0.0, 0.0], [0.0, 0.0, 3.0, 0.0], [0.0, 0.0, 0.0, 1.0]]),\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateAffine.test_create_translate_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_create_grid_and_affine.py_TestCreateAffine.test_create_translate_", "embedding": null, "metadata": {"file_path": "tests/test_create_grid_and_affine.py", "file_name": "test_create_grid_and_affine.py", "file_type": "text/x-python", "category": "test", "start_line": 237, "end_line": 259, "span_ids": ["TestCreateAffine.test_create_translate", "impl"], "tokens": 477}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCreateAffine(unittest.TestCase):\n\n def test_create_translate(self):\n test_assert(create_translate, (2, 2), np.array([[1.0, 0.0, 2.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]))\n test_assert(create_translate, (2, [2, 2, 2]), np.array([[1.0, 0.0, 2.0], [0.0, 1.0, 2.0], [0.0, 0.0, 1.0]]))\n test_assert(\n create_translate,\n (3, [1.5, 2.4]),\n np.array([[1.0, 0.0, 0.0, 1.5], [0.0, 1.0, 0.0, 2.4], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]),\n )\n test_assert(\n create_translate,\n (3, 1.5),\n np.array([[1.0, 0.0, 0.0, 1.5], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]),\n )\n test_assert(\n create_translate,\n (3, [1, 2, 3, 4, 5]),\n np.array([[1.0, 0.0, 0.0, 1.0], [0.0, 1.0, 0.0, 2.0], [0.0, 0.0, 1.0, 3.0], [0.0, 0.0, 0.0, 1.0]]),\n )\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_crop_foreground.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_crop_foreground.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_crop_foreground.py", "file_name": "test_crop_foreground.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 52, "span_ids": ["TestCropForeground", "TestCropForeground.test_value", "impl:7", "docstring", "impl:9"], "tokens": 690}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.transforms import CropForeground\n\nTEST_CASE_1 = [\n {\"select_fn\": lambda x: x > 0, \"channel_indexes\": None, \"margin\": 0},\n np.array([[[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 3, 2, 0], [0, 1, 2, 1, 0], [0, 0, 0, 0, 0]]]),\n np.array([[[1, 2, 1], [2, 3, 2], [1, 2, 1]]]),\n]\n\nTEST_CASE_2 = [\n {\"select_fn\": lambda x: x > 1, \"channel_indexes\": None, \"margin\": 0},\n np.array([[[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 3, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]]),\n np.array([[[3]]]),\n]\n\nTEST_CASE_3 = [\n {\"select_fn\": lambda x: x > 0, \"channel_indexes\": 0, \"margin\": 0},\n np.array([[[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 3, 2, 0], [0, 1, 2, 1, 0], [0, 0, 0, 0, 0]]]),\n np.array([[[1, 2, 1], [2, 3, 2], [1, 2, 1]]]),\n]\n\nTEST_CASE_4 = [\n {\"select_fn\": lambda x: x > 0, \"channel_indexes\": None, \"margin\": 1},\n np.array([[[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 3, 2, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]]),\n np.array([[[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 3, 2, 0], [0, 0, 0, 0, 0]]]),\n]\n\n\nclass TestCropForeground(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4])\n def test_value(self, argments, image, expected_data):\n result = CropForeground(**argments)(image)\n np.testing.assert_allclose(result, expected_data)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_crop_foregroundd.py_unittest_TEST_CASE_3._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_crop_foregroundd.py_unittest_TEST_CASE_3._", "embedding": null, "metadata": {"file_path": "tests/test_crop_foregroundd.py", "file_name": "test_crop_foregroundd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 43, "span_ids": ["impl:5", "docstring"], "tokens": 581}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.transforms import CropForegroundd\n\nTEST_CASE_1 = [\n {\n \"keys\": [\"img\", \"label\"],\n \"source_key\": \"label\",\n \"select_fn\": lambda x: x > 0,\n \"channel_indexes\": None,\n \"margin\": 0,\n },\n {\n \"img\": np.array([[[1, 0, 2, 0, 1], [0, 1, 2, 1, 0], [2, 2, 3, 2, 2], [0, 1, 2, 1, 0], [1, 0, 2, 0, 1]]]),\n \"label\": np.array([[[0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0]]]),\n },\n np.array([[[1, 2, 1], [2, 3, 2], [1, 2, 1]]]),\n]\n\nTEST_CASE_2 = [\n {\"keys\": [\"img\"], \"source_key\": \"img\", \"select_fn\": lambda x: x > 1, \"channel_indexes\": None, \"margin\": 0},\n {\"img\": np.array([[[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 3, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]])},\n np.array([[[3]]]),\n]\n\nTEST_CASE_3 = [\n {\"keys\": [\"img\"], \"source_key\": \"img\", \"select_fn\": lambda x: x > 0, \"channel_indexes\": 0, \"margin\": 0},\n {\"img\": np.array([[[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 3, 2, 0], [0, 1, 2, 1, 0], [0, 0, 0, 0, 0]]])},\n np.array([[[1, 2, 1], [2, 3, 2], [1, 2, 1]]]),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_crop_foregroundd.py_TEST_CASE_4_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_crop_foregroundd.py_TEST_CASE_4_", "embedding": null, "metadata": {"file_path": "tests/test_crop_foregroundd.py", "file_name": "test_crop_foregroundd.py", "file_type": "text/x-python", "category": "test", "start_line": 45, "end_line": 61, "span_ids": ["impl:9", "TestCropForegroundd", "impl:5", "TestCropForegroundd.test_value"], "tokens": 279}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_4 = [\n {\"keys\": [\"img\"], \"source_key\": \"img\", \"select_fn\": lambda x: x > 0, \"channel_indexes\": None, \"margin\": 1},\n {\"img\": np.array([[[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 3, 2, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]])},\n np.array([[[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 3, 2, 0], [0, 0, 0, 0, 0]]]),\n]\n\n\nclass TestCropForegroundd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4])\n def test_value(self, argments, image, expected_data):\n result = CropForegroundd(**argments)(image)\n np.testing.assert_allclose(result[\"img\"], expected_data)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_csv_saver.py_os_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_csv_saver.py_os_", "embedding": null, "metadata": {"file_path": "tests/test_csv_saver.py", "file_name": "test_csv_saver.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 48, "span_ids": ["TestCSVSaver.test_saved_content", "TestCSVSaver", "impl", "docstring"], "tokens": 242}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport csv\nimport shutil\nimport unittest\nimport numpy as np\nimport torch\n\n\nfrom monai.data import CSVSaver\n\n\nclass TestCSVSaver(unittest.TestCase):\n def test_saved_content(self):\n default_dir = os.path.join(\".\", \"tempdir\")\n shutil.rmtree(default_dir, ignore_errors=True)\n\n saver = CSVSaver(output_dir=default_dir, filename=\"predictions.csv\")\n\n meta_data = {\"filename_or_obj\": [\"testfile\" + str(i) for i in range(8)]}\n saver.save_batch(torch.zeros(8), meta_data)\n saver.finalize()\n filepath = os.path.join(default_dir, \"predictions.csv\")\n self.assertTrue(os.path.exists(filepath))\n with open(filepath, \"r\") as f:\n reader = csv.reader(f)\n i = 0\n for row in reader:\n self.assertEqual(row[0], \"testfile\" + str(i))\n self.assertEqual(np.array(row[1:]).astype(np.float32), 0.0)\n i += 1\n self.assertEqual(i, 8)\n shutil.rmtree(default_dir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_stats.py_unittest_TEST_CASE_7._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_stats.py_unittest_TEST_CASE_7._", "embedding": null, "metadata": {"file_path": "tests/test_data_stats.py", "file_name": "test_data_stats.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 106, "span_ids": ["impl:9", "docstring"], "tokens": 741}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport os\nimport shutil\nimport logging\nimport tempfile\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\nfrom monai.transforms import DataStats\n\nTEST_CASE_1 = [\n {\n \"prefix\": \"test data\",\n \"data_shape\": False,\n \"value_range\": False,\n \"data_value\": False,\n \"additional_info\": None,\n \"logger_handler\": None,\n },\n np.array([[0, 1], [1, 2]]),\n \"test data statistics:\",\n]\n\nTEST_CASE_2 = [\n {\n \"prefix\": \"test data\",\n \"data_shape\": True,\n \"value_range\": False,\n \"data_value\": False,\n \"additional_info\": None,\n \"logger_handler\": None,\n },\n np.array([[0, 1], [1, 2]]),\n \"test data statistics:\\nShape: (2, 2)\",\n]\n\nTEST_CASE_3 = [\n {\n \"prefix\": \"test data\",\n \"data_shape\": True,\n \"value_range\": True,\n \"data_value\": False,\n \"additional_info\": None,\n \"logger_handler\": None,\n },\n np.array([[0, 1], [1, 2]]),\n \"test data statistics:\\nShape: (2, 2)\\nValue range: (0, 2)\",\n]\n\nTEST_CASE_4 = [\n {\n \"prefix\": \"test data\",\n \"data_shape\": True,\n \"value_range\": True,\n \"data_value\": True,\n \"additional_info\": None,\n \"logger_handler\": None,\n },\n np.array([[0, 1], [1, 2]]),\n \"test data statistics:\\nShape: (2, 2)\\nValue range: (0, 2)\\nValue: [[0 1]\\n [1 2]]\",\n]\n\nTEST_CASE_5 = [\n {\n \"prefix\": \"test data\",\n \"data_shape\": True,\n \"value_range\": True,\n \"data_value\": True,\n \"additional_info\": lambda x: np.mean(x),\n \"logger_handler\": None,\n },\n np.array([[0, 1], [1, 2]]),\n \"test data statistics:\\nShape: (2, 2)\\nValue range: (0, 2)\\nValue: [[0 1]\\n [1 2]]\\nAdditional info: 1.0\",\n]\n\nTEST_CASE_6 = [\n {\n \"prefix\": \"test data\",\n \"data_shape\": True,\n \"value_range\": True,\n \"data_value\": True,\n \"additional_info\": lambda x: torch.mean(x.float()),\n \"logger_handler\": None,\n },\n torch.tensor([[0, 1], [1, 2]]),\n (\n \"test data statistics:\\nShape: torch.Size([2, 2])\\nValue range: (0, 2)\\n\"\n \"Value: tensor([[0, 1],\\n [1, 2]])\\nAdditional info: 1.0\"\n ),\n]\n\nTEST_CASE_7 = [\n np.array([[0, 1], [1, 2]]),\n \"test data statistics:\\nShape: (2, 2)\\nValue range: (0, 2)\\nValue: [[0 1]\\n [1 2]]\\nAdditional info: 1.0\\n\",\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_stats.py_TestDataStats_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_stats.py_TestDataStats_", "embedding": null, "metadata": {"file_path": "tests/test_data_stats.py", "file_name": "test_data_stats.py", "file_type": "text/x-python", "category": "test", "start_line": 109, "end_line": 141, "span_ids": ["impl:15", "TestDataStats.test_file", "TestDataStats.test_value", "TestDataStats"], "tokens": 268}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestDataStats(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5, TEST_CASE_6])\n def test_value(self, input_param, input_data, expected_print):\n transform = DataStats(**input_param)\n _ = transform(input_data)\n self.assertEqual(transform.output, expected_print)\n\n @parameterized.expand([TEST_CASE_7])\n def test_file(self, input_data, expected_print):\n tempdir = tempfile.mkdtemp()\n filename = os.path.join(tempdir, \"test_data_stats.log\")\n handler = logging.FileHandler(filename, mode=\"w\")\n input_param = {\n \"prefix\": \"test data\",\n \"data_shape\": True,\n \"value_range\": True,\n \"data_value\": True,\n \"additional_info\": lambda x: np.mean(x),\n \"logger_handler\": handler,\n }\n transform = DataStats(**input_param)\n _ = transform(input_data)\n handler.stream.close()\n transform._logger.removeHandler(handler)\n with open(filename, \"r\") as f:\n content = f.read()\n self.assertEqual(content, expected_print)\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_statsd.py_unittest_TEST_CASE_6._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_statsd.py_unittest_TEST_CASE_6._", "embedding": null, "metadata": {"file_path": "tests/test_data_statsd.py", "file_name": "test_data_statsd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 101, "span_ids": ["impl:9", "docstring"], "tokens": 687}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport os\nimport shutil\nimport logging\nimport tempfile\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\nfrom monai.transforms import DataStatsd\n\nTEST_CASE_1 = [\n {\n \"keys\": \"img\",\n \"prefix\": \"test data\",\n \"data_shape\": False,\n \"value_range\": False,\n \"data_value\": False,\n \"additional_info\": None,\n },\n {\"img\": np.array([[0, 1], [1, 2]])},\n \"test data statistics:\",\n]\n\nTEST_CASE_2 = [\n {\n \"keys\": \"img\",\n \"prefix\": \"test data\",\n \"data_shape\": True,\n \"value_range\": False,\n \"data_value\": False,\n \"additional_info\": None,\n },\n {\"img\": np.array([[0, 1], [1, 2]])},\n \"test data statistics:\\nShape: (2, 2)\",\n]\n\nTEST_CASE_3 = [\n {\n \"keys\": \"img\",\n \"prefix\": \"test data\",\n \"data_shape\": True,\n \"value_range\": True,\n \"data_value\": False,\n \"additional_info\": None,\n },\n {\"img\": np.array([[0, 1], [1, 2]])},\n \"test data statistics:\\nShape: (2, 2)\\nValue range: (0, 2)\",\n]\n\nTEST_CASE_4 = [\n {\n \"keys\": \"img\",\n \"prefix\": \"test data\",\n \"data_shape\": True,\n \"value_range\": True,\n \"data_value\": True,\n \"additional_info\": None,\n },\n {\"img\": np.array([[0, 1], [1, 2]])},\n \"test data statistics:\\nShape: (2, 2)\\nValue range: (0, 2)\\nValue: [[0 1]\\n [1 2]]\",\n]\n\nTEST_CASE_5 = [\n {\n \"keys\": \"img\",\n \"prefix\": \"test data\",\n \"data_shape\": True,\n \"value_range\": True,\n \"data_value\": True,\n \"additional_info\": lambda x: np.mean(x),\n },\n {\"img\": np.array([[0, 1], [1, 2]])},\n \"test data statistics:\\nShape: (2, 2)\\nValue range: (0, 2)\\nValue: [[0 1]\\n [1 2]]\\nAdditional info: 1.0\",\n]\n\nTEST_CASE_6 = [\n {\n \"keys\": \"img\",\n \"prefix\": \"test data\",\n \"data_shape\": True,\n \"value_range\": True,\n \"data_value\": True,\n \"additional_info\": lambda x: torch.mean(x.float()),\n },\n {\"img\": torch.tensor([[0, 1], [1, 2]])},\n (\n \"test data statistics:\\nShape: torch.Size([2, 2])\\nValue range: (0, 2)\\n\"\n \"Value: tensor([[0, 1],\\n [1, 2]])\\nAdditional info: 1.0\"\n ),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_statsd.py_TEST_CASE_7_TEST_CASE_8._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_statsd.py_TEST_CASE_7_TEST_CASE_8._", "embedding": null, "metadata": {"file_path": "tests/test_data_statsd.py", "file_name": "test_data_statsd.py", "file_type": "text/x-python", "category": "test", "start_line": 103, "end_line": 119, "span_ids": ["impl:9"], "tokens": 216}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_7 = [\n {\n \"keys\": (\"img\", \"affine\"),\n \"prefix\": (\"image\", \"affine\"),\n \"data_shape\": True,\n \"value_range\": (True, False),\n \"data_value\": (False, True),\n \"additional_info\": (lambda x: np.mean(x), None),\n },\n {\"img\": np.array([[0, 1], [1, 2]]), \"affine\": np.eye(2, 2)},\n \"affine statistics:\\nShape: (2, 2)\\nValue: [[1. 0.]\\n [0. 1.]]\",\n]\n\nTEST_CASE_8 = [\n {\"img\": np.array([[0, 1], [1, 2]])},\n \"test data statistics:\\nShape: (2, 2)\\nValue range: (0, 2)\\nValue: [[0 1]\\n [1 2]]\\nAdditional info: 1.0\\n\",\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_statsd.py_TestDataStatsd_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_statsd.py_TestDataStatsd_", "embedding": null, "metadata": {"file_path": "tests/test_data_statsd.py", "file_name": "test_data_statsd.py", "file_type": "text/x-python", "category": "test", "start_line": 122, "end_line": 155, "span_ids": ["TestDataStatsd.test_file", "TestDataStatsd", "TestDataStatsd.test_value", "impl:17"], "tokens": 286}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestDataStatsd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5, TEST_CASE_6, TEST_CASE_7])\n def test_value(self, input_param, input_data, expected_print):\n transform = DataStatsd(**input_param)\n _ = transform(input_data)\n self.assertEqual(transform.printer.output, expected_print)\n\n @parameterized.expand([TEST_CASE_8])\n def test_file(self, input_data, expected_print):\n tempdir = tempfile.mkdtemp()\n filename = os.path.join(tempdir, \"test_stats.log\")\n handler = logging.FileHandler(filename, mode=\"w\")\n input_param = {\n \"keys\": \"img\",\n \"prefix\": \"test data\",\n \"data_shape\": True,\n \"value_range\": True,\n \"data_value\": True,\n \"additional_info\": lambda x: np.mean(x),\n \"logger_handler\": handler,\n }\n transform = DataStatsd(**input_param)\n _ = transform(input_data)\n handler.stream.close()\n transform.printer._logger.removeHandler(handler)\n with open(filename, \"r\") as f:\n content = f.read()\n self.assertEqual(content, expected_print)\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dataloader.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dataloader.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_dataloader.py", "file_name": "test_dataloader.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 40, "span_ids": ["TestDataLoader", "TestDataLoader.test_values", "impl", "docstring"], "tokens": 295}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nfrom monai.data import CacheDataset, DataLoader\nfrom monai.transforms import DataStatsd, SimulateDelayd, Compose\n\n\nclass TestDataLoader(unittest.TestCase):\n def test_values(self):\n datalist = [\n {\"image\": \"spleen_19.nii.gz\", \"label\": \"spleen_label_19.nii.gz\"},\n {\"image\": \"spleen_31.nii.gz\", \"label\": \"spleen_label_31.nii.gz\"},\n ]\n transform = Compose(\n [\n DataStatsd(keys=[\"image\", \"label\"], data_shape=False, value_range=False, data_value=True),\n SimulateDelayd(keys=[\"image\", \"label\"], delay_time=0.1),\n ]\n )\n dataset = CacheDataset(data=datalist, transform=transform, cache_rate=0.5, cache_num=1)\n dataloader = DataLoader(dataset=dataset, batch_size=2, num_workers=2)\n for d in dataloader:\n self.assertEqual(d[\"image\"][0], \"spleen_19.nii.gz\")\n self.assertEqual(d[\"image\"][1], \"spleen_31.nii.gz\")\n self.assertEqual(d[\"label\"][0], \"spleen_label_19.nii.gz\")\n self.assertEqual(d[\"label\"][1], \"spleen_label_31.nii.gz\")\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dataset.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dataset.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_dataset.py", "file_name": "test_dataset.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 80, "span_ids": ["TestDataset.test_shape", "impl:3", "TestDataset", "docstring"], "tokens": 707}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport os\nimport shutil\nimport numpy as np\nimport tempfile\nimport nibabel as nib\nfrom parameterized import parameterized\nfrom monai.data import Dataset\nfrom monai.transforms import Compose, LoadNiftid, SimulateDelayd\n\nTEST_CASE_1 = [(128, 128, 128)]\n\n\nclass TestDataset(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1])\n def test_shape(self, expected_shape):\n test_image = nib.Nifti1Image(np.random.randint(0, 2, size=[128, 128, 128]), np.eye(4))\n tempdir = tempfile.mkdtemp()\n nib.save(test_image, os.path.join(tempdir, \"test_image1.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_label1.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_extra1.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_image2.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_label2.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_extra2.nii.gz\"))\n test_data = [\n {\n \"image\": os.path.join(tempdir, \"test_image1.nii.gz\"),\n \"label\": os.path.join(tempdir, \"test_label1.nii.gz\"),\n \"extra\": os.path.join(tempdir, \"test_extra1.nii.gz\"),\n },\n {\n \"image\": os.path.join(tempdir, \"test_image2.nii.gz\"),\n \"label\": os.path.join(tempdir, \"test_label2.nii.gz\"),\n \"extra\": os.path.join(tempdir, \"test_extra2.nii.gz\"),\n },\n ]\n test_transform = Compose(\n [\n LoadNiftid(keys=[\"image\", \"label\", \"extra\"]),\n SimulateDelayd(keys=[\"image\", \"label\", \"extra\"], delay_time=[1e-7, 1e-6, 1e-5]),\n ]\n )\n dataset = Dataset(data=test_data, transform=test_transform)\n data1 = dataset[0]\n data2 = dataset[1]\n\n self.assertTupleEqual(data1[\"image\"].shape, expected_shape)\n self.assertTupleEqual(data1[\"label\"].shape, expected_shape)\n self.assertTupleEqual(data1[\"extra\"].shape, expected_shape)\n self.assertTupleEqual(data2[\"image\"].shape, expected_shape)\n self.assertTupleEqual(data2[\"label\"].shape, expected_shape)\n self.assertTupleEqual(data2[\"extra\"].shape, expected_shape)\n\n dataset = Dataset(data=test_data, transform=LoadNiftid(keys=[\"image\", \"label\", \"extra\"]))\n data1_simple = dataset[0]\n data2_simple = dataset[1]\n\n self.assertTupleEqual(data1_simple[\"image\"].shape, expected_shape)\n self.assertTupleEqual(data1_simple[\"label\"].shape, expected_shape)\n self.assertTupleEqual(data1_simple[\"extra\"].shape, expected_shape)\n self.assertTupleEqual(data2_simple[\"image\"].shape, expected_shape)\n self.assertTupleEqual(data2_simple[\"label\"].shape, expected_shape)\n self.assertTupleEqual(data2_simple[\"extra\"].shape, expected_shape)\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_decathlondataset.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_decathlondataset.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_decathlondataset.py", "file_name": "test_decathlondataset.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 72, "span_ids": ["TestDecathlonDataset", "TestDecathlonDataset.test_values", "impl", "docstring"], "tokens": 482}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport os\nimport shutil\nimport tempfile\n\nfrom monai.apps import DecathlonDataset\nfrom monai.transforms import LoadNiftid, AddChanneld, ScaleIntensityd, ToTensord, Compose\nfrom tests.utils import skip_if_quick\n\n\nclass TestDecathlonDataset(unittest.TestCase):\n @skip_if_quick\n def test_values(self):\n tempdir = tempfile.mkdtemp()\n transform = Compose(\n [\n LoadNiftid(keys=[\"image\", \"label\"]),\n AddChanneld(keys=[\"image\", \"label\"]),\n ScaleIntensityd(keys=\"image\"),\n ToTensord(keys=[\"image\", \"label\"]),\n ]\n )\n\n def _test_dataset(dataset):\n self.assertEqual(len(dataset), 52)\n self.assertTrue(\"image\" in dataset[0])\n self.assertTrue(\"label\" in dataset[0])\n self.assertTrue(\"image_meta_dict\" in dataset[0])\n self.assertTupleEqual(dataset[0][\"image\"].shape, (1, 33, 47, 34))\n\n try:\n data = DecathlonDataset(\n root_dir=tempdir, task=\"Task04_Hippocampus\", transform=transform, section=\"validation\", download=True\n )\n except RuntimeError as e:\n if str(e).startswith(\"download failed due to network issue or permission denied.\"):\n shutil.rmtree(tempdir)\n return\n\n _test_dataset(data)\n data = DecathlonDataset(\n root_dir=tempdir, task=\"Task04_Hippocampus\", transform=transform, section=\"validation\", download=False\n )\n _test_dataset(data)\n data = DecathlonDataset(root_dir=tempdir, task=\"Task04_Hippocampus\", section=\"validation\", download=False)\n self.assertTupleEqual(data[0][\"image\"].shape, (33, 47, 34))\n shutil.rmtree(os.path.join(tempdir, \"Task04_Hippocampus\"))\n try:\n data = DecathlonDataset(\n root_dir=tempdir, task=\"Task04_Hippocampus\", transform=transform, section=\"validation\", download=False\n )\n except RuntimeError as e:\n print(str(e))\n self.assertTrue(str(e).startswith(\"can not find dataset directory\"))\n\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_delete_itemsd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_delete_itemsd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_delete_itemsd.py", "file_name": "test_delete_itemsd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 36, "span_ids": ["TestDeleteItemsd", "impl:3", "TestDeleteItemsd.test_memory", "docstring"], "tokens": 177}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport time\nimport sys\nfrom parameterized import parameterized\nfrom monai.transforms import DeleteItemsd\n\nTEST_CASE_1 = [{\"keys\": [str(i) for i in range(30)]}, 20]\n\n\nclass TestDeleteItemsd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1])\n def test_memory(self, input_param, expected_key_size):\n input_data = dict()\n for i in range(50):\n input_data[str(i)] = [time.time()] * 100000\n result = DeleteItemsd(**input_param)(input_data)\n self.assertEqual(len(result.keys()), expected_key_size)\n self.assertGreaterEqual(\n sys.getsizeof(input_data) * float(expected_key_size) / len(input_data), sys.getsizeof(result)\n )\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_densenet.py_unittest_TEST_CASE_1._4_channel_3D_batch_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_densenet.py_unittest_TEST_CASE_1._4_channel_3D_batch_", "embedding": null, "metadata": {"file_path": "tests/test_densenet.py", "file_name": "test_densenet.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 24, "span_ids": ["docstring"], "tokens": 109}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.networks.nets import densenet121, densenet169, densenet201, densenet264\n\n\nTEST_CASE_1 = [ # 4-channel 3D, batch 16\n {\"spatial_dims\": 3, \"in_channels\": 2, \"out_channels\": 3},\n torch.randn(16, 2, 32, 64, 48),\n (16, 3),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_densenet.py_TestDENSENET_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_densenet.py_TestDENSENET_", "embedding": null, "metadata": {"file_path": "tests/test_densenet.py", "file_name": "test_densenet.py", "file_type": "text/x-python", "category": "test", "start_line": 27, "end_line": 59, "span_ids": ["TestDENSENET.test_264_shape", "TestDENSENET", "TestDENSENET.test_169_shape", "TestDENSENET.test_201_shape", "TestDENSENET.test_121_shape"], "tokens": 272}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestDENSENET(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1])\n def test_121_shape(self, input_param, input_data, expected_shape):\n net = densenet121(**input_param)\n net.eval()\n with torch.no_grad():\n result = net.forward(input_data)\n self.assertEqual(result.shape, expected_shape)\n\n @parameterized.expand([TEST_CASE_1])\n def test_169_shape(self, input_param, input_data, expected_shape):\n net = densenet169(**input_param)\n net.eval()\n with torch.no_grad():\n result = net.forward(input_data)\n self.assertEqual(result.shape, expected_shape)\n\n @parameterized.expand([TEST_CASE_1])\n def test_201_shape(self, input_param, input_data, expected_shape):\n net = densenet201(**input_param)\n net.eval()\n with torch.no_grad():\n result = net.forward(input_data)\n self.assertEqual(result.shape, expected_shape)\n\n @parameterized.expand([TEST_CASE_1])\n def test_264_shape(self, input_param, input_data, expected_shape):\n net = densenet264(**input_param)\n net.eval()\n with torch.no_grad():\n result = net.forward(input_data)\n self.assertEqual(result.shape, expected_shape)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dice_loss.py_unittest_TEST_CASES": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dice_loss.py_unittest_TEST_CASES", "embedding": null, "metadata": {"file_path": "tests/test_dice_loss.py", "file_name": "test_dice_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 111, "span_ids": ["docstring"], "tokens": 35}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.losses import DiceLoss\n\nTEST_CASES =\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dice_loss.py_TestDiceLoss_TestDiceLoss.test_ill_opts.None_2.DiceLoss_reduction_None_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dice_loss.py_TestDiceLoss_TestDiceLoss.test_ill_opts.None_2.DiceLoss_reduction_None_", "embedding": null, "metadata": {"file_path": "tests/test_dice_loss.py", "file_name": "test_dice_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 114, "end_line": 133, "span_ids": ["TestDiceLoss.test_shape", "TestDiceLoss.test_ill_shape", "TestDiceLoss", "TestDiceLoss.test_ill_opts"], "tokens": 227}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestDiceLoss(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_shape(self, input_param, input_data, expected_val):\n result = DiceLoss(**input_param).forward(**input_data)\n np.testing.assert_allclose(result.detach().cpu().numpy(), expected_val, rtol=1e-5)\n\n def test_ill_shape(self):\n loss = DiceLoss()\n with self.assertRaisesRegex(AssertionError, \"\"):\n loss.forward(torch.ones((1, 2, 3)), torch.ones((4, 5, 6)))\n\n def test_ill_opts(self):\n with self.assertRaisesRegex(ValueError, \"\"):\n DiceLoss(sigmoid=True, softmax=True)\n chn_input = torch.ones((1, 1, 3))\n chn_target = torch.ones((1, 1, 3))\n with self.assertRaisesRegex(ValueError, \"\"):\n DiceLoss(reduction=\"unknown\")(chn_input, chn_target)\n with self.assertRaisesRegex(ValueError, \"\"):\n DiceLoss(reduction=None)(chn_input, chn_target)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dice_loss.py_TestDiceLoss.test_input_warnings_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dice_loss.py_TestDiceLoss.test_input_warnings_", "embedding": null, "metadata": {"file_path": "tests/test_dice_loss.py", "file_name": "test_dice_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 135, "end_line": 151, "span_ids": ["impl:3", "TestDiceLoss.test_input_warnings"], "tokens": 147}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestDiceLoss(unittest.TestCase):\n\n def test_input_warnings(self):\n chn_input = torch.ones((1, 1, 3))\n chn_target = torch.ones((1, 1, 3))\n with self.assertWarns(Warning):\n loss = DiceLoss(include_background=False)\n loss.forward(chn_input, chn_target)\n with self.assertWarns(Warning):\n loss = DiceLoss(softmax=True)\n loss.forward(chn_input, chn_target)\n with self.assertWarns(Warning):\n loss = DiceLoss(to_onehot_y=True)\n loss.forward(chn_input, chn_target)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_discriminator.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_discriminator.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_discriminator.py", "file_name": "test_discriminator.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 53, "span_ids": ["impl:9", "TestDiscriminator.test_shape", "TestDiscriminator", "docstring"], "tokens": 344}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.networks.nets import Discriminator\n\n\nTEST_CASE_0 = [\n {\"in_shape\": (1, 64, 64), \"channels\": (2, 4, 8), \"strides\": (2, 2, 2), \"num_res_units\": 0},\n torch.rand(16, 1, 64, 64),\n (16, 1),\n]\n\nTEST_CASE_1 = [\n {\"in_shape\": (1, 64, 64), \"channels\": (2, 4, 8), \"strides\": (2, 2, 2), \"num_res_units\": 2},\n torch.rand(16, 1, 64, 64),\n (16, 1),\n]\n\nTEST_CASE_2 = [\n {\"in_shape\": (1, 64, 64), \"channels\": (2, 4), \"strides\": (2, 2), \"num_res_units\": 0},\n torch.rand(16, 1, 64, 64),\n (16, 1),\n]\n\nCASES = [TEST_CASE_0, TEST_CASE_1, TEST_CASE_2]\n\n\nclass TestDiscriminator(unittest.TestCase):\n @parameterized.expand(CASES)\n def test_shape(self, input_param, input_data, expected_shape):\n net = Discriminator(**input_param)\n net.eval()\n with torch.no_grad():\n result = net.forward(input_data)\n self.assertEqual(result.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_divisible_pad.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_divisible_pad.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_divisible_pad.py", "file_name": "test_divisible_pad.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 45, "span_ids": ["TestDivisiblePad", "TestDivisiblePad.test_pad_shape", "impl:5", "docstring"], "tokens": 252}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom monai.transforms import DivisiblePad\nfrom parameterized import parameterized\n\n# pad first dim to be divisible by 7, the second unchanged.\nTEST_CASE_1 = [\n {\"k\": (7, -1), \"mode\": \"constant\"},\n np.zeros((3, 8, 7)),\n np.zeros((3, 14, 7)),\n]\n\n# pad all dimensions to be divisible by 5\nTEST_CASE_2 = [\n {\"k\": 5, \"mode\": \"constant\"},\n np.zeros((3, 10, 5, 17)),\n np.zeros((3, 10, 5, 20)),\n]\n\n\nclass TestDivisiblePad(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2])\n def test_pad_shape(self, input_param, input_data, expected_val):\n padder = DivisiblePad(**input_param)\n result = padder(input_data)\n self.assertAlmostEqual(result.shape, expected_val.shape)\n result = padder(input_data, mode=input_param[\"mode\"])\n self.assertAlmostEqual(result.shape, expected_val.shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_divisible_padd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_divisible_padd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_divisible_padd.py", "file_name": "test_divisible_padd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 47, "span_ids": ["TestDivisiblePadd.test_pad_shape", "TestDivisiblePadd", "impl:7", "docstring"], "tokens": 284}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom monai.transforms import DivisiblePadd\nfrom parameterized import parameterized\n\nTEST_CASE_1 = [\n {\"keys\": [\"img\"], \"k\": [4, 3, 2], \"mode\": \"constant\"},\n {\"img\": np.zeros((3, 8, 8, 4))},\n np.zeros((3, 8, 9, 4)),\n]\n\nTEST_CASE_2 = [\n {\"keys\": [\"img\"], \"k\": 7, \"mode\": \"constant\"},\n {\"img\": np.zeros((3, 8, 7))},\n np.zeros((3, 14, 7)),\n]\n\nTEST_CASE_3 = [\n {\"keys\": [\"img\"], \"k\": 0, \"mode\": {\"constant\"}},\n {\"img\": np.zeros((3, 8))},\n np.zeros((3, 8)),\n]\n\n\nclass TestDivisiblePadd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_pad_shape(self, input_param, input_data, expected_val):\n padder = DivisiblePadd(**input_param)\n result = padder(input_data)\n np.testing.assert_allclose(result[\"img\"], expected_val)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_download_and_extract.py_os_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_download_and_extract.py_os_", "embedding": null, "metadata": {"file_path": "tests/test_download_and_extract.py", "file_name": "test_download_and_extract.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 56, "span_ids": ["TestDownloadAndExtract.test_actions", "TestDownloadAndExtract", "impl", "docstring"], "tokens": 339}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport shutil\nimport tempfile\nimport unittest\nfrom urllib.error import ContentTooShortError, HTTPError\n\nfrom tests.utils import skip_if_quick\n\nfrom monai.apps import download_and_extract, download_url, extractall\n\n\nclass TestDownloadAndExtract(unittest.TestCase):\n @skip_if_quick\n def test_actions(self):\n tempdir = tempfile.mkdtemp()\n url = \"https://www.dropbox.com/s/5wwskxctvcxiuea/MedNIST.tar.gz?dl=1\"\n filepath = os.path.join(tempdir, \"MedNIST.tar.gz\")\n output_dir = tempdir\n md5_value = \"0bc7306e7427e00ad1c5526a6677552d\"\n try:\n download_and_extract(url, filepath, output_dir, md5_value)\n download_and_extract(url, filepath, output_dir, md5_value)\n except (ContentTooShortError, HTTPError):\n pass # ignore remote errors in this test\n\n wrong_md5 = \"0\"\n try:\n download_url(url, filepath, wrong_md5)\n except RuntimeError as e:\n self.assertTrue(str(e).startswith(\"MD5 check\"))\n shutil.rmtree(os.path.join(tempdir, \"MedNIST\"))\n except (ContentTooShortError, HTTPError):\n pass # ignore remote errors in this test\n\n try:\n extractall(filepath, output_dir, wrong_md5)\n except RuntimeError as e:\n self.assertTrue(str(e).startswith(\"MD5 check\"))\n\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_downsample_block.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_downsample_block.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_downsample_block.py", "file_name": "test_downsample_block.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 51, "span_ids": ["TestMaxAvgPool", "impl:3", "TestMaxAvgPool.test_shape", "docstring"], "tokens": 421}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport torch\nfrom monai.networks.blocks import MaxAvgPool\nfrom parameterized import parameterized\n\nTEST_CASES = [\n [{\"spatial_dims\": 2, \"kernel_size\": 2}, torch.randn(7, 4, 64, 48), (7, 8, 32, 24)], # 4-channel 2D, batch 7\n [{\"spatial_dims\": 1, \"kernel_size\": 4}, torch.randn(16, 4, 63), (16, 8, 15)], # 4-channel 1D, batch 16\n [ # 4-channel 1D, batch 16\n {\"spatial_dims\": 1, \"kernel_size\": 4, \"padding\": 1},\n torch.randn(16, 4, 63),\n (16, 8, 16),\n ],\n [ # 4-channel 3D, batch 16\n {\"spatial_dims\": 3, \"kernel_size\": 3, \"ceil_mode\": True},\n torch.randn(16, 4, 32, 24, 48),\n (16, 8, 11, 8, 16),\n ],\n [ # 1-channel 3D, batch 16\n {\"spatial_dims\": 3, \"kernel_size\": 3, \"ceil_mode\": False},\n torch.randn(16, 1, 32, 24, 48),\n (16, 2, 10, 8, 16),\n ],\n]\n\n\nclass TestMaxAvgPool(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_shape(self, input_param, input_data, expected_shape):\n net = MaxAvgPool(**input_param)\n net.eval()\n with torch.no_grad():\n result = net(input_data)\n self.assertEqual(result.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_ensemble_evaluator.py_torch_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_ensemble_evaluator.py_torch_", "embedding": null, "metadata": {"file_path": "tests/test_ensemble_evaluator.py", "file_name": "test_ensemble_evaluator.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 63, "span_ids": ["TestEnsembleEvaluator", "TestEnsembleEvaluator.test_content", "impl", "docstring"], "tokens": 350}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import torch\nimport unittest\nfrom ignite.engine import Events\nfrom monai.engines import EnsembleEvaluator\n\n\nclass TestEnsembleEvaluator(unittest.TestCase):\n def test_content(self):\n device = torch.device(\"cpu:0\")\n\n class TestDataset(torch.utils.data.Dataset):\n def __len__(self):\n return 8\n\n def __getitem__(self, index):\n return {\"image\": torch.tensor([index]), \"label\": torch.zeros(1)}\n\n val_loader = torch.utils.data.DataLoader(TestDataset())\n\n class TestNet(torch.nn.Module):\n def __init__(self, func):\n super().__init__()\n self.func = func\n\n def forward(self, x):\n return self.func(x)\n\n net0 = TestNet(lambda x: x + 1)\n net1 = TestNet(lambda x: x + 2)\n net2 = TestNet(lambda x: x + 3)\n net3 = TestNet(lambda x: x + 4)\n net4 = TestNet(lambda x: x + 5)\n\n val_engine = EnsembleEvaluator(\n device=device,\n val_data_loader=val_loader,\n networks=[net0, net1, net2, net3, net4],\n pred_keys=[\"pred0\", \"pred1\", \"pred2\", \"pred3\", \"pred4\"],\n )\n\n @val_engine.on(Events.ITERATION_COMPLETED)\n def run_post_transform(engine):\n for i in range(5):\n expected_value = engine.state.iteration + i\n torch.testing.assert_allclose(engine.state.output[f\"pred{i}\"], expected_value)\n\n val_engine.run()\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_flip.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_flip.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_flip.py", "file_name": "test_flip.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 44, "span_ids": ["TestFlip.test_invalid_inputs", "TestFlip.test_correct_results", "impl:5", "TestFlip", "docstring"], "tokens": 235}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.transforms import Flip\nfrom tests.utils import NumpyImageTestCase2D\n\nINVALID_CASES = [(\"wrong_axis\", [\"s\", 1], TypeError), (\"not_numbers\", \"s\", TypeError)]\n\nVALID_CASES = [(\"no_axis\", None), (\"one_axis\", 1), (\"many_axis\", [0, 1])]\n\n\nclass TestFlip(NumpyImageTestCase2D):\n @parameterized.expand(INVALID_CASES)\n def test_invalid_inputs(self, _, spatial_axis, raises):\n with self.assertRaises(raises):\n flip = Flip(spatial_axis)\n flip(self.imt[0])\n\n @parameterized.expand(VALID_CASES)\n def test_correct_results(self, _, spatial_axis):\n flip = Flip(spatial_axis=spatial_axis)\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.flip(channel, spatial_axis))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(expected, flip(self.imt[0])))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_flipd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_flipd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_flipd.py", "file_name": "test_flipd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 45, "span_ids": ["TestFlipd.test_invalid_cases", "TestFlipd.test_correct_results", "impl:5", "docstring", "TestFlipd"], "tokens": 262}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.transforms import Flipd\nfrom tests.utils import NumpyImageTestCase2D\n\nINVALID_CASES = [(\"wrong_axis\", [\"s\", 1], TypeError), (\"not_numbers\", \"s\", TypeError)]\n\nVALID_CASES = [(\"no_axis\", None), (\"one_axis\", 1), (\"many_axis\", [0, 1])]\n\n\nclass TestFlipd(NumpyImageTestCase2D):\n @parameterized.expand(INVALID_CASES)\n def test_invalid_cases(self, _, spatial_axis, raises):\n with self.assertRaises(raises):\n flip = Flipd(keys=\"img\", spatial_axis=spatial_axis)\n flip({\"img\": self.imt[0]})\n\n @parameterized.expand(VALID_CASES)\n def test_correct_results(self, _, spatial_axis):\n flip = Flipd(keys=\"img\", spatial_axis=spatial_axis)\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.flip(channel, spatial_axis))\n expected = np.stack(expected)\n res = flip({\"img\": self.imt[0]})\n assert np.allclose(expected, res[\"img\"])\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_unittest_TestFocalLoss.test_consistency_with_cross_entropy_2d.self_assertAlmostEqual_ma": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_unittest_TestFocalLoss.test_consistency_with_cross_entropy_2d.self_assertAlmostEqual_ma", "embedding": null, "metadata": {"file_path": "tests/test_focal_loss.py", "file_name": "test_focal_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 43, "span_ids": ["TestFocalLoss", "TestFocalLoss.test_consistency_with_cross_entropy_2d", "docstring"], "tokens": 300}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nfrom monai.losses import FocalLoss\n\n\nclass TestFocalLoss(unittest.TestCase):\n def test_consistency_with_cross_entropy_2d(self):\n # For gamma=0 the focal loss reduces to the cross entropy loss\n focal_loss = FocalLoss(gamma=0.0, reduction=\"mean\")\n ce = nn.CrossEntropyLoss(reduction=\"mean\")\n max_error = 0\n class_num = 10\n batch_size = 128\n for _ in range(100):\n # Create a random tensor of shape (batch_size, class_num, 8, 4)\n x = torch.rand(batch_size, class_num, 8, 4, requires_grad=True)\n # Create a random batch of classes\n l = torch.randint(low=0, high=class_num, size=(batch_size, 1, 8, 4))\n if torch.cuda.is_available():\n x = x.cuda()\n l = l.cuda()\n output0 = focal_loss(x, l)\n output1 = ce(x, l[:, 0])\n a = float(output0.cpu().detach())\n b = float(output1.cpu().detach())\n if abs(a - b) > max_error:\n max_error = abs(a - b)\n self.assertAlmostEqual(max_error, 0.0, places=3)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_consistency_with_cross_entropy_classification_TestFocalLoss.test_consistency_with_cross_entropy_classification.self_assertAlmostEqual_ma": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_consistency_with_cross_entropy_classification_TestFocalLoss.test_consistency_with_cross_entropy_classification.self_assertAlmostEqual_ma", "embedding": null, "metadata": {"file_path": "tests/test_focal_loss.py", "file_name": "test_focal_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 45, "end_line": 67, "span_ids": ["TestFocalLoss.test_consistency_with_cross_entropy_classification"], "tokens": 258}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestFocalLoss(unittest.TestCase):\n\n def test_consistency_with_cross_entropy_classification(self):\n # for gamma=0 the focal loss reduces to the cross entropy loss\n focal_loss = FocalLoss(gamma=0.0, reduction=\"mean\")\n ce = nn.CrossEntropyLoss(reduction=\"mean\")\n max_error = 0\n class_num = 10\n batch_size = 128\n for _ in range(100):\n # Create a random scores tensor of shape (batch_size, class_num)\n x = torch.rand(batch_size, class_num, requires_grad=True)\n # Create a random batch of classes\n l = torch.randint(low=0, high=class_num, size=(batch_size, 1))\n l = l.long()\n if torch.cuda.is_available():\n x = x.cuda()\n l = l.cuda()\n output0 = focal_loss(x, l)\n output1 = ce(x, l[:, 0])\n a = float(output0.cpu().detach())\n b = float(output1.cpu().detach())\n if abs(a - b) > max_error:\n max_error = abs(a - b)\n self.assertAlmostEqual(max_error, 0.0, places=3)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_bin_seg_2d_TestFocalLoss.test_bin_seg_2d.self_assertAlmostEqual_fo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_bin_seg_2d_TestFocalLoss.test_bin_seg_2d.self_assertAlmostEqual_fo", "embedding": null, "metadata": {"file_path": "tests/test_focal_loss.py", "file_name": "test_focal_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 69, "end_line": 82, "span_ids": ["TestFocalLoss.test_bin_seg_2d"], "tokens": 235}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestFocalLoss(unittest.TestCase):\n\n def test_bin_seg_2d(self):\n # define 2d examples\n target = torch.tensor([[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]])\n # add another dimension corresponding to the batch (batch size = 1 here)\n target = target.unsqueeze(0) # shape (1, H, W)\n pred_very_good = 1000 * F.one_hot(target, num_classes=2).permute(0, 3, 1, 2).float()\n\n # initialize the mean dice loss\n loss = FocalLoss()\n\n # focal loss for pred_very_good should be close to 0\n target = target.unsqueeze(1) # shape (1, 1, H, W)\n focal_loss_good = float(loss(pred_very_good, target).cpu())\n self.assertAlmostEqual(focal_loss_good, 0.0, places=3)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_empty_class_2d_TestFocalLoss.test_empty_class_2d.self_assertAlmostEqual_fo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_empty_class_2d_TestFocalLoss.test_empty_class_2d.self_assertAlmostEqual_fo", "embedding": null, "metadata": {"file_path": "tests/test_focal_loss.py", "file_name": "test_focal_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 84, "end_line": 98, "span_ids": ["TestFocalLoss.test_empty_class_2d"], "tokens": 242}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestFocalLoss(unittest.TestCase):\n\n def test_empty_class_2d(self):\n num_classes = 2\n # define 2d examples\n target = torch.tensor([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])\n # add another dimension corresponding to the batch (batch size = 1 here)\n target = target.unsqueeze(0) # shape (1, H, W)\n pred_very_good = 1000 * F.one_hot(target, num_classes=num_classes).permute(0, 3, 1, 2).float()\n\n # initialize the mean dice loss\n loss = FocalLoss()\n\n # focal loss for pred_very_good should be close to 0\n target = target.unsqueeze(1) # shape (1, 1, H, W)\n focal_loss_good = float(loss(pred_very_good, target).cpu())\n self.assertAlmostEqual(focal_loss_good, 0.0, places=3)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_multi_class_seg_2d_TestFocalLoss.test_multi_class_seg_2d.None_1": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_multi_class_seg_2d_TestFocalLoss.test_multi_class_seg_2d.None_1", "embedding": null, "metadata": {"file_path": "tests/test_focal_loss.py", "file_name": "test_focal_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 100, "end_line": 118, "span_ids": ["TestFocalLoss.test_multi_class_seg_2d"], "tokens": 321}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestFocalLoss(unittest.TestCase):\n\n def test_multi_class_seg_2d(self):\n num_classes = 6 # labels 0 to 5\n # define 2d examples\n target = torch.tensor([[0, 0, 0, 0], [0, 1, 2, 0], [0, 3, 4, 0], [0, 0, 0, 0]])\n # add another dimension corresponding to the batch (batch size = 1 here)\n target = target.unsqueeze(0) # shape (1, H, W)\n pred_very_good = 1000 * F.one_hot(target, num_classes=num_classes).permute(0, 3, 1, 2).float()\n # initialize the mean dice loss\n loss = FocalLoss()\n\n # focal loss for pred_very_good should be close to 0\n target_one_hot = F.one_hot(target, num_classes=num_classes).permute(0, 3, 1, 2) # test one hot\n target = target.unsqueeze(1) # shape (1, 1, H, W)\n\n focal_loss_good = float(loss(pred_very_good, target).cpu())\n self.assertAlmostEqual(focal_loss_good, 0.0, places=3)\n\n focal_loss_good = float(loss(pred_very_good, target_one_hot).cpu())\n self.assertAlmostEqual(focal_loss_good, 0.0, places=3)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_bin_seg_3d_TestFocalLoss.test_bin_seg_3d.None_1": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_bin_seg_3d_TestFocalLoss.test_bin_seg_3d.None_1", "embedding": null, "metadata": {"file_path": "tests/test_focal_loss.py", "file_name": "test_focal_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 120, "end_line": 147, "span_ids": ["TestFocalLoss.test_bin_seg_3d"], "tokens": 452}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestFocalLoss(unittest.TestCase):\n\n def test_bin_seg_3d(self):\n num_classes = 2 # labels 0, 1\n # define 3d examples\n target = torch.tensor(\n [\n # raw 0\n [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]],\n # raw 1\n [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]],\n # raw 2\n [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]],\n ]\n )\n # add another dimension corresponding to the batch (batch size = 1 here)\n target = target.unsqueeze(0) # shape (1, H, W, D)\n target_one_hot = F.one_hot(target, num_classes=num_classes).permute(0, 4, 1, 2, 3) # test one hot\n pred_very_good = 1000 * F.one_hot(target, num_classes=num_classes).permute(0, 4, 1, 2, 3).float()\n\n # initialize the mean dice loss\n loss = FocalLoss()\n\n # focal loss for pred_very_good should be close to 0\n target = target.unsqueeze(1) # shape (1, 1, H, W)\n focal_loss_good = float(loss(pred_very_good, target).cpu())\n self.assertAlmostEqual(focal_loss_good, 0.0, places=3)\n\n focal_loss_good = float(loss(pred_very_good, target_one_hot).cpu())\n self.assertAlmostEqual(focal_loss_good, 0.0, places=3)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_ill_opts_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_focal_loss.py_TestFocalLoss.test_ill_opts_", "embedding": null, "metadata": {"file_path": "tests/test_focal_loss.py", "file_name": "test_focal_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 149, "end_line": 166, "span_ids": ["TestFocalLoss.test_ill_shape", "TestFocalLoss.test_ill_opts", "impl"], "tokens": 171}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestFocalLoss(unittest.TestCase):\n\n def test_ill_opts(self):\n chn_input = torch.ones((1, 2, 3))\n chn_target = torch.ones((1, 1, 3))\n with self.assertRaisesRegex(ValueError, \"\"):\n FocalLoss(reduction=\"unknown\")(chn_input, chn_target)\n with self.assertRaisesRegex(ValueError, \"\"):\n FocalLoss(reduction=None)(chn_input, chn_target)\n\n def test_ill_shape(self):\n chn_input = torch.ones((1, 2, 3))\n chn_target = torch.ones((1, 3))\n with self.assertRaisesRegex(ValueError, \"\"):\n FocalLoss(reduction=\"mean\")(chn_input, chn_target)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_filter.py_unittest_GaussianFilterTestCase.test_1d.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_filter.py_unittest_GaussianFilterTestCase.test_1d.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_gaussian_filter.py", "file_name": "test_gaussian_filter.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 43, "span_ids": ["GaussianFilterTestCase.test_1d", "GaussianFilterTestCase", "docstring"], "tokens": 211}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\n\nfrom monai.networks.layers import GaussianFilter\n\n\nclass GaussianFilterTestCase(unittest.TestCase):\n def test_1d(self):\n a = torch.ones(1, 8, 10)\n g = GaussianFilter(1, 3, 3).to(torch.device(\"cpu:0\"))\n expected = np.array(\n [\n [\n [\n 0.56658804,\n 0.69108766,\n 0.79392236,\n 0.86594427,\n 0.90267116,\n 0.9026711,\n 0.8659443,\n 0.7939224,\n 0.6910876,\n 0.56658804,\n ]\n ]\n ]\n )\n expected = np.tile(expected, (1, 8, 1))\n np.testing.assert_allclose(g(a).cpu().numpy(), expected, rtol=1e-5)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_filter.py_GaussianFilterTestCase.test_2d_GaussianFilterTestCase.test_2d.if_torch_cuda_is_availabl.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_filter.py_GaussianFilterTestCase.test_2d_GaussianFilterTestCase.test_2d.if_torch_cuda_is_availabl.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_gaussian_filter.py", "file_name": "test_gaussian_filter.py", "file_type": "text/x-python", "category": "test", "start_line": 45, "end_line": 63, "span_ids": ["GaussianFilterTestCase.test_2d"], "tokens": 216}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class GaussianFilterTestCase(unittest.TestCase):\n\n def test_2d(self):\n a = torch.ones(1, 1, 3, 3)\n g = GaussianFilter(2, 3, 3).to(torch.device(\"cpu:0\"))\n expected = np.array(\n [\n [\n [\n [0.13380532, 0.14087981, 0.13380532],\n [0.14087981, 0.14832835, 0.14087981],\n [0.13380532, 0.14087981, 0.13380532],\n ]\n ]\n ]\n )\n\n np.testing.assert_allclose(g(a).cpu().numpy(), expected, rtol=1e-5)\n if torch.cuda.is_available():\n g = GaussianFilter(2, 3, 3).to(torch.device(\"cuda:0\"))\n np.testing.assert_allclose(g(a.cuda()).cpu().numpy(), expected, rtol=1e-2)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_filter.py_GaussianFilterTestCase.test_3d_GaussianFilterTestCase.test_3d.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_filter.py_GaussianFilterTestCase.test_3d_GaussianFilterTestCase.test_3d.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_gaussian_filter.py", "file_name": "test_gaussian_filter.py", "file_type": "text/x-python", "category": "test", "start_line": 65, "end_line": 96, "span_ids": ["GaussianFilterTestCase.test_3d"], "tokens": 464}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class GaussianFilterTestCase(unittest.TestCase):\n\n def test_3d(self):\n a = torch.ones(1, 1, 4, 3, 4)\n g = GaussianFilter(3, 3, 3).to(torch.device(\"cpu:0\"))\n expected = np.array(\n [\n [\n [\n [\n [0.07294822, 0.08033235, 0.08033235, 0.07294822],\n [0.07680509, 0.08457965, 0.08457965, 0.07680509],\n [0.07294822, 0.08033235, 0.08033235, 0.07294822],\n ],\n [\n [0.08033235, 0.08846395, 0.08846395, 0.08033235],\n [0.08457965, 0.09314119, 0.09314119, 0.08457966],\n [0.08033235, 0.08846396, 0.08846396, 0.08033236],\n ],\n [\n [0.08033235, 0.08846395, 0.08846395, 0.08033235],\n [0.08457965, 0.09314119, 0.09314119, 0.08457966],\n [0.08033235, 0.08846396, 0.08846396, 0.08033236],\n ],\n [\n [0.07294822, 0.08033235, 0.08033235, 0.07294822],\n [0.07680509, 0.08457965, 0.08457965, 0.07680509],\n [0.07294822, 0.08033235, 0.08033235, 0.07294822],\n ],\n ]\n ]\n ]\n )\n np.testing.assert_allclose(g(a).cpu().numpy(), expected, rtol=1e-5)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_filter.py_GaussianFilterTestCase.test_3d_sigmas_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_filter.py_GaussianFilterTestCase.test_3d_sigmas_", "embedding": null, "metadata": {"file_path": "tests/test_gaussian_filter.py", "file_name": "test_gaussian_filter.py", "file_type": "text/x-python", "category": "test", "start_line": 98, "end_line": 126, "span_ids": ["GaussianFilterTestCase.test_wrong_args", "GaussianFilterTestCase.test_3d_sigmas", "impl"], "tokens": 421}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class GaussianFilterTestCase(unittest.TestCase):\n\n def test_3d_sigmas(self):\n a = torch.ones(1, 1, 4, 3, 2)\n g = GaussianFilter(3, [3, 2, 1], 3).to(torch.device(\"cpu:0\"))\n expected = np.array(\n [\n [\n [\n [[0.1422854, 0.1422854], [0.15806103, 0.15806103], [0.1422854, 0.1422854]],\n [[0.15668818, 0.15668817], [0.17406069, 0.17406069], [0.15668818, 0.15668817]],\n [[0.15668818, 0.15668817], [0.17406069, 0.17406069], [0.15668818, 0.15668817]],\n [[0.1422854, 0.1422854], [0.15806103, 0.15806103], [0.1422854, 0.1422854]],\n ]\n ]\n ]\n )\n np.testing.assert_allclose(g(a).cpu().numpy(), expected, rtol=1e-5)\n if torch.cuda.is_available():\n g = GaussianFilter(3, [3, 2, 1], 3).to(torch.device(\"cuda:0\"))\n np.testing.assert_allclose(g(a.cuda()).cpu().numpy(), expected, rtol=1e-2)\n\n def test_wrong_args(self):\n with self.assertRaisesRegex(ValueError, \"\"):\n GaussianFilter(3, [3, 2], 3).to(torch.device(\"cpu:0\"))\n GaussianFilter(3, [3, 2, 1], 3).to(torch.device(\"cpu:0\")) # test init\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generalized_dice_loss.py_unittest_TEST_CASES": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generalized_dice_loss.py_unittest_TEST_CASES", "embedding": null, "metadata": {"file_path": "tests/test_generalized_dice_loss.py", "file_name": "test_generalized_dice_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 111, "span_ids": ["docstring"], "tokens": 37}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.losses import GeneralizedDiceLoss\n\nTEST_CASES =\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generalized_dice_loss.py_TestGeneralizedDiceLoss_TestGeneralizedDiceLoss.test_ill_shape.with_self_assertRaisesReg.loss_forward_torch_ones_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generalized_dice_loss.py_TestGeneralizedDiceLoss_TestGeneralizedDiceLoss.test_ill_shape.with_self_assertRaisesReg.loss_forward_torch_ones_", "embedding": null, "metadata": {"file_path": "tests/test_generalized_dice_loss.py", "file_name": "test_generalized_dice_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 114, "end_line": 123, "span_ids": ["TestGeneralizedDiceLoss.test_shape", "TestGeneralizedDiceLoss", "TestGeneralizedDiceLoss.test_ill_shape"], "tokens": 127}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestGeneralizedDiceLoss(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_shape(self, input_param, input_data, expected_val):\n result = GeneralizedDiceLoss(**input_param).forward(**input_data)\n np.testing.assert_allclose(result.detach().cpu().numpy(), expected_val, rtol=1e-5)\n\n def test_ill_shape(self):\n loss = GeneralizedDiceLoss()\n with self.assertRaisesRegex(AssertionError, \"\"):\n loss.forward(torch.ones((1, 2, 3)), torch.ones((4, 5, 6)))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generalized_dice_loss.py_TestGeneralizedDiceLoss.test_ill_opts_TestGeneralizedDiceLoss.test_ill_opts.None_2.GeneralizedDiceLoss_reduc": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generalized_dice_loss.py_TestGeneralizedDiceLoss.test_ill_opts_TestGeneralizedDiceLoss.test_ill_opts.None_2.GeneralizedDiceLoss_reduc", "embedding": null, "metadata": {"file_path": "tests/test_generalized_dice_loss.py", "file_name": "test_generalized_dice_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 125, "end_line": 133, "span_ids": ["TestGeneralizedDiceLoss.test_ill_opts"], "tokens": 121}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestGeneralizedDiceLoss(unittest.TestCase):\n\n def test_ill_opts(self):\n with self.assertRaisesRegex(ValueError, \"\"):\n GeneralizedDiceLoss(sigmoid=True, softmax=True)\n chn_input = torch.ones((1, 1, 3))\n chn_target = torch.ones((1, 1, 3))\n with self.assertRaisesRegex(ValueError, \"\"):\n GeneralizedDiceLoss(reduction=\"unknown\")(chn_input, chn_target)\n with self.assertRaisesRegex(ValueError, \"\"):\n GeneralizedDiceLoss(reduction=None)(chn_input, chn_target)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generalized_dice_loss.py_TestGeneralizedDiceLoss.test_input_warnings_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generalized_dice_loss.py_TestGeneralizedDiceLoss.test_input_warnings_", "embedding": null, "metadata": {"file_path": "tests/test_generalized_dice_loss.py", "file_name": "test_generalized_dice_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 135, "end_line": 151, "span_ids": ["impl:3", "TestGeneralizedDiceLoss.test_input_warnings"], "tokens": 155}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestGeneralizedDiceLoss(unittest.TestCase):\n\n def test_input_warnings(self):\n chn_input = torch.ones((1, 1, 3))\n chn_target = torch.ones((1, 1, 3))\n with self.assertWarns(Warning):\n loss = GeneralizedDiceLoss(include_background=False)\n loss.forward(chn_input, chn_target)\n with self.assertWarns(Warning):\n loss = GeneralizedDiceLoss(softmax=True)\n loss.forward(chn_input, chn_target)\n with self.assertWarns(Warning):\n loss = GeneralizedDiceLoss(to_onehot_y=True)\n loss.forward(chn_input, chn_target)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generate_pos_neg_label_crop_centers.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generate_pos_neg_label_crop_centers.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_generate_pos_neg_label_crop_centers.py", "file_name": "test_generate_pos_neg_label_crop_centers.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 45, "span_ids": ["TestGeneratePosNegLabelCropCenters", "impl:3", "TestGeneratePosNegLabelCropCenters.test_type_shape", "docstring"], "tokens": 227}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.transforms import generate_pos_neg_label_crop_centers\n\nTEST_CASE_1 = [\n {\n \"label\": np.random.randint(0, 2, size=[3, 3, 3, 3]),\n \"spatial_size\": [2, 2, 2],\n \"num_samples\": 2,\n \"pos_ratio\": 1.0,\n \"image\": None,\n \"image_threshold\": 0,\n \"rand_state\": np.random.RandomState(),\n },\n list,\n 2,\n 3,\n]\n\n\nclass TestGeneratePosNegLabelCropCenters(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1])\n def test_type_shape(self, input_data, expected_type, expected_count, expected_shape):\n result = generate_pos_neg_label_crop_centers(**input_data)\n self.assertIsInstance(result, expected_type)\n self.assertEqual(len(result), expected_count)\n self.assertEqual(len(result[0]), expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generate_spatial_bounding_box.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generate_spatial_bounding_box.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_generate_spatial_bounding_box.py", "file_name": "test_generate_spatial_bounding_box.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 68, "span_ids": ["TestGenerateSpatialBoundingBox", "impl:7", "TestGenerateSpatialBoundingBox.test_value", "docstring", "impl:9"], "tokens": 645}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.transforms import generate_spatial_bounding_box\n\nTEST_CASE_1 = [\n {\n \"img\": np.array([[[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 3, 2, 0], [0, 1, 2, 1, 0], [0, 0, 0, 0, 0]]]),\n \"select_fn\": lambda x: x > 0,\n \"channel_indexes\": None,\n \"margin\": 0,\n },\n ([1, 1], [4, 4]),\n]\n\nTEST_CASE_2 = [\n {\n \"img\": np.array([[[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 3, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]]),\n \"select_fn\": lambda x: x > 1,\n \"channel_indexes\": None,\n \"margin\": 0,\n },\n ([2, 2], [3, 3]),\n]\n\nTEST_CASE_3 = [\n {\n \"img\": np.array([[[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 3, 2, 0], [0, 1, 2, 1, 0], [0, 0, 0, 0, 0]]]),\n \"select_fn\": lambda x: x > 0,\n \"channel_indexes\": 0,\n \"margin\": 0,\n },\n ([1, 1], [4, 4]),\n]\n\nTEST_CASE_4 = [\n {\n \"img\": np.array([[[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 3, 2, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]]),\n \"select_fn\": lambda x: x > 0,\n \"channel_indexes\": None,\n \"margin\": 1,\n },\n ([0, 0], [4, 5]),\n]\n\n\nclass TestGenerateSpatialBoundingBox(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4])\n def test_value(self, input_data, expected_box):\n result = generate_spatial_bounding_box(**input_data)\n self.assertTupleEqual(result, expected_box)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generator.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generator.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_generator.py", "file_name": "test_generator.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 52, "span_ids": ["TestGenerator", "impl:9", "TestGenerator.test_shape", "docstring"], "tokens": 362}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.networks.nets import Generator\n\nTEST_CASE_0 = [\n {\"latent_shape\": (64,), \"start_shape\": (8, 8, 8), \"channels\": (8, 4, 1), \"strides\": (2, 2, 2), \"num_res_units\": 0},\n torch.rand(16, 64),\n (16, 1, 64, 64),\n]\n\nTEST_CASE_1 = [\n {\"latent_shape\": (64,), \"start_shape\": (8, 8, 8), \"channels\": (8, 4, 1), \"strides\": (2, 2, 2), \"num_res_units\": 2},\n torch.rand(16, 64),\n (16, 1, 64, 64),\n]\n\nTEST_CASE_2 = [\n {\"latent_shape\": (64,), \"start_shape\": (8, 8, 8), \"channels\": (8, 1), \"strides\": (2, 2), \"num_res_units\": 2},\n torch.rand(16, 64),\n (16, 1, 32, 32),\n]\n\nCASES = [TEST_CASE_0, TEST_CASE_1, TEST_CASE_2]\n\n\nclass TestGenerator(unittest.TestCase):\n @parameterized.expand(CASES)\n def test_shape(self, input_param, input_data, expected_shape):\n net = Generator(**input_param)\n net.eval()\n with torch.no_grad():\n result = net.forward(input_data)\n self.assertEqual(result.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_loader.py_tempfile_TestHandlerCheckpointLoader.test_one_save_one_load.shutil_rmtree_tempdir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_loader.py_tempfile_TestHandlerCheckpointLoader.test_one_save_one_load.shutil_rmtree_tempdir_", "embedding": null, "metadata": {"file_path": "tests/test_handler_checkpoint_loader.py", "file_name": "test_handler_checkpoint_loader.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 42, "span_ids": ["TestHandlerCheckpointLoader.test_one_save_one_load", "TestHandlerCheckpointLoader", "docstring"], "tokens": 286}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import tempfile\nimport shutil\nimport torch\nimport unittest\nfrom ignite.engine import Engine\nimport torch.optim as optim\nfrom monai.handlers import CheckpointSaver, CheckpointLoader\nimport logging\nimport sys\n\n\nclass TestHandlerCheckpointLoader(unittest.TestCase):\n def test_one_save_one_load(self):\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n net1 = torch.nn.PReLU()\n data1 = net1.state_dict()\n data1[\"weight\"] = torch.tensor([0.1])\n net1.load_state_dict(data1)\n net2 = torch.nn.PReLU()\n data2 = net2.state_dict()\n data2[\"weight\"] = torch.tensor([0.2])\n net2.load_state_dict(data2)\n engine = Engine(lambda e, b: None)\n tempdir = tempfile.mkdtemp()\n CheckpointSaver(save_dir=tempdir, save_dict={\"net\": net1}, save_final=True).attach(engine)\n engine.run([0] * 8, max_epochs=5)\n path = tempdir + \"/net_final_iteration=40.pth\"\n CheckpointLoader(load_path=path, load_dict={\"net\": net2}).attach(engine)\n engine.run([0] * 8, max_epochs=1)\n torch.testing.assert_allclose(net2.state_dict()[\"weight\"], 0.1)\n shutil.rmtree(tempdir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_loader.py_TestHandlerCheckpointLoader.test_two_save_one_load_TestHandlerCheckpointLoader.test_two_save_one_load.shutil_rmtree_tempdir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_loader.py_TestHandlerCheckpointLoader.test_two_save_one_load_TestHandlerCheckpointLoader.test_two_save_one_load.shutil_rmtree_tempdir_", "embedding": null, "metadata": {"file_path": "tests/test_handler_checkpoint_loader.py", "file_name": "test_handler_checkpoint_loader.py", "file_type": "text/x-python", "category": "test", "start_line": 44, "end_line": 64, "span_ids": ["TestHandlerCheckpointLoader.test_two_save_one_load"], "tokens": 271}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestHandlerCheckpointLoader(unittest.TestCase):\n\n def test_two_save_one_load(self):\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n net1 = torch.nn.PReLU()\n optimizer = optim.SGD(net1.parameters(), lr=0.02)\n data1 = net1.state_dict()\n data1[\"weight\"] = torch.tensor([0.1])\n net1.load_state_dict(data1)\n net2 = torch.nn.PReLU()\n data2 = net2.state_dict()\n data2[\"weight\"] = torch.tensor([0.2])\n net2.load_state_dict(data2)\n engine = Engine(lambda e, b: None)\n tempdir = tempfile.mkdtemp()\n save_dict = {\"net\": net1, \"opt\": optimizer}\n CheckpointSaver(save_dir=tempdir, save_dict=save_dict, save_final=True).attach(engine)\n engine.run([0] * 8, max_epochs=5)\n path = tempdir + \"/checkpoint_final_iteration=40.pth\"\n CheckpointLoader(load_path=path, load_dict={\"net\": net2}).attach(engine)\n engine.run([0] * 8, max_epochs=1)\n torch.testing.assert_allclose(net2.state_dict()[\"weight\"], 0.1)\n shutil.rmtree(tempdir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_loader.py_TestHandlerCheckpointLoader.test_save_single_device_load_multi_devices_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_loader.py_TestHandlerCheckpointLoader.test_save_single_device_load_multi_devices_", "embedding": null, "metadata": {"file_path": "tests/test_handler_checkpoint_loader.py", "file_name": "test_handler_checkpoint_loader.py", "file_type": "text/x-python", "category": "test", "start_line": 66, "end_line": 90, "span_ids": ["TestHandlerCheckpointLoader.test_save_single_device_load_multi_devices", "impl"], "tokens": 268}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestHandlerCheckpointLoader(unittest.TestCase):\n\n def test_save_single_device_load_multi_devices(self):\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n net1 = torch.nn.PReLU()\n data1 = net1.state_dict()\n data1[\"weight\"] = torch.tensor([0.1])\n net1.load_state_dict(data1)\n net2 = torch.nn.PReLU()\n data2 = net2.state_dict()\n data2[\"weight\"] = torch.tensor([0.2])\n net2.load_state_dict(data2)\n net2 = torch.nn.DataParallel(net2)\n engine = Engine(lambda e, b: None)\n tempdir = tempfile.mkdtemp()\n CheckpointSaver(save_dir=tempdir, save_dict={\"net\": net1}, save_final=True).attach(engine)\n engine.run([0] * 8, max_epochs=5)\n path = tempdir + \"/net_final_iteration=40.pth\"\n CheckpointLoader(load_path=path, load_dict={\"net\": net2}).attach(engine)\n engine.run([0] * 8, max_epochs=1)\n torch.testing.assert_allclose(net2.state_dict()[\"module.weight\"], 0.1)\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_saver.py_os_TEST_CASE_5._True_False_None_1_Tr": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_saver.py_os_TEST_CASE_5._True_False_None_1_Tr", "embedding": null, "metadata": {"file_path": "tests/test_handler_checkpoint_saver.py", "file_name": "test_handler_checkpoint_saver.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 50, "span_ids": ["docstring"], "tokens": 254}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport tempfile\nimport shutil\nimport torch\nimport unittest\nfrom ignite.engine import Engine\nfrom monai.handlers import CheckpointSaver\nimport torch.optim as optim\nfrom parameterized import parameterized\nimport logging\nimport sys\n\nTEST_CASE_1 = [True, False, None, 1, True, 0, None, [\"test_checkpoint_final_iteration=40.pth\"]]\n\nTEST_CASE_2 = [\n False,\n True,\n \"val_loss\",\n 2,\n True,\n 0,\n None,\n [\"test_checkpoint_key_metric=32.pth\", \"test_checkpoint_key_metric=40.pth\"],\n]\n\nTEST_CASE_3 = [False, False, None, 1, True, 2, 2, [\"test_checkpoint_epoch=2.pth\", \"test_checkpoint_epoch=4.pth\"]]\n\nTEST_CASE_4 = [\n False,\n False,\n None,\n 1,\n False,\n 10,\n 2,\n [\"test_checkpoint_iteration=30.pth\", \"test_checkpoint_iteration=40.pth\"],\n]\n\nTEST_CASE_5 = [True, False, None, 1, True, 0, None, [\"test_checkpoint_final_iteration=40.pth\"], True]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_saver.py_TestHandlerCheckpointSaver_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_saver.py_TestHandlerCheckpointSaver_", "embedding": null, "metadata": {"file_path": "tests/test_handler_checkpoint_saver.py", "file_name": "test_handler_checkpoint_saver.py", "file_type": "text/x-python", "category": "test", "start_line": 53, "end_line": 104, "span_ids": ["impl:11", "TestHandlerCheckpointSaver", "TestHandlerCheckpointSaver.test_file"], "tokens": 321}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestHandlerCheckpointSaver(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5])\n def test_file(\n self,\n save_final,\n save_key_metric,\n key_metric_name,\n key_metric_n_saved,\n epoch_level,\n save_interval,\n n_saved,\n filenames,\n multi_devices=False,\n ):\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n data = [0] * 8\n\n # set up engine\n def _train_func(engine, batch):\n engine.state.metrics[\"val_loss\"] = engine.state.iteration\n\n engine = Engine(_train_func)\n\n # set up testing handler\n net = torch.nn.PReLU()\n if multi_devices:\n net = torch.nn.DataParallel(net)\n optimizer = optim.SGD(net.parameters(), lr=0.02)\n tempdir = tempfile.mkdtemp()\n handler = CheckpointSaver(\n tempdir,\n {\"net\": net, \"opt\": optimizer},\n \"CheckpointSaver\",\n \"test\",\n save_final,\n save_key_metric,\n key_metric_name,\n key_metric_n_saved,\n epoch_level,\n save_interval,\n n_saved,\n )\n handler.attach(engine)\n engine.run(data, max_epochs=5)\n for filename in filenames:\n self.assertTrue(os.path.exists(os.path.join(tempdir, filename)))\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_classification_saver.py_os_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_classification_saver.py_os_", "embedding": null, "metadata": {"file_path": "tests/test_handler_classification_saver.py", "file_name": "test_handler_classification_saver.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 55, "span_ids": ["TestHandlerClassificationSaver", "TestHandlerClassificationSaver.test_saved_content", "impl", "docstring"], "tokens": 283}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport csv\nimport shutil\nimport unittest\nimport numpy as np\nimport torch\nfrom ignite.engine import Engine\n\nfrom monai.handlers import ClassificationSaver\n\n\nclass TestHandlerClassificationSaver(unittest.TestCase):\n def test_saved_content(self):\n default_dir = os.path.join(\".\", \"tempdir\")\n shutil.rmtree(default_dir, ignore_errors=True)\n\n # set up engine\n def _train_func(engine, batch):\n return torch.zeros(8)\n\n engine = Engine(_train_func)\n\n # set up testing handler\n saver = ClassificationSaver(output_dir=default_dir, filename=\"predictions.csv\")\n saver.attach(engine)\n\n data = [{\"filename_or_obj\": [\"testfile\" + str(i) for i in range(8)]}]\n engine.run(data, max_epochs=1)\n filepath = os.path.join(default_dir, \"predictions.csv\")\n self.assertTrue(os.path.exists(filepath))\n with open(filepath, \"r\") as f:\n reader = csv.reader(f)\n i = 0\n for row in reader:\n self.assertEqual(row[0], \"testfile\" + str(i))\n self.assertEqual(np.array(row[1:]).astype(np.float32), 0.0)\n i += 1\n self.assertEqual(i, 8)\n shutil.rmtree(default_dir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_lr_scheduler.py_torch_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_lr_scheduler.py_torch_", "embedding": null, "metadata": {"file_path": "tests/test_handler_lr_scheduler.py", "file_name": "test_handler_lr_scheduler.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 64, "span_ids": ["TestHandlerLrSchedule", "TestHandlerLrSchedule.test_content", "impl", "docstring"], "tokens": 368}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import torch\nimport unittest\nimport numpy as np\nfrom ignite.engine import Engine, Events\nfrom monai.handlers import LrScheduleHandler\nimport logging\nimport sys\n\n\nclass TestHandlerLrSchedule(unittest.TestCase):\n def test_content(self):\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n data = [0] * 8\n\n # set up engine\n def _train_func(engine, batch):\n pass\n\n val_engine = Engine(_train_func)\n train_engine = Engine(_train_func)\n\n @train_engine.on(Events.EPOCH_COMPLETED)\n def run_validation(engine):\n val_engine.run(data)\n val_engine.state.metrics[\"val_loss\"] = 1\n\n # set up testing handler\n net = torch.nn.PReLU()\n\n def _reduce_lr_on_plateau():\n optimizer = torch.optim.SGD(net.parameters(), 0.1)\n lr_scheduler = torch.optim.lr_scheduler.ReduceLROnPlateau(optimizer, patience=1)\n handler = LrScheduleHandler(lr_scheduler, step_transform=lambda x: val_engine.state.metrics[\"val_loss\"])\n handler.attach(train_engine)\n return lr_scheduler\n\n def _reduce_on_step():\n optimizer = torch.optim.SGD(net.parameters(), 0.1)\n lr_scheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=2, gamma=0.1)\n handler = LrScheduleHandler(lr_scheduler)\n handler.attach(train_engine)\n return lr_scheduler\n\n schedulers = _reduce_lr_on_plateau(), _reduce_on_step()\n\n train_engine.run(data, max_epochs=5)\n for scheduler in schedulers:\n np.testing.assert_allclose(scheduler._last_lr[0], 0.001)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_mean_dice.py_unittest_TestHandlerMeanDice.test_compute.self_assertAlmostEqual_av": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_mean_dice.py_unittest_TestHandlerMeanDice.test_compute.self_assertAlmostEqual_av", "embedding": null, "metadata": {"file_path": "tests/test_handler_mean_dice.py", "file_name": "test_handler_mean_dice.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 40, "span_ids": ["TestHandlerMeanDice", "TestHandlerMeanDice.test_compute", "docstring"], "tokens": 262}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.handlers import MeanDice\n\nTEST_CASE_1 = [{\"to_onehot_y\": True, \"mutually_exclusive\": True}, 0.75]\nTEST_CASE_2 = [{\"include_background\": False, \"to_onehot_y\": True, \"mutually_exclusive\": False}, 0.66666]\nTEST_CASE_3 = [{\"mutually_exclusive\": True, \"sigmoid\": True}]\n\n\nclass TestHandlerMeanDice(unittest.TestCase):\n # TODO test multi node averaged dice\n\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2])\n def test_compute(self, input_params, expected_avg):\n dice_metric = MeanDice(**input_params)\n\n y_pred = torch.Tensor([[[0], [1]], [[1], [0]]])\n y = torch.ones((2, 1, 1))\n dice_metric.update([y_pred, y])\n\n y_pred = torch.Tensor([[[0], [1]], [[1], [0]]])\n y = torch.Tensor([[[1]], [[0]]])\n dice_metric.update([y_pred, y])\n\n avg_dice = dice_metric.compute()\n self.assertAlmostEqual(avg_dice, expected_avg, places=4)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_mean_dice.py_TestHandlerMeanDice.test_misconfig_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_mean_dice.py_TestHandlerMeanDice.test_misconfig_", "embedding": null, "metadata": {"file_path": "tests/test_handler_mean_dice.py", "file_name": "test_handler_mean_dice.py", "file_type": "text/x-python", "category": "test", "start_line": 42, "end_line": 67, "span_ids": ["TestHandlerMeanDice.test_misconfig", "impl:7", "TestHandlerMeanDice.test_shape_mismatch"], "tokens": 240}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestHandlerMeanDice(unittest.TestCase):\n\n @parameterized.expand([TEST_CASE_3])\n def test_misconfig(self, input_params):\n with self.assertRaisesRegex(ValueError, \"compatib\"):\n dice_metric = MeanDice(**input_params)\n\n y_pred = torch.Tensor([[0, 1], [1, 0]])\n y = torch.ones((2, 1))\n dice_metric.update([y_pred, y])\n\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2])\n def test_shape_mismatch(self, input_params, _expected):\n dice_metric = MeanDice(**input_params)\n with self.assertRaises((AssertionError, ValueError)):\n y_pred = torch.Tensor([[0, 1], [1, 0]])\n y = torch.ones((2, 3))\n dice_metric.update([y_pred, y])\n\n with self.assertRaises((AssertionError, ValueError)):\n y_pred = torch.Tensor([[0, 1], [1, 0]])\n y = torch.ones((3, 2))\n dice_metric.update([y_pred, y])\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_rocauc.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_rocauc.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_handler_rocauc.py", "file_name": "test_handler_rocauc.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 37, "span_ids": ["TestHandlerROCAUC", "TestHandlerROCAUC.test_compute", "impl", "docstring"], "tokens": 177}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nimport torch\n\nfrom monai.handlers import ROCAUC\n\n\nclass TestHandlerROCAUC(unittest.TestCase):\n def test_compute(self):\n auc_metric = ROCAUC(to_onehot_y=True, softmax=True)\n\n y_pred = torch.Tensor([[0.1, 0.9], [0.3, 1.4]])\n y = torch.Tensor([[0], [1]])\n auc_metric.update([y_pred, y])\n\n y_pred = torch.Tensor([[0.2, 0.1], [0.1, 0.5]])\n y = torch.Tensor([[0], [1]])\n auc_metric.update([y_pred, y])\n\n auc = auc_metric.compute()\n np.testing.assert_allclose(0.75, auc)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_segmentation_saver.py_os_TestHandlerSegmentationSaver.test_saved_content.None_3": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_segmentation_saver.py_os_TestHandlerSegmentationSaver.test_saved_content.None_3", "embedding": null, "metadata": {"file_path": "tests/test_handler_segmentation_saver.py", "file_name": "test_handler_segmentation_saver.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 49, "span_ids": ["TestHandlerSegmentationSaver.test_saved_content", "TestHandlerSegmentationSaver", "docstring"], "tokens": 297}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport shutil\nimport unittest\n\nimport numpy as np\nimport torch\nfrom ignite.engine import Engine\nfrom parameterized import parameterized\n\nfrom monai.handlers import SegmentationSaver\n\nTEST_CASE_0 = [\".nii.gz\"]\n\nTEST_CASE_1 = [\".png\"]\n\n\nclass TestHandlerSegmentationSaver(unittest.TestCase):\n @parameterized.expand([TEST_CASE_0, TEST_CASE_1])\n def test_saved_content(self, output_ext):\n default_dir = os.path.join(\".\", \"tempdir\")\n shutil.rmtree(default_dir, ignore_errors=True)\n\n # set up engine\n def _train_func(engine, batch):\n return torch.randint(0, 255, (8, 1, 2, 2)).float()\n\n engine = Engine(_train_func)\n\n # set up testing handler\n saver = SegmentationSaver(output_dir=default_dir, output_postfix=\"seg\", output_ext=output_ext, scale=255)\n saver.attach(engine)\n\n data = [{\"filename_or_obj\": [\"testfile\" + str(i) for i in range(8)]}]\n engine.run(data, max_epochs=1)\n for i in range(8):\n filepath = os.path.join(\"testfile\" + str(i), \"testfile\" + str(i) + \"_seg\" + output_ext)\n self.assertTrue(os.path.exists(os.path.join(default_dir, filepath)))\n shutil.rmtree(default_dir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_segmentation_saver.py_TestHandlerSegmentationSaver.test_save_resized_content_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_segmentation_saver.py_TestHandlerSegmentationSaver.test_save_resized_content_", "embedding": null, "metadata": {"file_path": "tests/test_handler_segmentation_saver.py", "file_name": "test_handler_segmentation_saver.py", "file_type": "text/x-python", "category": "test", "start_line": 51, "end_line": 83, "span_ids": ["impl:5", "TestHandlerSegmentationSaver.test_save_resized_content"], "tokens": 318}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestHandlerSegmentationSaver(unittest.TestCase):\n\n @parameterized.expand([TEST_CASE_0, TEST_CASE_1])\n def test_save_resized_content(self, output_ext):\n default_dir = os.path.join(\".\", \"tempdir\")\n shutil.rmtree(default_dir, ignore_errors=True)\n\n # set up engine\n def _train_func(engine, batch):\n return torch.randint(0, 255, (8, 1, 2, 2)).float()\n\n engine = Engine(_train_func)\n\n # set up testing handler\n saver = SegmentationSaver(output_dir=default_dir, output_postfix=\"seg\", output_ext=output_ext, scale=255)\n saver.attach(engine)\n\n data = [\n {\n \"filename_or_obj\": [\"testfile\" + str(i) for i in range(8)],\n \"spatial_shape\": [(28, 28)] * 8,\n \"affine\": [np.diag(np.ones(4)) * 5] * 8,\n \"original_affine\": [np.diag(np.ones(4)) * 1.0] * 8,\n }\n ]\n engine.run(data, max_epochs=1)\n for i in range(8):\n filepath = os.path.join(\"testfile\" + str(i), \"testfile\" + str(i) + \"_seg\" + output_ext)\n self.assertTrue(os.path.exists(os.path.join(default_dir, filepath)))\n shutil.rmtree(default_dir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_stats.py_torch_TestHandlerStats.test_metrics_print.for_idx_line_in_enumerat.if_grep_match_line_.if_idx_in_5_10_.self_assertTrue_has_key_w": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_stats.py_torch_TestHandlerStats.test_metrics_print.for_idx_line_in_enumerat.if_grep_match_line_.if_idx_in_5_10_.self_assertTrue_has_key_w", "embedding": null, "metadata": {"file_path": "tests/test_handler_stats.py", "file_name": "test_handler_stats.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 58, "span_ids": ["TestHandlerStats.test_metrics_print", "TestHandlerStats", "docstring"], "tokens": 302}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import torch\nimport os\nimport shutil\nimport logging\nimport tempfile\nimport re\nimport unittest\nfrom io import StringIO\n\nfrom ignite.engine import Engine, Events\n\nfrom monai.handlers import StatsHandler\n\n\nclass TestHandlerStats(unittest.TestCase):\n def test_metrics_print(self):\n log_stream = StringIO()\n logging.basicConfig(stream=log_stream, level=logging.INFO)\n key_to_handler = \"test_logging\"\n key_to_print = \"testing_metric\"\n\n # set up engine\n def _train_func(engine, batch):\n return torch.tensor(0.0)\n\n engine = Engine(_train_func)\n\n # set up dummy metric\n @engine.on(Events.EPOCH_COMPLETED)\n def _update_metric(engine):\n current_metric = engine.state.metrics.get(key_to_print, 0.1)\n engine.state.metrics[key_to_print] = current_metric + 0.1\n\n # set up testing handler\n stats_handler = StatsHandler(name=key_to_handler)\n stats_handler.attach(engine)\n\n engine.run(range(3), max_epochs=2)\n\n # check logging output\n output_str = log_stream.getvalue()\n grep = re.compile(f\".*{key_to_handler}.*\")\n has_key_word = re.compile(f\".*{key_to_print}.*\")\n for idx, line in enumerate(output_str.split(\"\\n\")):\n if grep.match(line):\n if idx in [5, 10]:\n self.assertTrue(has_key_word.match(line))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_stats.py_TestHandlerStats.test_loss_print_TestHandlerStats.test_loss_print.for_idx_line_in_enumerat.if_grep_match_line_.if_idx_in_1_2_3_6_7_.self_assertTrue_has_key_w": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_stats.py_TestHandlerStats.test_loss_print_TestHandlerStats.test_loss_print.for_idx_line_in_enumerat.if_grep_match_line_.if_idx_in_1_2_3_6_7_.self_assertTrue_has_key_w", "embedding": null, "metadata": {"file_path": "tests/test_handler_stats.py", "file_name": "test_handler_stats.py", "file_type": "text/x-python", "category": "test", "start_line": 60, "end_line": 85, "span_ids": ["TestHandlerStats.test_loss_print"], "tokens": 220}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestHandlerStats(unittest.TestCase):\n\n def test_loss_print(self):\n log_stream = StringIO()\n logging.basicConfig(stream=log_stream, level=logging.INFO)\n key_to_handler = \"test_logging\"\n key_to_print = \"myLoss\"\n\n # set up engine\n def _train_func(engine, batch):\n return torch.tensor(0.0)\n\n engine = Engine(_train_func)\n\n # set up testing handler\n stats_handler = StatsHandler(name=key_to_handler, tag_name=key_to_print)\n stats_handler.attach(engine)\n\n engine.run(range(3), max_epochs=2)\n\n # check logging output\n output_str = log_stream.getvalue()\n grep = re.compile(f\".*{key_to_handler}.*\")\n has_key_word = re.compile(f\".*{key_to_print}.*\")\n for idx, line in enumerate(output_str.split(\"\\n\")):\n if grep.match(line):\n if idx in [1, 2, 3, 6, 7, 8]:\n self.assertTrue(has_key_word.match(line))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_stats.py_TestHandlerStats.test_loss_dict_TestHandlerStats.test_loss_dict.for_idx_line_in_enumerat.if_grep_match_line_.if_idx_in_1_2_3_6_7_.self_assertTrue_has_key_w": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_stats.py_TestHandlerStats.test_loss_dict_TestHandlerStats.test_loss_dict.for_idx_line_in_enumerat.if_grep_match_line_.if_idx_in_1_2_3_6_7_.self_assertTrue_has_key_w", "embedding": null, "metadata": {"file_path": "tests/test_handler_stats.py", "file_name": "test_handler_stats.py", "file_type": "text/x-python", "category": "test", "start_line": 87, "end_line": 112, "span_ids": ["TestHandlerStats.test_loss_dict"], "tokens": 227}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestHandlerStats(unittest.TestCase):\n\n def test_loss_dict(self):\n log_stream = StringIO()\n logging.basicConfig(stream=log_stream, level=logging.INFO)\n key_to_handler = \"test_logging\"\n key_to_print = \"myLoss1\"\n\n # set up engine\n def _train_func(engine, batch):\n return torch.tensor(0.0)\n\n engine = Engine(_train_func)\n\n # set up testing handler\n stats_handler = StatsHandler(name=key_to_handler, output_transform=lambda x: {key_to_print: x})\n stats_handler.attach(engine)\n\n engine.run(range(3), max_epochs=2)\n\n # check logging output\n output_str = log_stream.getvalue()\n grep = re.compile(f\".*{key_to_handler}.*\")\n has_key_word = re.compile(f\".*{key_to_print}.*\")\n for idx, line in enumerate(output_str.split(\"\\n\")):\n if grep.match(line):\n if idx in [1, 2, 3, 6, 7, 8]:\n self.assertTrue(has_key_word.match(line))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_stats.py_TestHandlerStats.test_loss_file_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_stats.py_TestHandlerStats.test_loss_file_", "embedding": null, "metadata": {"file_path": "tests/test_handler_stats.py", "file_name": "test_handler_stats.py", "file_type": "text/x-python", "category": "test", "start_line": 114, "end_line": 149, "span_ids": ["TestHandlerStats.test_loss_file", "impl"], "tokens": 286}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestHandlerStats(unittest.TestCase):\n\n def test_loss_file(self):\n logging.basicConfig(level=logging.INFO)\n key_to_handler = \"test_logging\"\n key_to_print = \"myLoss\"\n\n tempdir = tempfile.mkdtemp()\n filename = os.path.join(tempdir, \"test_loss_stats.log\")\n handler = logging.FileHandler(filename, mode=\"w\")\n\n # set up engine\n def _train_func(engine, batch):\n return torch.tensor(0.0)\n\n engine = Engine(_train_func)\n\n # set up testing handler\n stats_handler = StatsHandler(name=key_to_handler, tag_name=key_to_print, logger_handler=handler)\n stats_handler.attach(engine)\n\n engine.run(range(3), max_epochs=2)\n handler.stream.close()\n stats_handler.logger.removeHandler(handler)\n with open(filename, \"r\") as f:\n output_str = f.read()\n grep = re.compile(f\".*{key_to_handler}.*\")\n has_key_word = re.compile(f\".*{key_to_print}.*\")\n for idx, line in enumerate(output_str.split(\"\\n\")):\n if grep.match(line):\n if idx in [1, 2, 3, 6, 7, 8]:\n self.assertTrue(has_key_word.match(line))\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_tb_image.py_glob_TEST_CASES._20_20_2_20_20_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_tb_image.py_glob_TEST_CASES._20_20_2_20_20_", "embedding": null, "metadata": {"file_path": "tests/test_handler_tb_image.py", "file_name": "test_handler_tb_image.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 24, "span_ids": ["docstring"], "tokens": 113}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import glob\nimport os\nimport shutil\nimport unittest\nimport tempfile\nimport numpy as np\nimport torch\nfrom ignite.engine import Engine, Events\nfrom parameterized import parameterized\n\nfrom monai.handlers import TensorBoardImageHandler\n\nTEST_CASES = [[[20, 20]], [[2, 20, 20]], [[3, 20, 20]], [[20, 20, 20]], [[2, 20, 20, 20]], [[2, 2, 20, 20, 20]]]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_tb_image.py_TestHandlerTBImage_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_tb_image.py_TestHandlerTBImage_", "embedding": null, "metadata": {"file_path": "tests/test_handler_tb_image.py", "file_name": "test_handler_tb_image.py", "file_type": "text/x-python", "category": "test", "start_line": 27, "end_line": 53, "span_ids": ["TestHandlerTBImage.test_tb_image_shape", "impl:3", "TestHandlerTBImage"], "tokens": 206}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestHandlerTBImage(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_tb_image_shape(self, shape):\n tempdir = tempfile.mkdtemp()\n shutil.rmtree(tempdir, ignore_errors=True)\n\n # set up engine\n def _train_func(engine, batch):\n return torch.zeros((1, 1, 10, 10))\n\n engine = Engine(_train_func)\n\n # set up testing handler\n stats_handler = TensorBoardImageHandler(log_dir=tempdir)\n engine.add_event_handler(Events.ITERATION_COMPLETED, stats_handler)\n\n data = zip(np.random.normal(size=(10, 4, *shape)), np.random.normal(size=(10, 4, *shape)))\n engine.run(data, epoch_length=10, max_epochs=1)\n\n self.assertTrue(os.path.exists(tempdir))\n self.assertTrue(len(glob.glob(tempdir)) > 0)\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_tb_stats.py_os_TestHandlerTBStats.test_metrics_print.shutil_rmtree_tempdir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_tb_stats.py_os_TestHandlerTBStats.test_metrics_print.shutil_rmtree_tempdir_", "embedding": null, "metadata": {"file_path": "tests/test_handler_tb_stats.py", "file_name": "test_handler_tb_stats.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 48, "span_ids": ["TestHandlerTBStats.test_metrics_print", "TestHandlerTBStats", "docstring"], "tokens": 223}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport shutil\nimport tempfile\nimport unittest\nimport glob\n\nfrom ignite.engine import Engine, Events\nfrom torch.utils.tensorboard import SummaryWriter\n\nfrom monai.handlers import TensorBoardStatsHandler\n\n\nclass TestHandlerTBStats(unittest.TestCase):\n def test_metrics_print(self):\n tempdir = tempfile.mkdtemp()\n shutil.rmtree(tempdir, ignore_errors=True)\n\n # set up engine\n def _train_func(engine, batch):\n return batch + 1.0\n\n engine = Engine(_train_func)\n\n # set up dummy metric\n @engine.on(Events.EPOCH_COMPLETED)\n def _update_metric(engine):\n current_metric = engine.state.metrics.get(\"acc\", 0.1)\n engine.state.metrics[\"acc\"] = current_metric + 0.1\n\n # set up testing handler\n stats_handler = TensorBoardStatsHandler(log_dir=tempdir)\n stats_handler.attach(engine)\n engine.run(range(3), max_epochs=2)\n # check logging output\n\n self.assertTrue(os.path.exists(tempdir))\n shutil.rmtree(tempdir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_tb_stats.py_TestHandlerTBStats.test_metrics_writer_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_tb_stats.py_TestHandlerTBStats.test_metrics_writer_", "embedding": null, "metadata": {"file_path": "tests/test_handler_tb_stats.py", "file_name": "test_handler_tb_stats.py", "file_type": "text/x-python", "category": "test", "start_line": 50, "end_line": 81, "span_ids": ["TestHandlerTBStats.test_metrics_writer", "impl"], "tokens": 246}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestHandlerTBStats(unittest.TestCase):\n\n def test_metrics_writer(self):\n tempdir = tempfile.mkdtemp()\n shutil.rmtree(tempdir, ignore_errors=True)\n\n # set up engine\n def _train_func(engine, batch):\n return batch + 1.0\n\n engine = Engine(_train_func)\n\n # set up dummy metric\n @engine.on(Events.EPOCH_COMPLETED)\n def _update_metric(engine):\n current_metric = engine.state.metrics.get(\"acc\", 0.1)\n engine.state.metrics[\"acc\"] = current_metric + 0.1\n\n # set up testing handler\n writer = SummaryWriter(log_dir=tempdir)\n stats_handler = TensorBoardStatsHandler(\n writer, output_transform=lambda x: {\"loss\": x * 2.0}, global_epoch_transform=lambda x: x * 3.0\n )\n stats_handler.attach(engine)\n engine.run(range(3), max_epochs=2)\n # check logging output\n self.assertTrue(os.path.exists(tempdir))\n self.assertTrue(len(glob.glob(tempdir)) > 0)\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_validation.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_validation.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_handler_validation.py", "file_name": "test_handler_validation.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 48, "span_ids": ["TestEvaluator", "TestHandlerValidation.test_content", "TestEvaluator._iteration", "impl", "docstring", "TestHandlerValidation"], "tokens": 205}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport torch\nfrom ignite.engine import Engine\nfrom monai.data import Dataset\nfrom monai.handlers import ValidationHandler\nfrom monai.engines import Evaluator\n\n\nclass TestEvaluator(Evaluator):\n def _iteration(self, engine, batchdata):\n pass\n\n\nclass TestHandlerValidation(unittest.TestCase):\n def test_content(self):\n data = [0] * 8\n\n # set up engine\n def _train_func(engine, batch):\n pass\n\n engine = Engine(_train_func)\n\n # set up testing handler\n val_data_loader = torch.utils.data.DataLoader(Dataset(data))\n evaluator = TestEvaluator(torch.device(\"cpu:0\"), val_data_loader)\n saver = ValidationHandler(evaluator, interval=2)\n saver.attach(engine)\n\n engine.run(data, max_epochs=5)\n self.assertEqual(evaluator.state.max_epochs, 4)\n self.assertEqual(evaluator.state.epoch_length, 8)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_header_correct.py_unittest_TestCorrection.test_correct.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_header_correct.py_unittest_TestCorrection.test_correct.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_header_correct.py", "file_name": "test_header_correct.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 28, "span_ids": ["TestCorrection", "TestCorrection.test_correct", "docstring"], "tokens": 197}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport nibabel as nib\nimport numpy as np\n\nfrom monai.data import correct_nifti_header_if_necessary\n\n\nclass TestCorrection(unittest.TestCase):\n def test_correct(self):\n test_img = nib.Nifti1Image(np.zeros((1, 2, 3)), np.eye(4))\n test_img.header.set_zooms((100, 100, 100))\n test_img = correct_nifti_header_if_necessary(test_img)\n np.testing.assert_allclose(\n test_img.affine,\n np.array([[100.0, 0.0, 0.0, 0.0], [0.0, 100.0, 0.0, 0.0], [0.0, 0.0, 100.0, 0.0], [0.0, 0.0, 0.0, 1.0]]),\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_header_correct.py_TestCorrection.test_affine_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_header_correct.py_TestCorrection.test_affine_", "embedding": null, "metadata": {"file_path": "tests/test_header_correct.py", "file_name": "test_header_correct.py", "file_type": "text/x-python", "category": "test", "start_line": 30, "end_line": 41, "span_ids": ["TestCorrection.test_affine", "impl"], "tokens": 172}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestCorrection(unittest.TestCase):\n\n def test_affine(self):\n test_img = nib.Nifti1Image(np.zeros((1, 2, 3)), np.eye(4) * 20.0)\n test_img = correct_nifti_header_if_necessary(test_img)\n np.testing.assert_allclose(\n test_img.affine,\n np.array([[20.0, 0.0, 0.0, 0.0], [0.0, 20.0, 0.0, 0.0], [0.0, 0.0, 20.0, 0.0], [0.0, 0.0, 0.0, 20.0]]),\n )\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_highresnet.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_highresnet.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_highresnet.py", "file_name": "test_highresnet.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 56, "span_ids": ["TestHighResNet.test_shape", "TestHighResNet", "impl:9", "docstring"], "tokens": 437}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.networks.nets import HighResNet\n\nTEST_CASE_1 = [ # single channel 3D, batch 16\n {\"spatial_dims\": 3, \"in_channels\": 1, \"out_channels\": 3, \"norm_type\": \"instance\"},\n torch.randn(16, 1, 32, 24, 48),\n (16, 3, 32, 24, 48),\n]\n\nTEST_CASE_2 = [ # 4-channel 3D, batch 1\n {\"spatial_dims\": 3, \"in_channels\": 4, \"out_channels\": 3, \"acti_type\": \"relu6\"},\n torch.randn(1, 4, 17, 64, 48),\n (1, 3, 17, 64, 48),\n]\n\nTEST_CASE_3 = [ # 4-channel 2D, batch 7\n {\"spatial_dims\": 2, \"in_channels\": 4, \"out_channels\": 3},\n torch.randn(7, 4, 64, 48),\n (7, 3, 64, 48),\n]\n\nTEST_CASE_4 = [ # 4-channel 1D, batch 16\n {\"spatial_dims\": 1, \"in_channels\": 4, \"out_channels\": 3, \"dropout_prob\": 0.1},\n torch.randn(16, 4, 63),\n (16, 3, 63),\n]\n\n\nclass TestHighResNet(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4])\n def test_shape(self, input_param, input_data, expected_shape):\n net = HighResNet(**input_param)\n net.eval()\n with torch.no_grad():\n result = net.forward(input_data)\n self.assertEqual(result.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_identity.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_identity.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_identity.py", "file_name": "test_identity.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 29, "span_ids": ["TestIdentity", "TestIdentity.test_identity", "impl", "docstring"], "tokens": 79}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\n\nfrom monai.transforms.utility.array import Identity\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestIdentity(NumpyImageTestCase2D):\n def test_identity(self):\n img = self.imt\n identity = Identity()\n self.assertTrue(np.allclose(img, identity(img)))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_identityd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_identityd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_identityd.py", "file_name": "test_identityd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 29, "span_ids": ["TestIdentityd.test_identityd", "TestIdentityd", "impl", "docstring"], "tokens": 91}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nfrom monai.transforms.utility.dictionary import Identityd\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestIdentityd(NumpyImageTestCase2D):\n def test_identityd(self):\n img = self.imt\n data = dict()\n data[\"img\"] = img\n identity = Identityd(keys=data.keys())\n self.assertEqual(data, identity(data))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_img2tensorboard.py_tempfile_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_img2tensorboard.py_tempfile_", "embedding": null, "metadata": {"file_path": "tests/test_img2tensorboard.py", "file_name": "test_img2tensorboard.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 53, "span_ids": ["TestImg2Tensorboard.test_write_gray", "TestImg2Tensorboard", "impl", "docstring"], "tokens": 294}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import tempfile\nimport unittest\n\nfrom monai.visualize import make_animated_gif_summary\nimport numpy as np\nimport tensorboard\nimport torch\n\n\nclass TestImg2Tensorboard(unittest.TestCase):\n def test_write_gray(self):\n with tempfile.TemporaryDirectory() as out_dir:\n nparr = np.ones(shape=(1, 32, 32, 32), dtype=np.float32)\n summary_object_np = make_animated_gif_summary(\n tag=\"test_summary_nparr.png\",\n image=nparr,\n max_out=1,\n animation_axes=(3,),\n image_axes=(1, 2),\n scale_factor=253.0,\n )\n assert isinstance(\n summary_object_np, tensorboard.compat.proto.summary_pb2.Summary\n ), \"make_animated_gif_summary must return a tensorboard.summary object from numpy array\"\n\n tensorarr = torch.tensor(nparr)\n summary_object_tensor = make_animated_gif_summary(\n tag=\"test_summary_tensorarr.png\",\n image=tensorarr,\n max_out=1,\n animation_axes=(3,),\n image_axes=(1, 2),\n scale_factor=253.0,\n )\n assert isinstance(\n summary_object_tensor, tensorboard.compat.proto.summary_pb2.Summary\n ), \"make_animated_gif_summary must return a tensorboard.summary object from tensor input\"\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_classification_2d.py_os_MedNISTDataset.__getitem__.return.self_transforms_self_imag": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_classification_2d.py_os_MedNISTDataset.__getitem__.return.self_transforms_self_imag", "embedding": null, "metadata": {"file_path": "tests/test_integration_classification_2d.py", "file_name": "test_integration_classification_2d.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 43, "span_ids": ["MedNISTDataset", "MedNISTDataset.__len__", "MedNISTDataset.__init__", "docstring", "MedNISTDataset.__getitem__"], "tokens": 217}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport shutil\nimport subprocess\nimport tarfile\nimport tempfile\nimport unittest\n\nimport numpy as np\nimport torch\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.metrics import compute_roc_auc\nfrom monai.networks.nets import densenet121\nfrom monai.transforms import AddChannel, Compose, LoadPNG, RandFlip, RandRotate, RandZoom, ScaleIntensity, ToTensor\nfrom monai.utils import set_determinism\nfrom tests.utils import skip_if_quick\n\nTEST_DATA_URL = \"https://www.dropbox.com/s/5wwskxctvcxiuea/MedNIST.tar.gz\"\n\n\nclass MedNISTDataset(torch.utils.data.Dataset):\n def __init__(self, image_files, labels, transforms):\n self.image_files = image_files\n self.labels = labels\n self.transforms = transforms\n\n def __len__(self):\n return len(self.image_files)\n\n def __getitem__(self, index):\n return self.transforms(self.image_files[index]), self.labels[index]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_classification_2d.py_run_training_test_run_training_test.return.epoch_loss_values_best_m": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_classification_2d.py_run_training_test_run_training_test.return.epoch_loss_values_best_m", "embedding": null, "metadata": {"file_path": "tests/test_integration_classification_2d.py", "file_name": "test_integration_classification_2d.py", "file_type": "text/x-python", "category": "test", "start_line": 46, "end_line": 125, "span_ids": ["run_training_test"], "tokens": 848}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def run_training_test(root_dir, train_x, train_y, val_x, val_y, device=torch.device(\"cuda:0\")):\n\n monai.config.print_config()\n # define transforms for image and classification\n train_transforms = Compose(\n [\n LoadPNG(image_only=True),\n AddChannel(),\n ScaleIntensity(),\n RandRotate(range_x=15, prob=0.5, keep_size=True),\n RandFlip(spatial_axis=0, prob=0.5),\n RandZoom(min_zoom=0.9, max_zoom=1.1, prob=0.5),\n ToTensor(),\n ]\n )\n train_transforms.set_random_state(1234)\n val_transforms = Compose([LoadPNG(image_only=True), AddChannel(), ScaleIntensity(), ToTensor()])\n\n # create train, val data loaders\n train_ds = MedNISTDataset(train_x, train_y, train_transforms)\n train_loader = DataLoader(train_ds, batch_size=300, shuffle=True, num_workers=10)\n\n val_ds = MedNISTDataset(val_x, val_y, val_transforms)\n val_loader = DataLoader(val_ds, batch_size=300, num_workers=10)\n\n model = densenet121(spatial_dims=2, in_channels=1, out_channels=len(np.unique(train_y))).to(device)\n loss_function = torch.nn.CrossEntropyLoss()\n optimizer = torch.optim.Adam(model.parameters(), 1e-5)\n epoch_num = 4\n val_interval = 1\n\n # start training validation\n best_metric = -1\n best_metric_epoch = -1\n epoch_loss_values = list()\n metric_values = list()\n model_filename = os.path.join(root_dir, \"best_metric_model.pth\")\n for epoch in range(epoch_num):\n print(\"-\" * 10)\n print(f\"Epoch {epoch + 1}/{epoch_num}\")\n model.train()\n epoch_loss = 0\n step = 0\n for batch_data in train_loader:\n step += 1\n inputs, labels = batch_data[0].to(device), batch_data[1].to(device)\n optimizer.zero_grad()\n outputs = model(inputs)\n loss = loss_function(outputs, labels)\n loss.backward()\n optimizer.step()\n epoch_loss += loss.item()\n epoch_loss /= step\n epoch_loss_values.append(epoch_loss)\n print(f\"epoch {epoch + 1} average loss:{epoch_loss:0.4f}\")\n\n if (epoch + 1) % val_interval == 0:\n model.eval()\n with torch.no_grad():\n y_pred = torch.tensor([], dtype=torch.float32, device=device)\n y = torch.tensor([], dtype=torch.long, device=device)\n for val_data in val_loader:\n val_images, val_labels = val_data[0].to(device), val_data[1].to(device)\n y_pred = torch.cat([y_pred, model(val_images)], dim=0)\n y = torch.cat([y, val_labels], dim=0)\n auc_metric = compute_roc_auc(y_pred, y, to_onehot_y=True, softmax=True)\n metric_values.append(auc_metric)\n acc_value = torch.eq(y_pred.argmax(dim=1), y)\n acc_metric = acc_value.sum().item() / len(acc_value)\n if auc_metric > best_metric:\n best_metric = auc_metric\n best_metric_epoch = epoch + 1\n torch.save(model.state_dict(), model_filename)\n print(\"saved new best metric model\")\n print(\n f\"current epoch {epoch +1} current AUC: {auc_metric:0.4f} \"\n f\"current accuracy: {acc_metric:0.4f} best AUC: {best_metric:0.4f} at epoch {best_metric_epoch}\"\n )\n print(f\"train completed, best_metric: {best_metric:0.4f} at epoch: {best_metric_epoch}\")\n return epoch_loss_values, best_metric, best_metric_epoch", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_classification_2d.py_run_inference_test_run_inference_test.return.tps": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_classification_2d.py_run_inference_test_run_inference_test.return.tps", "embedding": null, "metadata": {"file_path": "tests/test_integration_classification_2d.py", "file_name": "test_integration_classification_2d.py", "file_type": "text/x-python", "category": "test", "start_line": 128, "end_line": 149, "span_ids": ["run_inference_test"], "tokens": 277}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def run_inference_test(root_dir, test_x, test_y, device=torch.device(\"cuda:0\")):\n # define transforms for image and classification\n val_transforms = Compose([LoadPNG(image_only=True), AddChannel(), ScaleIntensity(), ToTensor()])\n val_ds = MedNISTDataset(test_x, test_y, val_transforms)\n val_loader = DataLoader(val_ds, batch_size=300, num_workers=10)\n\n model = densenet121(spatial_dims=2, in_channels=1, out_channels=len(np.unique(test_y))).to(device)\n\n model_filename = os.path.join(root_dir, \"best_metric_model.pth\")\n model.load_state_dict(torch.load(model_filename))\n model.eval()\n y_true = list()\n y_pred = list()\n with torch.no_grad():\n for test_data in val_loader:\n test_images, test_labels = test_data[0].to(device), test_data[1].to(device)\n pred = model(test_images).argmax(dim=1)\n for i in range(len(pred)):\n y_true.append(test_labels[i].item())\n y_pred.append(pred[i].item())\n tps = [np.sum((np.asarray(y_true) == idx) & (np.asarray(y_pred) == idx)) for idx in np.unique(test_y)]\n return tps", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_classification_2d.py_IntegrationClassification2D_IntegrationClassification2D.setUp.self.device.torch_device_cuda_0_if_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_classification_2d.py_IntegrationClassification2D_IntegrationClassification2D.setUp.self.device.torch_device_cuda_0_if_", "embedding": null, "metadata": {"file_path": "tests/test_integration_classification_2d.py", "file_name": "test_integration_classification_2d.py", "file_type": "text/x-python", "category": "test", "start_line": 152, "end_line": 196, "span_ids": ["IntegrationClassification2D", "IntegrationClassification2D.setUp"], "tokens": 428}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class IntegrationClassification2D(unittest.TestCase):\n def setUp(self):\n set_determinism(seed=0)\n self.data_dir = tempfile.mkdtemp()\n\n # download\n subprocess.call([\"wget\", \"-nv\", \"-P\", self.data_dir, TEST_DATA_URL])\n dataset_file = os.path.join(self.data_dir, \"MedNIST.tar.gz\")\n assert os.path.exists(dataset_file)\n\n # extract tarfile\n datafile = tarfile.open(dataset_file)\n datafile.extractall(path=self.data_dir)\n datafile.close()\n\n # find image files and labels\n data_dir = os.path.join(self.data_dir, \"MedNIST\")\n class_names = sorted((x for x in os.listdir(data_dir) if os.path.isdir(os.path.join(data_dir, x))))\n image_files = [\n [os.path.join(data_dir, class_name, x) for x in sorted(os.listdir(os.path.join(data_dir, class_name)))]\n for class_name in class_names\n ]\n image_file_list, image_classes = [], []\n for i, _ in enumerate(class_names):\n image_file_list.extend(image_files[i])\n image_classes.extend([i] * len(image_files[i]))\n\n # split train, val, test\n valid_frac, test_frac = 0.1, 0.1\n self.train_x, self.train_y = [], []\n self.val_x, self.val_y = [], []\n self.test_x, self.test_y = [], []\n for i in range(len(image_classes)):\n rann = np.random.random()\n if rann < valid_frac:\n self.val_x.append(image_file_list[i])\n self.val_y.append(image_classes[i])\n elif rann < test_frac + valid_frac:\n self.test_x.append(image_file_list[i])\n self.test_y.append(image_classes[i])\n else:\n self.train_x.append(image_file_list[i])\n self.train_y.append(image_classes[i])\n\n self.device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu:0\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_classification_2d.py_IntegrationClassification2D.tearDown_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_classification_2d.py_IntegrationClassification2D.tearDown_", "embedding": null, "metadata": {"file_path": "tests/test_integration_classification_2d.py", "file_name": "test_integration_classification_2d.py", "file_type": "text/x-python", "category": "test", "start_line": 198, "end_line": 236, "span_ids": ["impl:3", "IntegrationClassification2D.test_training", "IntegrationClassification2D.tearDown"], "tokens": 364}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class IntegrationClassification2D(unittest.TestCase):\n\n def tearDown(self):\n set_determinism(seed=None)\n shutil.rmtree(self.data_dir)\n\n @skip_if_quick\n def test_training(self):\n repeated = []\n for i in range(2):\n torch.manual_seed(0)\n\n repeated.append([])\n losses, best_metric, best_metric_epoch = run_training_test(\n self.data_dir, self.train_x, self.train_y, self.val_x, self.val_y, device=self.device\n )\n\n # check training properties\n np.testing.assert_allclose(\n losses, [0.7797081090842083, 0.16179659706392105, 0.07446704363557184, 0.045996826011568875], rtol=1e-3\n )\n repeated[i].extend(losses)\n print(\"best metric\", best_metric)\n np.testing.assert_allclose(best_metric, 0.9999268330306007, rtol=1e-4)\n repeated[i].append(best_metric)\n np.testing.assert_allclose(best_metric_epoch, 4)\n model_file = os.path.join(self.data_dir, \"best_metric_model.pth\")\n self.assertTrue(os.path.exists(model_file))\n\n infer_metric = run_inference_test(self.data_dir, self.test_x, self.test_y, device=self.device)\n\n # check inference properties\n np.testing.assert_allclose(np.asarray(infer_metric), [1031, 895, 981, 1033, 960, 1047], atol=1)\n repeated[i].extend(infer_metric)\n\n np.testing.assert_allclose(repeated[0], repeated[1])\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_determinism.py_unittest_run_test._TestBatch.__len__.return.train_steps": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_determinism.py_unittest_run_test._TestBatch.__len__.return.train_steps", "embedding": null, "metadata": {"file_path": "tests/test_integration_determinism.py", "file_name": "test_integration_determinism.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 40, "span_ids": ["run_test", "docstring"], "tokens": 245}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom torch.utils.data import DataLoader, Dataset\n\nfrom monai.data import create_test_image_2d\nfrom monai.losses import DiceLoss\nfrom monai.networks.nets import UNet\nfrom monai.transforms import Compose, AddChannel, RandRotate90, RandSpatialCrop, ScaleIntensity, ToTensor\nfrom monai.utils import set_determinism\n\n\ndef run_test(batch_size=64, train_steps=200, device=torch.device(\"cuda:0\")):\n class _TestBatch(Dataset):\n def __init__(self, transforms):\n self.transforms = transforms\n\n def __getitem__(self, _unused_id):\n im, seg = create_test_image_2d(128, 128, noise_max=1, num_objs=4, num_seg_classes=1)\n seed = np.random.randint(2147483647)\n self.transforms.set_random_state(seed=seed)\n im = self.transforms(im)\n self.transforms.set_random_state(seed=seed)\n seg = self.transforms(seg)\n return im, seg\n\n def __len__(self):\n return train_steps\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_determinism.py_run_test.net_run_test.return.epoch_loss_step": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_determinism.py_run_test.net_run_test.return.epoch_loss_step", "embedding": null, "metadata": {"file_path": "tests/test_integration_determinism.py", "file_name": "test_integration_determinism.py", "file_type": "text/x-python", "category": "test", "start_line": 42, "end_line": 67, "span_ids": ["run_test"], "tokens": 248}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def run_test(batch_size=64, train_steps=200, device=torch.device(\"cuda:0\")):\n # ... other code\n\n net = UNet(\n dimensions=2, in_channels=1, out_channels=1, channels=(4, 8, 16, 32), strides=(2, 2, 2), num_res_units=2\n ).to(device)\n\n loss = DiceLoss(sigmoid=True)\n opt = torch.optim.Adam(net.parameters(), 1e-2)\n train_transforms = Compose(\n [AddChannel(), ScaleIntensity(), RandSpatialCrop((96, 96), random_size=False), RandRotate90(), ToTensor()]\n )\n\n src = DataLoader(_TestBatch(train_transforms), batch_size=batch_size, shuffle=True)\n\n net.train()\n epoch_loss = 0\n step = 0\n for img, seg in src:\n step += 1\n opt.zero_grad()\n output = net(img.to(device))\n step_loss = loss(output, seg.to(device))\n step_loss.backward()\n opt.step()\n epoch_loss += step_loss.item()\n epoch_loss /= step\n\n return epoch_loss, step", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_determinism.py_TestDeterminism_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_determinism.py_TestDeterminism_", "embedding": null, "metadata": {"file_path": "tests/test_integration_determinism.py", "file_name": "test_integration_determinism.py", "file_type": "text/x-python", "category": "test", "start_line": 70, "end_line": 87, "span_ids": ["TestDeterminism.tearDown", "impl", "TestDeterminism.setUp", "TestDeterminism", "TestDeterminism.test_training"], "tokens": 136}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestDeterminism(unittest.TestCase):\n def setUp(self):\n set_determinism(seed=0)\n self.device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu:0\")\n\n def tearDown(self):\n set_determinism(seed=None)\n\n def test_training(self):\n loss, step = run_test(device=self.device)\n print(f\"Deterministic loss {loss} at training step {step}\")\n np.testing.assert_allclose(step, 4)\n np.testing.assert_allclose(loss, 0.5346279, rtol=1e-6)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_os_from_tests_utils_import_s": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_os_from_tests_utils_import_s", "embedding": null, "metadata": {"file_path": "tests/test_integration_segmentation_3d.py", "file_name": "test_integration_segmentation_3d.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 41, "span_ids": ["docstring"], "tokens": 192}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport shutil\nimport tempfile\nimport unittest\nfrom glob import glob\n\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom torch.utils.data import DataLoader\nfrom torch.utils.tensorboard import SummaryWriter\n\nimport monai\nfrom monai.data import create_test_image_3d, NiftiSaver, list_data_collate\nfrom monai.inferers import sliding_window_inference\nfrom monai.metrics import DiceMetric\nfrom monai.networks.nets import UNet\nfrom monai.transforms import (\n Compose,\n AsChannelFirstd,\n LoadNiftid,\n RandCropByPosNegLabeld,\n RandRotate90d,\n ScaleIntensityd,\n Spacingd,\n ToTensord,\n)\nfrom monai.visualize import plot_2d_or_3d_image\nfrom monai.utils import set_determinism\nfrom tests.utils import skip_if_quick", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_run_training_test_run_training_test.metric_values.list_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_run_training_test_run_training_test.metric_values.list_", "embedding": null, "metadata": {"file_path": "tests/test_integration_segmentation_3d.py", "file_name": "test_integration_segmentation_3d.py", "file_type": "text/x-python", "category": "test", "start_line": 44, "end_line": 104, "span_ids": ["run_training_test"], "tokens": 777}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def run_training_test(root_dir, device=torch.device(\"cuda:0\"), cachedataset=False):\n monai.config.print_config()\n images = sorted(glob(os.path.join(root_dir, \"img*.nii.gz\")))\n segs = sorted(glob(os.path.join(root_dir, \"seg*.nii.gz\")))\n train_files = [{\"img\": img, \"seg\": seg} for img, seg in zip(images[:20], segs[:20])]\n val_files = [{\"img\": img, \"seg\": seg} for img, seg in zip(images[-20:], segs[-20:])]\n\n # define transforms for image and segmentation\n train_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\", \"seg\"]),\n AsChannelFirstd(keys=[\"img\", \"seg\"], channel_dim=-1),\n Spacingd(keys=[\"img\", \"seg\"], pixdim=[1.2, 0.8, 0.7], mode=[\"bilinear\", \"nearest\"]),\n ScaleIntensityd(keys=[\"img\", \"seg\"]),\n RandCropByPosNegLabeld(\n keys=[\"img\", \"seg\"], label_key=\"seg\", spatial_size=[96, 96, 96], pos=1, neg=1, num_samples=4\n ),\n RandRotate90d(keys=[\"img\", \"seg\"], prob=0.8, spatial_axes=[0, 2]),\n ToTensord(keys=[\"img\", \"seg\"]),\n ]\n )\n train_transforms.set_random_state(1234)\n val_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\", \"seg\"]),\n AsChannelFirstd(keys=[\"img\", \"seg\"], channel_dim=-1),\n Spacingd(keys=[\"img\", \"seg\"], pixdim=[1.2, 0.8, 0.7], mode=[\"bilinear\", \"nearest\"]),\n ScaleIntensityd(keys=[\"img\", \"seg\"]),\n ToTensord(keys=[\"img\", \"seg\"]),\n ]\n )\n\n # create a training data loader\n if cachedataset:\n train_ds = monai.data.CacheDataset(data=train_files, transform=train_transforms, cache_rate=0.8)\n else:\n train_ds = monai.data.Dataset(data=train_files, transform=train_transforms)\n # use batch_size=2 to load images and use RandCropByPosNegLabeld to generate 2 x 4 images for network training\n train_loader = DataLoader(train_ds, batch_size=2, shuffle=True, num_workers=4, collate_fn=list_data_collate)\n # create a validation data loader\n val_ds = monai.data.Dataset(data=val_files, transform=val_transforms)\n val_loader = DataLoader(val_ds, batch_size=1, num_workers=4, collate_fn=list_data_collate)\n dice_metric = DiceMetric(include_background=True, to_onehot_y=False, sigmoid=True, reduction=\"mean\")\n\n # create UNet, DiceLoss and Adam optimizer\n model = monai.networks.nets.UNet(\n dimensions=3,\n in_channels=1,\n out_channels=1,\n channels=(16, 32, 64, 128, 256),\n strides=(2, 2, 2, 2),\n num_res_units=2,\n ).to(device)\n loss_function = monai.losses.DiceLoss(sigmoid=True)\n optimizer = torch.optim.Adam(model.parameters(), 5e-4)\n\n # start a typical PyTorch training\n val_interval = 2\n best_metric, best_metric_epoch = -1, -1\n epoch_loss_values = list()\n metric_values = list()\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_run_training_test.writer_run_training_test.return.epoch_loss_values_best_m": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_run_training_test.writer_run_training_test.return.epoch_loss_values_best_m", "embedding": null, "metadata": {"file_path": "tests/test_integration_segmentation_3d.py", "file_name": "test_integration_segmentation_3d.py", "file_type": "text/x-python", "category": "test", "start_line": 105, "end_line": 163, "span_ids": ["run_training_test"], "tokens": 708}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def run_training_test(root_dir, device=torch.device(\"cuda:0\"), cachedataset=False):\n # ... other code\n writer = SummaryWriter(log_dir=os.path.join(root_dir, \"runs\"))\n model_filename = os.path.join(root_dir, \"best_metric_model.pth\")\n for epoch in range(6):\n print(\"-\" * 10)\n print(f\"Epoch {epoch + 1}/{6}\")\n model.train()\n epoch_loss = 0\n step = 0\n for batch_data in train_loader:\n step += 1\n inputs, labels = batch_data[\"img\"].to(device), batch_data[\"seg\"].to(device)\n optimizer.zero_grad()\n outputs = model(inputs)\n loss = loss_function(outputs, labels)\n loss.backward()\n optimizer.step()\n epoch_loss += loss.item()\n epoch_len = len(train_ds) // train_loader.batch_size\n print(f\"{step}/{epoch_len}, train_loss:{loss.item():0.4f}\")\n writer.add_scalar(\"train_loss\", loss.item(), epoch_len * epoch + step)\n epoch_loss /= step\n epoch_loss_values.append(epoch_loss)\n print(f\"epoch {epoch +1} average loss:{epoch_loss:0.4f}\")\n\n if (epoch + 1) % val_interval == 0:\n model.eval()\n with torch.no_grad():\n metric_sum = 0.0\n metric_count = 0\n val_images = None\n val_labels = None\n val_outputs = None\n for val_data in val_loader:\n val_images, val_labels = val_data[\"img\"].to(device), val_data[\"seg\"].to(device)\n sw_batch_size, roi_size = 4, (96, 96, 96)\n val_outputs = sliding_window_inference(val_images, roi_size, sw_batch_size, model)\n value = dice_metric(y_pred=val_outputs, y=val_labels)\n not_nans = dice_metric.not_nans.item()\n metric_count += not_nans\n metric_sum += value.item() * not_nans\n metric = metric_sum / metric_count\n metric_values.append(metric)\n if metric > best_metric:\n best_metric = metric\n best_metric_epoch = epoch + 1\n torch.save(model.state_dict(), model_filename)\n print(\"saved new best metric model\")\n print(\n f\"current epoch {epoch +1} current mean dice: {metric:0.4f} \"\n f\"best mean dice: {best_metric:0.4f} at epoch {best_metric_epoch}\"\n )\n writer.add_scalar(\"val_mean_dice\", metric, epoch + 1)\n # plot the last model output as GIF image in TensorBoard with the corresponding image and label\n plot_2d_or_3d_image(val_images, epoch + 1, writer, index=0, tag=\"image\")\n plot_2d_or_3d_image(val_labels, epoch + 1, writer, index=0, tag=\"label\")\n plot_2d_or_3d_image(val_outputs, epoch + 1, writer, index=0, tag=\"output\")\n print(f\"train completed, best_metric: {best_metric:0.4f} at epoch: {best_metric_epoch}\")\n writer.close()\n return epoch_loss_values, best_metric, best_metric_epoch", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_run_inference_test_run_inference_test.return.metric": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_run_inference_test_run_inference_test.return.metric", "embedding": null, "metadata": {"file_path": "tests/test_integration_segmentation_3d.py", "file_name": "test_integration_segmentation_3d.py", "file_type": "text/x-python", "category": "test", "start_line": 166, "end_line": 214, "span_ids": ["run_inference_test"], "tokens": 587}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def run_inference_test(root_dir, device=torch.device(\"cuda:0\")):\n images = sorted(glob(os.path.join(root_dir, \"im*.nii.gz\")))\n segs = sorted(glob(os.path.join(root_dir, \"seg*.nii.gz\")))\n val_files = [{\"img\": img, \"seg\": seg} for img, seg in zip(images, segs)]\n\n # define transforms for image and segmentation\n val_transforms = Compose(\n [\n LoadNiftid(keys=[\"img\", \"seg\"]),\n AsChannelFirstd(keys=[\"img\", \"seg\"], channel_dim=-1),\n Spacingd(keys=[\"img\", \"seg\"], pixdim=[1.2, 0.8, 0.7], mode=[\"bilinear\", \"nearest\"]),\n ScaleIntensityd(keys=[\"img\", \"seg\"]),\n ToTensord(keys=[\"img\", \"seg\"]),\n ]\n )\n val_ds = monai.data.Dataset(data=val_files, transform=val_transforms)\n # sliding window inferene need to input 1 image in every iteration\n val_loader = DataLoader(val_ds, batch_size=1, num_workers=4, collate_fn=list_data_collate)\n dice_metric = DiceMetric(include_background=True, to_onehot_y=False, sigmoid=True, reduction=\"mean\")\n\n model = UNet(\n dimensions=3,\n in_channels=1,\n out_channels=1,\n channels=(16, 32, 64, 128, 256),\n strides=(2, 2, 2, 2),\n num_res_units=2,\n ).to(device)\n\n model_filename = os.path.join(root_dir, \"best_metric_model.pth\")\n model.load_state_dict(torch.load(model_filename))\n model.eval()\n with torch.no_grad():\n metric_sum = 0.0\n metric_count = 0\n saver = NiftiSaver(output_dir=os.path.join(root_dir, \"output\"), dtype=int)\n for val_data in val_loader:\n val_images, val_labels = val_data[\"img\"].to(device), val_data[\"seg\"].to(device)\n # define sliding window size and batch size for windows inference\n sw_batch_size, roi_size = 4, (96, 96, 96)\n val_outputs = sliding_window_inference(val_images, roi_size, sw_batch_size, model)\n value = dice_metric(y_pred=val_outputs, y=val_labels)\n not_nans = dice_metric.not_nans.item()\n metric_count += not_nans\n metric_sum += value.item() * not_nans\n val_outputs = (val_outputs.sigmoid() >= 0.5).float()\n saver.save_batch(val_outputs, val_data[\"img_meta_dict\"])\n metric = metric_sum / metric_count\n return metric", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_IntegrationSegmentation3D_IntegrationSegmentation3D.tearDown.shutil_rmtree_self_data_d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_IntegrationSegmentation3D_IntegrationSegmentation3D.tearDown.shutil_rmtree_self_data_d", "embedding": null, "metadata": {"file_path": "tests/test_integration_segmentation_3d.py", "file_name": "test_integration_segmentation_3d.py", "file_type": "text/x-python", "category": "test", "start_line": 217, "end_line": 233, "span_ids": ["IntegrationSegmentation3D", "IntegrationSegmentation3D.tearDown", "IntegrationSegmentation3D.setUp"], "tokens": 191}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class IntegrationSegmentation3D(unittest.TestCase):\n def setUp(self):\n set_determinism(seed=0)\n\n self.data_dir = tempfile.mkdtemp()\n for i in range(40):\n im, seg = create_test_image_3d(128, 128, 128, num_seg_classes=1, channel_dim=-1)\n n = nib.Nifti1Image(im, np.eye(4))\n nib.save(n, os.path.join(self.data_dir, f\"img{i:d}.nii.gz\"))\n n = nib.Nifti1Image(seg, np.eye(4))\n nib.save(n, os.path.join(self.data_dir, f\"seg{i:d}.nii.gz\"))\n\n self.device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu:0\")\n\n def tearDown(self):\n set_determinism(seed=None)\n shutil.rmtree(self.data_dir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_IntegrationSegmentation3D.test_training_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_segmentation_3d.py_IntegrationSegmentation3D.test_training_", "embedding": null, "metadata": {"file_path": "tests/test_integration_segmentation_3d.py", "file_name": "test_integration_segmentation_3d.py", "file_type": "text/x-python", "category": "test", "start_line": 235, "end_line": 327, "span_ids": ["IntegrationSegmentation3D.test_training", "impl"], "tokens": 920}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class IntegrationSegmentation3D(unittest.TestCase):\n\n @skip_if_quick\n def test_training(self):\n repeated = []\n for i in range(3):\n torch.manual_seed(0)\n\n repeated.append([])\n losses, best_metric, best_metric_epoch = run_training_test(\n self.data_dir, device=self.device, cachedataset=(i == 2)\n )\n\n # check training properties\n np.testing.assert_allclose(\n losses,\n [\n 0.5446721106767655,\n 0.47511033713817596,\n 0.4449633926153183,\n 0.42703236639499664,\n 0.43338048458099365,\n 0.4250185787677765,\n ],\n rtol=1e-3,\n )\n repeated[i].extend(losses)\n print(\"best metric\", best_metric)\n np.testing.assert_allclose(best_metric, 0.9315729558467865, rtol=1e-3)\n repeated[i].append(best_metric)\n np.testing.assert_allclose(best_metric_epoch, 6)\n self.assertTrue(len(glob(os.path.join(self.data_dir, \"runs\"))) > 0)\n model_file = os.path.join(self.data_dir, \"best_metric_model.pth\")\n self.assertTrue(os.path.exists(model_file))\n\n infer_metric = run_inference_test(self.data_dir, device=self.device)\n\n # check inference properties\n print(\"infer metric\", infer_metric)\n np.testing.assert_allclose(infer_metric, 0.9317406713962555, rtol=1e-3)\n repeated[i].append(infer_metric)\n output_files = sorted(glob(os.path.join(self.data_dir, \"output\", \"img*\", \"*.nii.gz\")))\n sums = [\n 0.12231683731079102,\n 0.1304492950439453,\n 0.13103389739990234,\n 0.12055253982543945,\n 0.16393518447875977,\n 0.14713191986083984,\n 0.12597894668579102,\n 0.14522886276245117,\n 0.13489341735839844,\n 0.15492963790893555,\n 0.1398162841796875,\n 0.1469135284423828,\n 0.1236867904663086,\n 0.09705924987792969,\n 0.1391434669494629,\n 0.17519617080688477,\n 0.15174245834350586,\n 0.08218145370483398,\n 0.1685023307800293,\n 0.17438125610351562,\n 0.17048406600952148,\n 0.180755615234375,\n 0.1407794952392578,\n 0.11354923248291016,\n 0.12623214721679688,\n 0.12312602996826172,\n 0.20070409774780273,\n 0.13995695114135742,\n 0.12910842895507812,\n 0.08772659301757812,\n 0.10249042510986328,\n 0.11148881912231445,\n 0.09734582901000977,\n 0.13138771057128906,\n 0.1410813331604004,\n 0.16798830032348633,\n 0.1925334930419922,\n 0.1564631462097168,\n 0.16519880294799805,\n 0.06282520294189453,\n ]\n for (output, s) in zip(output_files, sums):\n ave = np.mean(nib.load(output).get_fdata())\n np.testing.assert_allclose(ave, s, rtol=5e-3)\n repeated[i].append(ave)\n np.testing.assert_allclose(repeated[0], repeated[1])\n np.testing.assert_allclose(repeated[0], repeated[2])\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_sliding_window.py_os_from_tests_utils_import_m": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_sliding_window.py_os_from_tests_utils_import_m", "embedding": null, "metadata": {"file_path": "tests/test_integration_sliding_window.py", "file_name": "test_integration_sliding_window.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 30, "span_ids": ["docstring"], "tokens": 126}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport shutil\nimport tempfile\nimport unittest\n\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom ignite.engine import Engine\nfrom torch.utils.data import DataLoader\n\nfrom monai.data import NiftiDataset, create_test_image_3d\nfrom monai.inferers import sliding_window_inference\nfrom monai.handlers import SegmentationSaver\nfrom monai.networks.nets import UNet\nfrom monai.networks import predict_segmentation\nfrom monai.transforms import AddChannel\nfrom monai.utils import set_determinism\nfrom tests.utils import make_nifti_image", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_sliding_window.py_run_test_run_test.return.saved_name": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_sliding_window.py_run_test_run_test.return.saved_name", "embedding": null, "metadata": {"file_path": "tests/test_integration_sliding_window.py", "file_name": "test_integration_sliding_window.py", "file_type": "text/x-python", "category": "test", "start_line": 33, "end_line": 60, "span_ids": ["run_test"], "tokens": 307}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def run_test(batch_size, img_name, seg_name, output_dir, device=torch.device(\"cuda:0\")):\n ds = NiftiDataset([img_name], [seg_name], transform=AddChannel(), seg_transform=AddChannel(), image_only=False)\n loader = DataLoader(ds, batch_size=1, pin_memory=torch.cuda.is_available())\n\n net = UNet(\n dimensions=3, in_channels=1, out_channels=1, channels=(4, 8, 16, 32), strides=(2, 2, 2), num_res_units=2\n ).to(device)\n roi_size = (16, 32, 48)\n sw_batch_size = batch_size\n\n def _sliding_window_processor(_engine, batch):\n net.eval()\n img, seg, meta_data = batch\n with torch.no_grad():\n seg_probs = sliding_window_inference(img.to(device), roi_size, sw_batch_size, net)\n return predict_segmentation(seg_probs)\n\n infer_engine = Engine(_sliding_window_processor)\n\n SegmentationSaver(\n output_dir=output_dir, output_ext=\".nii.gz\", output_postfix=\"seg\", batch_transform=lambda x: x[2]\n ).attach(infer_engine)\n\n infer_engine.run(loader)\n\n basename = os.path.basename(img_name)[: -len(\".nii.gz\")]\n saved_name = os.path.join(output_dir, basename, f\"{basename}_seg.nii.gz\")\n return saved_name", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_sliding_window.py_TestIntegrationSlidingWindow_TestIntegrationSlidingWindow.tearDown.if_os_path_exists_self_se.os_remove_self_seg_name_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_sliding_window.py_TestIntegrationSlidingWindow_TestIntegrationSlidingWindow.tearDown.if_os_path_exists_self_se.os_remove_self_seg_name_", "embedding": null, "metadata": {"file_path": "tests/test_integration_sliding_window.py", "file_name": "test_integration_sliding_window.py", "file_type": "text/x-python", "category": "test", "start_line": 63, "end_line": 77, "span_ids": ["TestIntegrationSlidingWindow.tearDown", "TestIntegrationSlidingWindow", "TestIntegrationSlidingWindow.setUp"], "tokens": 159}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestIntegrationSlidingWindow(unittest.TestCase):\n def setUp(self):\n set_determinism(seed=0)\n\n im, seg = create_test_image_3d(25, 28, 63, rad_max=10, noise_max=1, num_objs=4, num_seg_classes=1)\n self.img_name = make_nifti_image(im)\n self.seg_name = make_nifti_image(seg)\n self.device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu:0\")\n\n def tearDown(self):\n set_determinism(seed=None)\n if os.path.exists(self.img_name):\n os.remove(self.img_name)\n if os.path.exists(self.seg_name):\n os.remove(self.seg_name)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_sliding_window.py_TestIntegrationSlidingWindow.test_training_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_sliding_window.py_TestIntegrationSlidingWindow.test_training_", "embedding": null, "metadata": {"file_path": "tests/test_integration_sliding_window.py", "file_name": "test_integration_sliding_window.py", "file_type": "text/x-python", "category": "test", "start_line": 79, "end_line": 92, "span_ids": ["TestIntegrationSlidingWindow.test_training", "impl"], "tokens": 129}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestIntegrationSlidingWindow(unittest.TestCase):\n\n def test_training(self):\n tempdir = tempfile.mkdtemp()\n output_file = run_test(\n batch_size=2, img_name=self.img_name, seg_name=self.seg_name, output_dir=tempdir, device=self.device\n )\n output_image = nib.load(output_file).get_fdata()\n np.testing.assert_allclose(np.sum(output_image), 33583)\n np.testing.assert_allclose(output_image.shape, (28, 25, 63, 1))\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_stn.py_from___future___import_pr_STNBenchmark.forward.return.self_stn_x_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_stn.py_from___future___import_pr_STNBenchmark.forward.return.self_stn_x_", "embedding": null, "metadata": {"file_path": "tests/test_integration_stn.py", "file_name": "test_integration_stn.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 73, "span_ids": ["STNBenchmark.forward", "STNBenchmark.stn", "docstring", "STNBenchmark.__init__", "STNBenchmark", "STNBenchmark.stn_ref"], "tokens": 543}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "from __future__ import print_function\n\nimport unittest\n\nimport numpy as np\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport torch.optim as optim\n\nfrom monai.data import create_test_image_2d\nfrom monai.networks.layers import AffineTransform\nfrom monai.utils import set_determinism\n\n\nclass STNBenchmark(nn.Module):\n \"\"\"\n adapted from https://pytorch.org/tutorials/intermediate/spatial_transformer_tutorial.html\n \"\"\"\n\n def __init__(self, is_ref=True, reverse_indexing=False):\n super().__init__()\n self.is_ref = is_ref\n self.localization = nn.Sequential(\n nn.Conv2d(1, 8, kernel_size=7),\n nn.MaxPool2d(2, stride=2),\n nn.ReLU(True),\n nn.Conv2d(8, 10, kernel_size=5),\n nn.MaxPool2d(2, stride=2),\n nn.ReLU(True),\n )\n # Regressor for the 3 * 2 affine matrix\n self.fc_loc = nn.Sequential(nn.Linear(10 * 3 * 3, 32), nn.ReLU(True), nn.Linear(32, 3 * 2))\n # Initialize the weights/bias with identity transformation\n self.fc_loc[2].weight.data.zero_()\n self.fc_loc[2].bias.data.copy_(torch.tensor([1, 0, 0, 0, 1, 0], dtype=torch.float))\n if not self.is_ref:\n self.xform = AffineTransform(normalized=True, reverse_indexing=reverse_indexing)\n\n # Spatial transformer network forward function\n def stn_ref(self, x):\n xs = self.localization(x)\n xs = xs.view(-1, 10 * 3 * 3)\n theta = self.fc_loc(xs)\n theta = theta.view(-1, 2, 3)\n\n grid = F.affine_grid(theta, x.size(), align_corners=False)\n x = F.grid_sample(x, grid, align_corners=False)\n return x\n\n def stn(self, x):\n xs = self.localization(x)\n xs = xs.view(-1, 10 * 3 * 3)\n theta = self.fc_loc(xs)\n theta = theta.view(-1, 2, 3)\n x = self.xform(x, theta, spatial_size=x.size()[2:])\n return x\n\n def forward(self, x):\n if self.is_ref:\n return self.stn_ref(x)\n return self.stn(x)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_stn.py_compare_2d_compare_2d.return.model_img_a_detach_cpu": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_stn.py_compare_2d_compare_2d.return.model_img_a_detach_cpu", "embedding": null, "metadata": {"file_path": "tests/test_integration_stn.py", "file_name": "test_integration_stn.py", "file_type": "text/x-python", "category": "test", "start_line": 76, "end_line": 96, "span_ids": ["compare_2d"], "tokens": 281}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def compare_2d(is_ref=True, device=None, reverse_indexing=False):\n batch_size = 32\n img_a = [create_test_image_2d(28, 28, 5, rad_max=6, noise_max=1)[0][None] for _ in range(batch_size)]\n img_b = [create_test_image_2d(28, 28, 5, rad_max=6, noise_max=1)[0][None] for _ in range(batch_size)]\n img_a = np.stack(img_a, axis=0)\n img_b = np.stack(img_b, axis=0)\n img_a = torch.as_tensor(img_a, device=device)\n img_b = torch.as_tensor(img_b, device=device)\n model = STNBenchmark(is_ref=is_ref, reverse_indexing=reverse_indexing).to(device)\n optimizer = optim.SGD(model.parameters(), lr=0.001)\n model.train()\n init_loss = None\n for _ in range(20):\n optimizer.zero_grad()\n output_a = model(img_a)\n loss = torch.mean((output_a - img_b) ** 2)\n if init_loss is None:\n init_loss = loss.item()\n loss.backward()\n optimizer.step()\n return model(img_a).detach().cpu().numpy(), loss.item(), init_loss", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_stn.py_TestSpatialTransformerCore_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_stn.py_TestSpatialTransformerCore_", "embedding": null, "metadata": {"file_path": "tests/test_integration_stn.py", "file_name": "test_integration_stn.py", "file_type": "text/x-python", "category": "test", "start_line": 99, "end_line": 132, "span_ids": ["TestSpatialTransformerCore", "TestSpatialTransformerCore.tearDown", "impl", "TestSpatialTransformerCore.test_training", "TestSpatialTransformerCore.setUp"], "tokens": 307}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestSpatialTransformerCore(unittest.TestCase):\n def setUp(self):\n self.device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu:0\")\n\n def tearDown(self):\n set_determinism(seed=None)\n\n def test_training(self):\n \"\"\"\n check that the quality AffineTransform backpropagation\n \"\"\"\n atol = 1e-5\n set_determinism(seed=0)\n out_ref, loss_ref, init_loss_ref = compare_2d(True, self.device)\n print(out_ref.shape, loss_ref, init_loss_ref)\n\n set_determinism(seed=0)\n out, loss, init_loss = compare_2d(False, self.device)\n print(out.shape, loss, init_loss)\n np.testing.assert_allclose(out_ref, out, atol=atol)\n np.testing.assert_allclose(init_loss_ref, init_loss, atol=atol)\n np.testing.assert_allclose(loss_ref, loss, atol=atol)\n\n set_determinism(seed=0)\n out, loss, init_loss = compare_2d(False, self.device, True)\n print(out.shape, loss, init_loss)\n np.testing.assert_allclose(out_ref, out, atol=atol)\n np.testing.assert_allclose(init_loss_ref, init_loss, atol=atol)\n np.testing.assert_allclose(loss_ref, loss, atol=atol)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_unet_2d.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_unet_2d.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_integration_unet_2d.py", "file_name": "test_integration_unet_2d.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 57, "span_ids": ["TestIntegrationUnet2D", "impl", "run_test", "TestIntegrationUnet2D.test_unet_training", "docstring"], "tokens": 363}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom ignite.engine import create_supervised_trainer\nfrom torch.utils.data import DataLoader, Dataset\n\nfrom monai.data import create_test_image_2d\nfrom monai.losses import DiceLoss\nfrom monai.networks.nets import UNet\n\n\ndef run_test(batch_size=64, train_steps=100, device=torch.device(\"cuda:0\")):\n class _TestBatch(Dataset):\n def __getitem__(self, _unused_id):\n im, seg = create_test_image_2d(128, 128, noise_max=1, num_objs=4, num_seg_classes=1)\n return im[None], seg[None].astype(np.float32)\n\n def __len__(self):\n return train_steps\n\n net = UNet(\n dimensions=2, in_channels=1, out_channels=1, channels=(4, 8, 16, 32), strides=(2, 2, 2), num_res_units=2\n ).to(device)\n\n loss = DiceLoss(sigmoid=True)\n opt = torch.optim.Adam(net.parameters(), 1e-4)\n src = DataLoader(_TestBatch(), batch_size=batch_size)\n\n trainer = create_supervised_trainer(net, opt, loss, device, False)\n\n trainer.run(src, 1)\n loss = trainer.state.output\n return loss\n\n\nclass TestIntegrationUnet2D(unittest.TestCase):\n def test_unet_training(self):\n loss = run_test(device=torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu:0\"))\n print(loss)\n self.assertGreaterEqual(0.85, loss)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_os_from_tests_utils_import_s": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_os_from_tests_utils_import_s", "embedding": null, "metadata": {"file_path": "tests/test_integration_workflows.py", "file_name": "test_integration_workflows.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 52, "span_ids": ["docstring"], "tokens": 232}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport sys\nimport shutil\nimport tempfile\nimport unittest\nfrom glob import glob\nimport logging\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom ignite.metrics import Accuracy\n\nimport monai\nfrom monai.transforms import (\n Compose,\n LoadNiftid,\n AsChannelFirstd,\n ScaleIntensityd,\n RandCropByPosNegLabeld,\n RandRotate90d,\n ToTensord,\n Activationsd,\n AsDiscreted,\n KeepLargestConnectedComponentd,\n)\nfrom monai.handlers import (\n StatsHandler,\n TensorBoardStatsHandler,\n TensorBoardImageHandler,\n ValidationHandler,\n LrScheduleHandler,\n CheckpointSaver,\n CheckpointLoader,\n SegmentationSaver,\n MeanDice,\n)\nfrom monai.data import create_test_image_3d\nfrom monai.engines import SupervisedTrainer, SupervisedEvaluator\nfrom monai.inferers import SimpleInferer, SlidingWindowInferer\nfrom monai.utils import set_determinism\nfrom tests.utils import skip_if_quick", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_run_training_test_run_training_test.val_handlers._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_run_training_test_run_training_test.val_handlers._", "embedding": null, "metadata": {"file_path": "tests/test_integration_workflows.py", "file_name": "test_integration_workflows.py", "file_type": "text/x-python", "category": "test", "start_line": 55, "end_line": 118, "span_ids": ["run_training_test"], "tokens": 762}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def run_training_test(root_dir, device=torch.device(\"cuda:0\")):\n images = sorted(glob(os.path.join(root_dir, \"img*.nii.gz\")))\n segs = sorted(glob(os.path.join(root_dir, \"seg*.nii.gz\")))\n train_files = [{\"image\": img, \"label\": seg} for img, seg in zip(images[:20], segs[:20])]\n val_files = [{\"image\": img, \"label\": seg} for img, seg in zip(images[-20:], segs[-20:])]\n\n # define transforms for image and segmentation\n train_transforms = Compose(\n [\n LoadNiftid(keys=[\"image\", \"label\"]),\n AsChannelFirstd(keys=[\"image\", \"label\"], channel_dim=-1),\n ScaleIntensityd(keys=[\"image\", \"label\"]),\n RandCropByPosNegLabeld(\n keys=[\"image\", \"label\"], label_key=\"label\", spatial_size=[96, 96, 96], pos=1, neg=1, num_samples=4\n ),\n RandRotate90d(keys=[\"image\", \"label\"], prob=0.5, spatial_axes=[0, 2]),\n ToTensord(keys=[\"image\", \"label\"]),\n ]\n )\n val_transforms = Compose(\n [\n LoadNiftid(keys=[\"image\", \"label\"]),\n AsChannelFirstd(keys=[\"image\", \"label\"], channel_dim=-1),\n ScaleIntensityd(keys=[\"image\", \"label\"]),\n ToTensord(keys=[\"image\", \"label\"]),\n ]\n )\n\n # create a training data loader\n train_ds = monai.data.CacheDataset(data=train_files, transform=train_transforms, cache_rate=0.5)\n # use batch_size=2 to load images and use RandCropByPosNegLabeld to generate 2 x 4 images for network training\n train_loader = monai.data.DataLoader(train_ds, batch_size=2, shuffle=True, num_workers=4)\n # create a validation data loader\n val_ds = monai.data.CacheDataset(data=val_files, transform=val_transforms, cache_rate=1.0)\n val_loader = monai.data.DataLoader(val_ds, batch_size=1, num_workers=4)\n\n # create UNet, DiceLoss and Adam optimizer\n net = monai.networks.nets.UNet(\n dimensions=3,\n in_channels=1,\n out_channels=1,\n channels=(16, 32, 64, 128, 256),\n strides=(2, 2, 2, 2),\n num_res_units=2,\n ).to(device)\n loss = monai.losses.DiceLoss(sigmoid=True)\n opt = torch.optim.Adam(net.parameters(), 1e-3)\n lr_scheduler = torch.optim.lr_scheduler.StepLR(opt, step_size=2, gamma=0.1)\n\n val_post_transforms = Compose(\n [\n Activationsd(keys=\"pred\", sigmoid=True),\n AsDiscreted(keys=\"pred\", threshold_values=True),\n KeepLargestConnectedComponentd(keys=\"pred\", applied_labels=[1]),\n ]\n )\n val_handlers = [\n StatsHandler(output_transform=lambda x: None),\n TensorBoardStatsHandler(log_dir=root_dir, output_transform=lambda x: None),\n TensorBoardImageHandler(\n log_dir=root_dir, batch_transform=lambda x: (x[\"image\"], x[\"label\"]), output_transform=lambda x: x[\"pred\"]\n ),\n CheckpointSaver(save_dir=root_dir, save_dict={\"net\": net}, save_key_metric=True),\n ]\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_run_training_test.evaluator_run_training_test.return.evaluator_state_best_metr": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_run_training_test.evaluator_run_training_test.return.evaluator_state_best_metr", "embedding": null, "metadata": {"file_path": "tests/test_integration_workflows.py", "file_name": "test_integration_workflows.py", "file_type": "text/x-python", "category": "test", "start_line": 120, "end_line": 163, "span_ids": ["run_training_test"], "tokens": 423}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def run_training_test(root_dir, device=torch.device(\"cuda:0\")):\n # ... other code\n\n evaluator = SupervisedEvaluator(\n device=device,\n val_data_loader=val_loader,\n network=net,\n inferer=SlidingWindowInferer(roi_size=(96, 96, 96), sw_batch_size=4, overlap=0.5),\n post_transform=val_post_transforms,\n key_val_metric={\n \"val_mean_dice\": MeanDice(include_background=True, output_transform=lambda x: (x[\"pred\"], x[\"label\"]))\n },\n additional_metrics={\"val_acc\": Accuracy(output_transform=lambda x: (x[\"pred\"], x[\"label\"]))},\n val_handlers=val_handlers,\n )\n\n train_post_transforms = Compose(\n [\n Activationsd(keys=\"pred\", sigmoid=True),\n AsDiscreted(keys=\"pred\", threshold_values=True),\n KeepLargestConnectedComponentd(keys=\"pred\", applied_labels=[1]),\n ]\n )\n train_handlers = [\n LrScheduleHandler(lr_scheduler=lr_scheduler, print_lr=True),\n ValidationHandler(validator=evaluator, interval=2, epoch_level=True),\n StatsHandler(tag_name=\"train_loss\", output_transform=lambda x: x[\"loss\"]),\n TensorBoardStatsHandler(log_dir=root_dir, tag_name=\"train_loss\", output_transform=lambda x: x[\"loss\"]),\n CheckpointSaver(save_dir=root_dir, save_dict={\"net\": net, \"opt\": opt}, save_interval=2, epoch_level=True),\n ]\n\n trainer = SupervisedTrainer(\n device=device,\n max_epochs=5,\n train_data_loader=train_loader,\n network=net,\n optimizer=opt,\n loss_function=loss,\n inferer=SimpleInferer(),\n amp=False,\n post_transform=train_post_transforms,\n key_train_metric={\"train_acc\": Accuracy(output_transform=lambda x: (x[\"pred\"], x[\"label\"]))},\n train_handlers=train_handlers,\n )\n trainer.run()\n\n return evaluator.state.best_metric", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_run_inference_test_run_inference_test.return.evaluator_state_best_metr": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_run_inference_test_run_inference_test.return.evaluator_state_best_metr", "embedding": null, "metadata": {"file_path": "tests/test_integration_workflows.py", "file_name": "test_integration_workflows.py", "file_type": "text/x-python", "category": "test", "start_line": 166, "end_line": 226, "span_ids": ["run_inference_test"], "tokens": 555}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def run_inference_test(root_dir, model_file, device=torch.device(\"cuda:0\")):\n images = sorted(glob(os.path.join(root_dir, \"im*.nii.gz\")))\n segs = sorted(glob(os.path.join(root_dir, \"seg*.nii.gz\")))\n val_files = [{\"image\": img, \"label\": seg} for img, seg in zip(images, segs)]\n\n # define transforms for image and segmentation\n val_transforms = Compose(\n [\n LoadNiftid(keys=[\"image\", \"label\"]),\n AsChannelFirstd(keys=[\"image\", \"label\"], channel_dim=-1),\n ScaleIntensityd(keys=[\"image\", \"label\"]),\n ToTensord(keys=[\"image\", \"label\"]),\n ]\n )\n\n # create a validation data loader\n val_ds = monai.data.Dataset(data=val_files, transform=val_transforms)\n val_loader = monai.data.DataLoader(val_ds, batch_size=1, num_workers=4)\n\n # create UNet, DiceLoss and Adam optimizer\n net = monai.networks.nets.UNet(\n dimensions=3,\n in_channels=1,\n out_channels=1,\n channels=(16, 32, 64, 128, 256),\n strides=(2, 2, 2, 2),\n num_res_units=2,\n ).to(device)\n\n val_post_transforms = Compose(\n [\n Activationsd(keys=\"pred\", sigmoid=True),\n AsDiscreted(keys=\"pred\", threshold_values=True),\n KeepLargestConnectedComponentd(keys=\"pred\", applied_labels=[1]),\n ]\n )\n val_handlers = [\n StatsHandler(output_transform=lambda x: None),\n CheckpointLoader(load_path=f\"{model_file}\", load_dict={\"net\": net}),\n SegmentationSaver(\n output_dir=root_dir,\n batch_transform=lambda batch: batch[\"image_meta_dict\"],\n output_transform=lambda output: output[\"pred\"],\n ),\n ]\n\n evaluator = SupervisedEvaluator(\n device=device,\n val_data_loader=val_loader,\n network=net,\n inferer=SlidingWindowInferer(roi_size=(96, 96, 96), sw_batch_size=4, overlap=0.5),\n post_transform=val_post_transforms,\n key_val_metric={\n \"val_mean_dice\": MeanDice(include_background=True, output_transform=lambda x: (x[\"pred\"], x[\"label\"]))\n },\n additional_metrics={\"val_acc\": Accuracy(output_transform=lambda x: (x[\"pred\"], x[\"label\"]))},\n val_handlers=val_handlers,\n )\n evaluator.run()\n\n return evaluator.state.best_metric", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_IntegrationWorkflows_IntegrationWorkflows.tearDown.shutil_rmtree_self_data_d": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_IntegrationWorkflows_IntegrationWorkflows.tearDown.shutil_rmtree_self_data_d", "embedding": null, "metadata": {"file_path": "tests/test_integration_workflows.py", "file_name": "test_integration_workflows.py", "file_type": "text/x-python", "category": "test", "start_line": 229, "end_line": 247, "span_ids": ["IntegrationWorkflows.tearDown", "IntegrationWorkflows.setUp", "IntegrationWorkflows"], "tokens": 207}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class IntegrationWorkflows(unittest.TestCase):\n def setUp(self):\n set_determinism(seed=0)\n\n self.data_dir = tempfile.mkdtemp()\n for i in range(40):\n im, seg = create_test_image_3d(128, 128, 128, num_seg_classes=1, channel_dim=-1)\n n = nib.Nifti1Image(im, np.eye(4))\n nib.save(n, os.path.join(self.data_dir, f\"img{i:d}.nii.gz\"))\n n = nib.Nifti1Image(seg, np.eye(4))\n nib.save(n, os.path.join(self.data_dir, f\"seg{i:d}.nii.gz\"))\n\n self.device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu:0\")\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\n def tearDown(self):\n set_determinism(seed=None)\n shutil.rmtree(self.data_dir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_IntegrationWorkflows.test_training_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_IntegrationWorkflows.test_training_", "embedding": null, "metadata": {"file_path": "tests/test_integration_workflows.py", "file_name": "test_integration_workflows.py", "file_type": "text/x-python", "category": "test", "start_line": 249, "end_line": 319, "span_ids": ["IntegrationWorkflows.test_training", "impl"], "tokens": 745}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class IntegrationWorkflows(unittest.TestCase):\n\n @skip_if_quick\n def test_training(self):\n repeated = []\n for i in range(2):\n torch.manual_seed(0)\n\n repeated.append([])\n best_metric = run_training_test(self.data_dir, device=self.device)\n print(\"best metric\", best_metric)\n np.testing.assert_allclose(best_metric, 0.9232678800821305, rtol=1e-3)\n repeated[i].append(best_metric)\n\n model_file = sorted(glob(os.path.join(self.data_dir, \"net_key_metric*.pth\")))[-1]\n infer_metric = run_inference_test(self.data_dir, model_file, device=self.device)\n print(\"infer metric\", infer_metric)\n # check inference properties\n np.testing.assert_allclose(infer_metric, 0.9224808603525162, rtol=1e-3)\n repeated[i].append(infer_metric)\n output_files = sorted(glob(os.path.join(self.data_dir, \"img*\", \"*.nii.gz\")))\n sums = [\n 0.14212512969970703,\n 0.1506481170654297,\n 0.1368846893310547,\n 0.13330554962158203,\n 0.18573999404907227,\n 0.1647019386291504,\n 0.1408066749572754,\n 0.16658973693847656,\n 0.15639686584472656,\n 0.17746448516845703,\n 0.16197776794433594,\n 0.16469907760620117,\n 0.14304876327514648,\n 0.10998392105102539,\n 0.16064167022705078,\n 0.1962604522705078,\n 0.17453575134277344,\n 0.052756309509277344,\n 0.19060277938842773,\n 0.20035600662231445,\n 0.19619369506835938,\n 0.20325279235839844,\n 0.15996408462524414,\n 0.13104581832885742,\n 0.14955568313598633,\n 0.135528564453125,\n 0.2252669334411621,\n 0.16170835494995117,\n 0.14747190475463867,\n 0.10289239883422852,\n 0.11845922470092773,\n 0.13117074966430664,\n 0.11201333999633789,\n 0.15172672271728516,\n 0.15926742553710938,\n 0.18946075439453125,\n 0.21686124801635742,\n 0.1773381233215332,\n 0.1864323616027832,\n 0.035613059997558594,\n ]\n for (output, s) in zip(output_files, sums):\n ave = np.mean(nib.load(output).get_fdata())\n np.testing.assert_allclose(ave, s, rtol=1e-2)\n repeated[i].append(ave)\n np.testing.assert_allclose(repeated[0], repeated[1])\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_unittest_grid_2.torch_tensor_0_0_0_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_unittest_grid_2.torch_tensor_0_0_0_", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_component.py", "file_name": "test_keep_largest_connected_component.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 20, "span_ids": ["docstring"], "tokens": 192}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import KeepLargestConnectedComponent\n\ngrid_1 = torch.tensor([[[[0, 0, 1, 0, 0], [0, 2, 1, 1, 1], [1, 2, 1, 0, 0], [1, 2, 0, 1, 0], [2, 2, 0, 0, 2]]]])\ngrid_2 = torch.tensor([[[[0, 0, 0, 0, 1], [0, 0, 1, 1, 1], [1, 0, 1, 1, 2], [1, 0, 1, 2, 2], [0, 0, 0, 0, 1]]]])", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_grid_3_grid_3.torch_tensor_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_grid_3_grid_3.torch_tensor_", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_component.py", "file_name": "test_keep_largest_connected_component.py", "file_type": "text/x-python", "category": "test", "start_line": 21, "end_line": 70, "span_ids": ["docstring"], "tokens": 824}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "grid_3 = torch.tensor(\n [\n [\n [\n [1.0, 1.0, 0.0, 1.0, 1.0],\n [1.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [1.0, 0.0, 1.0, 0.0, 0.0],\n [1.0, 0.0, 0.0, 1.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 1.0],\n ],\n ],\n [\n [\n [1.0, 1.0, 1.0, 1.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [1.0, 0.0, 1.0, 1.0, 0.0],\n [1.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n ],\n ]\n)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_1_TEST_CASE_6._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_1_TEST_CASE_6._", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_component.py", "file_name": "test_keep_largest_connected_component.py", "file_type": "text/x-python", "category": "test", "start_line": 73, "end_line": 113, "span_ids": ["impl:17", "impl:7"], "tokens": 710}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_1 = [\n \"value_1\",\n {\"independent\": False, \"applied_labels\": 1},\n grid_1,\n torch.tensor([[[[0, 0, 1, 0, 0], [0, 2, 1, 1, 1], [0, 2, 1, 0, 0], [0, 2, 0, 1, 0], [2, 2, 0, 0, 2]]]]),\n]\n\nTEST_CASE_2 = [\n \"value_2\",\n {\"independent\": False, \"applied_labels\": [2]},\n grid_1,\n torch.tensor([[[[0, 0, 1, 0, 0], [0, 2, 1, 1, 1], [1, 2, 1, 0, 0], [1, 2, 0, 1, 0], [2, 2, 0, 0, 0]]]]),\n]\n\nTEST_CASE_3 = [\n \"independent_value_1_2\",\n {\"independent\": True, \"applied_labels\": [1, 2]},\n grid_1,\n torch.tensor([[[[0, 0, 1, 0, 0], [0, 2, 1, 1, 1], [0, 2, 1, 0, 0], [0, 2, 0, 1, 0], [2, 2, 0, 0, 0]]]]),\n]\n\nTEST_CASE_4 = [\n \"dependent_value_1_2\",\n {\"independent\": False, \"applied_labels\": [1, 2]},\n grid_1,\n torch.tensor([[[[0, 0, 1, 0, 0], [0, 2, 1, 1, 1], [1, 2, 1, 0, 0], [1, 2, 0, 1, 0], [2, 2, 0, 0, 2]]]]),\n]\n\nTEST_CASE_5 = [\n \"value_1\",\n {\"independent\": True, \"applied_labels\": [1]},\n grid_2,\n torch.tensor([[[[0, 0, 0, 0, 1], [0, 0, 1, 1, 1], [0, 0, 1, 1, 2], [0, 0, 1, 2, 2], [0, 0, 0, 0, 0]]]]),\n]\n\nTEST_CASE_6 = [\n \"independent_value_1_2\",\n {\"independent\": True, \"applied_labels\": [1, 2]},\n grid_2,\n torch.tensor([[[[0, 0, 0, 0, 1], [0, 0, 1, 1, 1], [0, 0, 1, 1, 2], [0, 0, 1, 2, 2], [0, 0, 0, 0, 0]]]]),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_7_TEST_CASE_10._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_7_TEST_CASE_10._", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_component.py", "file_name": "test_keep_largest_connected_component.py", "file_type": "text/x-python", "category": "test", "start_line": 115, "end_line": 141, "span_ids": ["impl:17", "impl:25"], "tokens": 509}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_7 = [\n \"dependent_value_1_2\",\n {\"independent\": False, \"applied_labels\": [1, 2]},\n grid_2,\n torch.tensor([[[[0, 0, 0, 0, 1], [0, 0, 1, 1, 1], [0, 0, 1, 1, 2], [0, 0, 1, 2, 2], [0, 0, 0, 0, 1]]]]),\n]\n\nTEST_CASE_8 = [\n \"value_1_connect_1\",\n {\"independent\": False, \"applied_labels\": [1], \"connectivity\": 1},\n grid_1,\n torch.tensor([[[[0, 0, 1, 0, 0], [0, 2, 1, 1, 1], [0, 2, 1, 0, 0], [0, 2, 0, 0, 0], [2, 2, 0, 0, 2]]]]),\n]\n\nTEST_CASE_9 = [\n \"independent_value_1_2_connect_1\",\n {\"independent\": True, \"applied_labels\": [1, 2], \"connectivity\": 1},\n grid_1,\n torch.tensor([[[[0, 0, 1, 0, 0], [0, 2, 1, 1, 1], [0, 2, 1, 0, 0], [0, 2, 0, 0, 0], [2, 2, 0, 0, 0]]]]),\n]\n\nTEST_CASE_10 = [\n \"dependent_value_1_2_connect_1\",\n {\"independent\": False, \"applied_labels\": [1, 2], \"connectivity\": 1},\n grid_1,\n torch.tensor([[[[0, 0, 1, 0, 0], [0, 2, 1, 1, 1], [1, 2, 1, 0, 0], [1, 2, 0, 0, 0], [2, 2, 0, 0, 0]]]]),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_11_TEST_CASE_11._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_11_TEST_CASE_11._", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_component.py", "file_name": "test_keep_largest_connected_component.py", "file_type": "text/x-python", "category": "test", "start_line": 143, "end_line": 197, "span_ids": ["impl:25"], "tokens": 873}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_11 = [\n \"onehot_independent_batch_2_apply_label_1_connect_1\",\n {\"independent\": True, \"applied_labels\": [1], \"connectivity\": 1},\n grid_3,\n torch.tensor(\n [\n [\n [\n [1.0, 1.0, 0.0, 1.0, 1.0],\n [1.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 1.0],\n ],\n ],\n [\n [\n [1.0, 1.0, 1.0, 1.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n ],\n ]\n ),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_12_TEST_CASE_12._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_12_TEST_CASE_12._", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_component.py", "file_name": "test_keep_largest_connected_component.py", "file_type": "text/x-python", "category": "test", "start_line": 199, "end_line": 253, "span_ids": ["impl:29"], "tokens": 873}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_12 = [\n \"onehot_independent_batch_2_apply_label_1_connect_2\",\n {\"independent\": True, \"applied_labels\": [1], \"connectivity\": 2},\n grid_3,\n torch.tensor(\n [\n [\n [\n [1.0, 1.0, 0.0, 1.0, 1.0],\n [1.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 1.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 1.0],\n ],\n ],\n [\n [\n [1.0, 1.0, 1.0, 1.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n ],\n ]\n ),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_13_TEST_CASE_13._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_13_TEST_CASE_13._", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_component.py", "file_name": "test_keep_largest_connected_component.py", "file_type": "text/x-python", "category": "test", "start_line": 255, "end_line": 309, "span_ids": ["impl:31"], "tokens": 878}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_13 = [\n \"onehot_independent_batch_2_apply_label_1_2_connect_2\",\n {\"independent\": True, \"applied_labels\": [1, 2], \"connectivity\": 2},\n grid_3,\n torch.tensor(\n [\n [\n [\n [1.0, 1.0, 0.0, 1.0, 1.0],\n [1.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 1.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 0.0],\n ],\n ],\n [\n [\n [1.0, 1.0, 1.0, 1.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n ],\n ]\n ),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_14_TEST_CASE_14._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_14_TEST_CASE_14._", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_component.py", "file_name": "test_keep_largest_connected_component.py", "file_type": "text/x-python", "category": "test", "start_line": 311, "end_line": 365, "span_ids": ["impl:33"], "tokens": 878}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_14 = [\n \"onehot_dependent_batch_2_apply_label_1_2_connect_2\",\n {\"independent\": False, \"applied_labels\": [1, 2], \"connectivity\": 2},\n grid_3,\n torch.tensor(\n [\n [\n [\n [1.0, 1.0, 0.0, 1.0, 1.0],\n [1.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [1.0, 0.0, 1.0, 0.0, 0.0],\n [1.0, 0.0, 0.0, 1.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 1.0],\n ],\n ],\n [\n [\n [1.0, 1.0, 1.0, 1.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n ],\n ]\n ),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_15_TEST_CASE_15._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TEST_CASE_15_TEST_CASE_15._", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_component.py", "file_name": "test_keep_largest_connected_component.py", "file_type": "text/x-python", "category": "test", "start_line": 367, "end_line": 421, "span_ids": ["impl:35"], "tokens": 878}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_15 = [\n \"onehot_dependent_batch_2_apply_label_1_2_connect_1\",\n {\"independent\": False, \"applied_labels\": [1, 2], \"connectivity\": 1},\n grid_3,\n torch.tensor(\n [\n [\n [\n [1.0, 1.0, 0.0, 1.0, 1.0],\n [1.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [1.0, 0.0, 1.0, 0.0, 0.0],\n [1.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 0.0],\n ],\n ],\n [\n [\n [1.0, 1.0, 1.0, 1.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n ],\n ]\n ),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_VALID_CASES_INVALID_CASES._ITEST_CASE_1_ITEST_CASE": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_VALID_CASES_INVALID_CASES._ITEST_CASE_1_ITEST_CASE", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_component.py", "file_name": "test_keep_largest_connected_component.py", "file_type": "text/x-python", "category": "test", "start_line": 423, "end_line": 445, "span_ids": ["impl:37"], "tokens": 167}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "VALID_CASES = [\n TEST_CASE_1,\n TEST_CASE_2,\n TEST_CASE_3,\n TEST_CASE_4,\n TEST_CASE_5,\n TEST_CASE_6,\n TEST_CASE_7,\n TEST_CASE_8,\n TEST_CASE_9,\n TEST_CASE_10,\n TEST_CASE_11,\n TEST_CASE_12,\n TEST_CASE_13,\n TEST_CASE_14,\n TEST_CASE_15,\n]\n\nITEST_CASE_1 = [\"no_applied_labels_for_single_channel\", {\"independent\": False}, grid_1, TypeError]\n\nITEST_CASE_2 = [\"no_applied_labels_for_multi_channel\", {\"independent\": False}, grid_3, TypeError]\n\nINVALID_CASES = [ITEST_CASE_1, ITEST_CASE_2]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TestKeepLargestConnectedComponent_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_component.py_TestKeepLargestConnectedComponent_", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_component.py", "file_name": "test_keep_largest_connected_component.py", "file_type": "text/x-python", "category": "test", "start_line": 448, "end_line": 471, "span_ids": ["impl:45", "TestKeepLargestConnectedComponent", "TestKeepLargestConnectedComponent.test_raise_exception", "TestKeepLargestConnectedComponent.test_correct_results"], "tokens": 171}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestKeepLargestConnectedComponent(unittest.TestCase):\n @parameterized.expand(VALID_CASES)\n def test_correct_results(self, _, args, tensor, expected):\n converter = KeepLargestConnectedComponent(**args)\n if torch.cuda.is_available():\n result = converter(tensor.clone().cuda())\n assert torch.allclose(result, expected.cuda())\n else:\n result = converter(tensor.clone())\n assert torch.allclose(result, expected)\n\n @parameterized.expand(INVALID_CASES)\n def test_raise_exception(self, _, args, tensor, expected_error):\n with self.assertRaises(expected_error):\n converter = KeepLargestConnectedComponent(**args)\n if torch.cuda.is_available():\n _ = converter(tensor.clone().cuda())\n else:\n _ = converter(tensor.clone())\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_unittest_grid_2._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_unittest_grid_2._", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_componentd.py", "file_name": "test_keep_largest_connected_componentd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 24, "span_ids": ["docstring"], "tokens": 205}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import KeepLargestConnectedComponentd\n\ngrid_1 = {\n \"img\": torch.tensor([[[[0, 0, 1, 0, 0], [0, 2, 1, 1, 1], [1, 2, 1, 0, 0], [1, 2, 0, 1, 0], [2, 2, 0, 0, 2]]]])\n}\ngrid_2 = {\n \"img\": torch.tensor([[[[0, 0, 0, 0, 1], [0, 0, 1, 1, 1], [1, 0, 1, 1, 2], [1, 0, 1, 2, 2], [0, 0, 0, 0, 1]]]])\n}", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_grid_3_grid_3._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_grid_3_grid_3._", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_componentd.py", "file_name": "test_keep_largest_connected_componentd.py", "file_type": "text/x-python", "category": "test", "start_line": 25, "end_line": 76, "span_ids": ["docstring"], "tokens": 831}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "grid_3 = {\n \"img\": torch.tensor(\n [\n [\n [\n [1.0, 1.0, 0.0, 1.0, 1.0],\n [1.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [1.0, 0.0, 1.0, 0.0, 0.0],\n [1.0, 0.0, 0.0, 1.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 1.0],\n ],\n ],\n [\n [\n [1.0, 1.0, 1.0, 1.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [1.0, 0.0, 1.0, 1.0, 0.0],\n [1.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n ],\n ]\n )\n}", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_1_TEST_CASE_6._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_1_TEST_CASE_6._", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_componentd.py", "file_name": "test_keep_largest_connected_componentd.py", "file_type": "text/x-python", "category": "test", "start_line": 78, "end_line": 118, "span_ids": ["impl:15", "impl:7"], "tokens": 746}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_1 = [\n \"value_1\",\n {\"keys\": [\"img\"], \"independent\": False, \"applied_labels\": 1},\n grid_1,\n torch.tensor([[[[0, 0, 1, 0, 0], [0, 2, 1, 1, 1], [0, 2, 1, 0, 0], [0, 2, 0, 1, 0], [2, 2, 0, 0, 2]]]]),\n]\n\nTEST_CASE_2 = [\n \"value_2\",\n {\"keys\": [\"img\"], \"independent\": False, \"applied_labels\": [2]},\n grid_1,\n torch.tensor([[[[0, 0, 1, 0, 0], [0, 2, 1, 1, 1], [1, 2, 1, 0, 0], [1, 2, 0, 1, 0], [2, 2, 0, 0, 0]]]]),\n]\n\nTEST_CASE_3 = [\n \"independent_value_1_2\",\n {\"keys\": [\"img\"], \"independent\": True, \"applied_labels\": [1, 2]},\n grid_1,\n torch.tensor([[[[0, 0, 1, 0, 0], [0, 2, 1, 1, 1], [0, 2, 1, 0, 0], [0, 2, 0, 1, 0], [2, 2, 0, 0, 0]]]]),\n]\n\nTEST_CASE_4 = [\n \"dependent_value_1_2\",\n {\"keys\": [\"img\"], \"independent\": False, \"applied_labels\": [1, 2]},\n grid_1,\n torch.tensor([[[[0, 0, 1, 0, 0], [0, 2, 1, 1, 1], [1, 2, 1, 0, 0], [1, 2, 0, 1, 0], [2, 2, 0, 0, 2]]]]),\n]\n\nTEST_CASE_5 = [\n \"value_1\",\n {\"keys\": [\"img\"], \"independent\": True, \"applied_labels\": [1]},\n grid_2,\n torch.tensor([[[[0, 0, 0, 0, 1], [0, 0, 1, 1, 1], [0, 0, 1, 1, 2], [0, 0, 1, 2, 2], [0, 0, 0, 0, 0]]]]),\n]\n\nTEST_CASE_6 = [\n \"independent_value_1_2\",\n {\"keys\": [\"img\"], \"independent\": True, \"applied_labels\": [1, 2]},\n grid_2,\n torch.tensor([[[[0, 0, 0, 0, 1], [0, 0, 1, 1, 1], [0, 0, 1, 1, 2], [0, 0, 1, 2, 2], [0, 0, 0, 0, 0]]]]),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_7_TEST_CASE_10._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_7_TEST_CASE_10._", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_componentd.py", "file_name": "test_keep_largest_connected_componentd.py", "file_type": "text/x-python", "category": "test", "start_line": 120, "end_line": 146, "span_ids": ["impl:23", "impl:15"], "tokens": 533}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_7 = [\n \"dependent_value_1_2\",\n {\"keys\": [\"img\"], \"independent\": False, \"applied_labels\": [1, 2]},\n grid_2,\n torch.tensor([[[[0, 0, 0, 0, 1], [0, 0, 1, 1, 1], [0, 0, 1, 1, 2], [0, 0, 1, 2, 2], [0, 0, 0, 0, 1]]]]),\n]\n\nTEST_CASE_8 = [\n \"value_1_connect_1\",\n {\"keys\": [\"img\"], \"independent\": False, \"applied_labels\": [1], \"connectivity\": 1},\n grid_1,\n torch.tensor([[[[0, 0, 1, 0, 0], [0, 2, 1, 1, 1], [0, 2, 1, 0, 0], [0, 2, 0, 0, 0], [2, 2, 0, 0, 2]]]]),\n]\n\nTEST_CASE_9 = [\n \"independent_value_1_2_connect_1\",\n {\"keys\": [\"img\"], \"independent\": True, \"applied_labels\": [1, 2], \"connectivity\": 1},\n grid_1,\n torch.tensor([[[[0, 0, 1, 0, 0], [0, 2, 1, 1, 1], [0, 2, 1, 0, 0], [0, 2, 0, 0, 0], [2, 2, 0, 0, 0]]]]),\n]\n\nTEST_CASE_10 = [\n \"dependent_value_1_2_connect_1\",\n {\"keys\": [\"img\"], \"independent\": False, \"applied_labels\": [1, 2], \"connectivity\": 1},\n grid_1,\n torch.tensor([[[[0, 0, 1, 0, 0], [0, 2, 1, 1, 1], [1, 2, 1, 0, 0], [1, 2, 0, 0, 0], [2, 2, 0, 0, 0]]]]),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_11_TEST_CASE_11._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_11_TEST_CASE_11._", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_componentd.py", "file_name": "test_keep_largest_connected_componentd.py", "file_type": "text/x-python", "category": "test", "start_line": 148, "end_line": 202, "span_ids": ["impl:23"], "tokens": 879}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_11 = [\n \"onehot_independent_batch_2_apply_label_1_connect_1\",\n {\"keys\": [\"img\"], \"independent\": True, \"applied_labels\": [1], \"connectivity\": 1},\n grid_3,\n torch.tensor(\n [\n [\n [\n [1.0, 1.0, 0.0, 1.0, 1.0],\n [1.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 1.0],\n ],\n ],\n [\n [\n [1.0, 1.0, 1.0, 1.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n ],\n ]\n ),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_12_TEST_CASE_12._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_12_TEST_CASE_12._", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_componentd.py", "file_name": "test_keep_largest_connected_componentd.py", "file_type": "text/x-python", "category": "test", "start_line": 204, "end_line": 258, "span_ids": ["impl:29"], "tokens": 879}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_12 = [\n \"onehot_independent_batch_2_apply_label_1_connect_2\",\n {\"keys\": [\"img\"], \"independent\": True, \"applied_labels\": [1], \"connectivity\": 2},\n grid_3,\n torch.tensor(\n [\n [\n [\n [1.0, 1.0, 0.0, 1.0, 1.0],\n [1.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 1.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 1.0],\n ],\n ],\n [\n [\n [1.0, 1.0, 1.0, 1.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n ],\n ]\n ),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_13_TEST_CASE_13._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_13_TEST_CASE_13._", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_componentd.py", "file_name": "test_keep_largest_connected_componentd.py", "file_type": "text/x-python", "category": "test", "start_line": 260, "end_line": 314, "span_ids": ["impl:31"], "tokens": 884}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_13 = [\n \"onehot_independent_batch_2_apply_label_1_2_connect_2\",\n {\"keys\": [\"img\"], \"independent\": True, \"applied_labels\": [1, 2], \"connectivity\": 2},\n grid_3,\n torch.tensor(\n [\n [\n [\n [1.0, 1.0, 0.0, 1.0, 1.0],\n [1.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 1.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 0.0],\n ],\n ],\n [\n [\n [1.0, 1.0, 1.0, 1.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n ],\n ]\n ),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_14_TEST_CASE_14._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_14_TEST_CASE_14._", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_componentd.py", "file_name": "test_keep_largest_connected_componentd.py", "file_type": "text/x-python", "category": "test", "start_line": 316, "end_line": 370, "span_ids": ["impl:33"], "tokens": 884}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_14 = [\n \"onehot_dependent_batch_2_apply_label_1_2_connect_2\",\n {\"keys\": [\"img\"], \"independent\": False, \"applied_labels\": [1, 2], \"connectivity\": 2},\n grid_3,\n torch.tensor(\n [\n [\n [\n [1.0, 1.0, 0.0, 1.0, 1.0],\n [1.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [1.0, 0.0, 1.0, 0.0, 0.0],\n [1.0, 0.0, 0.0, 1.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 1.0],\n ],\n ],\n [\n [\n [1.0, 1.0, 1.0, 1.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n ],\n ]\n ),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_15_TEST_CASE_15._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TEST_CASE_15_TEST_CASE_15._", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_componentd.py", "file_name": "test_keep_largest_connected_componentd.py", "file_type": "text/x-python", "category": "test", "start_line": 372, "end_line": 426, "span_ids": ["impl:35"], "tokens": 884}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_15 = [\n \"onehot_dependent_batch_2_apply_label_1_2_connect_1\",\n {\"keys\": [\"img\"], \"independent\": False, \"applied_labels\": [1, 2], \"connectivity\": 1},\n grid_3,\n torch.tensor(\n [\n [\n [\n [1.0, 1.0, 0.0, 1.0, 1.0],\n [1.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [1.0, 0.0, 1.0, 0.0, 0.0],\n [1.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 0.0],\n ],\n ],\n [\n [\n [1.0, 1.0, 1.0, 1.0, 0.0],\n [1.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [0.0, 1.0, 0.0, 0.0, 0.0],\n [1.0, 1.0, 1.0, 1.0, 0.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 1.0],\n [0.0, 0.0, 1.0, 1.0, 0.0],\n [0.0, 0.0, 1.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n ],\n [\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n [0.0, 0.0, 0.0, 0.0, 1.0],\n [0.0, 0.0, 0.0, 1.0, 1.0],\n [0.0, 0.0, 0.0, 0.0, 0.0],\n ],\n ],\n ]\n ),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_VALID_CASES_INVALID_CASES._ITEST_CASE_1_ITEST_CASE": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_VALID_CASES_INVALID_CASES._ITEST_CASE_1_ITEST_CASE", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_componentd.py", "file_name": "test_keep_largest_connected_componentd.py", "file_type": "text/x-python", "category": "test", "start_line": 428, "end_line": 450, "span_ids": ["impl:37"], "tokens": 179}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "VALID_CASES = [\n TEST_CASE_1,\n TEST_CASE_2,\n TEST_CASE_3,\n TEST_CASE_4,\n TEST_CASE_5,\n TEST_CASE_6,\n TEST_CASE_7,\n TEST_CASE_8,\n TEST_CASE_9,\n TEST_CASE_10,\n TEST_CASE_11,\n TEST_CASE_12,\n TEST_CASE_13,\n TEST_CASE_14,\n TEST_CASE_15,\n]\n\nITEST_CASE_1 = [\"no_applied_labels_for_single_channel\", {\"keys\": [\"img\"], \"independent\": False}, grid_1, TypeError]\n\nITEST_CASE_2 = [\"no_applied_labels_for_multi_channel\", {\"keys\": [\"img\"], \"independent\": False}, grid_3, TypeError]\n\nINVALID_CASES = [ITEST_CASE_1, ITEST_CASE_2]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TestKeepLargestConnectedComponentd_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_keep_largest_connected_componentd.py_TestKeepLargestConnectedComponentd_", "embedding": null, "metadata": {"file_path": "tests/test_keep_largest_connected_componentd.py", "file_name": "test_keep_largest_connected_componentd.py", "file_type": "text/x-python", "category": "test", "start_line": 453, "end_line": 476, "span_ids": ["TestKeepLargestConnectedComponentd.test_correct_results", "TestKeepLargestConnectedComponentd.test_raise_exception", "TestKeepLargestConnectedComponentd", "impl:45"], "tokens": 192}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestKeepLargestConnectedComponentd(unittest.TestCase):\n @parameterized.expand(VALID_CASES)\n def test_correct_results(self, _, args, input_dict, expected):\n converter = KeepLargestConnectedComponentd(**args)\n if torch.cuda.is_available():\n input_dict[\"img\"] = input_dict[\"img\"].cuda()\n result = converter(input_dict)\n torch.allclose(result[\"img\"], expected.cuda())\n else:\n result = converter(input_dict)\n torch.allclose(result[\"img\"], expected)\n\n @parameterized.expand(INVALID_CASES)\n def test_raise_exception(self, _, args, input_dict, expected_error):\n with self.assertRaises(expected_error):\n converter = KeepLargestConnectedComponentd(**args)\n if torch.cuda.is_available():\n input_dict[\"img\"] = input_dict[\"img\"].cuda()\n _ = converter(input_dict)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contour.py_unittest_expected_output_for_cube": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contour.py_unittest_expected_output_for_cube", "embedding": null, "metadata": {"file_path": "tests/test_label_to_contour.py", "file_name": "test_label_to_contour.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 100, "span_ids": ["docstring"], "tokens": 30}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport torch\nimport numpy as np\nfrom monai.transforms import LabelToContour\n\nexpected_output_for_cube =\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contour.py_gen_fixed_cube_gen_fixed_cube.return.cube_expected_output_for": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contour.py_gen_fixed_cube_gen_fixed_cube.return.cube_expected_output_for", "embedding": null, "metadata": {"file_path": "tests/test_label_to_contour.py", "file_name": "test_label_to_contour.py", "file_type": "text/x-python", "category": "test", "start_line": 103, "end_line": 113, "span_ids": ["gen_fixed_cube"], "tokens": 129}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def gen_fixed_cube():\n scale, core_start, core_end = 8, 1, 7\n cube = torch.zeros(scale, scale, scale)\n cube[core_start:core_end, core_start:core_end, core_start:core_end] = torch.ones(\n core_end - core_start, core_end - core_start, core_end - core_start\n )\n cube = torch.unsqueeze(cube, 0)\n\n batch_size, channels = 10, 6\n cube = cube.repeat(batch_size, channels, 1, 1, 1)\n return cube, expected_output_for_cube", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contour.py_gen_fixed_img_gen_fixed_img.return.img_expected_output_for_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contour.py_gen_fixed_img_gen_fixed_img.return.img_expected_output_for_", "embedding": null, "metadata": {"file_path": "tests/test_label_to_contour.py", "file_name": "test_label_to_contour.py", "file_type": "text/x-python", "category": "test", "start_line": 116, "end_line": 139, "span_ids": ["gen_fixed_img"], "tokens": 300}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def gen_fixed_img():\n img = torch.tensor(\n [\n [0, 0, 0, 1, 1, 1, 1],\n [0, 0, 0, 1, 1, 1, 1],\n [0, 0, 1, 1, 1, 1, 1],\n [0, 1, 1, 1, 1, 1, 1],\n [1, 1, 1, 1, 1, 1, 1],\n ],\n dtype=torch.float32,\n )\n batch_size, channels = 10, 6\n img = img.repeat(batch_size, channels, 1, 1)\n expected_output_for_img = torch.tensor(\n [\n [0, 0, 0, 1, 1, 1, 1],\n [0, 0, 0, 1, 0, 0, 1],\n [0, 0, 1, 1, 0, 0, 1],\n [0, 1, 1, 0, 0, 0, 1],\n [1, 1, 1, 1, 1, 1, 1],\n ],\n dtype=torch.float32,\n )\n return img, expected_output_for_img", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contour.py_TestContour_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contour.py_TestContour_", "embedding": null, "metadata": {"file_path": "tests/test_label_to_contour.py", "file_name": "test_label_to_contour.py", "file_type": "text/x-python", "category": "test", "start_line": 142, "end_line": 177, "span_ids": ["impl:3", "TestContour", "TestContour.test_contour"], "tokens": 349}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestContour(unittest.TestCase):\n def test_contour(self):\n input_param = {\"kernel_type\": \"Laplace\"}\n\n # check 5-dim input data\n test_cube, expected_output = gen_fixed_cube()\n test_result_cube = LabelToContour(**input_param)(test_cube)\n self.assertEqual(test_result_cube.shape, test_cube.shape)\n\n test_result_np = test_result_cube.data.cpu().numpy()\n batch_size, channels = test_cube.shape[0], test_cube.shape[1]\n for batch in range(batch_size):\n for channel in range(channels):\n np.testing.assert_allclose(test_result_np[batch, channel, ...], expected_output)\n\n # check 4-dim input data\n test_img, expected_output = gen_fixed_img()\n batch_size, channels = test_img.shape[0], test_img.shape[1]\n test_result_img = LabelToContour(**input_param)(test_img)\n self.assertEqual(test_result_img.shape, test_img.shape)\n\n test_result_np = test_result_img.data.cpu().numpy()\n for batch in range(batch_size):\n for channel in range(channels):\n np.testing.assert_allclose(test_result_img[batch, channel, ...], expected_output)\n\n # check invalid input data\n error_input = torch.rand(1, 2, 3)\n self.assertRaises(RuntimeError, LabelToContour(**input_param), error_input)\n error_input = torch.rand(1, 2, 3, 4, 5, 6)\n self.assertRaises(RuntimeError, LabelToContour(**input_param), error_input)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contourd.py_unittest_expected_output_for_cube": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contourd.py_unittest_expected_output_for_cube", "embedding": null, "metadata": {"file_path": "tests/test_label_to_contourd.py", "file_name": "test_label_to_contourd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 100, "span_ids": ["docstring"], "tokens": 30}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport torch\nimport numpy as np\nfrom monai.transforms import LabelToContourd\n\nexpected_output_for_cube =\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contourd.py_gen_fixed_cube_gen_fixed_cube.return.cube_expected_output_for": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contourd.py_gen_fixed_cube_gen_fixed_cube.return.cube_expected_output_for", "embedding": null, "metadata": {"file_path": "tests/test_label_to_contourd.py", "file_name": "test_label_to_contourd.py", "file_type": "text/x-python", "category": "test", "start_line": 103, "end_line": 113, "span_ids": ["gen_fixed_cube"], "tokens": 129}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def gen_fixed_cube():\n scale, core_start, core_end = 8, 1, 7\n cube = torch.zeros(scale, scale, scale)\n cube[core_start:core_end, core_start:core_end, core_start:core_end] = torch.ones(\n core_end - core_start, core_end - core_start, core_end - core_start\n )\n cube = torch.unsqueeze(cube, 0)\n\n batch_size, channels = 10, 6\n cube = cube.repeat(batch_size, channels, 1, 1, 1)\n return cube, expected_output_for_cube", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contourd.py_gen_fixed_img_gen_fixed_img.return.img_expected_output_for_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contourd.py_gen_fixed_img_gen_fixed_img.return.img_expected_output_for_", "embedding": null, "metadata": {"file_path": "tests/test_label_to_contourd.py", "file_name": "test_label_to_contourd.py", "file_type": "text/x-python", "category": "test", "start_line": 116, "end_line": 139, "span_ids": ["gen_fixed_img"], "tokens": 300}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def gen_fixed_img():\n img = torch.tensor(\n [\n [0, 0, 0, 1, 1, 1, 1],\n [0, 0, 0, 1, 1, 1, 1],\n [0, 0, 1, 1, 1, 1, 1],\n [0, 1, 1, 1, 1, 1, 1],\n [1, 1, 1, 1, 1, 1, 1],\n ],\n dtype=torch.float32,\n )\n batch_size, channels = 10, 6\n img = img.repeat(batch_size, channels, 1, 1)\n expected_output_for_img = torch.tensor(\n [\n [0, 0, 0, 1, 1, 1, 1],\n [0, 0, 0, 1, 0, 0, 1],\n [0, 0, 1, 1, 0, 0, 1],\n [0, 1, 1, 0, 0, 0, 1],\n [1, 1, 1, 1, 1, 1, 1],\n ],\n dtype=torch.float32,\n )\n return img, expected_output_for_img", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contourd.py_TestContourd_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_contourd.py_TestContourd_", "embedding": null, "metadata": {"file_path": "tests/test_label_to_contourd.py", "file_name": "test_label_to_contourd.py", "file_type": "text/x-python", "category": "test", "start_line": 142, "end_line": 177, "span_ids": ["impl:3", "TestContourd", "TestContourd.test_contour"], "tokens": 381}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestContourd(unittest.TestCase):\n def test_contour(self):\n input_param = {\"keys\": \"img\", \"kernel_type\": \"Laplace\"}\n\n # check 5-dim input data\n test_cube, expected_output = gen_fixed_cube()\n test_result_cube = LabelToContourd(**input_param)({\"img\": test_cube})\n self.assertEqual(test_result_cube[\"img\"].shape, test_cube.shape)\n\n test_result_np = test_result_cube[\"img\"].data.cpu().numpy()\n batch_size, channels = test_cube.shape[0], test_cube.shape[1]\n for batch in range(batch_size):\n for channel in range(channels):\n np.testing.assert_allclose(test_result_np[batch, channel, ...], expected_output)\n\n # check 4-dim input data\n test_img, expected_output = gen_fixed_img()\n batch_size, channels = test_img.shape[0], test_img.shape[1]\n test_result_img = LabelToContourd(**input_param)({\"img\": test_img})\n self.assertEqual(test_result_img[\"img\"].shape, test_img.shape)\n\n test_result_np = test_result_img[\"img\"].data.cpu().numpy()\n for batch in range(batch_size):\n for channel in range(channels):\n np.testing.assert_allclose(test_result_img[\"img\"][batch, channel, ...], expected_output)\n\n # check invalid input data\n error_input = {\"img\": torch.rand(1, 2, 3)}\n self.assertRaises(RuntimeError, LabelToContourd(**input_param), error_input)\n error_input = {\"img\": torch.rand(1, 2, 3, 4, 5, 6)}\n self.assertRaises(RuntimeError, LabelToContourd(**input_param), error_input)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_mask.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_mask.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_label_to_mask.py", "file_name": "test_label_to_mask.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 58, "span_ids": ["TestLabelToMask.test_value", "impl:11", "impl:7", "docstring", "TestLabelToMask"], "tokens": 726}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.transforms import LabelToMask\n\nTEST_CASE_1 = [\n {\"select_labels\": [2, 3], \"merge_channels\": False},\n np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6]]]),\n np.array([[[0, 0, 0], [1, 1, 1], [1, 1, 1], [0, 0, 0], [0, 0, 0], [0, 0, 0]]]),\n]\n\nTEST_CASE_2 = [\n {\"select_labels\": 2, \"merge_channels\": False},\n np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6]]]),\n np.array([[[0, 0, 0], [1, 1, 1], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]]),\n]\n\nTEST_CASE_3 = [\n {\"select_labels\": [1, 2], \"merge_channels\": False},\n np.array([[[0, 0, 1], [0, 1, 0]], [[1, 0, 0], [0, 1, 1]], [[1, 0, 1], [1, 1, 0]]]),\n np.array([[[1, 0, 0], [0, 1, 1]], [[1, 0, 1], [1, 1, 0]]]),\n]\n\nTEST_CASE_4 = [\n {\"select_labels\": 2, \"merge_channels\": False},\n np.array([[[0, 0, 1], [0, 1, 0]], [[1, 0, 0], [0, 1, 1]], [[1, 0, 1], [1, 1, 0]]]),\n np.array([[[1, 0, 1], [1, 1, 0]]]),\n]\n\nTEST_CASE_5 = [\n {\"select_labels\": [1, 2], \"merge_channels\": True},\n np.array([[[0, 0, 1], [0, 1, 0]], [[1, 0, 0], [0, 1, 1]], [[1, 0, 1], [1, 1, 0]]]),\n np.array([[[1, 0, 1], [1, 1, 1]]]),\n]\n\n\nclass TestLabelToMask(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5])\n def test_value(self, argments, image, expected_data):\n result = LabelToMask(**argments)(image)\n np.testing.assert_allclose(result, expected_data)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_maskd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_label_to_maskd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_label_to_maskd.py", "file_name": "test_label_to_maskd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 58, "span_ids": ["impl:11", "TestLabelToMaskd", "impl:7", "TestLabelToMaskd.test_value", "docstring"], "tokens": 781}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.transforms import LabelToMaskd\n\nTEST_CASE_1 = [\n {\"keys\": \"img\", \"select_labels\": [2, 3], \"merge_channels\": False},\n {\"img\": np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6]]])},\n np.array([[[0, 0, 0], [1, 1, 1], [1, 1, 1], [0, 0, 0], [0, 0, 0], [0, 0, 0]]]),\n]\n\nTEST_CASE_2 = [\n {\"keys\": \"img\", \"select_labels\": 2, \"merge_channels\": False},\n {\"img\": np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6]]])},\n np.array([[[0, 0, 0], [1, 1, 1], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]]),\n]\n\nTEST_CASE_3 = [\n {\"keys\": \"img\", \"select_labels\": [1, 2], \"merge_channels\": False},\n {\"img\": np.array([[[0, 0, 1], [0, 1, 0]], [[1, 0, 0], [0, 1, 1]], [[1, 0, 1], [1, 1, 0]]])},\n np.array([[[1, 0, 0], [0, 1, 1]], [[1, 0, 1], [1, 1, 0]]]),\n]\n\nTEST_CASE_4 = [\n {\"keys\": \"img\", \"select_labels\": 2, \"merge_channels\": False},\n {\"img\": np.array([[[0, 0, 1], [0, 1, 0]], [[1, 0, 0], [0, 1, 1]], [[1, 0, 1], [1, 1, 0]]])},\n np.array([[[1, 0, 1], [1, 1, 0]]]),\n]\n\nTEST_CASE_5 = [\n {\"keys\": \"img\", \"select_labels\": [1, 2], \"merge_channels\": True},\n {\"img\": np.array([[[0, 0, 1], [0, 1, 0]], [[1, 0, 0], [0, 1, 1]], [[1, 0, 1], [1, 1, 0]]])},\n np.array([[[1, 0, 1], [1, 1, 1]]]),\n]\n\n\nclass TestLabelToMaskd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5])\n def test_value(self, argments, image, expected_data):\n result = LabelToMaskd(**argments)(image)\n np.testing.assert_allclose(result[\"img\"], expected_data)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_lambda.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_lambda.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_lambda.py", "file_name": "test_lambda.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 42, "span_ids": ["impl", "TestLambda.test_lambda_identity", "docstring", "TestLambda", "TestLambda.test_lambda_slicing"], "tokens": 155}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\n\nfrom monai.transforms.utility.array import Lambda\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestLambda(NumpyImageTestCase2D):\n def test_lambda_identity(self):\n img = self.imt\n\n def identity_func(x):\n return x\n\n lambd = Lambda(func=identity_func)\n self.assertTrue(np.allclose(identity_func(img), lambd(img)))\n\n def test_lambda_slicing(self):\n img = self.imt\n\n def slice_func(x):\n return x[:, :, :6, ::-2]\n\n lambd = Lambda(func=slice_func)\n self.assertTrue(np.allclose(slice_func(img), lambd(img)))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_lambdad.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_lambdad.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_lambdad.py", "file_name": "test_lambdad.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 50, "span_ids": ["impl", "TestLambdad", "docstring", "TestLambdad.test_lambdad_identity", "TestLambdad.test_lambdad_slicing"], "tokens": 238}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\n\nfrom monai.transforms.utility.dictionary import Lambdad\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestLambdad(NumpyImageTestCase2D):\n def test_lambdad_identity(self):\n img = self.imt\n data = dict()\n data[\"img\"] = img\n\n def identity_func(x):\n return x\n\n lambd = Lambdad(keys=data.keys(), func=identity_func)\n expected = data\n expected[\"img\"] = identity_func(data[\"img\"])\n self.assertTrue(np.allclose(expected[\"img\"], lambd(data)[\"img\"]))\n\n def test_lambdad_slicing(self):\n img = self.imt\n data = dict()\n data[\"img\"] = img\n\n def slice_func(x):\n return x[:, :, :6, ::-2]\n\n lambd = Lambdad(keys=data.keys(), func=slice_func)\n expected = dict()\n expected[\"img\"] = slice_func(data[\"img\"])\n self.assertTrue(np.allclose(expected[\"img\"], lambd(data)[\"img\"]))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_list_data_collate.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_list_data_collate.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_list_data_collate.py", "file_name": "test_list_data_collate.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 46, "span_ids": ["impl:21", "TestListDataCollate.test_type_shape", "TestListDataCollate", "docstring"], "tokens": 426}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport torch\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.data import list_data_collate\n\na = {\"image\": np.array([1, 2, 3]), \"label\": np.array([4, 5, 6])}\nb = {\"image\": np.array([7, 8, 9]), \"label\": np.array([10, 11, 12])}\nc = {\"image\": np.array([13, 14, 15]), \"label\": np.array([16, 7, 18])}\nd = {\"image\": np.array([19, 20, 21]), \"label\": np.array([22, 23, 24])}\nTEST_CASE_1 = [[[a, b], [c, d]], dict, torch.Size([4, 3])] # dataset returns a list of dictionary data\n\ne = (np.array([1, 2, 3]), np.array([4, 5, 6]))\nf = (np.array([7, 8, 9]), np.array([10, 11, 12]))\ng = (np.array([13, 14, 15]), np.array([16, 7, 18]))\nh = (np.array([19, 20, 21]), np.array([22, 23, 24]))\nTEST_CASE_2 = [[[e, f], [g, h]], list, torch.Size([4, 3])] # dataset returns a list of tuple data\n\n\nclass TestListDataCollate(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2])\n def test_type_shape(self, input_data, expected_type, expected_shape):\n result = list_data_collate(input_data)\n self.assertIsInstance(result, expected_type)\n if isinstance(result, dict):\n data = result[\"image\"]\n else:\n data = result[0]\n self.assertEqual(data.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_decathalon_datalist.py_unittest_TestLoadDecathalonDatalist.test_seg_values.shutil_rmtree_tempdir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_decathalon_datalist.py_unittest_TestLoadDecathalonDatalist.test_seg_values.shutil_rmtree_tempdir_", "embedding": null, "metadata": {"file_path": "tests/test_load_decathalon_datalist.py", "file_name": "test_load_decathalon_datalist.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 40, "span_ids": ["TestLoadDecathalonDatalist", "TestLoadDecathalonDatalist.test_seg_values", "docstring"], "tokens": 299}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport os\nimport json\nimport shutil\nimport tempfile\nfrom monai.data import load_decathalon_datalist\n\n\nclass TestLoadDecathalonDatalist(unittest.TestCase):\n def test_seg_values(self):\n tempdir = tempfile.mkdtemp()\n test_data = {\n \"name\": \"Spleen\",\n \"description\": \"Spleen Segmentation\",\n \"labels\": {\"0\": \"background\", \"1\": \"spleen\"},\n \"training\": [\n {\"image\": \"spleen_19.nii.gz\", \"label\": \"spleen_19.nii.gz\"},\n {\"image\": \"spleen_31.nii.gz\", \"label\": \"spleen_31.nii.gz\"},\n ],\n \"test\": [\"spleen_15.nii.gz\", \"spleen_23.nii.gz\"],\n }\n json_str = json.dumps(test_data)\n file_path = os.path.join(tempdir, \"test_data.json\")\n with open(file_path, \"w\") as json_file:\n json_file.write(json_str)\n result = load_decathalon_datalist(file_path, True, \"training\", tempdir)\n self.assertEqual(result[0][\"image\"], os.path.join(tempdir, \"spleen_19.nii.gz\"))\n self.assertEqual(result[0][\"label\"], os.path.join(tempdir, \"spleen_19.nii.gz\"))\n shutil.rmtree(tempdir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_decathalon_datalist.py_TestLoadDecathalonDatalist.test_cls_values_TestLoadDecathalonDatalist.test_cls_values.shutil_rmtree_tempdir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_decathalon_datalist.py_TestLoadDecathalonDatalist.test_cls_values_TestLoadDecathalonDatalist.test_cls_values.shutil_rmtree_tempdir_", "embedding": null, "metadata": {"file_path": "tests/test_load_decathalon_datalist.py", "file_name": "test_load_decathalon_datalist.py", "file_type": "text/x-python", "category": "test", "start_line": 42, "end_line": 58, "span_ids": ["TestLoadDecathalonDatalist.test_cls_values"], "tokens": 231}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadDecathalonDatalist(unittest.TestCase):\n\n def test_cls_values(self):\n tempdir = tempfile.mkdtemp()\n test_data = {\n \"name\": \"ChestXRay\",\n \"description\": \"Chest X-ray classification\",\n \"labels\": {\"0\": \"background\", \"1\": \"chest\"},\n \"training\": [{\"image\": \"chest_19.nii.gz\", \"label\": 0}, {\"image\": \"chest_31.nii.gz\", \"label\": 1}],\n \"test\": [\"chest_15.nii.gz\", \"chest_23.nii.gz\"],\n }\n json_str = json.dumps(test_data)\n file_path = os.path.join(tempdir, \"test_data.json\")\n with open(file_path, \"w\") as json_file:\n json_file.write(json_str)\n result = load_decathalon_datalist(file_path, False, \"training\", tempdir)\n self.assertEqual(result[0][\"image\"], os.path.join(tempdir, \"chest_19.nii.gz\"))\n self.assertEqual(result[0][\"label\"], 0)\n shutil.rmtree(tempdir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_decathalon_datalist.py_TestLoadDecathalonDatalist.test_seg_no_basedir_TestLoadDecathalonDatalist.test_seg_no_basedir.None_1": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_decathalon_datalist.py_TestLoadDecathalonDatalist.test_seg_no_basedir_TestLoadDecathalonDatalist.test_seg_no_basedir.None_1", "embedding": null, "metadata": {"file_path": "tests/test_load_decathalon_datalist.py", "file_name": "test_load_decathalon_datalist.py", "file_type": "text/x-python", "category": "test", "start_line": 60, "end_line": 84, "span_ids": ["TestLoadDecathalonDatalist.test_seg_no_basedir"], "tokens": 314}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadDecathalonDatalist(unittest.TestCase):\n\n def test_seg_no_basedir(self):\n tempdir = tempfile.mkdtemp()\n test_data = {\n \"name\": \"Spleen\",\n \"description\": \"Spleen Segmentation\",\n \"labels\": {\"0\": \"background\", \"1\": \"spleen\"},\n \"training\": [\n {\n \"image\": os.path.join(tempdir, \"spleen_19.nii.gz\"),\n \"label\": os.path.join(tempdir, \"spleen_19.nii.gz\"),\n },\n {\n \"image\": os.path.join(tempdir, \"spleen_31.nii.gz\"),\n \"label\": os.path.join(tempdir, \"spleen_31.nii.gz\"),\n },\n ],\n \"test\": [os.path.join(tempdir, \"spleen_15.nii.gz\"), os.path.join(tempdir, \"spleen_23.nii.gz\")],\n }\n json_str = json.dumps(test_data)\n file_path = os.path.join(tempdir, \"test_data.json\")\n with open(file_path, \"w\") as json_file:\n json_file.write(json_str)\n result = load_decathalon_datalist(file_path, True, \"training\", None)\n self.assertEqual(result[0][\"image\"], os.path.join(tempdir, \"spleen_19.nii.gz\"))\n self.assertEqual(result[0][\"label\"], os.path.join(tempdir, \"spleen_19.nii.gz\"))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_decathalon_datalist.py_TestLoadDecathalonDatalist.test_seg_no_labels_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_decathalon_datalist.py_TestLoadDecathalonDatalist.test_seg_no_labels_", "embedding": null, "metadata": {"file_path": "tests/test_load_decathalon_datalist.py", "file_name": "test_load_decathalon_datalist.py", "file_type": "text/x-python", "category": "test", "start_line": 86, "end_line": 105, "span_ids": ["TestLoadDecathalonDatalist.test_seg_no_labels", "impl"], "tokens": 203}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadDecathalonDatalist(unittest.TestCase):\n\n def test_seg_no_labels(self):\n tempdir = tempfile.mkdtemp()\n test_data = {\n \"name\": \"Spleen\",\n \"description\": \"Spleen Segmentation\",\n \"labels\": {\"0\": \"background\", \"1\": \"spleen\"},\n \"test\": [\"spleen_15.nii.gz\", \"spleen_23.nii.gz\"],\n }\n json_str = json.dumps(test_data)\n file_path = os.path.join(tempdir, \"test_data.json\")\n with open(file_path, \"w\") as json_file:\n json_file.write(json_str)\n result = load_decathalon_datalist(file_path, True, \"test\", tempdir)\n self.assertEqual(result[0][\"image\"], os.path.join(tempdir, \"spleen_15.nii.gz\"))\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_nifti.py_unittest_TEST_CASE_4._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_nifti.py_unittest_TEST_CASE_4._", "embedding": null, "metadata": {"file_path": "tests/test_load_nifti.py", "file_name": "test_load_nifti.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 35, "span_ids": ["docstring"], "tokens": 226}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport os\nimport shutil\nimport numpy as np\nimport tempfile\nimport nibabel as nib\nfrom parameterized import parameterized\nfrom monai.transforms import LoadNifti\n\nTEST_CASE_1 = [{\"as_closest_canonical\": False, \"image_only\": True}, [\"test_image.nii.gz\"], (128, 128, 128)]\n\nTEST_CASE_2 = [{\"as_closest_canonical\": False, \"image_only\": False}, [\"test_image.nii.gz\"], (128, 128, 128)]\n\nTEST_CASE_3 = [\n {\"as_closest_canonical\": False, \"image_only\": True},\n [\"test_image1.nii.gz\", \"test_image2.nii.gz\", \"test_image3.nii.gz\"],\n (3, 128, 128, 128),\n]\n\nTEST_CASE_4 = [\n {\"as_closest_canonical\": False, \"image_only\": False},\n [\"test_image1.nii.gz\", \"test_image2.nii.gz\", \"test_image3.nii.gz\"],\n (3, 128, 128, 128),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_nifti.py_TestLoadNifti_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_nifti.py_TestLoadNifti_", "embedding": null, "metadata": {"file_path": "tests/test_load_nifti.py", "file_name": "test_load_nifti.py", "file_type": "text/x-python", "category": "test", "start_line": 38, "end_line": 60, "span_ids": ["TestLoadNifti", "impl:9", "TestLoadNifti.test_shape"], "tokens": 238}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadNifti(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4])\n def test_shape(self, input_param, filenames, expected_shape):\n test_image = np.random.randint(0, 2, size=[128, 128, 128])\n tempdir = tempfile.mkdtemp()\n for i, name in enumerate(filenames):\n filenames[i] = os.path.join(tempdir, name)\n nib.save(nib.Nifti1Image(test_image, np.eye(4)), filenames[i])\n result = LoadNifti(**input_param)(filenames)\n\n if isinstance(result, tuple):\n result, header = result\n self.assertTrue(\"affine\" in header)\n np.testing.assert_allclose(header[\"affine\"], np.eye(4))\n if input_param[\"as_closest_canonical\"]:\n np.testing.asesrt_allclose(header[\"original_affine\"], np.eye(4))\n self.assertTupleEqual(result.shape, expected_shape)\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_niftid.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_niftid.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_load_niftid.py", "file_name": "test_load_niftid.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 43, "span_ids": ["TestLoadNiftid", "impl:5", "TestLoadNiftid.test_shape", "docstring"], "tokens": 262}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport os\nimport shutil\nimport numpy as np\nimport tempfile\nimport nibabel as nib\nfrom parameterized import parameterized\nfrom monai.transforms import LoadNiftid\n\nKEYS = [\"image\", \"label\", \"extra\"]\n\nTEST_CASE_1 = [{\"keys\": KEYS, \"as_closest_canonical\": False}, (128, 128, 128)]\n\n\nclass TestLoadNiftid(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1])\n def test_shape(self, input_param, expected_shape):\n test_image = nib.Nifti1Image(np.random.randint(0, 2, size=[128, 128, 128]), np.eye(4))\n test_data = dict()\n tempdir = tempfile.mkdtemp()\n for key in KEYS:\n nib.save(test_image, os.path.join(tempdir, key + \".nii.gz\"))\n test_data.update({key: os.path.join(tempdir, key + \".nii.gz\")})\n result = LoadNiftid(**input_param)(test_data)\n for key in KEYS:\n self.assertTupleEqual(result[key].shape, expected_shape)\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpy.py_unittest_TestLoadNumpy.test_npy.shutil_rmtree_tempdir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpy.py_unittest_TestLoadNumpy.test_npy.shutil_rmtree_tempdir_", "embedding": null, "metadata": {"file_path": "tests/test_load_numpy.py", "file_name": "test_load_numpy.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 32, "span_ids": ["TestLoadNumpy.test_npy", "TestLoadNumpy", "docstring"], "tokens": 155}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport os\nimport shutil\nimport numpy as np\nimport tempfile\nfrom monai.transforms import LoadNumpy\n\n\nclass TestLoadNumpy(unittest.TestCase):\n def test_npy(self):\n test_data = np.random.randint(0, 256, size=[3, 4, 4])\n tempdir = tempfile.mkdtemp()\n filepath = os.path.join(tempdir, \"test_data.npy\")\n np.save(filepath, test_data)\n\n result = LoadNumpy()(filepath)\n self.assertTupleEqual(result[1][\"spatial_shape\"], test_data.shape)\n self.assertTupleEqual(result[0].shape, test_data.shape)\n np.testing.assert_allclose(result[0], test_data)\n\n shutil.rmtree(tempdir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpy.py_TestLoadNumpy.test_npz1_TestLoadNumpy.test_npz1.shutil_rmtree_tempdir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpy.py_TestLoadNumpy.test_npz1_TestLoadNumpy.test_npz1.shutil_rmtree_tempdir_", "embedding": null, "metadata": {"file_path": "tests/test_load_numpy.py", "file_name": "test_load_numpy.py", "file_type": "text/x-python", "category": "test", "start_line": 34, "end_line": 45, "span_ids": ["TestLoadNumpy.test_npz1"], "tokens": 135}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadNumpy(unittest.TestCase):\n\n def test_npz1(self):\n test_data1 = np.random.randint(0, 256, size=[3, 4, 4])\n tempdir = tempfile.mkdtemp()\n filepath = os.path.join(tempdir, \"test_data.npy\")\n np.save(filepath, test_data1)\n\n result = LoadNumpy()(filepath)\n self.assertTupleEqual(result[1][\"spatial_shape\"], test_data1.shape)\n self.assertTupleEqual(result[0].shape, test_data1.shape)\n np.testing.assert_allclose(result[0], test_data1)\n\n shutil.rmtree(tempdir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpy.py_TestLoadNumpy.test_npz2_TestLoadNumpy.test_npz2.shutil_rmtree_tempdir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpy.py_TestLoadNumpy.test_npz2_TestLoadNumpy.test_npz2.shutil_rmtree_tempdir_", "embedding": null, "metadata": {"file_path": "tests/test_load_numpy.py", "file_name": "test_load_numpy.py", "file_type": "text/x-python", "category": "test", "start_line": 47, "end_line": 59, "span_ids": ["TestLoadNumpy.test_npz2"], "tokens": 179}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadNumpy(unittest.TestCase):\n\n def test_npz2(self):\n test_data1 = np.random.randint(0, 256, size=[3, 4, 4])\n test_data2 = np.random.randint(0, 256, size=[3, 4, 4])\n tempdir = tempfile.mkdtemp()\n filepath = os.path.join(tempdir, \"test_data.npz\")\n np.savez(filepath, test_data1, test_data2)\n\n result = LoadNumpy()(filepath)\n self.assertTupleEqual(result[1][\"spatial_shape\"], test_data1.shape)\n self.assertTupleEqual(result[0].shape, (2, 3, 4, 4))\n np.testing.assert_allclose(result[0], np.stack([test_data1, test_data2]))\n\n shutil.rmtree(tempdir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpy.py_TestLoadNumpy.test_npz3_TestLoadNumpy.test_npz3.shutil_rmtree_tempdir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpy.py_TestLoadNumpy.test_npz3_TestLoadNumpy.test_npz3.shutil_rmtree_tempdir_", "embedding": null, "metadata": {"file_path": "tests/test_load_numpy.py", "file_name": "test_load_numpy.py", "file_type": "text/x-python", "category": "test", "start_line": 61, "end_line": 73, "span_ids": ["TestLoadNumpy.test_npz3"], "tokens": 194}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadNumpy(unittest.TestCase):\n\n def test_npz3(self):\n test_data1 = np.random.randint(0, 256, size=[3, 4, 4])\n test_data2 = np.random.randint(0, 256, size=[3, 4, 4])\n tempdir = tempfile.mkdtemp()\n filepath = os.path.join(tempdir, \"test_data.npz\")\n np.savez(filepath, test1=test_data1, test2=test_data2)\n\n result = LoadNumpy(npz_keys=[\"test1\", \"test2\"])(filepath)\n self.assertTupleEqual(result[1][\"spatial_shape\"], test_data1.shape)\n self.assertTupleEqual(result[0].shape, (2, 3, 4, 4))\n np.testing.assert_allclose(result[0], np.stack([test_data1, test_data2]))\n\n shutil.rmtree(tempdir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpy.py_TestLoadNumpy.test_npy_pickle_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpy.py_TestLoadNumpy.test_npy_pickle_", "embedding": null, "metadata": {"file_path": "tests/test_load_numpy.py", "file_name": "test_load_numpy.py", "file_type": "text/x-python", "category": "test", "start_line": 75, "end_line": 90, "span_ids": ["TestLoadNumpy.test_npy_pickle", "impl"], "tokens": 146}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadNumpy(unittest.TestCase):\n\n def test_npy_pickle(self):\n test_data = {\"test\": np.random.randint(0, 256, size=[3, 4, 4])}\n tempdir = tempfile.mkdtemp()\n filepath = os.path.join(tempdir, \"test_data.npy\")\n np.save(filepath, test_data, allow_pickle=True)\n\n result = LoadNumpy(data_only=True, dtype=None)(filepath).item()\n self.assertTupleEqual(result[\"test\"].shape, test_data[\"test\"].shape)\n np.testing.assert_allclose(result[\"test\"], test_data[\"test\"])\n\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpyd.py_unittest_TestLoadNumpyd.test_npy.shutil_rmtree_tempdir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpyd.py_unittest_TestLoadNumpyd.test_npy.shutil_rmtree_tempdir_", "embedding": null, "metadata": {"file_path": "tests/test_load_numpyd.py", "file_name": "test_load_numpyd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 32, "span_ids": ["TestLoadNumpyd", "TestLoadNumpyd.test_npy", "docstring"], "tokens": 166}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport os\nimport shutil\nimport numpy as np\nimport tempfile\nfrom monai.transforms import LoadNumpyd\n\n\nclass TestLoadNumpyd(unittest.TestCase):\n def test_npy(self):\n test_data = np.random.randint(0, 256, size=[3, 4, 4])\n tempdir = tempfile.mkdtemp()\n filepath = os.path.join(tempdir, \"test_data.npy\")\n np.save(filepath, test_data)\n\n result = LoadNumpyd(keys=\"mask\")({\"mask\": filepath})\n self.assertTupleEqual(result[\"mask_meta_dict\"][\"spatial_shape\"], test_data.shape)\n self.assertTupleEqual(result[\"mask\"].shape, test_data.shape)\n np.testing.assert_allclose(result[\"mask\"], test_data)\n\n shutil.rmtree(tempdir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpyd.py_TestLoadNumpyd.test_npz1_TestLoadNumpyd.test_npz1.shutil_rmtree_tempdir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpyd.py_TestLoadNumpyd.test_npz1_TestLoadNumpyd.test_npz1.shutil_rmtree_tempdir_", "embedding": null, "metadata": {"file_path": "tests/test_load_numpyd.py", "file_name": "test_load_numpyd.py", "file_type": "text/x-python", "category": "test", "start_line": 34, "end_line": 45, "span_ids": ["TestLoadNumpyd.test_npz1"], "tokens": 145}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadNumpyd(unittest.TestCase):\n\n def test_npz1(self):\n test_data1 = np.random.randint(0, 256, size=[3, 4, 4])\n tempdir = tempfile.mkdtemp()\n filepath = os.path.join(tempdir, \"test_data.npy\")\n np.save(filepath, test_data1)\n\n result = LoadNumpyd(keys=\"mask\")({\"mask\": filepath})\n self.assertTupleEqual(result[\"mask_meta_dict\"][\"spatial_shape\"], test_data1.shape)\n self.assertTupleEqual(result[\"mask\"].shape, test_data1.shape)\n np.testing.assert_allclose(result[\"mask\"], test_data1)\n\n shutil.rmtree(tempdir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpyd.py_TestLoadNumpyd.test_npz2_TestLoadNumpyd.test_npz2.shutil_rmtree_tempdir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpyd.py_TestLoadNumpyd.test_npz2_TestLoadNumpyd.test_npz2.shutil_rmtree_tempdir_", "embedding": null, "metadata": {"file_path": "tests/test_load_numpyd.py", "file_name": "test_load_numpyd.py", "file_type": "text/x-python", "category": "test", "start_line": 47, "end_line": 59, "span_ids": ["TestLoadNumpyd.test_npz2"], "tokens": 189}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadNumpyd(unittest.TestCase):\n\n def test_npz2(self):\n test_data1 = np.random.randint(0, 256, size=[3, 4, 4])\n test_data2 = np.random.randint(0, 256, size=[3, 4, 4])\n tempdir = tempfile.mkdtemp()\n filepath = os.path.join(tempdir, \"test_data.npz\")\n np.savez(filepath, test_data1, test_data2)\n\n result = LoadNumpyd(keys=\"mask\")({\"mask\": filepath})\n self.assertTupleEqual(result[\"mask_meta_dict\"][\"spatial_shape\"], test_data1.shape)\n self.assertTupleEqual(result[\"mask\"].shape, (2, 3, 4, 4))\n np.testing.assert_allclose(result[\"mask\"], np.stack([test_data1, test_data2]))\n\n shutil.rmtree(tempdir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpyd.py_TestLoadNumpyd.test_npz3_TestLoadNumpyd.test_npz3.shutil_rmtree_tempdir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpyd.py_TestLoadNumpyd.test_npz3_TestLoadNumpyd.test_npz3.shutil_rmtree_tempdir_", "embedding": null, "metadata": {"file_path": "tests/test_load_numpyd.py", "file_name": "test_load_numpyd.py", "file_type": "text/x-python", "category": "test", "start_line": 61, "end_line": 73, "span_ids": ["TestLoadNumpyd.test_npz3"], "tokens": 204}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadNumpyd(unittest.TestCase):\n\n def test_npz3(self):\n test_data1 = np.random.randint(0, 256, size=[3, 4, 4])\n test_data2 = np.random.randint(0, 256, size=[3, 4, 4])\n tempdir = tempfile.mkdtemp()\n filepath = os.path.join(tempdir, \"test_data.npz\")\n np.savez(filepath, test1=test_data1, test2=test_data2)\n\n result = LoadNumpyd(keys=\"mask\", npz_keys=[\"test1\", \"test2\"])({\"mask\": filepath})\n self.assertTupleEqual(result[\"mask_meta_dict\"][\"spatial_shape\"], test_data1.shape)\n self.assertTupleEqual(result[\"mask\"].shape, (2, 3, 4, 4))\n np.testing.assert_allclose(result[\"mask\"], np.stack([test_data1, test_data2]))\n\n shutil.rmtree(tempdir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpyd.py_TestLoadNumpyd.test_npy_pickle_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpyd.py_TestLoadNumpyd.test_npy_pickle_", "embedding": null, "metadata": {"file_path": "tests/test_load_numpyd.py", "file_name": "test_load_numpyd.py", "file_type": "text/x-python", "category": "test", "start_line": 75, "end_line": 90, "span_ids": ["TestLoadNumpyd.test_npy_pickle", "impl"], "tokens": 154}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadNumpyd(unittest.TestCase):\n\n def test_npy_pickle(self):\n test_data = {\"test\": np.random.randint(0, 256, size=[3, 4, 4])}\n tempdir = tempfile.mkdtemp()\n filepath = os.path.join(tempdir, \"test_data.npy\")\n np.save(filepath, test_data, allow_pickle=True)\n\n result = LoadNumpyd(keys=\"mask\", dtype=None)({\"mask\": filepath})[\"mask\"].item()\n self.assertTupleEqual(result[\"test\"].shape, test_data[\"test\"].shape)\n np.testing.assert_allclose(result[\"test\"], test_data[\"test\"])\n\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_png.py_unittest_TEST_CASE_3._128_128_test_image": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_png.py_unittest_TEST_CASE_3._128_128_test_image", "embedding": null, "metadata": {"file_path": "tests/test_load_png.py", "file_name": "test_load_png.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 25, "span_ids": ["docstring"], "tokens": 143}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport os\nimport shutil\nimport numpy as np\nimport tempfile\nfrom PIL import Image\nfrom parameterized import parameterized\nfrom monai.transforms import LoadPNG\n\nTEST_CASE_1 = [(128, 128), [\"test_image.png\"], (128, 128), (128, 128)]\n\nTEST_CASE_2 = [(128, 128, 3), [\"test_image.png\"], (128, 128, 3), (128, 128)]\n\nTEST_CASE_3 = [(128, 128), [\"test_image1.png\", \"test_image2.png\", \"test_image3.png\"], (3, 128, 128), (128, 128)]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_png.py_TestLoadPNG_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_png.py_TestLoadPNG_", "embedding": null, "metadata": {"file_path": "tests/test_load_png.py", "file_name": "test_load_png.py", "file_type": "text/x-python", "category": "test", "start_line": 28, "end_line": 48, "span_ids": ["TestLoadPNG.test_shape", "TestLoadPNG", "impl:7"], "tokens": 225}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadPNG(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_shape(self, data_shape, filenames, expected_shape, meta_shape):\n test_image = np.random.randint(0, 256, size=data_shape)\n tempdir = tempfile.mkdtemp()\n for i, name in enumerate(filenames):\n filenames[i] = os.path.join(tempdir, name)\n Image.fromarray(test_image.astype(\"uint8\")).save(filenames[i])\n result = LoadPNG()(filenames)\n self.assertTupleEqual(result[1][\"spatial_shape\"], meta_shape)\n self.assertTupleEqual(result[0].shape, expected_shape)\n if result[0].shape == test_image.shape:\n np.testing.assert_allclose(result[0], test_image)\n else:\n np.testing.assert_allclose(result[0], np.tile(test_image, [result[0].shape[0], 1, 1]))\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_pngd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_pngd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_load_pngd.py", "file_name": "test_load_pngd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 43, "span_ids": ["TestLoadPNGd", "impl:5", "TestLoadPNGd.test_shape", "docstring"], "tokens": 240}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport os\nimport shutil\nimport numpy as np\nimport tempfile\nfrom PIL import Image\nfrom parameterized import parameterized\nfrom monai.transforms import LoadPNGd\n\nKEYS = [\"image\", \"label\", \"extra\"]\n\nTEST_CASE_1 = [{\"keys\": KEYS}, (128, 128, 3)]\n\n\nclass TestLoadPNGd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1])\n def test_shape(self, input_param, expected_shape):\n test_image = np.random.randint(0, 256, size=[128, 128, 3])\n tempdir = tempfile.mkdtemp()\n test_data = dict()\n for key in KEYS:\n Image.fromarray(test_image.astype(\"uint8\")).save(os.path.join(tempdir, key + \".png\"))\n test_data.update({key: os.path.join(tempdir, key + \".png\")})\n result = LoadPNGd(**input_param)(test_data)\n for key in KEYS:\n self.assertTupleEqual(result[key].shape, expected_shape)\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_os_TestLoadSpacingOrientation.test_load_spacingd.None_5": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_os_TestLoadSpacingOrientation.test_load_spacingd.None_5", "embedding": null, "metadata": {"file_path": "tests/test_load_spacing_orientation.py", "file_name": "test_load_spacing_orientation.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 46, "span_ids": ["TestLoadSpacingOrientation.test_load_spacingd", "TestLoadSpacingOrientation", "docstring"], "tokens": 368}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport time\nimport unittest\n\nimport nibabel\nimport numpy as np\nfrom nibabel.processing import resample_to_output\nfrom parameterized import parameterized\n\nfrom monai.transforms import AddChanneld, LoadNiftid, Orientationd, Spacingd\n\nFILES = tuple(\n os.path.join(os.path.dirname(__file__), \"testing_data\", filename)\n for filename in (\"anatomical.nii\", \"reoriented_anat_moved.nii\")\n)\n\n\nclass TestLoadSpacingOrientation(unittest.TestCase):\n @parameterized.expand(FILES)\n def test_load_spacingd(self, filename):\n data = {\"image\": filename}\n data_dict = LoadNiftid(keys=\"image\")(data)\n data_dict = AddChanneld(keys=\"image\")(data_dict)\n t = time.time()\n res_dict = Spacingd(keys=\"image\", pixdim=(1, 0.2, 1), diagonal=True, padding_mode=\"zeros\")(data_dict)\n t1 = time.time()\n print(f\"time monai: {t1 - t}\")\n anat = nibabel.Nifti1Image(data_dict[\"image\"][0], data_dict[\"image_meta_dict\"][\"original_affine\"])\n ref = resample_to_output(anat, (1, 0.2, 1), order=1)\n t2 = time.time()\n print(f\"time scipy: {t2 - t1}\")\n self.assertTrue(t2 >= t1)\n np.testing.assert_allclose(res_dict[\"image_meta_dict\"][\"affine\"], ref.affine)\n np.testing.assert_allclose(res_dict[\"image\"].shape[1:], ref.shape)\n np.testing.assert_allclose(ref.get_fdata(), res_dict[\"image\"][0], atol=0.05)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_TestLoadSpacingOrientation.test_load_spacingd_rotate_TestLoadSpacingOrientation.test_load_spacingd_rotate.if_anatomical_not_in_fi.else_.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_TestLoadSpacingOrientation.test_load_spacingd_rotate_TestLoadSpacingOrientation.test_load_spacingd_rotate.if_anatomical_not_in_fi.else_.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_load_spacing_orientation.py", "file_name": "test_load_spacing_orientation.py", "file_type": "text/x-python", "category": "test", "start_line": 48, "end_line": 73, "span_ids": ["TestLoadSpacingOrientation.test_load_spacingd_rotate"], "tokens": 422}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadSpacingOrientation(unittest.TestCase):\n\n @parameterized.expand(FILES)\n def test_load_spacingd_rotate(self, filename):\n data = {\"image\": filename}\n data_dict = LoadNiftid(keys=\"image\")(data)\n data_dict = AddChanneld(keys=\"image\")(data_dict)\n affine = data_dict[\"image_meta_dict\"][\"affine\"]\n data_dict[\"image_meta_dict\"][\"original_affine\"] = data_dict[\"image_meta_dict\"][\"affine\"] = (\n np.array([[0, 0, 1, 0], [0, 1, 0, 0], [-1, 0, 0, 0], [0, 0, 0, 1]]) @ affine\n )\n t = time.time()\n res_dict = Spacingd(keys=\"image\", pixdim=(1, 2, 3), diagonal=True, padding_mode=\"zeros\")(data_dict)\n t1 = time.time()\n print(f\"time monai: {t1 - t}\")\n anat = nibabel.Nifti1Image(data_dict[\"image\"][0], data_dict[\"image_meta_dict\"][\"original_affine\"])\n ref = resample_to_output(anat, (1, 2, 3), order=1)\n t2 = time.time()\n print(f\"time scipy: {t2 - t1}\")\n self.assertTrue(t2 >= t1)\n np.testing.assert_allclose(res_dict[\"image_meta_dict\"][\"affine\"], ref.affine)\n if \"anatomical\" not in filename:\n np.testing.assert_allclose(res_dict[\"image\"].shape[1:], ref.shape)\n np.testing.assert_allclose(ref.get_fdata(), res_dict[\"image\"][0], atol=0.05)\n else:\n # different from the ref implementation (shape computed by round\n # instead of ceil)\n np.testing.assert_allclose(ref.get_fdata()[..., :-1], res_dict[\"image\"][0], atol=0.05)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_TestLoadSpacingOrientation.test_load_spacingd_non_diag_TestLoadSpacingOrientation.test_load_spacingd_non_diag.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_TestLoadSpacingOrientation.test_load_spacingd_non_diag_TestLoadSpacingOrientation.test_load_spacingd_non_diag.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_load_spacing_orientation.py", "file_name": "test_load_spacing_orientation.py", "file_type": "text/x-python", "category": "test", "start_line": 75, "end_line": 94, "span_ids": ["TestLoadSpacingOrientation.test_load_spacingd_non_diag"], "tokens": 301}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadSpacingOrientation(unittest.TestCase):\n\n def test_load_spacingd_non_diag(self):\n data = {\"image\": FILES[1]}\n data_dict = LoadNiftid(keys=\"image\")(data)\n data_dict = AddChanneld(keys=\"image\")(data_dict)\n affine = data_dict[\"image_meta_dict\"][\"affine\"]\n data_dict[\"image_meta_dict\"][\"original_affine\"] = data_dict[\"image_meta_dict\"][\"affine\"] = (\n np.array([[0, 0, 1, 0], [0, 1, 0, 0], [-1, 0, 0, 0], [0, 0, 0, 1]]) @ affine\n )\n res_dict = Spacingd(keys=\"image\", pixdim=(1, 2, 3), diagonal=False, padding_mode=\"zeros\")(data_dict)\n np.testing.assert_allclose(\n res_dict[\"image_meta_dict\"][\"affine\"],\n np.array(\n [\n [0.0, 0.0, 3.0, -27.599409],\n [0.0, 2.0, 0.0, -47.977585],\n [-1.0, 0.0, 0.0, 35.297897],\n [0.0, 0.0, 0.0, 1.0],\n ]\n ),\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_TestLoadSpacingOrientation.test_load_spacingd_rotate_non_diag_TestLoadSpacingOrientation.test_load_spacingd_rotate_non_diag.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_TestLoadSpacingOrientation.test_load_spacingd_rotate_non_diag_TestLoadSpacingOrientation.test_load_spacingd_rotate_non_diag.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_load_spacing_orientation.py", "file_name": "test_load_spacing_orientation.py", "file_type": "text/x-python", "category": "test", "start_line": 96, "end_line": 104, "span_ids": ["TestLoadSpacingOrientation.test_load_spacingd_rotate_non_diag"], "tokens": 196}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadSpacingOrientation(unittest.TestCase):\n\n def test_load_spacingd_rotate_non_diag(self):\n data = {\"image\": FILES[0]}\n data_dict = LoadNiftid(keys=\"image\")(data)\n data_dict = AddChanneld(keys=\"image\")(data_dict)\n res_dict = Spacingd(keys=\"image\", pixdim=(1, 2, 3), diagonal=False, padding_mode=\"border\")(data_dict)\n np.testing.assert_allclose(\n res_dict[\"image_meta_dict\"][\"affine\"],\n np.array([[-1.0, 0.0, 0.0, 32.0], [0.0, 2.0, 0.0, -40.0], [0.0, 0.0, 3.0, -16.0], [0.0, 0.0, 0.0, 1.0]]),\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_TestLoadSpacingOrientation.test_load_spacingd_rotate_non_diag_ornt_TestLoadSpacingOrientation.test_load_spacingd_rotate_non_diag_ornt.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_TestLoadSpacingOrientation.test_load_spacingd_rotate_non_diag_ornt_TestLoadSpacingOrientation.test_load_spacingd_rotate_non_diag_ornt.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_load_spacing_orientation.py", "file_name": "test_load_spacing_orientation.py", "file_type": "text/x-python", "category": "test", "start_line": 106, "end_line": 115, "span_ids": ["TestLoadSpacingOrientation.test_load_spacingd_rotate_non_diag_ornt"], "tokens": 217}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadSpacingOrientation(unittest.TestCase):\n\n def test_load_spacingd_rotate_non_diag_ornt(self):\n data = {\"image\": FILES[0]}\n data_dict = LoadNiftid(keys=\"image\")(data)\n data_dict = AddChanneld(keys=\"image\")(data_dict)\n res_dict = Spacingd(keys=\"image\", pixdim=(1, 2, 3), diagonal=False, padding_mode=\"border\")(data_dict)\n res_dict = Orientationd(keys=\"image\", axcodes=\"LPI\")(res_dict)\n np.testing.assert_allclose(\n res_dict[\"image_meta_dict\"][\"affine\"],\n np.array([[-1.0, 0.0, 0.0, 32.0], [0.0, -2.0, 0.0, 40.0], [0.0, 0.0, -3.0, 32.0], [0.0, 0.0, 0.0, 1.0]]),\n )", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_TestLoadSpacingOrientation.test_load_spacingd_non_diag_ornt_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_spacing_orientation.py_TestLoadSpacingOrientation.test_load_spacingd_non_diag_ornt_", "embedding": null, "metadata": {"file_path": "tests/test_load_spacing_orientation.py", "file_name": "test_load_spacing_orientation.py", "file_type": "text/x-python", "category": "test", "start_line": 117, "end_line": 142, "span_ids": ["impl:3", "TestLoadSpacingOrientation.test_load_spacingd_non_diag_ornt"], "tokens": 337}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestLoadSpacingOrientation(unittest.TestCase):\n\n def test_load_spacingd_non_diag_ornt(self):\n data = {\"image\": FILES[1]}\n data_dict = LoadNiftid(keys=\"image\")(data)\n data_dict = AddChanneld(keys=\"image\")(data_dict)\n affine = data_dict[\"image_meta_dict\"][\"affine\"]\n data_dict[\"image_meta_dict\"][\"original_affine\"] = data_dict[\"image_meta_dict\"][\"affine\"] = (\n np.array([[0, 0, 1, 0], [0, 1, 0, 0], [-1, 0, 0, 0], [0, 0, 0, 1]]) @ affine\n )\n res_dict = Spacingd(keys=\"image\", pixdim=(1, 2, 3), diagonal=False, padding_mode=\"border\")(data_dict)\n res_dict = Orientationd(keys=\"image\", axcodes=\"LPI\")(res_dict)\n np.testing.assert_allclose(\n res_dict[\"image_meta_dict\"][\"affine\"],\n np.array(\n [\n [-3.0, 0.0, 0.0, 56.4005909],\n [0.0, -2.0, 0.0, 52.02241516],\n [0.0, 0.0, -1.0, 35.29789734],\n [0.0, 0.0, 0.0, 1.0],\n ]\n ),\n )\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_map_transform.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_map_transform.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_map_transform.py", "file_name": "test_map_transform.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 42, "span_ids": ["TestRandomizable.test_wrong_keys", "MapTest", "MapTest.__call__", "TestRandomizable.test_keys", "impl:5", "docstring", "TestRandomizable"], "tokens": 179}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nfrom parameterized import parameterized\n\nfrom monai.transforms import MapTransform\n\nTEST_CASES = [[\"item\", (\"item\",)], [None, (None,)], [[\"item1\", \"item2\"], (\"item1\", \"item2\")]]\n\nTEST_ILL_CASES = [[list()], [tuple()], [[list()]]]\n\n\nclass MapTest(MapTransform):\n def __call__(self, data):\n pass\n\n\nclass TestRandomizable(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_keys(self, keys, expected):\n transform = MapTest(keys=keys)\n self.assertEqual(transform.keys, expected)\n\n @parameterized.expand(TEST_ILL_CASES)\n def test_wrong_keys(self, keys):\n with self.assertRaisesRegex(ValueError, \"\"):\n MapTest(keys=keys)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mask_intensity.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mask_intensity.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_mask_intensity.py", "file_name": "test_mask_intensity.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 46, "span_ids": ["TestMaskIntensity.test_value", "TestMaskIntensity", "impl:7", "docstring"], "tokens": 612}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.transforms import MaskIntensity\n\nTEST_CASE_1 = [\n {\"mask_data\": np.array([[[0, 0, 0], [0, 1, 0], [0, 0, 0]]])},\n np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]]),\n np.array([[[0, 0, 0], [0, 2, 0], [0, 0, 0]], [[0, 0, 0], [0, 5, 0], [0, 0, 0]]]),\n]\n\nTEST_CASE_2 = [\n {\"mask_data\": np.array([[[0, 0, 0], [0, 5, 0], [0, 0, 0]]])},\n np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]]),\n np.array([[[0, 0, 0], [0, 2, 0], [0, 0, 0]], [[0, 0, 0], [0, 5, 0], [0, 0, 0]]]),\n]\n\nTEST_CASE_3 = [\n {\"mask_data\": np.array([[[0, 0, 0], [0, 1, 0], [0, 0, 0]], [[0, 1, 0], [0, 1, 0], [0, 1, 0]]])},\n np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]]),\n np.array([[[0, 0, 0], [0, 2, 0], [0, 0, 0]], [[0, 4, 0], [0, 5, 0], [0, 6, 0]]]),\n]\n\n\nclass TestMaskIntensity(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_value(self, argments, image, expected_data):\n result = MaskIntensity(**argments)(image)\n np.testing.assert_allclose(result, expected_data)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mask_intensityd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mask_intensityd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_mask_intensityd.py", "file_name": "test_mask_intensityd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 46, "span_ids": ["TestMaskIntensityd.test_value", "TestMaskIntensityd", "impl:7", "docstring"], "tokens": 647}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.transforms import MaskIntensityd\n\nTEST_CASE_1 = [\n {\"keys\": \"img\", \"mask_data\": np.array([[[0, 0, 0], [0, 1, 0], [0, 0, 0]]])},\n {\"img\": np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]])},\n np.array([[[0, 0, 0], [0, 2, 0], [0, 0, 0]], [[0, 0, 0], [0, 5, 0], [0, 0, 0]]]),\n]\n\nTEST_CASE_2 = [\n {\"keys\": \"img\", \"mask_data\": np.array([[[0, 0, 0], [0, 5, 0], [0, 0, 0]]])},\n {\"img\": np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]])},\n np.array([[[0, 0, 0], [0, 2, 0], [0, 0, 0]], [[0, 0, 0], [0, 5, 0], [0, 0, 0]]]),\n]\n\nTEST_CASE_3 = [\n {\"keys\": \"img\", \"mask_data\": np.array([[[0, 0, 0], [0, 1, 0], [0, 0, 0]], [[0, 1, 0], [0, 1, 0], [0, 1, 0]]])},\n {\"img\": np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]])},\n np.array([[[0, 0, 0], [0, 2, 0], [0, 0, 0]], [[0, 4, 0], [0, 5, 0], [0, 6, 0]]]),\n]\n\n\nclass TestMaskIntensityd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_value(self, argments, image, expected_data):\n result = MaskIntensityd(**argments)(image)\n np.testing.assert_allclose(result[\"img\"], expected_data)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_masked_dice_loss.py_unittest_TEST_CASES": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_masked_dice_loss.py_unittest_TEST_CASES", "embedding": null, "metadata": {"file_path": "tests/test_masked_dice_loss.py", "file_name": "test_masked_dice_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 115, "span_ids": ["docstring"], "tokens": 37}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.losses import MaskedDiceLoss\n\nTEST_CASES =\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_masked_dice_loss.py_TestDiceLoss_TestDiceLoss.test_ill_shape.with_self_assertRaisesReg.loss_forward_torch_ones_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_masked_dice_loss.py_TestDiceLoss_TestDiceLoss.test_ill_shape.with_self_assertRaisesReg.loss_forward_torch_ones_", "embedding": null, "metadata": {"file_path": "tests/test_masked_dice_loss.py", "file_name": "test_masked_dice_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 118, "end_line": 127, "span_ids": ["TestDiceLoss.test_shape", "TestDiceLoss.test_ill_shape", "TestDiceLoss"], "tokens": 125}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestDiceLoss(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_shape(self, input_param, input_data, expected_val):\n result = MaskedDiceLoss(**input_param).forward(**input_data)\n np.testing.assert_allclose(result.detach().cpu().numpy(), expected_val, rtol=1e-5)\n\n def test_ill_shape(self):\n loss = MaskedDiceLoss()\n with self.assertRaisesRegex(AssertionError, \"\"):\n loss.forward(torch.ones((1, 2, 3)), torch.ones((4, 5, 6)))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_masked_dice_loss.py_TestDiceLoss.test_ill_opts_TestDiceLoss.test_ill_opts.None_2.MaskedDiceLoss_reduction_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_masked_dice_loss.py_TestDiceLoss.test_ill_opts_TestDiceLoss.test_ill_opts.None_2.MaskedDiceLoss_reduction_", "embedding": null, "metadata": {"file_path": "tests/test_masked_dice_loss.py", "file_name": "test_masked_dice_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 129, "end_line": 137, "span_ids": ["TestDiceLoss.test_ill_opts"], "tokens": 119}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestDiceLoss(unittest.TestCase):\n\n def test_ill_opts(self):\n with self.assertRaisesRegex(ValueError, \"\"):\n MaskedDiceLoss(sigmoid=True, softmax=True)\n chn_input = torch.ones((1, 1, 3))\n chn_target = torch.ones((1, 1, 3))\n with self.assertRaisesRegex(ValueError, \"\"):\n MaskedDiceLoss(reduction=\"unknown\")(chn_input, chn_target)\n with self.assertRaisesRegex(ValueError, \"\"):\n MaskedDiceLoss(reduction=None)(chn_input, chn_target)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_masked_dice_loss.py_TestDiceLoss.test_input_warnings_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_masked_dice_loss.py_TestDiceLoss.test_input_warnings_", "embedding": null, "metadata": {"file_path": "tests/test_masked_dice_loss.py", "file_name": "test_masked_dice_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 139, "end_line": 155, "span_ids": ["impl:3", "TestDiceLoss.test_input_warnings"], "tokens": 153}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestDiceLoss(unittest.TestCase):\n\n def test_input_warnings(self):\n chn_input = torch.ones((1, 1, 3))\n chn_target = torch.ones((1, 1, 3))\n with self.assertWarns(Warning):\n loss = MaskedDiceLoss(include_background=False)\n loss.forward(chn_input, chn_target)\n with self.assertWarns(Warning):\n loss = MaskedDiceLoss(softmax=True)\n loss.forward(chn_input, chn_target)\n with self.assertWarns(Warning):\n loss = MaskedDiceLoss(to_onehot_y=True)\n loss.forward(chn_input, chn_target)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mean_ensemble.py_unittest_TEST_CASE_6._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mean_ensemble.py_unittest_TEST_CASE_6._", "embedding": null, "metadata": {"file_path": "tests/test_mean_ensemble.py", "file_name": "test_mean_ensemble.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 52, "span_ids": ["impl:11", "docstring"], "tokens": 538}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\nfrom monai.transforms import MeanEnsemble\n\nTEST_CASE_1 = [\n {\"weights\": None},\n [torch.ones(2, 2, 2, 2), torch.ones(2, 2, 2, 2) + 2],\n torch.ones(2, 2, 2, 2) + 1,\n]\n\nTEST_CASE_2 = [\n {\"weights\": None},\n torch.stack([torch.ones(2, 2, 2, 2), torch.ones(2, 2, 2, 2) + 2]),\n torch.ones(2, 2, 2, 2) + 1,\n]\n\nTEST_CASE_3 = [\n {\"weights\": [1, 3]},\n [torch.ones(2, 2, 2, 2), torch.ones(2, 2, 2, 2) + 2],\n torch.ones(2, 2, 2, 2) * 2.5,\n]\n\nTEST_CASE_4 = [\n {\"weights\": [[[1, 3]], [[3, 1]]]},\n [torch.ones(2, 2, 2, 2), torch.ones(2, 2, 2, 2) + 2],\n torch.ones(2, 2, 2, 2) * torch.tensor([2.5, 1.5]).reshape(1, 2, 1, 1),\n]\n\nTEST_CASE_5 = [\n {\"weights\": np.array([[[1, 3]], [[3, 1]]])},\n [torch.ones(2, 2, 2, 2), torch.ones(2, 2, 2, 2) + 2],\n torch.ones(2, 2, 2, 2) * torch.tensor([2.5, 1.5]).reshape(1, 2, 1, 1),\n]\n\nTEST_CASE_6 = [\n {\"weights\": torch.tensor([[[1, 3]], [[3, 1]]])},\n [torch.ones(2, 2, 2, 2), torch.ones(2, 2, 2, 2) + 2],\n torch.ones(2, 2, 2, 2) * torch.tensor([2.5, 1.5]).reshape(1, 2, 1, 1),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mean_ensemble.py_TestMeanEnsemble_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mean_ensemble.py_TestMeanEnsemble_", "embedding": null, "metadata": {"file_path": "tests/test_mean_ensemble.py", "file_name": "test_mean_ensemble.py", "file_type": "text/x-python", "category": "test", "start_line": 55, "end_line": 73, "span_ids": ["TestMeanEnsemble.test_cuda_value", "TestMeanEnsemble", "TestMeanEnsemble.test_value", "impl:13"], "tokens": 251}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestMeanEnsemble(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5, TEST_CASE_6])\n def test_value(self, input_param, img, expected_value):\n result = MeanEnsemble(**input_param)(img)\n torch.testing.assert_allclose(result, expected_value)\n\n def test_cuda_value(self):\n img = torch.stack([torch.ones(2, 2, 2, 2), torch.ones(2, 2, 2, 2) + 2])\n expected_value = torch.ones(2, 2, 2, 2) * torch.tensor([2.5, 1.5]).reshape(1, 2, 1, 1)\n if torch.cuda.is_available():\n img = img.to(torch.device(\"cuda:0\"))\n expected_value = expected_value.to(torch.device(\"cuda:0\"))\n result = MeanEnsemble(torch.tensor([[[1, 3]], [[3, 1]]]))(img)\n torch.testing.assert_allclose(result, expected_value)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mean_ensembled.py_unittest_TEST_CASE_6._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mean_ensembled.py_unittest_TEST_CASE_6._", "embedding": null, "metadata": {"file_path": "tests/test_mean_ensembled.py", "file_name": "test_mean_ensembled.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 52, "span_ids": ["impl:9", "docstring"], "tokens": 673}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\nfrom monai.transforms import MeanEnsembled\n\nTEST_CASE_1 = [\n {\"keys\": [\"pred0\", \"pred1\"], \"output_key\": \"output\", \"weights\": None},\n {\"pred0\": torch.ones(2, 2, 2, 2), \"pred1\": torch.ones(2, 2, 2, 2) + 2},\n torch.ones(2, 2, 2, 2) + 1,\n]\n\nTEST_CASE_2 = [\n {\"keys\": \"output\", \"weights\": None},\n {\"output\": torch.stack([torch.ones(2, 2, 2, 2), torch.ones(2, 2, 2, 2) + 2])},\n torch.ones(2, 2, 2, 2) + 1,\n]\n\nTEST_CASE_3 = [\n {\"keys\": [\"pred0\", \"pred1\"], \"output_key\": \"output\", \"weights\": [1, 3]},\n {\"pred0\": torch.ones(2, 2, 2, 2), \"pred1\": torch.ones(2, 2, 2, 2) + 2},\n torch.ones(2, 2, 2, 2) * 2.5,\n]\n\nTEST_CASE_4 = [\n {\"keys\": [\"pred0\", \"pred1\"], \"output_key\": \"output\", \"weights\": [[[1, 3]], [[3, 1]]]},\n {\"pred0\": torch.ones(2, 2, 2, 2), \"pred1\": torch.ones(2, 2, 2, 2) + 2},\n torch.ones(2, 2, 2, 2) * torch.tensor([2.5, 1.5]).reshape(1, 2, 1, 1),\n]\n\nTEST_CASE_5 = [\n {\"keys\": [\"pred0\", \"pred1\"], \"output_key\": \"output\", \"weights\": np.array([[[1, 3]], [[3, 1]]])},\n {\"pred0\": torch.ones(2, 2, 2, 2), \"pred1\": torch.ones(2, 2, 2, 2) + 2},\n torch.ones(2, 2, 2, 2) * torch.tensor([2.5, 1.5]).reshape(1, 2, 1, 1),\n]\n\nTEST_CASE_6 = [\n {\"keys\": [\"pred0\", \"pred1\"], \"output_key\": \"output\", \"weights\": torch.tensor([[[1, 3]], [[3, 1]]])},\n {\"pred0\": torch.ones(2, 2, 2, 2), \"pred1\": torch.ones(2, 2, 2, 2) + 2},\n torch.ones(2, 2, 2, 2) * torch.tensor([2.5, 1.5]).reshape(1, 2, 1, 1),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mean_ensembled.py_TestMeanEnsembled_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mean_ensembled.py_TestMeanEnsembled_", "embedding": null, "metadata": {"file_path": "tests/test_mean_ensembled.py", "file_name": "test_mean_ensembled.py", "file_type": "text/x-python", "category": "test", "start_line": 55, "end_line": 73, "span_ids": ["TestMeanEnsembled.test_value", "impl:13", "TestMeanEnsembled", "TestMeanEnsembled.test_cuda_value"], "tokens": 262}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestMeanEnsembled(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5, TEST_CASE_6])\n def test_value(self, input_param, data, expected_value):\n result = MeanEnsembled(**input_param)(data)\n torch.testing.assert_allclose(result[\"output\"], expected_value)\n\n def test_cuda_value(self):\n img = torch.stack([torch.ones(2, 2, 2, 2), torch.ones(2, 2, 2, 2) + 2])\n expected_value = torch.ones(2, 2, 2, 2) * torch.tensor([2.5, 1.5]).reshape(1, 2, 1, 1)\n if torch.cuda.is_available():\n img = img.to(torch.device(\"cuda:0\"))\n expected_value = expected_value.to(torch.device(\"cuda:0\"))\n result = MeanEnsembled(keys=\"output\", weights=torch.tensor([[[1, 3]], [[3, 1]]]))({\"output\": img})\n torch.testing.assert_allclose(result[\"output\"], expected_value)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mednistdataset.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mednistdataset.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_mednistdataset.py", "file_name": "test_mednistdataset.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 60, "span_ids": ["TestMedNISTDataset", "TestMedNISTDataset.test_values", "impl", "docstring"], "tokens": 388}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport os\nimport shutil\nimport tempfile\n\nfrom monai.apps import MedNISTDataset\nfrom monai.transforms import LoadPNGd, AddChanneld, ScaleIntensityd, ToTensord, Compose\nfrom tests.utils import skip_if_quick\n\n\nclass TestMedNISTDataset(unittest.TestCase):\n @skip_if_quick\n def test_values(self):\n tempdir = tempfile.mkdtemp()\n transform = Compose(\n [\n LoadPNGd(keys=\"image\"),\n AddChanneld(keys=\"image\"),\n ScaleIntensityd(keys=\"image\"),\n ToTensord(keys=[\"image\", \"label\"]),\n ]\n )\n\n def _test_dataset(dataset):\n self.assertEqual(len(dataset), 5986)\n self.assertTrue(\"image\" in dataset[0])\n self.assertTrue(\"label\" in dataset[0])\n self.assertTrue(\"image_meta_dict\" in dataset[0])\n self.assertTupleEqual(dataset[0][\"image\"].shape, (1, 64, 64))\n\n data = MedNISTDataset(root_dir=tempdir, transform=transform, section=\"test\", download=True)\n _test_dataset(data)\n data = MedNISTDataset(root_dir=tempdir, transform=transform, section=\"test\", download=False)\n _test_dataset(data)\n data = MedNISTDataset(root_dir=tempdir, section=\"test\", download=False)\n self.assertTupleEqual(data[0][\"image\"].shape, (64, 64))\n shutil.rmtree(os.path.join(tempdir, \"MedNIST\"))\n try:\n data = MedNISTDataset(root_dir=tempdir, transform=transform, section=\"test\", download=False)\n except RuntimeError as e:\n print(str(e))\n self.assertTrue(str(e).startswith(\"can not find dataset directory\"))\n\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_dataset.py_os_RandTest.__call__.return.data_self__a": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_dataset.py_os_RandTest.__call__.return.data_self__a", "embedding": null, "metadata": {"file_path": "tests/test_nifti_dataset.py", "file_name": "test_nifti_dataset.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 36, "span_ids": ["RandTest", "RandTest.__call__", "RandTest.randomize", "docstring"], "tokens": 119}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport shutil\nimport tempfile\nimport unittest\n\nimport nibabel as nib\nimport numpy as np\n\nfrom monai.data import NiftiDataset\nfrom monai.transforms import Randomizable\n\nFILENAMES = [\"test1.nii.gz\", \"test2.nii\", \"test3.nii.gz\"]\n\n\nclass RandTest(Randomizable):\n \"\"\"\n randomisable transform for testing.\n \"\"\"\n\n def randomize(self, data=None):\n self._a = self.R.random()\n\n def __call__(self, data):\n self.randomize()\n return data + self._a", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_dataset.py_TestNiftiDataset_TestNiftiDataset.test_dataset.dataset_7.NiftiDataset_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_dataset.py_TestNiftiDataset_TestNiftiDataset.test_dataset.dataset_7.NiftiDataset_", "embedding": null, "metadata": {"file_path": "tests/test_nifti_dataset.py", "file_name": "test_nifti_dataset.py", "file_type": "text/x-python", "category": "test", "start_line": 39, "end_line": 102, "span_ids": ["TestNiftiDataset.test_dataset", "TestNiftiDataset"], "tokens": 724}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestNiftiDataset(unittest.TestCase):\n def test_dataset(self):\n tempdir = tempfile.mkdtemp()\n full_names, ref_data = [], []\n for filename in FILENAMES:\n test_image = np.random.randint(0, 2, size=(4, 4, 4))\n ref_data.append(test_image)\n save_path = os.path.join(tempdir, filename)\n full_names.append(save_path)\n nib.save(nib.Nifti1Image(test_image, np.eye(4)), save_path)\n\n # default loading no meta\n dataset = NiftiDataset(full_names)\n for d, ref in zip(dataset, ref_data):\n np.testing.assert_allclose(d, ref, atol=1e-3)\n\n # loading no meta, int\n dataset = NiftiDataset(full_names, dtype=np.float16)\n for d, _ in zip(dataset, ref_data):\n self.assertEqual(d.dtype, np.float16)\n\n # loading with meta, no transform\n dataset = NiftiDataset(full_names, image_only=False)\n for d_tuple, ref in zip(dataset, ref_data):\n d, meta = d_tuple\n np.testing.assert_allclose(d, ref, atol=1e-3)\n np.testing.assert_allclose(meta[\"original_affine\"], np.eye(4))\n\n # loading image/label, no meta\n dataset = NiftiDataset(full_names, seg_files=full_names, image_only=True)\n for d_tuple, ref in zip(dataset, ref_data):\n img, seg = d_tuple\n np.testing.assert_allclose(img, ref, atol=1e-3)\n np.testing.assert_allclose(seg, ref, atol=1e-3)\n\n # loading image/label, no meta\n dataset = NiftiDataset(full_names, transform=lambda x: x + 1, image_only=True)\n for d, ref in zip(dataset, ref_data):\n np.testing.assert_allclose(d, ref + 1, atol=1e-3)\n\n # set seg transform, but no seg_files\n with self.assertRaises(TypeError):\n dataset = NiftiDataset(full_names, seg_transform=lambda x: x + 1, image_only=True)\n _ = dataset[0]\n\n # set seg transform, but no seg_files\n with self.assertRaises(TypeError):\n dataset = NiftiDataset(full_names, seg_transform=lambda x: x + 1, image_only=True)\n _ = dataset[0]\n\n # loading image/label, with meta\n dataset = NiftiDataset(\n full_names, transform=lambda x: x + 1, seg_files=full_names, seg_transform=lambda x: x + 2, image_only=False\n )\n for d_tuple, ref in zip(dataset, ref_data):\n img, seg, meta = d_tuple\n np.testing.assert_allclose(img, ref + 1, atol=1e-3)\n np.testing.assert_allclose(seg, ref + 2, atol=1e-3)\n np.testing.assert_allclose(meta[\"original_affine\"], np.eye(4), atol=1e-3)\n\n # loading image/label, with meta\n dataset = NiftiDataset(\n full_names, transform=lambda x: x + 1, seg_files=full_names, labels=[1, 2, 3], image_only=False\n )\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_dataset.py_TestNiftiDataset.test_dataset.for_idx_d_tuple_ref_i_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_dataset.py_TestNiftiDataset.test_dataset.for_idx_d_tuple_ref_i_", "embedding": null, "metadata": {"file_path": "tests/test_nifti_dataset.py", "file_name": "test_nifti_dataset.py", "file_type": "text/x-python", "category": "test", "start_line": 103, "end_line": 124, "span_ids": ["TestNiftiDataset.test_dataset", "impl:3"], "tokens": 265}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestNiftiDataset(unittest.TestCase):\n def test_dataset(self):\n # ... other code\n for idx, (d_tuple, ref) in enumerate(zip(dataset, ref_data)):\n img, seg, label, meta = d_tuple\n np.testing.assert_allclose(img, ref + 1, atol=1e-3)\n np.testing.assert_allclose(seg, ref, atol=1e-3)\n np.testing.assert_allclose(idx + 1, label)\n np.testing.assert_allclose(meta[\"original_affine\"], np.eye(4), atol=1e-3)\n\n # loading image/label, with sync. transform\n dataset = NiftiDataset(\n full_names, transform=RandTest(), seg_files=full_names, seg_transform=RandTest(), image_only=False\n )\n for d_tuple, ref in zip(dataset, ref_data):\n img, seg, meta = d_tuple\n np.testing.assert_allclose(img, seg, atol=1e-3)\n self.assertTrue(not np.allclose(img, ref))\n np.testing.assert_allclose(meta[\"original_affine\"], np.eye(4), atol=1e-3)\n shutil.rmtree(tempdir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_header_revise.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_header_revise.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_nifti_header_revise.py", "file_name": "test_nifti_header_revise.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 40, "span_ids": ["impl", "TestRectifyHeaderSformQform", "TestRectifyHeaderSformQform.test_revise_q", "TestRectifyHeaderSformQform.test_revise_both", "docstring"], "tokens": 299}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport nibabel as nib\n\nimport numpy as np\n\nfrom monai.data import rectify_header_sform_qform\n\n\nclass TestRectifyHeaderSformQform(unittest.TestCase):\n def test_revise_q(self):\n img = nib.Nifti1Image(np.zeros((10, 10, 10)), np.eye(4))\n img.header.set_zooms((0.1, 0.2, 0.3))\n output = rectify_header_sform_qform(img)\n expected = np.diag([0.1, 0.2, 0.3, 1.0])\n np.testing.assert_allclose(output.affine, expected)\n\n def test_revise_both(self):\n img = nib.Nifti1Image(np.zeros((10, 10, 10)), np.eye(4))\n img.header.set_sform(np.diag([5, 3, 4, 1]))\n img.header.set_qform(np.diag([2, 3, 4, 1]))\n img.header.set_zooms((0.1, 0.2, 0.3))\n output = rectify_header_sform_qform(img)\n expected = np.diag([0.1, 0.2, 0.3, 1.0])\n np.testing.assert_allclose(output.affine, expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_os_TEST_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_os_TEST_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_nifti_rw.py", "file_name": "test_nifti_rw.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 46, "span_ids": ["docstring"], "tokens": 488}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport tempfile\nimport unittest\n\nimport shutil\nimport nibabel as nib\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.data import write_nifti\nfrom monai.transforms import LoadNifti, Orientation, Spacing\nfrom tests.utils import make_nifti_image\n\nTEST_IMAGE = np.arange(24).reshape((2, 4, 3))\nTEST_AFFINE = np.array(\n [[-5.3, 0.0, 0.0, 102.01], [0.0, 0.52, 2.17, -7.50], [-0.0, 1.98, -0.26, -23.12], [0.0, 0.0, 0.0, 1.0]]\n)\n\nTEST_CASES = [\n [TEST_IMAGE, TEST_AFFINE, dict(as_closest_canonical=True, image_only=False), np.arange(24).reshape((2, 4, 3))],\n [\n TEST_IMAGE,\n TEST_AFFINE,\n dict(as_closest_canonical=True, image_only=True),\n np.array(\n [\n [[12.0, 15.0, 18.0, 21.0], [13.0, 16.0, 19.0, 22.0], [14.0, 17.0, 20.0, 23.0]],\n [[0.0, 3.0, 6.0, 9.0], [1.0, 4.0, 7.0, 10.0], [2.0, 5.0, 8.0, 11.0]],\n ]\n ),\n ],\n [TEST_IMAGE, TEST_AFFINE, dict(as_closest_canonical=False, image_only=True), np.arange(24).reshape((2, 4, 3))],\n [TEST_IMAGE, TEST_AFFINE, dict(as_closest_canonical=False, image_only=False), np.arange(24).reshape((2, 4, 3))],\n [TEST_IMAGE, None, dict(as_closest_canonical=False, image_only=False), np.arange(24).reshape((2, 4, 3))],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead_TestNiftiLoadRead.test_orientation.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead_TestNiftiLoadRead.test_orientation.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_nifti_rw.py", "file_name": "test_nifti_rw.py", "file_type": "text/x-python", "category": "test", "start_line": 49, "end_line": 78, "span_ids": ["TestNiftiLoadRead", "TestNiftiLoadRead.test_orientation"], "tokens": 247}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestNiftiLoadRead(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_orientation(self, array, affine, reader_param, expected):\n test_image = make_nifti_image(array, affine)\n\n # read test cases\n loader = LoadNifti(**reader_param)\n load_result = loader(test_image)\n if isinstance(load_result, tuple):\n data_array, header = load_result\n else:\n data_array = load_result\n header = None\n if os.path.exists(test_image):\n os.remove(test_image)\n\n # write test cases\n if header is not None:\n write_nifti(data_array, test_image, header[\"affine\"], header.get(\"original_affine\", None))\n elif affine is not None:\n write_nifti(data_array, test_image, affine)\n saved = nib.load(test_image)\n saved_affine = saved.affine\n saved_data = saved.get_fdata()\n if os.path.exists(test_image):\n os.remove(test_image)\n\n if affine is not None:\n np.testing.assert_allclose(saved_affine, affine)\n np.testing.assert_allclose(saved_data, expected)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead.test_consistency_TestNiftiLoadRead.test_consistency.None_2.os_remove_test_image_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead.test_consistency_TestNiftiLoadRead.test_consistency.None_2.os_remove_test_image_", "embedding": null, "metadata": {"file_path": "tests/test_nifti_rw.py", "file_name": "test_nifti_rw.py", "file_type": "text/x-python", "category": "test", "start_line": 80, "end_line": 107, "span_ids": ["TestNiftiLoadRead.test_consistency"], "tokens": 373}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestNiftiLoadRead(unittest.TestCase):\n\n def test_consistency(self):\n np.set_printoptions(suppress=True, precision=3)\n test_image = make_nifti_image(np.arange(64).reshape(1, 8, 8), np.diag([1.5, 1.5, 1.5, 1]))\n data, header = LoadNifti(as_closest_canonical=False)(test_image)\n data, original_affine, new_affine = Spacing([0.8, 0.8, 0.8])(data[None], header[\"affine\"], mode=\"nearest\")\n data, _, new_affine = Orientation(\"ILP\")(data, new_affine)\n if os.path.exists(test_image):\n os.remove(test_image)\n write_nifti(data[0], test_image, new_affine, original_affine, mode=\"nearest\", padding_mode=\"border\")\n saved = nib.load(test_image)\n saved_data = saved.get_fdata()\n np.testing.assert_allclose(saved_data, np.arange(64).reshape(1, 8, 8), atol=1e-7)\n if os.path.exists(test_image):\n os.remove(test_image)\n write_nifti(\n data[0],\n test_image,\n new_affine,\n original_affine,\n mode=\"nearest\",\n padding_mode=\"border\",\n output_spatial_shape=(1, 8, 8),\n )\n saved = nib.load(test_image)\n saved_data = saved.get_fdata()\n np.testing.assert_allclose(saved_data, np.arange(64).reshape(1, 8, 8), atol=1e-7)\n if os.path.exists(test_image):\n os.remove(test_image)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead.test_write_2d_TestNiftiLoadRead.test_write_2d.shutil_rmtree_out_dir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead.test_write_2d_TestNiftiLoadRead.test_write_2d.shutil_rmtree_out_dir_", "embedding": null, "metadata": {"file_path": "tests/test_nifti_rw.py", "file_name": "test_nifti_rw.py", "file_type": "text/x-python", "category": "test", "start_line": 109, "end_line": 124, "span_ids": ["TestNiftiLoadRead.test_write_2d"], "tokens": 294}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestNiftiLoadRead(unittest.TestCase):\n\n def test_write_2d(self):\n out_dir = tempfile.mkdtemp()\n image_name = os.path.join(out_dir, \"test.nii.gz\")\n img = np.arange(6).reshape((2, 3))\n write_nifti(img, image_name, affine=np.diag([1]), target_affine=np.diag([1.4]))\n out = nib.load(image_name)\n np.testing.assert_allclose(out.get_fdata(), [[0, 1, 2], [3.0, 4, 5]])\n np.testing.assert_allclose(out.affine, np.diag([1.4, 1, 1, 1]))\n\n image_name = os.path.join(out_dir, \"test1.nii.gz\")\n img = np.arange(5).reshape((1, 5))\n write_nifti(img, image_name, affine=np.diag([1, 1, 1, 3, 3]), target_affine=np.diag([1.4, 2.0, 1, 3, 5]))\n out = nib.load(image_name)\n np.testing.assert_allclose(out.get_fdata(), [[0, 2, 4]])\n np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 1, 1]))\n shutil.rmtree(out_dir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead.test_write_3d_TestNiftiLoadRead.test_write_3d.shutil_rmtree_out_dir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead.test_write_3d_TestNiftiLoadRead.test_write_3d.shutil_rmtree_out_dir_", "embedding": null, "metadata": {"file_path": "tests/test_nifti_rw.py", "file_name": "test_nifti_rw.py", "file_type": "text/x-python", "category": "test", "start_line": 126, "end_line": 141, "span_ids": ["TestNiftiLoadRead.test_write_3d"], "tokens": 300}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestNiftiLoadRead(unittest.TestCase):\n\n def test_write_3d(self):\n out_dir = tempfile.mkdtemp()\n image_name = os.path.join(out_dir, \"test.nii.gz\")\n img = np.arange(6).reshape((1, 2, 3))\n write_nifti(img, image_name, affine=np.diag([1]), target_affine=np.diag([1.4]))\n out = nib.load(image_name)\n np.testing.assert_allclose(out.get_fdata(), [[[0, 1, 2], [3, 4, 5]]])\n np.testing.assert_allclose(out.affine, np.diag([1.4, 1, 1, 1]))\n\n image_name = os.path.join(out_dir, \"test1.nii.gz\")\n img = np.arange(5).reshape((1, 1, 5))\n write_nifti(img, image_name, affine=np.diag([1, 1, 1, 3, 3]), target_affine=np.diag([1.4, 2.0, 2, 3, 5]))\n out = nib.load(image_name)\n np.testing.assert_allclose(out.get_fdata(), [[[0, 2, 4]]])\n np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 2, 1]))\n shutil.rmtree(out_dir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead.test_write_4d_TestNiftiLoadRead.test_write_4d.shutil_rmtree_out_dir_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead.test_write_4d_TestNiftiLoadRead.test_write_4d.shutil_rmtree_out_dir_", "embedding": null, "metadata": {"file_path": "tests/test_nifti_rw.py", "file_name": "test_nifti_rw.py", "file_type": "text/x-python", "category": "test", "start_line": 143, "end_line": 158, "span_ids": ["TestNiftiLoadRead.test_write_4d"], "tokens": 319}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestNiftiLoadRead(unittest.TestCase):\n\n def test_write_4d(self):\n out_dir = tempfile.mkdtemp()\n image_name = os.path.join(out_dir, \"test.nii.gz\")\n img = np.arange(6).reshape((1, 1, 3, 2))\n write_nifti(img, image_name, affine=np.diag([1.4, 1]), target_affine=np.diag([1, 1.4, 1]))\n out = nib.load(image_name)\n np.testing.assert_allclose(out.get_fdata(), [[[[0, 1], [2, 3], [4, 5]]]])\n np.testing.assert_allclose(out.affine, np.diag([1, 1.4, 1, 1]))\n\n image_name = os.path.join(out_dir, \"test1.nii.gz\")\n img = np.arange(5).reshape((1, 1, 5, 1))\n write_nifti(img, image_name, affine=np.diag([1, 1, 1, 3, 3]), target_affine=np.diag([1.4, 2.0, 2, 3, 5]))\n out = nib.load(image_name)\n np.testing.assert_allclose(out.get_fdata(), [[[[0], [2], [4]]]])\n np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 2, 1]))\n shutil.rmtree(out_dir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead.test_write_5d_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_rw.py_TestNiftiLoadRead.test_write_5d_", "embedding": null, "metadata": {"file_path": "tests/test_nifti_rw.py", "file_name": "test_nifti_rw.py", "file_type": "text/x-python", "category": "test", "start_line": 160, "end_line": 183, "span_ids": ["TestNiftiLoadRead.test_write_5d", "impl:7"], "tokens": 402}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestNiftiLoadRead(unittest.TestCase):\n\n def test_write_5d(self):\n out_dir = tempfile.mkdtemp()\n image_name = os.path.join(out_dir, \"test.nii.gz\")\n img = np.arange(12).reshape((1, 1, 3, 2, 2))\n write_nifti(img, image_name, affine=np.diag([1]), target_affine=np.diag([1.4]))\n out = nib.load(image_name)\n np.testing.assert_allclose(\n out.get_fdata(),\n np.array([[[[[0.0, 1.0], [2.0, 3.0]], [[4.0, 5.0], [6.0, 7.0]], [[8.0, 9.0], [10.0, 11.0]]]]]),\n )\n np.testing.assert_allclose(out.affine, np.diag([1.4, 1, 1, 1]))\n\n image_name = os.path.join(out_dir, \"test1.nii.gz\")\n img = np.arange(10).reshape((1, 1, 5, 1, 2))\n write_nifti(img, image_name, affine=np.diag([1, 1, 1, 3, 3]), target_affine=np.diag([1.4, 2.0, 2, 3, 5]))\n out = nib.load(image_name)\n np.testing.assert_allclose(out.get_fdata(), np.array([[[[[0.0, 1.0]], [[4.0, 5.0]], [[8.0, 9.0]]]]]))\n np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 2, 1]))\n shutil.rmtree(out_dir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_saver.py_os_TestNiftiSaver.test_saved_content.None_2": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_saver.py_os_TestNiftiSaver.test_saved_content.None_2", "embedding": null, "metadata": {"file_path": "tests/test_nifti_saver.py", "file_name": "test_nifti_saver.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 34, "span_ids": ["TestNiftiSaver.test_saved_content", "TestNiftiSaver", "docstring"], "tokens": 195}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport shutil\nimport unittest\n\nimport numpy as np\nimport torch\n\nfrom monai.data import NiftiSaver\n\n\nclass TestNiftiSaver(unittest.TestCase):\n def test_saved_content(self):\n default_dir = os.path.join(\".\", \"tempdir\")\n shutil.rmtree(default_dir, ignore_errors=True)\n\n saver = NiftiSaver(output_dir=default_dir, output_postfix=\"seg\", output_ext=\".nii.gz\")\n\n meta_data = {\"filename_or_obj\": [\"testfile\" + str(i) for i in range(8)]}\n saver.save_batch(torch.zeros(8, 1, 2, 2), meta_data)\n for i in range(8):\n filepath = os.path.join(\"testfile\" + str(i), \"testfile\" + str(i) + \"_seg.nii.gz\")\n self.assertTrue(os.path.exists(os.path.join(default_dir, filepath)))\n shutil.rmtree(default_dir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_saver.py_TestNiftiSaver.test_saved_resize_content_TestNiftiSaver.test_saved_resize_content.None_2": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_saver.py_TestNiftiSaver.test_saved_resize_content_TestNiftiSaver.test_saved_resize_content.None_2", "embedding": null, "metadata": {"file_path": "tests/test_nifti_saver.py", "file_name": "test_nifti_saver.py", "file_type": "text/x-python", "category": "test", "start_line": 36, "end_line": 51, "span_ids": ["TestNiftiSaver.test_saved_resize_content"], "tokens": 227}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestNiftiSaver(unittest.TestCase):\n\n def test_saved_resize_content(self):\n default_dir = os.path.join(\".\", \"tempdir\")\n shutil.rmtree(default_dir, ignore_errors=True)\n\n saver = NiftiSaver(output_dir=default_dir, output_postfix=\"seg\", output_ext=\".nii.gz\", dtype=np.float32)\n\n meta_data = {\n \"filename_or_obj\": [\"testfile\" + str(i) for i in range(8)],\n \"affine\": [np.diag(np.ones(4)) * 5] * 8,\n \"original_affine\": [np.diag(np.ones(4)) * 1.0] * 8,\n }\n saver.save_batch(torch.randint(0, 255, (8, 8, 2, 2)), meta_data)\n for i in range(8):\n filepath = os.path.join(\"testfile\" + str(i), \"testfile\" + str(i) + \"_seg.nii.gz\")\n self.assertTrue(os.path.exists(os.path.join(default_dir, filepath)))\n shutil.rmtree(default_dir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_saver.py_TestNiftiSaver.test_saved_3d_resize_content_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_saver.py_TestNiftiSaver.test_saved_3d_resize_content_", "embedding": null, "metadata": {"file_path": "tests/test_nifti_saver.py", "file_name": "test_nifti_saver.py", "file_type": "text/x-python", "category": "test", "start_line": 53, "end_line": 74, "span_ids": ["TestNiftiSaver.test_saved_3d_resize_content", "impl"], "tokens": 264}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestNiftiSaver(unittest.TestCase):\n\n def test_saved_3d_resize_content(self):\n default_dir = os.path.join(\".\", \"tempdir\")\n shutil.rmtree(default_dir, ignore_errors=True)\n\n saver = NiftiSaver(output_dir=default_dir, output_postfix=\"seg\", output_ext=\".nii.gz\", dtype=np.float32)\n\n meta_data = {\n \"filename_or_obj\": [\"testfile\" + str(i) for i in range(8)],\n \"spatial_shape\": [(10, 10, 2)] * 8,\n \"affine\": [np.diag(np.ones(4)) * 5] * 8,\n \"original_affine\": [np.diag(np.ones(4)) * 1.0] * 8,\n }\n saver.save_batch(torch.randint(0, 255, (8, 8, 1, 2, 2)), meta_data)\n for i in range(8):\n filepath = os.path.join(\"testfile\" + str(i), \"testfile\" + str(i) + \"_seg.nii.gz\")\n self.assertTrue(os.path.exists(os.path.join(default_dir, filepath)))\n shutil.rmtree(default_dir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensity.py_unittest_TEST_CASE_3._nonzero_True_np_ar": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensity.py_unittest_TEST_CASE_3._nonzero_True_np_ar", "embedding": null, "metadata": {"file_path": "tests/test_normalize_intensity.py", "file_name": "test_normalize_intensity.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 27, "span_ids": ["docstring"], "tokens": 259}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import NormalizeIntensity\nfrom tests.utils import NumpyImageTestCase2D\n\nTEST_CASE_1 = [{\"nonzero\": True}, np.array([0.0, 3.0, 0.0, 4.0]), np.array([0.0, -1.0, 0.0, 1.0])]\n\nTEST_CASE_2 = [\n {\"subtrahend\": np.array([3.5, 3.5, 3.5, 3.5]), \"divisor\": np.array([0.5, 0.5, 0.5, 0.5]), \"nonzero\": True},\n np.array([0.0, 3.0, 0.0, 4.0]),\n np.array([0.0, -1.0, 0.0, 1.0]),\n]\n\nTEST_CASE_3 = [{\"nonzero\": True}, np.array([0.0, 0.0, 0.0, 0.0]), np.array([0.0, 0.0, 0.0, 0.0])]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensity.py_TestNormalizeIntensity_TestNormalizeIntensity.test_nonzero.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensity.py_TestNormalizeIntensity_TestNormalizeIntensity.test_nonzero.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_normalize_intensity.py", "file_name": "test_normalize_intensity.py", "file_type": "text/x-python", "category": "test", "start_line": 30, "end_line": 40, "span_ids": ["TestNormalizeIntensity.test_default", "TestNormalizeIntensity", "TestNormalizeIntensity.test_nonzero"], "tokens": 134}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestNormalizeIntensity(NumpyImageTestCase2D):\n def test_default(self):\n normalizer = NormalizeIntensity()\n normalized = normalizer(self.imt)\n expected = (self.imt - np.mean(self.imt)) / np.std(self.imt)\n np.testing.assert_allclose(normalized, expected, rtol=1e-6)\n\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_nonzero(self, input_param, input_data, expected_data):\n normalizer = NormalizeIntensity(**input_param)\n np.testing.assert_allclose(expected_data, normalizer(input_data))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensity.py_TestNormalizeIntensity.test_channel_wise_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensity.py_TestNormalizeIntensity.test_channel_wise_", "embedding": null, "metadata": {"file_path": "tests/test_normalize_intensity.py", "file_name": "test_normalize_intensity.py", "file_type": "text/x-python", "category": "test", "start_line": 42, "end_line": 51, "span_ids": ["TestNormalizeIntensity.test_channel_wise", "impl:7"], "tokens": 150}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestNormalizeIntensity(NumpyImageTestCase2D):\n\n def test_channel_wise(self):\n normalizer = NormalizeIntensity(nonzero=True, channel_wise=True)\n input_data = np.array([[0.0, 3.0, 0.0, 4.0], [0.0, 4.0, 0.0, 5.0]])\n expected = np.array([[0.0, -1.0, 0.0, 1.0], [0.0, -1.0, 0.0, 1.0]])\n np.testing.assert_allclose(expected, normalizer(input_data))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensityd.py_unittest_TEST_CASE_3._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensityd.py_unittest_TEST_CASE_3._", "embedding": null, "metadata": {"file_path": "tests/test_normalize_intensityd.py", "file_name": "test_normalize_intensityd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 40, "span_ids": ["docstring"], "tokens": 306}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import NormalizeIntensityd\nfrom tests.utils import NumpyImageTestCase2D\n\nTEST_CASE_1 = [\n {\"keys\": [\"img\"], \"nonzero\": True},\n {\"img\": np.array([0.0, 3.0, 0.0, 4.0])},\n np.array([0.0, -1.0, 0.0, 1.0]),\n]\n\nTEST_CASE_2 = [\n {\n \"keys\": [\"img\"],\n \"subtrahend\": np.array([3.5, 3.5, 3.5, 3.5]),\n \"divisor\": np.array([0.5, 0.5, 0.5, 0.5]),\n \"nonzero\": True,\n },\n {\"img\": np.array([0.0, 3.0, 0.0, 4.0])},\n np.array([0.0, -1.0, 0.0, 1.0]),\n]\n\nTEST_CASE_3 = [\n {\"keys\": [\"img\"], \"nonzero\": True},\n {\"img\": np.array([0.0, 0.0, 0.0, 0.0])},\n np.array([0.0, 0.0, 0.0, 0.0]),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensityd.py_TestNormalizeIntensityd_TestNormalizeIntensityd.test_nonzero.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensityd.py_TestNormalizeIntensityd_TestNormalizeIntensityd.test_nonzero.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_normalize_intensityd.py", "file_name": "test_normalize_intensityd.py", "file_type": "text/x-python", "category": "test", "start_line": 43, "end_line": 54, "span_ids": ["TestNormalizeIntensityd.test_nonzero", "TestNormalizeIntensityd", "TestNormalizeIntensityd.test_image_normalize_intensityd"], "tokens": 155}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestNormalizeIntensityd(NumpyImageTestCase2D):\n def test_image_normalize_intensityd(self):\n key = \"img\"\n normalizer = NormalizeIntensityd(keys=[key])\n normalized = normalizer({key: self.imt})\n expected = (self.imt - np.mean(self.imt)) / np.std(self.imt)\n np.testing.assert_allclose(normalized[key], expected, rtol=1e-6)\n\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_nonzero(self, input_param, input_data, expected_data):\n normalizer = NormalizeIntensityd(**input_param)\n np.testing.assert_allclose(expected_data, normalizer(input_data)[\"img\"])", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensityd.py_TestNormalizeIntensityd.test_channel_wise_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_normalize_intensityd.py_TestNormalizeIntensityd.test_channel_wise_", "embedding": null, "metadata": {"file_path": "tests/test_normalize_intensityd.py", "file_name": "test_normalize_intensityd.py", "file_type": "text/x-python", "category": "test", "start_line": 56, "end_line": 66, "span_ids": ["TestNormalizeIntensityd.test_channel_wise", "impl:7"], "tokens": 166}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestNormalizeIntensityd(NumpyImageTestCase2D):\n\n def test_channel_wise(self):\n key = \"img\"\n normalizer = NormalizeIntensityd(keys=key, nonzero=True, channel_wise=True)\n input_data = {key: np.array([[0.0, 3.0, 0.0, 4.0], [0.0, 4.0, 0.0, 5.0]])}\n expected = np.array([[0.0, -1.0, 0.0, 1.0], [0.0, -1.0, 0.0, 1.0]])\n np.testing.assert_allclose(expected, normalizer(input_data)[key])\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_optional_import.py_unittest_TestOptionalImport.test_import_wrong_number.None_2.print_my_module_randint_1": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_optional_import.py_unittest_TestOptionalImport.test_import_wrong_number.None_2.print_my_module_randint_1", "embedding": null, "metadata": {"file_path": "tests/test_optional_import.py", "file_name": "test_optional_import.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 45, "span_ids": ["TestOptionalImport", "TestOptionalImport.test_import_valid", "TestOptionalImport.test_import_wrong_number", "docstring", "TestOptionalImport.test_default"], "tokens": 257}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nfrom monai.utils import exact_version, optional_import\n\n\nclass TestOptionalImport(unittest.TestCase):\n def test_default(self):\n my_module, flag = optional_import(\"not_a_module\")\n self.assertFalse(flag)\n with self.assertRaises(AttributeError):\n my_module.test\n\n my_module, flag = optional_import(\"torch.randint\")\n with self.assertRaises(AttributeError):\n self.assertFalse(flag)\n print(my_module.test)\n\n def test_import_valid(self):\n my_module, flag = optional_import(\"torch\")\n self.assertTrue(flag)\n print(my_module.randint(1, 2, (1, 2)))\n\n def test_import_wrong_number(self):\n my_module, flag = optional_import(\"torch\", \"42\")\n with self.assertRaisesRegex(AttributeError, \"version\"):\n my_module.nn\n self.assertFalse(flag)\n with self.assertRaisesRegex(AttributeError, \"version\"):\n my_module.randint(1, 2, (1, 2))\n with self.assertRaisesRegex(ValueError, \"invalid literal\"):\n my_module, flag = optional_import(\"torch\", \"test\") # version should be number.number\n my_module.nn\n self.assertTrue(flag)\n print(my_module.randint(1, 2, (1, 2)))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_optional_import.py_TestOptionalImport.test_import_good_number_TestOptionalImport.test_import_good_number.None_5": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_optional_import.py_TestOptionalImport.test_import_good_number_TestOptionalImport.test_import_good_number.None_5", "embedding": null, "metadata": {"file_path": "tests/test_optional_import.py", "file_name": "test_optional_import.py", "file_type": "text/x-python", "category": "test", "start_line": 47, "end_line": 61, "span_ids": ["TestOptionalImport.test_import_good_number"], "tokens": 148}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestOptionalImport(unittest.TestCase):\n\n def test_import_good_number(self):\n my_module, flag = optional_import(\"torch\", \"0\")\n my_module.nn\n self.assertTrue(flag)\n print(my_module.randint(1, 2, (1, 2)))\n\n my_module, flag = optional_import(\"torch\", \"0.0.0.1\")\n my_module.nn\n self.assertTrue(flag)\n print(my_module.randint(1, 2, (1, 2)))\n\n my_module, flag = optional_import(\"torch\", \"1.1.0\")\n my_module.nn\n self.assertTrue(flag)\n print(my_module.randint(1, 2, (1, 2)))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_optional_import.py_TestOptionalImport.test_import_exact_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_optional_import.py_TestOptionalImport.test_import_exact_", "embedding": null, "metadata": {"file_path": "tests/test_optional_import.py", "file_name": "test_optional_import.py", "file_type": "text/x-python", "category": "test", "start_line": 63, "end_line": 89, "span_ids": ["TestOptionalImport.test_import_exact", "TestOptionalImport.test_additional", "impl", "TestOptionalImport.test_import_method"], "tokens": 208}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestOptionalImport(unittest.TestCase):\n\n def test_import_exact(self):\n my_module, flag = optional_import(\"torch\", \"0\", exact_version)\n with self.assertRaisesRegex(AttributeError, \"exact_version\"):\n my_module.nn\n self.assertFalse(flag)\n with self.assertRaisesRegex(AttributeError, \"exact_version\"):\n my_module.randint(1, 2, (1, 2))\n\n def test_import_method(self):\n nn, flag = optional_import(\"torch\", \"1.1\", name=\"nn\")\n self.assertTrue(flag)\n print(nn.functional)\n\n def test_additional(self):\n test_args = {\"a\": \"test\", \"b\": \"test\"}\n\n def versioning(module, ver, a):\n self.assertEqual(a, test_args)\n return True\n\n nn, flag = optional_import(\"torch\", \"1.1\", version_checker=versioning, name=\"nn\", version_args=test_args)\n self.assertTrue(flag)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientation.py_unittest_TEST_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientation.py_unittest_TEST_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_orientation.py", "file_name": "test_orientation.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 102, "span_ids": ["docstring"], "tokens": 1208}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport nibabel as nib\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.transforms import Orientation, create_rotate, create_translate\n\nTEST_CASES = [\n [\n {\"axcodes\": \"RAS\"},\n np.arange(12).reshape((2, 1, 2, 3)),\n {\"affine\": np.eye(4)},\n np.arange(12).reshape((2, 1, 2, 3)),\n \"RAS\",\n ],\n [\n {\"axcodes\": \"ALS\"},\n np.arange(12).reshape((2, 1, 2, 3)),\n {\"affine\": np.diag([-1, -1, 1, 1])},\n np.array([[[[3, 4, 5]], [[0, 1, 2]]], [[[9, 10, 11]], [[6, 7, 8]]]]),\n \"ALS\",\n ],\n [\n {\"axcodes\": \"RAS\"},\n np.arange(12).reshape((2, 1, 2, 3)),\n {\"affine\": np.diag([-1, -1, 1, 1])},\n np.array([[[[3, 4, 5], [0, 1, 2]]], [[[9, 10, 11], [6, 7, 8]]]]),\n \"RAS\",\n ],\n [\n {\"axcodes\": \"AL\"},\n np.arange(6).reshape((2, 1, 3)),\n {\"affine\": np.eye(3)},\n np.array([[[0], [1], [2]], [[3], [4], [5]]]),\n \"AL\",\n ],\n [{\"axcodes\": \"L\"}, np.arange(6).reshape((2, 3)), {\"affine\": np.eye(2)}, np.array([[2, 1, 0], [5, 4, 3]]), \"L\"],\n [{\"axcodes\": \"L\"}, np.arange(6).reshape((2, 3)), {\"affine\": np.eye(2)}, np.array([[2, 1, 0], [5, 4, 3]]), \"L\"],\n [{\"axcodes\": \"L\"}, np.arange(6).reshape((2, 3)), {\"affine\": np.diag([-1, 1])}, np.arange(6).reshape((2, 3)), \"L\"],\n [\n {\"axcodes\": \"LPS\"},\n np.arange(12).reshape((2, 1, 2, 3)),\n {\n \"affine\": create_translate(3, (10, 20, 30))\n @ create_rotate(3, (np.pi / 2, np.pi / 2, np.pi / 4))\n @ np.diag([-1, 1, 1, 1])\n },\n np.array([[[[2, 5]], [[1, 4]], [[0, 3]]], [[[8, 11]], [[7, 10]], [[6, 9]]]]),\n \"LPS\",\n ],\n [\n {\"as_closest_canonical\": True},\n np.arange(12).reshape((2, 1, 2, 3)),\n {\n \"affine\": create_translate(3, (10, 20, 30))\n @ create_rotate(3, (np.pi / 2, np.pi / 2, np.pi / 4))\n @ np.diag([-1, 1, 1, 1])\n },\n np.array([[[[0, 3]], [[1, 4]], [[2, 5]]], [[[6, 9]], [[7, 10]], [[8, 11]]]]),\n \"RAS\",\n ],\n [\n {\"as_closest_canonical\": True},\n np.arange(6).reshape((1, 2, 3)),\n {\"affine\": create_translate(2, (10, 20)) @ create_rotate(2, (np.pi / 3)) @ np.diag([-1, -0.2, 1])},\n np.array([[[3, 0], [4, 1], [5, 2]]]),\n \"RA\",\n ],\n [\n {\"axcodes\": \"LP\"},\n np.arange(6).reshape((1, 2, 3)),\n {\"affine\": create_translate(2, (10, 20)) @ create_rotate(2, (np.pi / 3)) @ np.diag([-1, -0.2, 1])},\n np.array([[[2, 5], [1, 4], [0, 3]]]),\n \"LP\",\n ],\n [\n {\"axcodes\": \"LPID\", \"labels\": tuple(zip(\"LPIC\", \"RASD\"))},\n np.zeros((1, 2, 3, 4, 5)),\n {\"affine\": np.diag([-1, -0.2, -1, 1, 1])},\n np.zeros((1, 2, 3, 4, 5)),\n \"LPID\",\n ],\n [\n {\"as_closest_canonical\": True, \"labels\": tuple(zip(\"LPIC\", \"RASD\"))},\n np.zeros((1, 2, 3, 4, 5)),\n {\"affine\": np.diag([-1, -0.2, -1, 1, 1])},\n np.zeros((1, 2, 3, 4, 5)),\n \"RASD\",\n ],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientation.py_ILL_CASES_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientation.py_ILL_CASES_", "embedding": null, "metadata": {"file_path": "tests/test_orientation.py", "file_name": "test_orientation.py", "file_type": "text/x-python", "category": "test", "start_line": 104, "end_line": 131, "span_ids": ["impl:3", "TestOrientationCase.test_bad_params", "TestOrientationCase", "TestOrientationCase.test_ornt", "impl:5"], "tokens": 265}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "ILL_CASES = [\n # no axcodes or as_cloest_canonical\n [{}, np.arange(6).reshape((2, 3)), \"L\"],\n # too short axcodes\n [{\"axcodes\": \"RA\"}, np.arange(12).reshape((2, 1, 2, 3)), {\"affine\": np.eye(4)}],\n]\n\n\nclass TestOrientationCase(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_ornt(self, init_param, img, data_param, expected_data, expected_code):\n ornt = Orientation(**init_param)\n res = ornt(img, **data_param)\n np.testing.assert_allclose(res[0], expected_data)\n original_affine = data_param[\"affine\"]\n np.testing.assert_allclose(original_affine, res[1])\n new_code = nib.orientations.aff2axcodes(res[2], labels=ornt.labels)\n self.assertEqual(\"\".join(new_code), expected_code)\n\n @parameterized.expand(ILL_CASES)\n def test_bad_params(self, init_param, img, data_param):\n with self.assertRaises(ValueError):\n Orientation(**init_param)(img, **data_param)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientationd.py_unittest_TestOrientationdCase.test_orntd.self_assertEqual_code_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientationd.py_unittest_TestOrientationdCase.test_orntd.self_assertEqual_code_", "embedding": null, "metadata": {"file_path": "tests/test_orientationd.py", "file_name": "test_orientationd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 27, "span_ids": ["TestOrientationdCase.test_orntd", "TestOrientationdCase", "docstring"], "tokens": 159}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport nibabel as nib\nimport numpy as np\n\nfrom monai.transforms import Orientationd\n\n\nclass TestOrientationdCase(unittest.TestCase):\n def test_orntd(self):\n data = {\"seg\": np.ones((2, 1, 2, 3)), \"seg_meta_dict\": {\"affine\": np.eye(4)}}\n ornt = Orientationd(keys=\"seg\", axcodes=\"RAS\")\n res = ornt(data)\n np.testing.assert_allclose(res[\"seg\"].shape, (2, 1, 2, 3))\n code = nib.aff2axcodes(res[\"seg_meta_dict\"][\"affine\"], ornt.ornt_transform.labels)\n self.assertEqual(code, (\"R\", \"A\", \"S\"))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientationd.py_TestOrientationdCase.test_orntd_3d_TestOrientationdCase.test_orntd_3d.None_3": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientationd.py_TestOrientationdCase.test_orntd_3d_TestOrientationdCase.test_orntd_3d.None_3", "embedding": null, "metadata": {"file_path": "tests/test_orientationd.py", "file_name": "test_orientationd.py", "file_type": "text/x-python", "category": "test", "start_line": 29, "end_line": 43, "span_ids": ["TestOrientationdCase.test_orntd_3d"], "tokens": 243}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestOrientationdCase(unittest.TestCase):\n\n def test_orntd_3d(self):\n data = {\n \"seg\": np.ones((2, 1, 2, 3)),\n \"img\": np.ones((2, 1, 2, 3)),\n \"seg_meta_dict\": {\"affine\": np.eye(4)},\n \"img_meta_dict\": {\"affine\": np.eye(4)},\n }\n ornt = Orientationd(keys=(\"img\", \"seg\"), axcodes=\"PLI\")\n res = ornt(data)\n np.testing.assert_allclose(res[\"img\"].shape, (2, 2, 1, 3))\n np.testing.assert_allclose(res[\"seg\"].shape, (2, 2, 1, 3))\n code = nib.aff2axcodes(res[\"seg_meta_dict\"][\"affine\"], ornt.ornt_transform.labels)\n self.assertEqual(code, (\"P\", \"L\", \"I\"))\n code = nib.aff2axcodes(res[\"img_meta_dict\"][\"affine\"], ornt.ornt_transform.labels)\n self.assertEqual(code, (\"P\", \"L\", \"I\"))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientationd.py_TestOrientationdCase.test_orntd_2d_TestOrientationdCase.test_orntd_2d.None_2": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientationd.py_TestOrientationdCase.test_orntd_2d_TestOrientationdCase.test_orntd_2d.None_2", "embedding": null, "metadata": {"file_path": "tests/test_orientationd.py", "file_name": "test_orientationd.py", "file_type": "text/x-python", "category": "test", "start_line": 45, "end_line": 58, "span_ids": ["TestOrientationdCase.test_orntd_2d"], "tokens": 210}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestOrientationdCase(unittest.TestCase):\n\n def test_orntd_2d(self):\n data = {\n \"seg\": np.ones((2, 1, 3)),\n \"img\": np.ones((2, 1, 3)),\n \"seg_meta_dict\": {\"affine\": np.eye(4)},\n \"img_meta_dict\": {\"affine\": np.eye(4)},\n }\n ornt = Orientationd(keys=(\"img\", \"seg\"), axcodes=\"PLI\")\n res = ornt(data)\n np.testing.assert_allclose(res[\"img\"].shape, (2, 3, 1))\n code = nib.aff2axcodes(res[\"seg_meta_dict\"][\"affine\"], ornt.ornt_transform.labels)\n self.assertEqual(code, (\"P\", \"L\", \"S\"))\n code = nib.aff2axcodes(res[\"img_meta_dict\"][\"affine\"], ornt.ornt_transform.labels)\n self.assertEqual(code, (\"P\", \"L\", \"S\"))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientationd.py_TestOrientationdCase.test_orntd_1d_TestOrientationdCase.test_orntd_1d.None_2": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientationd.py_TestOrientationdCase.test_orntd_1d_TestOrientationdCase.test_orntd_1d.None_2", "embedding": null, "metadata": {"file_path": "tests/test_orientationd.py", "file_name": "test_orientationd.py", "file_type": "text/x-python", "category": "test", "start_line": 60, "end_line": 73, "span_ids": ["TestOrientationdCase.test_orntd_1d"], "tokens": 200}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestOrientationdCase(unittest.TestCase):\n\n def test_orntd_1d(self):\n data = {\n \"seg\": np.ones((2, 3)),\n \"img\": np.ones((2, 3)),\n \"seg_meta_dict\": {\"affine\": np.eye(4)},\n \"img_meta_dict\": {\"affine\": np.eye(4)},\n }\n ornt = Orientationd(keys=(\"img\", \"seg\"), axcodes=\"L\")\n res = ornt(data)\n np.testing.assert_allclose(res[\"img\"].shape, (2, 3))\n code = nib.aff2axcodes(res[\"seg_meta_dict\"][\"affine\"], ornt.ornt_transform.labels)\n self.assertEqual(code, (\"L\", \"A\", \"S\"))\n code = nib.aff2axcodes(res[\"img_meta_dict\"][\"affine\"], ornt.ornt_transform.labels)\n self.assertEqual(code, (\"L\", \"A\", \"S\"))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientationd.py_TestOrientationdCase.test_orntd_canonical_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_orientationd.py_TestOrientationdCase.test_orntd_canonical_", "embedding": null, "metadata": {"file_path": "tests/test_orientationd.py", "file_name": "test_orientationd.py", "file_type": "text/x-python", "category": "test", "start_line": 75, "end_line": 94, "span_ids": ["impl", "TestOrientationdCase.test_orntd_canonical"], "tokens": 256}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestOrientationdCase(unittest.TestCase):\n\n def test_orntd_canonical(self):\n data = {\n \"seg\": np.ones((2, 1, 2, 3)),\n \"img\": np.ones((2, 1, 2, 3)),\n \"seg_meta_dict\": {\"affine\": np.eye(4)},\n \"img_meta_dict\": {\"affine\": np.eye(4)},\n }\n ornt = Orientationd(keys=(\"img\", \"seg\"), as_closest_canonical=True)\n res = ornt(data)\n np.testing.assert_allclose(res[\"img\"].shape, (2, 1, 2, 3))\n np.testing.assert_allclose(res[\"seg\"].shape, (2, 1, 2, 3))\n code = nib.aff2axcodes(res[\"seg_meta_dict\"][\"affine\"], ornt.ornt_transform.labels)\n self.assertEqual(code, (\"R\", \"A\", \"S\"))\n code = nib.aff2axcodes(res[\"img_meta_dict\"][\"affine\"], ornt.ornt_transform.labels)\n self.assertEqual(code, (\"R\", \"A\", \"S\"))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_parallel_execution.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_parallel_execution.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_parallel_execution.py", "file_name": "test_parallel_execution.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 59, "span_ids": ["TestParallelExecution.test_multi_gpu", "TestParallelExecution.test_single_gpu", "fake_loss", "TestParallelExecution", "docstring", "fake_data_stream", "TestParallelExecution.test_cpu"], "tokens": 395}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport warnings\n\nimport torch\n\nfrom monai.engines import create_multigpu_supervised_trainer\nfrom tests.utils import expect_failure_if_no_gpu\n\n\ndef fake_loss(y_pred, y):\n return (y_pred[0] + y).sum()\n\n\ndef fake_data_stream():\n while True:\n yield torch.rand((10, 1, 64, 64)), torch.rand((10, 1, 64, 64))\n\n\nclass TestParallelExecution(unittest.TestCase):\n \"\"\"\n Tests single GPU, multi GPU, and CPU execution with the Ignite supervised trainer.\n \"\"\"\n\n @expect_failure_if_no_gpu\n def test_single_gpu(self):\n net = torch.nn.Conv2d(1, 1, 3, padding=1)\n opt = torch.optim.Adam(net.parameters(), 1e-3)\n trainer = create_multigpu_supervised_trainer(net, opt, fake_loss, [torch.device(\"cuda:0\")])\n trainer.run(fake_data_stream(), 2, 2)\n\n @expect_failure_if_no_gpu\n def test_multi_gpu(self):\n net = torch.nn.Conv2d(1, 1, 3, padding=1)\n opt = torch.optim.Adam(net.parameters(), 1e-3)\n\n with warnings.catch_warnings():\n warnings.simplefilter(\"ignore\") # ignore warnings about imbalanced GPU memory\n\n trainer = create_multigpu_supervised_trainer(net, opt, fake_loss, None)\n\n trainer.run(fake_data_stream(), 2, 2)\n\n def test_cpu(self):\n net = torch.nn.Conv2d(1, 1, 3, padding=1)\n opt = torch.optim.Adam(net.parameters(), 1e-3)\n trainer = create_multigpu_supervised_trainer(net, opt, fake_loss, [])\n trainer.run(fake_data_stream(), 2, 2)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_persistentdataset.py_unittest_TEST_CASE_3._None_128_128_128_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_persistentdataset.py_unittest_TEST_CASE_3._None_128_128_128_", "embedding": null, "metadata": {"file_path": "tests/test_persistentdataset.py", "file_name": "test_persistentdataset.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 40, "span_ids": ["docstring"], "tokens": 221}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport os\nimport shutil\nimport numpy as np\nimport tempfile\nimport nibabel as nib\nfrom parameterized import parameterized\nfrom monai.data import PersistentDataset\nfrom monai.transforms import Compose, LoadNiftid, SimulateDelayd\n\nTEST_CASE_1 = [\n Compose(\n [\n LoadNiftid(keys=[\"image\", \"label\", \"extra\"]),\n SimulateDelayd(keys=[\"image\", \"label\", \"extra\"], delay_time=[1e-7, 1e-6, 1e-5]),\n ]\n ),\n (128, 128, 128),\n]\n\nTEST_CASE_2 = [\n [\n LoadNiftid(keys=[\"image\", \"label\", \"extra\"]),\n SimulateDelayd(keys=[\"image\", \"label\", \"extra\"], delay_time=[1e-7, 1e-6, 1e-5]),\n ],\n (128, 128, 128),\n]\n\nTEST_CASE_3 = [None, (128, 128, 128)]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_persistentdataset.py_TestDataset_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_persistentdataset.py_TestDataset_", "embedding": null, "metadata": {"file_path": "tests/test_persistentdataset.py", "file_name": "test_persistentdataset.py", "file_type": "text/x-python", "category": "test", "start_line": 43, "end_line": 99, "span_ids": ["TestDataset.test_shape", "TestDataset", "impl:7"], "tokens": 723}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestDataset(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_shape(self, transform, expected_shape):\n test_image = nib.Nifti1Image(np.random.randint(0, 2, size=[128, 128, 128]), np.eye(4))\n tempdir = tempfile.mkdtemp()\n nib.save(test_image, os.path.join(tempdir, \"test_image1.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_label1.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_extra1.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_image2.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_label2.nii.gz\"))\n nib.save(test_image, os.path.join(tempdir, \"test_extra2.nii.gz\"))\n test_data = [\n {\n \"image\": os.path.join(tempdir, \"test_image1.nii.gz\"),\n \"label\": os.path.join(tempdir, \"test_label1.nii.gz\"),\n \"extra\": os.path.join(tempdir, \"test_extra1.nii.gz\"),\n },\n {\n \"image\": os.path.join(tempdir, \"test_image2.nii.gz\"),\n \"label\": os.path.join(tempdir, \"test_label2.nii.gz\"),\n \"extra\": os.path.join(tempdir, \"test_extra2.nii.gz\"),\n },\n ]\n\n dataset_precached = PersistentDataset(data=test_data, transform=transform, cache_dir=tempdir)\n data1_precached = dataset_precached[0]\n data2_precached = dataset_precached[1]\n\n dataset_postcached = PersistentDataset(data=test_data, transform=transform, cache_dir=tempdir)\n data1_postcached = dataset_postcached[0]\n data2_postcached = dataset_postcached[1]\n shutil.rmtree(tempdir)\n\n if transform is None:\n self.assertEqual(data1_precached[\"image\"], os.path.join(tempdir, \"test_image1.nii.gz\"))\n self.assertEqual(data2_precached[\"label\"], os.path.join(tempdir, \"test_label2.nii.gz\"))\n self.assertEqual(data1_postcached[\"image\"], os.path.join(tempdir, \"test_image1.nii.gz\"))\n self.assertEqual(data2_postcached[\"extra\"], os.path.join(tempdir, \"test_extra2.nii.gz\"))\n else:\n self.assertTupleEqual(data1_precached[\"image\"].shape, expected_shape)\n self.assertTupleEqual(data1_precached[\"label\"].shape, expected_shape)\n self.assertTupleEqual(data1_precached[\"extra\"].shape, expected_shape)\n self.assertTupleEqual(data2_precached[\"image\"].shape, expected_shape)\n self.assertTupleEqual(data2_precached[\"label\"].shape, expected_shape)\n self.assertTupleEqual(data2_precached[\"extra\"].shape, expected_shape)\n\n self.assertTupleEqual(data1_postcached[\"image\"].shape, expected_shape)\n self.assertTupleEqual(data1_postcached[\"label\"].shape, expected_shape)\n self.assertTupleEqual(data1_postcached[\"extra\"].shape, expected_shape)\n self.assertTupleEqual(data2_postcached[\"image\"].shape, expected_shape)\n self.assertTupleEqual(data2_postcached[\"label\"].shape, expected_shape)\n self.assertTupleEqual(data2_postcached[\"extra\"].shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_plot_2d_or_3d_image.py_glob_TEST_CASE_5._1_3_10_10_10_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_plot_2d_or_3d_image.py_glob_TEST_CASE_5._1_3_10_10_10_", "embedding": null, "metadata": {"file_path": "tests/test_plot_2d_or_3d_image.py", "file_name": "test_plot_2d_or_3d_image.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 30, "span_ids": ["docstring"], "tokens": 141}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import glob\nimport os\nimport tempfile\nimport shutil\nimport unittest\nfrom torch.utils.tensorboard import SummaryWriter\nimport torch\nfrom parameterized import parameterized\nfrom monai.visualize import plot_2d_or_3d_image\n\nTEST_CASE_1 = [(1, 1, 10, 10)]\n\nTEST_CASE_2 = [(1, 3, 10, 10)]\n\nTEST_CASE_3 = [(1, 4, 10, 10)]\n\nTEST_CASE_4 = [(1, 1, 10, 10, 10)]\n\nTEST_CASE_5 = [(1, 3, 10, 10, 10)]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_plot_2d_or_3d_image.py_TestPlot2dOr3dImage_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_plot_2d_or_3d_image.py_TestPlot2dOr3dImage_", "embedding": null, "metadata": {"file_path": "tests/test_plot_2d_or_3d_image.py", "file_name": "test_plot_2d_or_3d_image.py", "file_type": "text/x-python", "category": "test", "start_line": 33, "end_line": 48, "span_ids": ["impl:11", "TestPlot2dOr3dImage", "TestPlot2dOr3dImage.test_tb_image_shape"], "tokens": 141}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestPlot2dOr3dImage(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5])\n def test_tb_image_shape(self, shape):\n tempdir = tempfile.mkdtemp()\n shutil.rmtree(tempdir, ignore_errors=True)\n\n plot_2d_or_3d_image(torch.zeros(shape), 0, SummaryWriter(log_dir=tempdir))\n\n self.assertTrue(os.path.exists(tempdir))\n self.assertTrue(len(glob.glob(tempdir)) > 0)\n shutil.rmtree(tempdir, ignore_errors=True)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_png_rw.py_os_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_png_rw.py_os_", "embedding": null, "metadata": {"file_path": "tests/test_png_rw.py", "file_name": "test_png_rw.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 86, "span_ids": ["TestPngWrite.test_write_output_shape", "impl", "TestPngWrite.test_write_gray", "docstring", "TestPngWrite.test_write_gray_1height", "TestPngWrite.test_write_2channels", "TestPngWrite", "TestPngWrite.test_write_rgb", "TestPngWrite.test_write_gray_1channel"], "tokens": 656}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport shutil\nimport tempfile\nimport unittest\n\nimport numpy as np\nfrom PIL import Image\n\nfrom monai.data import write_png\n\n\nclass TestPngWrite(unittest.TestCase):\n def test_write_gray(self):\n out_dir = tempfile.mkdtemp()\n image_name = os.path.join(out_dir, \"test.png\")\n img = np.random.rand(2, 3)\n img_save_val = (255 * img).astype(np.uint8)\n write_png(img, image_name, scale=255)\n out = np.asarray(Image.open(image_name))\n np.testing.assert_allclose(out, img_save_val)\n shutil.rmtree(out_dir)\n\n def test_write_gray_1height(self):\n out_dir = tempfile.mkdtemp()\n image_name = os.path.join(out_dir, \"test.png\")\n img = np.random.rand(1, 3)\n img_save_val = (65535 * img).astype(np.uint16)\n write_png(img, image_name, scale=65535)\n out = np.asarray(Image.open(image_name))\n np.testing.assert_allclose(out, img_save_val)\n shutil.rmtree(out_dir)\n\n def test_write_gray_1channel(self):\n out_dir = tempfile.mkdtemp()\n image_name = os.path.join(out_dir, \"test.png\")\n img = np.random.rand(2, 3, 1)\n img_save_val = (255 * img).astype(np.uint8).squeeze(2)\n write_png(img, image_name, scale=255)\n out = np.asarray(Image.open(image_name))\n np.testing.assert_allclose(out, img_save_val)\n shutil.rmtree(out_dir)\n\n def test_write_rgb(self):\n out_dir = tempfile.mkdtemp()\n image_name = os.path.join(out_dir, \"test.png\")\n img = np.random.rand(2, 3, 3)\n img_save_val = (255 * img).astype(np.uint8)\n write_png(img, image_name, scale=255)\n out = np.asarray(Image.open(image_name))\n np.testing.assert_allclose(out, img_save_val)\n shutil.rmtree(out_dir)\n\n def test_write_2channels(self):\n out_dir = tempfile.mkdtemp()\n image_name = os.path.join(out_dir, \"test.png\")\n img = np.random.rand(2, 3, 2)\n img_save_val = (255 * img).astype(np.uint8)\n write_png(img, image_name, scale=255)\n out = np.asarray(Image.open(image_name))\n np.testing.assert_allclose(out, img_save_val)\n shutil.rmtree(out_dir)\n\n def test_write_output_shape(self):\n out_dir = tempfile.mkdtemp()\n image_name = os.path.join(out_dir, \"test.png\")\n img = np.random.rand(2, 2, 3)\n write_png(img, image_name, (4, 4), scale=255)\n out = np.asarray(Image.open(image_name))\n np.testing.assert_allclose(out.shape, (4, 4, 3))\n shutil.rmtree(out_dir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_png_saver.py_os_TestPNGSaver.test_saved_content.None_2": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_png_saver.py_os_TestPNGSaver.test_saved_content.None_2", "embedding": null, "metadata": {"file_path": "tests/test_png_saver.py", "file_name": "test_png_saver.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 32, "span_ids": ["TestPNGSaver.test_saved_content", "TestPNGSaver", "docstring"], "tokens": 191}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport shutil\nimport unittest\nimport torch\n\nfrom monai.data import PNGSaver\n\n\nclass TestPNGSaver(unittest.TestCase):\n def test_saved_content(self):\n default_dir = os.path.join(\".\", \"tempdir\")\n shutil.rmtree(default_dir, ignore_errors=True)\n\n saver = PNGSaver(output_dir=default_dir, output_postfix=\"seg\", output_ext=\".png\", scale=255)\n\n meta_data = {\"filename_or_obj\": [\"testfile\" + str(i) for i in range(8)]}\n saver.save_batch(torch.randint(1, 200, (8, 1, 2, 2)), meta_data)\n for i in range(8):\n filepath = os.path.join(\"testfile\" + str(i), \"testfile\" + str(i) + \"_seg.png\")\n self.assertTrue(os.path.exists(os.path.join(default_dir, filepath)))\n shutil.rmtree(default_dir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_png_saver.py_TestPNGSaver.test_saved_content_three_channel_TestPNGSaver.test_saved_content_three_channel.None_2": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_png_saver.py_TestPNGSaver.test_saved_content_three_channel_TestPNGSaver.test_saved_content_three_channel.None_2", "embedding": null, "metadata": {"file_path": "tests/test_png_saver.py", "file_name": "test_png_saver.py", "file_type": "text/x-python", "category": "test", "start_line": 34, "end_line": 45, "span_ids": ["TestPNGSaver.test_saved_content_three_channel"], "tokens": 172}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestPNGSaver(unittest.TestCase):\n\n def test_saved_content_three_channel(self):\n default_dir = os.path.join(\".\", \"tempdir\")\n shutil.rmtree(default_dir, ignore_errors=True)\n\n saver = PNGSaver(output_dir=default_dir, output_postfix=\"seg\", output_ext=\".png\", scale=255)\n\n meta_data = {\"filename_or_obj\": [\"testfile\" + str(i) for i in range(8)]}\n saver.save_batch(torch.randint(1, 200, (8, 3, 2, 2)), meta_data)\n for i in range(8):\n filepath = os.path.join(\"testfile\" + str(i), \"testfile\" + str(i) + \"_seg.png\")\n self.assertTrue(os.path.exists(os.path.join(default_dir, filepath)))\n shutil.rmtree(default_dir)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_png_saver.py_TestPNGSaver.test_saved_content_spatial_size_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_png_saver.py_TestPNGSaver.test_saved_content_spatial_size_", "embedding": null, "metadata": {"file_path": "tests/test_png_saver.py", "file_name": "test_png_saver.py", "file_type": "text/x-python", "category": "test", "start_line": 47, "end_line": 68, "span_ids": ["TestPNGSaver.test_saved_content_spatial_size", "impl"], "tokens": 207}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestPNGSaver(unittest.TestCase):\n\n def test_saved_content_spatial_size(self):\n\n default_dir = os.path.join(\".\", \"tempdir\")\n shutil.rmtree(default_dir, ignore_errors=True)\n\n saver = PNGSaver(output_dir=default_dir, output_postfix=\"seg\", output_ext=\".png\", scale=255)\n\n meta_data = {\n \"filename_or_obj\": [\"testfile\" + str(i) for i in range(8)],\n \"spatial_shape\": [(4, 4) for i in range(8)],\n }\n saver.save_batch(torch.randint(1, 200, (8, 1, 2, 2)), meta_data)\n for i in range(8):\n filepath = os.path.join(\"testfile\" + str(i), \"testfile\" + str(i) + \"_seg.png\")\n self.assertTrue(os.path.exists(os.path.join(default_dir, filepath)))\n\n shutil.rmtree(default_dir)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_query_memory.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_query_memory.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_query_memory.py", "file_name": "test_query_memory.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 27, "span_ids": ["impl", "TestQueryMemory", "TestQueryMemory.test_output_str", "docstring"], "tokens": 75}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nfrom tests.utils import query_memory\n\n\nclass TestQueryMemory(unittest.TestCase):\n def test_output_str(self):\n self.assertTrue(isinstance(query_memory(2), str))\n all_device = query_memory(-1)\n self.assertTrue(isinstance(all_device, str))\n self.assertEqual(query_memory(\"test\"), \"\")\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_adjust_contrast.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_adjust_contrast.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rand_adjust_contrast.py", "file_name": "test_rand_adjust_contrast.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 39, "span_ids": ["TestRandAdjustContrast", "TestRandAdjustContrast.test_correct_results", "impl:5", "docstring"], "tokens": 223}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import RandAdjustContrast\nfrom tests.utils import NumpyImageTestCase2D\n\nTEST_CASE_1 = [(0.5, 4.5)]\n\nTEST_CASE_2 = [1.5]\n\n\nclass TestRandAdjustContrast(NumpyImageTestCase2D):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2])\n def test_correct_results(self, gamma):\n adjuster = RandAdjustContrast(prob=1.0, gamma=gamma)\n result = adjuster(self.imt)\n epsilon = 1e-7\n img_min = self.imt.min()\n img_range = self.imt.max() - img_min\n expected = (\n np.power(((self.imt - img_min) / float(img_range + epsilon)), adjuster.gamma_value) * img_range + img_min\n )\n np.testing.assert_allclose(expected, result, rtol=1e-05)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_adjust_contrastd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_adjust_contrastd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rand_adjust_contrastd.py", "file_name": "test_rand_adjust_contrastd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 39, "span_ids": ["impl:5", "TestRandAdjustContrastd.test_correct_results", "TestRandAdjustContrastd", "docstring"], "tokens": 234}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import RandAdjustContrastd\nfrom tests.utils import NumpyImageTestCase2D\n\nTEST_CASE_1 = [(0.5, 4.5)]\n\nTEST_CASE_2 = [1.5]\n\n\nclass TestRandAdjustContrastd(NumpyImageTestCase2D):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2])\n def test_correct_results(self, gamma):\n adjuster = RandAdjustContrastd(\"img\", prob=1.0, gamma=gamma)\n result = adjuster({\"img\": self.imt})\n epsilon = 1e-7\n img_min = self.imt.min()\n img_range = self.imt.max() - img_min\n expected = (\n np.power(((self.imt - img_min) / float(img_range + epsilon)), adjuster.gamma_value) * img_range + img_min\n )\n np.testing.assert_allclose(expected, result[\"img\"], rtol=1e-05)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affine.py_unittest_TEST_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affine.py_unittest_TEST_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_rand_affine.py", "file_name": "test_rand_affine.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 68, "span_ids": ["docstring"], "tokens": 616}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import RandAffine\n\nTEST_CASES = [\n [\n dict(as_tensor_output=False, device=None),\n {\"img\": torch.arange(27).reshape((3, 3, 3))},\n np.arange(27).reshape((3, 3, 3)),\n ],\n [\n dict(as_tensor_output=False, device=None, spatial_size=-1),\n {\"img\": torch.arange(27).reshape((3, 3, 3))},\n np.arange(27).reshape((3, 3, 3)),\n ],\n [\n dict(as_tensor_output=False, device=None),\n {\"img\": torch.arange(27).reshape((3, 3, 3)), \"spatial_size\": (2, 2)},\n np.array([[[2.0, 3.0], [5.0, 6.0]], [[11.0, 12.0], [14.0, 15.0]], [[20.0, 21.0], [23.0, 24.0]]]),\n ],\n [\n dict(as_tensor_output=True, device=None),\n {\"img\": torch.ones((1, 3, 3, 3)), \"spatial_size\": (2, 2, 2)},\n torch.ones((1, 2, 2, 2)),\n ],\n [\n dict(\n prob=0.9,\n rotate_range=(np.pi / 2,),\n shear_range=[1, 2],\n translate_range=[2, 1],\n as_tensor_output=True,\n padding_mode=\"zeros\",\n spatial_size=(2, 2, 2),\n device=None,\n ),\n {\"img\": torch.ones((1, 3, 3, 3)), \"mode\": \"bilinear\"},\n torch.tensor([[[[0.3658, 1.0000], [1.0000, 1.0000]], [[1.0000, 1.0000], [1.0000, 0.9333]]]]),\n ],\n [\n dict(\n prob=0.9,\n rotate_range=(np.pi / 2,),\n shear_range=[1, 2],\n translate_range=[2, 1],\n scale_range=[0.1, 0.2],\n as_tensor_output=True,\n device=None,\n ),\n {\"img\": torch.arange(64).reshape((1, 8, 8)), \"spatial_size\": (3, 3)},\n torch.tensor([[[18.7362, 15.5820, 12.4278], [27.3988, 24.2446, 21.0904], [36.0614, 32.9072, 29.7530]]]),\n ],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affine.py_TestRandAffine_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affine.py_TestRandAffine_", "embedding": null, "metadata": {"file_path": "tests/test_rand_affine.py", "file_name": "test_rand_affine.py", "file_type": "text/x-python", "category": "test", "start_line": 71, "end_line": 86, "span_ids": ["TestRandAffine", "impl:3", "TestRandAffine.test_rand_affine"], "tokens": 154}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRandAffine(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_rand_affine(self, input_param, input_data, expected_val):\n g = RandAffine(**input_param)\n g.set_random_state(123)\n result = g(**input_data)\n self.assertEqual(torch.is_tensor(result), torch.is_tensor(expected_val))\n if torch.is_tensor(result):\n np.testing.assert_allclose(result.cpu().numpy(), expected_val.cpu().numpy(), rtol=1e-4, atol=1e-4)\n else:\n np.testing.assert_allclose(result, expected_val, rtol=1e-4, atol=1e-4)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affine_grid.py_unittest_TEST_CASES": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affine_grid.py_unittest_TEST_CASES", "embedding": null, "metadata": {"file_path": "tests/test_rand_affine_grid.py", "file_name": "test_rand_affine_grid.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 181, "span_ids": ["docstring"], "tokens": 36}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import RandAffineGrid\n\nTEST_CASES =\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affine_grid.py_TestRandAffineGrid_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affine_grid.py_TestRandAffineGrid_", "embedding": null, "metadata": {"file_path": "tests/test_rand_affine_grid.py", "file_name": "test_rand_affine_grid.py", "file_type": "text/x-python", "category": "test", "start_line": 184, "end_line": 199, "span_ids": ["TestRandAffineGrid.test_rand_affine_grid", "impl:3", "TestRandAffineGrid"], "tokens": 157}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRandAffineGrid(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_rand_affine_grid(self, input_param, input_data, expected_val):\n g = RandAffineGrid(**input_param)\n g.set_random_state(123)\n result = g(**input_data)\n self.assertEqual(torch.is_tensor(result), torch.is_tensor(expected_val))\n if torch.is_tensor(result):\n np.testing.assert_allclose(result.cpu().numpy(), expected_val.cpu().numpy(), rtol=1e-4, atol=1e-4)\n else:\n np.testing.assert_allclose(result, expected_val, rtol=1e-4, atol=1e-4)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affined.py_unittest_TEST_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affined.py_unittest_TEST_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_rand_affined.py", "file_name": "test_rand_affined.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 138, "span_ids": ["docstring"], "tokens": 1358}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import RandAffined\nfrom monai.utils import GridSampleMode\n\nTEST_CASES = [\n [\n dict(as_tensor_output=False, device=None, spatial_size=None, keys=(\"img\", \"seg\")),\n {\"img\": torch.arange(27).reshape((3, 3, 3)), \"seg\": torch.arange(27).reshape((3, 3, 3))},\n np.arange(27).reshape((3, 3, 3)),\n ],\n [\n dict(as_tensor_output=False, device=None, spatial_size=(2, 2), keys=(\"img\", \"seg\")),\n {\"img\": torch.ones((3, 3, 3)), \"seg\": torch.ones((3, 3, 3))},\n np.ones((3, 2, 2)),\n ],\n [\n dict(as_tensor_output=True, device=None, spatial_size=(2, 2, 2), keys=(\"img\", \"seg\")),\n {\"img\": torch.ones((1, 3, 3, 3)), \"seg\": torch.ones((1, 3, 3, 3))},\n torch.ones((1, 2, 2, 2)),\n ],\n [\n dict(\n prob=0.9,\n rotate_range=(np.pi / 2,),\n shear_range=[1, 2],\n translate_range=[2, 1],\n as_tensor_output=True,\n spatial_size=(2, 2, 2),\n padding_mode=\"zeros\",\n device=None,\n keys=(\"img\", \"seg\"),\n mode=\"bilinear\",\n ),\n {\"img\": torch.ones((1, 3, 3, 3)), \"seg\": torch.ones((1, 3, 3, 3))},\n torch.tensor([[[[0.3658, 1.0000], [1.0000, 1.0000]], [[1.0000, 1.0000], [1.0000, 0.9333]]]]),\n ],\n [\n dict(\n prob=0.9,\n rotate_range=(np.pi / 2,),\n shear_range=[1, 2],\n translate_range=[2, 1],\n scale_range=[0.1, 0.2],\n as_tensor_output=True,\n spatial_size=(3, 3),\n keys=(\"img\", \"seg\"),\n device=None,\n ),\n {\"img\": torch.arange(64).reshape((1, 8, 8)), \"seg\": torch.arange(64).reshape((1, 8, 8))},\n torch.tensor([[[18.7362, 15.5820, 12.4278], [27.3988, 24.2446, 21.0904], [36.0614, 32.9072, 29.7530]]]),\n ],\n [\n dict(\n prob=0.9,\n mode=(\"bilinear\", \"nearest\"),\n rotate_range=(np.pi / 2,),\n shear_range=[1, 2],\n translate_range=[2, 1],\n scale_range=[0.1, 0.2],\n as_tensor_output=False,\n spatial_size=(3, 3),\n keys=(\"img\", \"seg\"),\n device=torch.device(\"cpu:0\"),\n ),\n {\"img\": torch.arange(64).reshape((1, 8, 8)), \"seg\": torch.arange(64).reshape((1, 8, 8))},\n {\n \"img\": np.array(\n [\n [\n [18.736153, 15.581954, 12.4277525],\n [27.398798, 24.244598, 21.090399],\n [36.061443, 32.90724, 29.753046],\n ]\n ]\n ),\n \"seg\": np.array([[[19.0, 20.0, 12.0], [27.0, 28.0, 20.0], [35.0, 36.0, 29.0]]]),\n },\n ],\n [\n dict(\n prob=0.9,\n rotate_range=(np.pi / 2,),\n shear_range=[1, 2],\n translate_range=[2, 1],\n as_tensor_output=True,\n spatial_size=(2, 2, 2),\n padding_mode=\"zeros\",\n device=None,\n keys=(\"img\", \"seg\"),\n mode=GridSampleMode.BILINEAR,\n ),\n {\"img\": torch.ones((1, 3, 3, 3)), \"seg\": torch.ones((1, 3, 3, 3))},\n torch.tensor([[[[0.3658, 1.0000], [1.0000, 1.0000]], [[1.0000, 1.0000], [1.0000, 0.9333]]]]),\n ],\n [\n dict(\n prob=0.9,\n mode=(GridSampleMode.BILINEAR, GridSampleMode.NEAREST),\n rotate_range=(np.pi / 2,),\n shear_range=[1, 2],\n translate_range=[2, 1],\n scale_range=[0.1, 0.2],\n as_tensor_output=False,\n spatial_size=(3, 3),\n keys=(\"img\", \"seg\"),\n device=torch.device(\"cpu:0\"),\n ),\n {\"img\": torch.arange(64).reshape((1, 8, 8)), \"seg\": torch.arange(64).reshape((1, 8, 8))},\n {\n \"img\": np.array(\n [\n [\n [18.736153, 15.581954, 12.4277525],\n [27.398798, 24.244598, 21.090399],\n [36.061443, 32.90724, 29.753046],\n ]\n ]\n ),\n \"seg\": np.array([[[19.0, 20.0, 12.0], [27.0, 28.0, 20.0], [35.0, 36.0, 29.0]]]),\n },\n ],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affined.py_TestRandAffined_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_affined.py_TestRandAffined_", "embedding": null, "metadata": {"file_path": "tests/test_rand_affined.py", "file_name": "test_rand_affined.py", "file_type": "text/x-python", "category": "test", "start_line": 141, "end_line": 158, "span_ids": ["TestRandAffined", "TestRandAffined.test_rand_affined", "impl:3"], "tokens": 178}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRandAffined(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_rand_affined(self, input_param, input_data, expected_val):\n g = RandAffined(**input_param).set_random_state(123)\n res = g(input_data)\n for key in res:\n result = res[key]\n expected = expected_val[key] if isinstance(expected_val, dict) else expected_val\n self.assertEqual(torch.is_tensor(result), torch.is_tensor(expected))\n if torch.is_tensor(result):\n np.testing.assert_allclose(result.cpu().numpy(), expected.cpu().numpy(), rtol=1e-4, atol=1e-4)\n else:\n np.testing.assert_allclose(result, expected, rtol=1e-4, atol=1e-4)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_crop_by_pos_neg_label.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_crop_by_pos_neg_label.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rand_crop_by_pos_neg_label.py", "file_name": "test_rand_crop_by_pos_neg_label.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 77, "span_ids": ["TestRandCropByPosNegLabel", "TestRandCropByPosNegLabel.test_type_shape", "impl:7", "docstring"], "tokens": 617}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import RandCropByPosNegLabel\n\nTEST_CASE_0 = [\n {\n \"label\": np.random.randint(0, 2, size=[3, 3, 3, 3]),\n \"spatial_size\": [2, 2, -1],\n \"pos\": 1,\n \"neg\": 1,\n \"num_samples\": 2,\n \"image\": np.random.randint(0, 2, size=[3, 3, 3, 3]),\n \"image_threshold\": 0,\n },\n {\"img\": np.random.randint(0, 2, size=[3, 3, 3, 3])},\n list,\n (3, 2, 2, 3),\n]\n\nTEST_CASE_1 = [\n {\n \"label\": np.random.randint(0, 2, size=[3, 3, 3, 3]),\n \"spatial_size\": [2, 2, 2],\n \"pos\": 1,\n \"neg\": 1,\n \"num_samples\": 2,\n \"image\": np.random.randint(0, 2, size=[3, 3, 3, 3]),\n \"image_threshold\": 0,\n },\n {\"img\": np.random.randint(0, 2, size=[3, 3, 3, 3])},\n list,\n (3, 2, 2, 2),\n]\n\nTEST_CASE_2 = [\n {\n \"label\": None,\n \"spatial_size\": [2, 2, 2],\n \"pos\": 1,\n \"neg\": 1,\n \"num_samples\": 2,\n \"image\": np.random.randint(0, 2, size=[3, 3, 3, 3]),\n \"image_threshold\": 0,\n },\n {\n \"img\": np.random.randint(0, 2, size=[3, 3, 3, 3]),\n \"label\": np.random.randint(0, 2, size=[3, 3, 3, 3]),\n \"image\": np.random.randint(0, 2, size=[3, 3, 3, 3]),\n },\n list,\n (3, 2, 2, 2),\n]\n\n\nclass TestRandCropByPosNegLabel(unittest.TestCase):\n @parameterized.expand([TEST_CASE_0, TEST_CASE_1, TEST_CASE_2])\n def test_type_shape(self, input_param, input_data, expected_type, expected_shape):\n result = RandCropByPosNegLabel(**input_param)(**input_data)\n self.assertIsInstance(result, expected_type)\n self.assertTupleEqual(result[0].shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_crop_by_pos_neg_labeld.py_unittest_TEST_CASE_2._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_crop_by_pos_neg_labeld.py_unittest_TEST_CASE_2._", "embedding": null, "metadata": {"file_path": "tests/test_rand_crop_by_pos_neg_labeld.py", "file_name": "test_rand_crop_by_pos_neg_labeld.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 81, "span_ids": ["impl:5", "docstring"], "tokens": 614}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import RandCropByPosNegLabeld\n\nTEST_CASE_0 = [\n {\n \"keys\": [\"image\", \"extral\", \"label\"],\n \"label_key\": \"label\",\n \"spatial_size\": [-1, 2, 2],\n \"pos\": 1,\n \"neg\": 1,\n \"num_samples\": 2,\n \"image_key\": None,\n \"image_threshold\": 0,\n },\n {\n \"image\": np.random.randint(0, 2, size=[3, 3, 3, 3]),\n \"extral\": np.random.randint(0, 2, size=[3, 3, 3, 3]),\n \"label\": np.random.randint(0, 2, size=[3, 3, 3, 3]),\n \"affine\": np.eye(3),\n \"shape\": \"CHWD\",\n },\n list,\n (3, 3, 2, 2),\n]\n\nTEST_CASE_1 = [\n {\n \"keys\": [\"image\", \"extral\", \"label\"],\n \"label_key\": \"label\",\n \"spatial_size\": [2, 2, 2],\n \"pos\": 1,\n \"neg\": 1,\n \"num_samples\": 2,\n \"image_key\": None,\n \"image_threshold\": 0,\n },\n {\n \"image\": np.random.randint(0, 2, size=[3, 3, 3, 3]),\n \"extral\": np.random.randint(0, 2, size=[3, 3, 3, 3]),\n \"label\": np.random.randint(0, 2, size=[3, 3, 3, 3]),\n \"affine\": np.eye(3),\n \"shape\": \"CHWD\",\n },\n list,\n (3, 2, 2, 2),\n]\n\nTEST_CASE_2 = [\n {\n \"keys\": [\"image\", \"extral\", \"label\"],\n \"label_key\": \"label\",\n \"spatial_size\": [2, 2, 2],\n \"pos\": 1,\n \"neg\": 1,\n \"num_samples\": 2,\n \"image_key\": None,\n \"image_threshold\": 0,\n },\n {\n \"image\": np.zeros([3, 3, 3, 3]) - 1,\n \"extral\": np.zeros([3, 3, 3, 3]),\n \"label\": np.ones([3, 3, 3, 3]),\n \"affine\": np.eye(3),\n \"shape\": \"CHWD\",\n },\n list,\n (3, 2, 2, 2),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_crop_by_pos_neg_labeld.py_TestRandCropByPosNegLabeld_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_crop_by_pos_neg_labeld.py_TestRandCropByPosNegLabeld_", "embedding": null, "metadata": {"file_path": "tests/test_rand_crop_by_pos_neg_labeld.py", "file_name": "test_rand_crop_by_pos_neg_labeld.py", "file_type": "text/x-python", "category": "test", "start_line": 84, "end_line": 96, "span_ids": ["TestRandCropByPosNegLabeld", "TestRandCropByPosNegLabeld.test_type_shape", "impl:7"], "tokens": 138}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRandCropByPosNegLabeld(unittest.TestCase):\n @parameterized.expand([TEST_CASE_0, TEST_CASE_1, TEST_CASE_2])\n def test_type_shape(self, input_param, input_data, expected_type, expected_shape):\n result = RandCropByPosNegLabeld(**input_param)(input_data)\n self.assertIsInstance(result, expected_type)\n self.assertTupleEqual(result[0][\"image\"].shape, expected_shape)\n self.assertTupleEqual(result[0][\"extral\"].shape, expected_shape)\n self.assertTupleEqual(result[0][\"label\"].shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_deform_grid.py_unittest_TEST_CASES": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_deform_grid.py_unittest_TEST_CASES", "embedding": null, "metadata": {"file_path": "tests/test_rand_deform_grid.py", "file_name": "test_rand_deform_grid.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 123, "span_ids": ["docstring"], "tokens": 36}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import RandDeformGrid\n\nTEST_CASES =\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_deform_grid.py_TestRandDeformGrid_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_deform_grid.py_TestRandDeformGrid_", "embedding": null, "metadata": {"file_path": "tests/test_rand_deform_grid.py", "file_name": "test_rand_deform_grid.py", "file_type": "text/x-python", "category": "test", "start_line": 126, "end_line": 141, "span_ids": ["TestRandDeformGrid.test_rand_deform_grid", "impl:3", "TestRandDeformGrid"], "tokens": 157}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRandDeformGrid(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_rand_deform_grid(self, input_param, input_data, expected_val):\n g = RandDeformGrid(**input_param)\n g.set_random_state(123)\n result = g(**input_data)\n self.assertEqual(torch.is_tensor(result), torch.is_tensor(expected_val))\n if torch.is_tensor(result):\n np.testing.assert_allclose(result.cpu().numpy(), expected_val.cpu().numpy(), rtol=1e-4, atol=1e-4)\n else:\n np.testing.assert_allclose(result, expected_val, rtol=1e-4, atol=1e-4)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elastic_2d.py_unittest_TEST_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elastic_2d.py_unittest_TEST_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_rand_elastic_2d.py", "file_name": "test_rand_elastic_2d.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 89, "span_ids": ["docstring"], "tokens": 807}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import Rand2DElastic\n\nTEST_CASES = [\n [\n {\"spacing\": (0.3, 0.3), \"magnitude_range\": (1.0, 2.0), \"prob\": 0.0, \"as_tensor_output\": False, \"device\": None},\n {\"img\": torch.ones((3, 3, 3)), \"spatial_size\": (2, 2)},\n np.ones((3, 2, 2)),\n ],\n [\n {\"spacing\": (0.3, 0.3), \"magnitude_range\": (1.0, 2.0), \"prob\": 0.0, \"as_tensor_output\": False, \"device\": None},\n {\"img\": torch.arange(27).reshape((3, 3, 3))},\n np.arange(27).reshape((3, 3, 3)),\n ],\n [\n {\n \"spacing\": (0.3, 0.3),\n \"magnitude_range\": (1.0, 2.0),\n \"prob\": 0.9,\n \"as_tensor_output\": False,\n \"device\": None,\n \"padding_mode\": \"zeros\",\n },\n {\"img\": torch.ones((3, 3, 3)), \"spatial_size\": (2, 2), \"mode\": \"bilinear\"},\n np.array(\n [\n [[0.45531988, 0.0], [0.0, 0.71558857]],\n [[0.45531988, 0.0], [0.0, 0.71558857]],\n [[0.45531988, 0.0], [0.0, 0.71558857]],\n ]\n ),\n ],\n [\n {\n \"spacing\": (1.0, 1.0),\n \"magnitude_range\": (1.0, 1.0),\n \"scale_range\": [1.2, 2.2],\n \"prob\": 0.9,\n \"padding_mode\": \"border\",\n \"as_tensor_output\": True,\n \"device\": None,\n \"spatial_size\": (2, 2),\n },\n {\"img\": torch.arange(27).reshape((3, 3, 3))},\n torch.tensor(\n [\n [[3.0793, 2.6141], [4.0568, 5.9978]],\n [[12.0793, 11.6141], [13.0568, 14.9978]],\n [[21.0793, 20.6141], [22.0568, 23.9978]],\n ]\n ),\n ],\n [\n {\n \"spacing\": (0.3, 0.3),\n \"magnitude_range\": (0.1, 0.2),\n \"translate_range\": [-0.01, 0.01],\n \"scale_range\": [0.01, 0.02],\n \"prob\": 0.9,\n \"as_tensor_output\": False,\n \"device\": None,\n \"spatial_size\": (2, 2),\n },\n {\"img\": torch.arange(27).reshape((3, 3, 3))},\n np.array(\n [\n [[1.3584113, 1.9251312], [5.626623, 6.642721]],\n [[10.358411, 10.925131], [14.626623, 15.642721]],\n [[19.358412, 19.92513], [23.626623, 24.642721]],\n ]\n ),\n ],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elastic_2d.py_TestRand2DElastic_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elastic_2d.py_TestRand2DElastic_", "embedding": null, "metadata": {"file_path": "tests/test_rand_elastic_2d.py", "file_name": "test_rand_elastic_2d.py", "file_type": "text/x-python", "category": "test", "start_line": 92, "end_line": 107, "span_ids": ["impl:3", "TestRand2DElastic.test_rand_2d_elastic", "TestRand2DElastic"], "tokens": 159}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRand2DElastic(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_rand_2d_elastic(self, input_param, input_data, expected_val):\n g = Rand2DElastic(**input_param)\n g.set_random_state(123)\n result = g(**input_data)\n self.assertEqual(torch.is_tensor(result), torch.is_tensor(expected_val))\n if torch.is_tensor(result):\n np.testing.assert_allclose(result.cpu().numpy(), expected_val.cpu().numpy(), rtol=1e-4, atol=1e-4)\n else:\n np.testing.assert_allclose(result, expected_val, rtol=1e-4, atol=1e-4)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elastic_3d.py_unittest_TEST_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elastic_3d.py_unittest_TEST_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_rand_elastic_3d.py", "file_name": "test_rand_elastic_3d.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 68, "span_ids": ["docstring"], "tokens": 581}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import Rand3DElastic\n\nTEST_CASES = [\n [\n {\n \"magnitude_range\": (0.3, 2.3),\n \"sigma_range\": (1.0, 20.0),\n \"prob\": 0.0,\n \"as_tensor_output\": False,\n \"device\": None,\n \"spatial_size\": -1,\n },\n {\"img\": torch.arange(72).reshape((2, 3, 3, 4))},\n np.arange(72).reshape((2, 3, 3, 4)),\n ],\n [\n {\n \"magnitude_range\": (0.3, 2.3),\n \"sigma_range\": (1.0, 20.0),\n \"prob\": 0.0,\n \"as_tensor_output\": False,\n \"device\": None,\n },\n {\"img\": torch.ones((2, 3, 3, 3)), \"spatial_size\": (2, 2, 2)},\n np.ones((2, 2, 2, 2)),\n ],\n [\n {\n \"magnitude_range\": (0.3, 0.3),\n \"sigma_range\": (1.0, 2.0),\n \"prob\": 0.9,\n \"as_tensor_output\": False,\n \"device\": None,\n },\n {\"img\": torch.arange(27).reshape((1, 3, 3, 3)), \"spatial_size\": (2, 2, 2)},\n np.array([[[[6.492354, 7.5022864], [9.519528, 10.524366]], [[15.51277, 16.525297], [18.533852, 19.539217]]]]),\n ],\n [\n {\n \"magnitude_range\": (0.3, 0.3),\n \"sigma_range\": (1.0, 2.0),\n \"prob\": 0.9,\n \"rotate_range\": [1, 1, 1],\n \"as_tensor_output\": False,\n \"device\": None,\n \"spatial_size\": (2, 2, 2),\n },\n {\"img\": torch.arange(27).reshape((1, 3, 3, 3)), \"mode\": \"bilinear\"},\n np.array([[[[5.005563, 9.463698], [9.289501, 13.741863]], [[12.320587, 16.779654], [16.597677, 21.049414]]]]),\n ],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elastic_3d.py_TestRand3DElastic_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elastic_3d.py_TestRand3DElastic_", "embedding": null, "metadata": {"file_path": "tests/test_rand_elastic_3d.py", "file_name": "test_rand_elastic_3d.py", "file_type": "text/x-python", "category": "test", "start_line": 71, "end_line": 86, "span_ids": ["impl:3", "TestRand3DElastic.test_rand_3d_elastic", "TestRand3DElastic"], "tokens": 159}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRand3DElastic(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_rand_3d_elastic(self, input_param, input_data, expected_val):\n g = Rand3DElastic(**input_param)\n g.set_random_state(123)\n result = g(**input_data)\n self.assertEqual(torch.is_tensor(result), torch.is_tensor(expected_val))\n if torch.is_tensor(result):\n np.testing.assert_allclose(result.cpu().numpy(), expected_val.cpu().numpy(), rtol=1e-4, atol=1e-4)\n else:\n np.testing.assert_allclose(result, expected_val, rtol=1e-4, atol=1e-4)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elasticd_2d.py_unittest_TEST_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elasticd_2d.py_unittest_TEST_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_rand_elasticd_2d.py", "file_name": "test_rand_elasticd_2d.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 135, "span_ids": ["docstring"], "tokens": 1291}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import Rand2DElasticd\n\nTEST_CASES = [\n [\n {\n \"keys\": (\"img\", \"seg\"),\n \"spacing\": (0.3, 0.3),\n \"magnitude_range\": (1.0, 2.0),\n \"prob\": 0.0,\n \"as_tensor_output\": False,\n \"device\": None,\n \"spatial_size\": (2, 2),\n },\n {\"img\": torch.ones((3, 3, 3)), \"seg\": torch.ones((3, 3, 3))},\n np.ones((3, 2, 2)),\n ],\n [\n {\n \"keys\": (\"img\", \"seg\"),\n \"spacing\": (0.3, 0.3),\n \"magnitude_range\": (0.3, 0.3),\n \"prob\": 0.0,\n \"as_tensor_output\": False,\n \"device\": None,\n \"spatial_size\": -1,\n },\n {\"img\": torch.arange(4).reshape((1, 2, 2)), \"seg\": torch.arange(4).reshape((1, 2, 2))},\n np.arange(4).reshape((1, 2, 2)),\n ],\n [\n {\n \"keys\": (\"img\", \"seg\"),\n \"spacing\": (0.3, 0.3),\n \"magnitude_range\": (1.0, 2.0),\n \"prob\": 0.9,\n \"as_tensor_output\": False,\n \"padding_mode\": \"zeros\",\n \"device\": None,\n \"spatial_size\": (2, 2),\n \"mode\": \"bilinear\",\n },\n {\"img\": torch.ones((3, 3, 3)), \"seg\": torch.ones((3, 3, 3))},\n np.array(\n [\n [[0.45531988, 0.0], [0.0, 0.71558857]],\n [[0.45531988, 0.0], [0.0, 0.71558857]],\n [[0.45531988, 0.0], [0.0, 0.71558857]],\n ]\n ),\n ],\n [\n {\n \"keys\": (\"img\", \"seg\"),\n \"spacing\": (1.0, 1.0),\n \"magnitude_range\": (1.0, 1.0),\n \"scale_range\": [1.2, 2.2],\n \"prob\": 0.9,\n \"padding_mode\": \"border\",\n \"as_tensor_output\": True,\n \"device\": None,\n \"spatial_size\": (2, 2),\n },\n {\"img\": torch.arange(27).reshape((3, 3, 3)), \"seg\": torch.arange(27).reshape((3, 3, 3))},\n torch.tensor(\n [\n [[3.0793, 2.6141], [4.0568, 5.9978]],\n [[12.0793, 11.6141], [13.0568, 14.9978]],\n [[21.0793, 20.6141], [22.0568, 23.9978]],\n ]\n ),\n ],\n [\n {\n \"keys\": (\"img\", \"seg\"),\n \"spacing\": (0.3, 0.3),\n \"magnitude_range\": (0.1, 0.2),\n \"translate_range\": [-0.01, 0.01],\n \"scale_range\": [0.01, 0.02],\n \"prob\": 0.9,\n \"as_tensor_output\": False,\n \"device\": None,\n \"spatial_size\": (2, 2),\n },\n {\"img\": torch.arange(27).reshape((3, 3, 3)), \"seg\": torch.arange(27).reshape((3, 3, 3))},\n np.array(\n [\n [[1.3584113, 1.9251312], [5.626623, 6.642721]],\n [[10.358411, 10.925131], [14.626623, 15.642721]],\n [[19.358412, 19.92513], [23.626623, 24.642721]],\n ]\n ),\n ],\n [\n {\n \"keys\": (\"img\", \"seg\"),\n \"mode\": (\"bilinear\", \"nearest\"),\n \"spacing\": (0.3, 0.3),\n \"magnitude_range\": (0.1, 0.2),\n \"translate_range\": [-0.01, 0.01],\n \"scale_range\": [0.01, 0.02],\n \"prob\": 0.9,\n \"as_tensor_output\": True,\n \"device\": None,\n \"spatial_size\": (2, 2),\n },\n {\"img\": torch.arange(27).reshape((3, 3, 3)), \"seg\": torch.arange(27).reshape((3, 3, 3))},\n {\n \"img\": torch.tensor(\n [\n [[1.3584, 1.9251], [5.6266, 6.6427]],\n [[10.3584, 10.9251], [14.6266, 15.6427]],\n [[19.3584, 19.9251], [23.6266, 24.6427]],\n ]\n ),\n \"seg\": torch.tensor([[[0.0, 2.0], [6.0, 8.0]], [[9.0, 11.0], [15.0, 17.0]], [[18.0, 20.0], [24.0, 26.0]]]),\n },\n ],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elasticd_2d.py_TestRand2DElasticd_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elasticd_2d.py_TestRand2DElasticd_", "embedding": null, "metadata": {"file_path": "tests/test_rand_elasticd_2d.py", "file_name": "test_rand_elasticd_2d.py", "file_type": "text/x-python", "category": "test", "start_line": 138, "end_line": 156, "span_ids": ["TestRand2DElasticd.test_rand_2d_elasticd", "impl:3", "TestRand2DElasticd"], "tokens": 188}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRand2DElasticd(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_rand_2d_elasticd(self, input_param, input_data, expected_val):\n g = Rand2DElasticd(**input_param)\n g.set_random_state(123)\n res = g(input_data)\n for key in res:\n result = res[key]\n expected = expected_val[key] if isinstance(expected_val, dict) else expected_val\n self.assertEqual(torch.is_tensor(result), torch.is_tensor(expected))\n if torch.is_tensor(result):\n np.testing.assert_allclose(result.cpu().numpy(), expected.cpu().numpy(), rtol=1e-4, atol=1e-4)\n else:\n np.testing.assert_allclose(result, expected, rtol=1e-4, atol=1e-4)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elasticd_3d.py_unittest_TEST_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elasticd_3d.py_unittest_TEST_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_rand_elasticd_3d.py", "file_name": "test_rand_elasticd_3d.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 106, "span_ids": ["docstring"], "tokens": 1117}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import Rand3DElasticd\n\nTEST_CASES = [\n [\n {\n \"keys\": (\"img\", \"seg\"),\n \"magnitude_range\": (0.3, 2.3),\n \"sigma_range\": (1.0, 20.0),\n \"prob\": 0.0,\n \"as_tensor_output\": False,\n \"device\": None,\n \"spatial_size\": (2, 2, 2),\n },\n {\"img\": torch.ones((2, 3, 3, 3)), \"seg\": torch.ones((2, 3, 3, 3))},\n np.ones((2, 2, 2, 2)),\n ],\n [\n {\n \"keys\": (\"img\", \"seg\"),\n \"magnitude_range\": (0.3, 2.3),\n \"sigma_range\": (1.0, 20.0),\n \"prob\": 0.0,\n \"as_tensor_output\": False,\n \"device\": None,\n \"spatial_size\": (2, -1, -1),\n },\n {\"img\": torch.ones((2, 3, 3, 3)), \"seg\": torch.ones((2, 3, 3, 3))},\n np.ones((2, 2, 3, 3)),\n ],\n [\n {\n \"keys\": (\"img\", \"seg\"),\n \"magnitude_range\": (0.3, 2.3),\n \"sigma_range\": (1.0, 20.0),\n \"prob\": 0.0,\n \"as_tensor_output\": False,\n \"device\": None,\n \"spatial_size\": -1,\n },\n {\"img\": torch.arange(8).reshape((1, 2, 2, 2)), \"seg\": torch.arange(8).reshape((1, 2, 2, 2))},\n np.arange(8).reshape((1, 2, 2, 2)),\n ],\n [\n {\n \"keys\": (\"img\", \"seg\"),\n \"magnitude_range\": (0.3, 0.3),\n \"sigma_range\": (1.0, 2.0),\n \"prob\": 0.9,\n \"as_tensor_output\": False,\n \"device\": None,\n \"spatial_size\": (2, 2, 2),\n },\n {\"img\": torch.arange(27).reshape((1, 3, 3, 3)), \"seg\": torch.arange(27).reshape((1, 3, 3, 3))},\n np.array([[[[6.492354, 7.5022864], [9.519528, 10.524366]], [[15.51277, 16.525297], [18.533852, 19.539217]]]]),\n ],\n [\n {\n \"keys\": (\"img\", \"seg\"),\n \"magnitude_range\": (0.3, 0.3),\n \"sigma_range\": (1.0, 2.0),\n \"prob\": 0.9,\n \"rotate_range\": [1, 1, 1],\n \"as_tensor_output\": False,\n \"device\": None,\n \"spatial_size\": (2, 2, 2),\n \"mode\": \"bilinear\",\n },\n {\"img\": torch.arange(27).reshape((1, 3, 3, 3)), \"seg\": torch.arange(27).reshape((1, 3, 3, 3))},\n np.array([[[[5.005563, 9.463698], [9.289501, 13.741863]], [[12.320587, 16.779654], [16.597677, 21.049414]]]]),\n ],\n [\n {\n \"keys\": (\"img\", \"seg\"),\n \"mode\": (\"bilinear\", \"nearest\"),\n \"magnitude_range\": (0.3, 0.3),\n \"sigma_range\": (1.0, 2.0),\n \"prob\": 0.9,\n \"rotate_range\": [1, 1, 1],\n \"as_tensor_output\": True,\n \"device\": torch.device(\"cpu:0\"),\n \"spatial_size\": (2, 2, 2),\n },\n {\"img\": torch.arange(27).reshape((1, 3, 3, 3)), \"seg\": torch.arange(27).reshape((1, 3, 3, 3))},\n {\n \"img\": torch.tensor([[[[5.0056, 9.4637], [9.2895, 13.7419]], [[12.3206, 16.7797], [16.5977, 21.0494]]]]),\n \"seg\": torch.tensor([[[[4.0, 14.0], [7.0, 14.0]], [[9.0, 19.0], [12.0, 22.0]]]]),\n },\n ],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elasticd_3d.py_TestRand3DElasticd_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_elasticd_3d.py_TestRand3DElasticd_", "embedding": null, "metadata": {"file_path": "tests/test_rand_elasticd_3d.py", "file_name": "test_rand_elasticd_3d.py", "file_type": "text/x-python", "category": "test", "start_line": 109, "end_line": 127, "span_ids": ["impl:3", "TestRand3DElasticd.test_rand_3d_elasticd", "TestRand3DElasticd"], "tokens": 188}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRand3DElasticd(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_rand_3d_elasticd(self, input_param, input_data, expected_val):\n g = Rand3DElasticd(**input_param)\n g.set_random_state(123)\n res = g(input_data)\n for key in res:\n result = res[key]\n expected = expected_val[key] if isinstance(expected_val, dict) else expected_val\n self.assertEqual(torch.is_tensor(result), torch.is_tensor(expected))\n if torch.is_tensor(result):\n np.testing.assert_allclose(result.cpu().numpy(), expected.cpu().numpy(), rtol=1e-4, atol=1e-4)\n else:\n np.testing.assert_allclose(result, expected, rtol=1e-4, atol=1e-4)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_flip.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_flip.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rand_flip.py", "file_name": "test_rand_flip.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 44, "span_ids": ["TestRandFlip.test_correct_results", "TestRandFlip", "TestRandFlip.test_invalid_inputs", "impl:5", "docstring"], "tokens": 253}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.transforms import RandFlip\nfrom tests.utils import NumpyImageTestCase2D\n\nINVALID_CASES = [(\"wrong_axis\", [\"s\", 1], TypeError), (\"not_numbers\", \"s\", TypeError)]\n\nVALID_CASES = [(\"no_axis\", None), (\"one_axis\", 1), (\"many_axis\", [0, 1])]\n\n\nclass TestRandFlip(NumpyImageTestCase2D):\n @parameterized.expand(INVALID_CASES)\n def test_invalid_inputs(self, _, spatial_axis, raises):\n with self.assertRaises(raises):\n flip = RandFlip(prob=1.0, spatial_axis=spatial_axis)\n flip(self.imt[0])\n\n @parameterized.expand(VALID_CASES)\n def test_correct_results(self, _, spatial_axis):\n flip = RandFlip(prob=1.0, spatial_axis=spatial_axis)\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.flip(channel, spatial_axis))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(expected, flip(self.imt[0])))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_flipd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_flipd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rand_flipd.py", "file_name": "test_rand_flipd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 37, "span_ids": ["TestRandFlipd.test_correct_results", "impl:3", "TestRandFlipd", "docstring"], "tokens": 189}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.transforms import RandFlipd\nfrom tests.utils import NumpyImageTestCase2D\n\nVALID_CASES = [(\"no_axis\", None), (\"one_axis\", 1), (\"many_axis\", [0, 1])]\n\n\nclass TestRandFlipd(NumpyImageTestCase2D):\n @parameterized.expand(VALID_CASES)\n def test_correct_results(self, _, spatial_axis):\n flip = RandFlipd(keys=\"img\", prob=1.0, spatial_axis=spatial_axis)\n res = flip({\"img\": self.imt[0]})\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.flip(channel, spatial_axis))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(expected, res[\"img\"]))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_gaussian_noise.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_gaussian_noise.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rand_gaussian_noise.py", "file_name": "test_rand_gaussian_noise.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 35, "span_ids": ["impl", "TestRandGaussianNoise.test_correct_results", "TestRandGaussianNoise", "docstring"], "tokens": 207}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom monai.transforms import RandGaussianNoise\nfrom parameterized import parameterized\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestRandGaussianNoise(NumpyImageTestCase2D):\n @parameterized.expand([(\"test_zero_mean\", 0, 0.1), (\"test_non_zero_mean\", 1, 0.5)])\n def test_correct_results(self, _, mean, std):\n seed = 0\n gaussian_fn = RandGaussianNoise(prob=1.0, mean=mean, std=std)\n gaussian_fn.set_random_state(seed)\n noised = gaussian_fn(self.imt)\n np.random.seed(seed)\n np.random.random()\n expected = self.imt + np.random.normal(mean, np.random.uniform(0, std), size=self.imt.shape)\n np.testing.assert_allclose(expected, noised, atol=1e-5)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_gaussian_noised.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_gaussian_noised.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rand_gaussian_noised.py", "file_name": "test_rand_gaussian_noised.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 36, "span_ids": ["impl", "TestRandGaussianNoised", "TestRandGaussianNoised.test_correct_results", "docstring"], "tokens": 235}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\n\nfrom parameterized import parameterized\n\nfrom monai.transforms import RandGaussianNoised\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestRandGaussianNoised(NumpyImageTestCase2D):\n @parameterized.expand([(\"test_zero_mean\", [\"img\"], 0, 0.1), (\"test_non_zero_mean\", [\"img\"], 1, 0.5)])\n def test_correct_results(self, _, keys, mean, std):\n seed = 0\n gaussian_fn = RandGaussianNoised(keys=keys, prob=1.0, mean=mean, std=std)\n gaussian_fn.set_random_state(seed)\n noised = gaussian_fn({\"img\": self.imt})\n np.random.seed(seed)\n np.random.random()\n expected = self.imt + np.random.normal(mean, np.random.uniform(0, std), size=self.imt.shape)\n np.testing.assert_allclose(expected, noised[\"img\"], atol=1e-5, rtol=1e-5)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotate.py_unittest_TestRandRotate2D.test_correct_results.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotate.py_unittest_TestRandRotate2D.test_correct_results.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_rand_rotate.py", "file_name": "test_rand_rotate.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 55, "span_ids": ["TestRandRotate2D", "TestRandRotate2D.test_correct_results", "docstring"], "tokens": 350}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport scipy.ndimage\nfrom parameterized import parameterized\nfrom tests.utils import NumpyImageTestCase2D, NumpyImageTestCase3D\n\nfrom monai.transforms import RandRotate\n\n\nclass TestRandRotate2D(NumpyImageTestCase2D):\n @parameterized.expand(\n [\n (90, True, \"bilinear\", \"border\", False),\n (45, True, \"nearest\", \"border\", False),\n (180, False, \"nearest\", \"zeros\", True),\n ((-45, 0), False, \"nearest\", \"zeros\", True),\n ]\n )\n def test_correct_results(self, degrees, keep_size, mode, padding_mode, align_corners):\n rotate_fn = RandRotate(\n range_x=degrees,\n prob=1.0,\n keep_size=keep_size,\n mode=mode,\n padding_mode=padding_mode,\n align_corners=align_corners,\n )\n rotate_fn.set_random_state(243)\n rotated = rotate_fn(self.imt[0])\n\n _order = 0 if mode == \"nearest\" else 1\n if mode == \"border\":\n _mode = \"nearest\"\n elif mode == \"reflection\":\n _mode = \"reflect\"\n else:\n _mode = \"constant\"\n angle = rotate_fn.x\n expected = scipy.ndimage.rotate(\n self.imt[0, 0], -angle, (0, 1), not keep_size, order=_order, mode=_mode, prefilter=False\n )\n expected = np.stack(expected).astype(np.float32)\n np.testing.assert_allclose(expected, rotated[0])", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotate.py_TestRandRotate3D_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotate.py_TestRandRotate3D_", "embedding": null, "metadata": {"file_path": "tests/test_rand_rotate.py", "file_name": "test_rand_rotate.py", "file_type": "text/x-python", "category": "test", "start_line": 58, "end_line": 85, "span_ids": ["TestRandRotate3D", "TestRandRotate3D.test_correct_results", "impl"], "tokens": 304}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRandRotate3D(NumpyImageTestCase3D):\n @parameterized.expand(\n [\n (90, -30, (0.0, 180), False, \"bilinear\", \"border\", False, (1, 87, 104, 109)),\n (45, (-20, 40), (20, 30), False, \"nearest\", \"border\", True, (1, 89, 105, 104)),\n (0.0, (360, 370), (-1, 1), True, \"nearest\", \"zeros\", True, (1, 48, 64, 80)),\n ((-45, 0), 0, 0, False, \"nearest\", \"zeros\", False, (1, 48, 77, 90)),\n ]\n )\n def test_correct_results(self, x, y, z, keep_size, mode, padding_mode, align_corners, expected):\n rotate_fn = RandRotate(\n range_x=x,\n range_y=y,\n range_z=z,\n prob=1.0,\n keep_size=keep_size,\n mode=mode,\n padding_mode=padding_mode,\n align_corners=align_corners,\n )\n rotate_fn.set_random_state(243)\n rotated = rotate_fn(self.imt[0])\n np.testing.assert_allclose(rotated.shape, expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotate90.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotate90.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rand_rotate90.py", "file_name": "test_rand_rotate90.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 64, "span_ids": ["TestRandRotate90", "impl", "TestRandRotate90.test_spatial_axes", "TestRandRotate90.test_prob_k_spatial_axes", "TestRandRotate90.test_k", "docstring", "TestRandRotate90.test_default"], "tokens": 412}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\n\nfrom monai.transforms import RandRotate90\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestRandRotate90(NumpyImageTestCase2D):\n def test_default(self):\n rotate = RandRotate90()\n rotate.set_random_state(123)\n rotated = rotate(self.imt[0])\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.rot90(channel, 0, (0, 1)))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(rotated, expected))\n\n def test_k(self):\n rotate = RandRotate90(max_k=2)\n rotate.set_random_state(234)\n rotated = rotate(self.imt[0])\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.rot90(channel, 0, (0, 1)))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(rotated, expected))\n\n def test_spatial_axes(self):\n rotate = RandRotate90(spatial_axes=(0, 1))\n rotate.set_random_state(234)\n rotated = rotate(self.imt[0])\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.rot90(channel, 0, (0, 1)))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(rotated, expected))\n\n def test_prob_k_spatial_axes(self):\n rotate = RandRotate90(prob=1.0, max_k=2, spatial_axes=(0, 1))\n rotate.set_random_state(234)\n rotated = rotate(self.imt[0])\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.rot90(channel, 1, (0, 1)))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(rotated, expected))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotate90d.py_unittest_TestRandRotate90d.test_spatial_axes.self_assertTrue_np_allclo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotate90d.py_unittest_TestRandRotate90d.test_spatial_axes.self_assertTrue_np_allclo", "embedding": null, "metadata": {"file_path": "tests/test_rand_rotate90d.py", "file_name": "test_rand_rotate90d.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 52, "span_ids": ["TestRandRotate90d.test_spatial_axes", "TestRandRotate90d", "TestRandRotate90d.test_default", "docstring", "TestRandRotate90d.test_k"], "tokens": 338}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\n\nfrom monai.transforms import RandRotate90d\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestRandRotate90d(NumpyImageTestCase2D):\n def test_default(self):\n key = None\n rotate = RandRotate90d(keys=key)\n rotate.set_random_state(123)\n rotated = rotate({key: self.imt[0]})\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.rot90(channel, 0, (0, 1)))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(rotated[key], expected))\n\n def test_k(self):\n key = \"test\"\n rotate = RandRotate90d(keys=key, max_k=2)\n rotate.set_random_state(234)\n rotated = rotate({key: self.imt[0]})\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.rot90(channel, 0, (0, 1)))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(rotated[key], expected))\n\n def test_spatial_axes(self):\n key = \"test\"\n rotate = RandRotate90d(keys=key, spatial_axes=(0, 1))\n rotate.set_random_state(234)\n rotated = rotate({key: self.imt[0]})\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.rot90(channel, 0, (0, 1)))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(rotated[key], expected))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotate90d.py_TestRandRotate90d.test_prob_k_spatial_axes_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotate90d.py_TestRandRotate90d.test_prob_k_spatial_axes_", "embedding": null, "metadata": {"file_path": "tests/test_rand_rotate90d.py", "file_name": "test_rand_rotate90d.py", "file_type": "text/x-python", "category": "test", "start_line": 54, "end_line": 74, "span_ids": ["TestRandRotate90d.test_prob_k_spatial_axes", "TestRandRotate90d.test_no_key", "impl"], "tokens": 208}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRandRotate90d(NumpyImageTestCase2D):\n\n def test_prob_k_spatial_axes(self):\n key = \"test\"\n rotate = RandRotate90d(keys=key, prob=1.0, max_k=2, spatial_axes=(0, 1))\n rotate.set_random_state(234)\n rotated = rotate({key: self.imt[0]})\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.rot90(channel, 1, (0, 1)))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(rotated[key], expected))\n\n def test_no_key(self):\n key = \"unknown\"\n rotate = RandRotate90d(keys=key, prob=1.0, max_k=2, spatial_axes=(0, 1))\n with self.assertRaisesRegex(KeyError, \"\"):\n rotated = rotate({\"test\": self.imt[0]})\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotated.py_unittest_TestRandRotated2D.test_correct_results.self_assertTrue_np_allclo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotated.py_unittest_TestRandRotated2D.test_correct_results.self_assertTrue_np_allclo", "embedding": null, "metadata": {"file_path": "tests/test_rand_rotated.py", "file_name": "test_rand_rotated.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 57, "span_ids": ["TestRandRotated2D.test_correct_results", "TestRandRotated2D", "docstring"], "tokens": 388}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\n\nimport scipy.ndimage\nfrom parameterized import parameterized\n\nfrom monai.transforms import RandRotated\nfrom tests.utils import NumpyImageTestCase2D, NumpyImageTestCase3D\nfrom monai.utils import GridSampleMode, GridSamplePadMode\n\n\nclass TestRandRotated2D(NumpyImageTestCase2D):\n @parameterized.expand(\n [\n (90, True, \"bilinear\", \"border\", False),\n (45, True, \"nearest\", \"border\", False),\n (180, False, \"nearest\", \"zeros\", True),\n ((-45, 0), False, \"nearest\", \"zeros\", True),\n ]\n )\n def test_correct_results(self, degrees, keep_size, mode, padding_mode, align_corners):\n rotate_fn = RandRotated(\n \"img\",\n range_x=degrees,\n prob=1.0,\n keep_size=keep_size,\n mode=mode,\n padding_mode=padding_mode,\n align_corners=align_corners,\n )\n rotate_fn.set_random_state(243)\n rotated = rotate_fn({\"img\": self.imt[0], \"seg\": self.segn[0]})\n\n _order = 0 if mode == \"nearest\" else 1\n if padding_mode == \"border\":\n _mode = \"nearest\"\n elif padding_mode == \"reflection\":\n _mode = \"reflect\"\n else:\n _mode = \"constant\"\n angle = rotate_fn.x\n expected = scipy.ndimage.rotate(\n self.imt[0, 0], -angle, (0, 1), not keep_size, order=_order, mode=_mode, prefilter=False\n )\n expected = np.stack(expected).astype(np.float32)\n self.assertTrue(np.allclose(expected, rotated[\"img\"][0]))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotated.py_TestRandRotated3D_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_rotated.py_TestRandRotated3D_", "embedding": null, "metadata": {"file_path": "tests/test_rand_rotated.py", "file_name": "test_rand_rotated.py", "file_type": "text/x-python", "category": "test", "start_line": 60, "end_line": 92, "span_ids": ["TestRandRotated3D", "TestRandRotated3D.test_correct_shapes", "impl"], "tokens": 510}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRandRotated3D(NumpyImageTestCase3D):\n @parameterized.expand(\n [\n (90, -30, (0.0, 180), False, \"bilinear\", \"border\", False, (1, 87, 104, 109)),\n (90, -30, (0.0, 180), False, GridSampleMode.NEAREST, GridSamplePadMode.BORDER, False, (1, 87, 104, 109)),\n (45, (-20, 40), (20, 30), False, \"nearest\", \"border\", True, (1, 89, 105, 104)),\n (45, (-20, 40), (20, 30), False, GridSampleMode.NEAREST, GridSamplePadMode.BORDER, True, (1, 89, 105, 104)),\n (0.0, (360, 370), (-1, 1), True, \"nearest\", \"zeros\", True, (1, 48, 64, 80)),\n (0.0, (360, 370), (-1, 1), True, GridSampleMode.NEAREST, GridSamplePadMode.ZEROS, True, (1, 48, 64, 80)),\n ((-45, 0), 0, 0, False, \"nearest\", \"zeros\", False, (1, 48, 77, 90)),\n ((-45, 0), 0, 0, False, GridSampleMode.NEAREST, GridSamplePadMode.ZEROS, False, (1, 48, 77, 90)),\n ]\n )\n def test_correct_shapes(self, x, y, z, keep_size, mode, padding_mode, align_corners, expected):\n rotate_fn = RandRotated(\n \"img\",\n range_x=x,\n range_y=y,\n range_z=z,\n prob=1.0,\n keep_size=keep_size,\n mode=mode,\n padding_mode=padding_mode,\n align_corners=align_corners,\n )\n rotate_fn.set_random_state(243)\n rotated = rotate_fn({\"img\": self.imt[0], \"seg\": self.segn[0]})\n np.testing.assert_allclose(rotated[\"img\"].shape, expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_scale_intensity.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_scale_intensity.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rand_scale_intensity.py", "file_name": "test_rand_scale_intensity.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 31, "span_ids": ["TestRandScaleIntensity", "TestRandScaleIntensity.test_value", "impl", "docstring"], "tokens": 142}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom monai.transforms import RandScaleIntensity\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestRandScaleIntensity(NumpyImageTestCase2D):\n def test_value(self):\n scaler = RandScaleIntensity(factors=0.5, prob=1.0)\n scaler.set_random_state(seed=0)\n result = scaler(self.imt)\n np.random.seed(0)\n expected = (self.imt * (1 + np.random.uniform(low=-0.5, high=0.5))).astype(np.float32)\n np.testing.assert_allclose(result, expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_scale_intensityd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_scale_intensityd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rand_scale_intensityd.py", "file_name": "test_rand_scale_intensityd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 32, "span_ids": ["TestRandScaleIntensityd", "TestRandScaleIntensityd.test_value", "impl", "docstring"], "tokens": 158}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom monai.transforms import RandScaleIntensityd\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestRandScaleIntensityd(NumpyImageTestCase2D):\n def test_value(self):\n key = \"img\"\n scaler = RandScaleIntensityd(keys=[key], factors=0.5, prob=1.0)\n scaler.set_random_state(seed=0)\n result = scaler({key: self.imt})\n np.random.seed(0)\n expected = (self.imt * (1 + np.random.uniform(low=-0.5, high=0.5))).astype(np.float32)\n np.testing.assert_allclose(result[key], expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_shift_intensity.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_shift_intensity.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rand_shift_intensity.py", "file_name": "test_rand_shift_intensity.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 31, "span_ids": ["impl", "TestRandShiftIntensity", "TestRandShiftIntensity.test_value", "docstring"], "tokens": 136}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom monai.transforms import RandShiftIntensity\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestRandShiftIntensity(NumpyImageTestCase2D):\n def test_value(self):\n shifter = RandShiftIntensity(offsets=1.0, prob=1.0)\n shifter.set_random_state(seed=0)\n result = shifter(self.imt)\n np.random.seed(0)\n expected = self.imt + np.random.uniform(low=-1.0, high=1.0)\n np.testing.assert_allclose(result, expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_shift_intensityd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_shift_intensityd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rand_shift_intensityd.py", "file_name": "test_rand_shift_intensityd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 32, "span_ids": ["TestRandShiftIntensityd", "TestRandShiftIntensityd.test_value", "impl", "docstring"], "tokens": 152}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom monai.transforms import RandShiftIntensityd\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestRandShiftIntensityd(NumpyImageTestCase2D):\n def test_value(self):\n key = \"img\"\n shifter = RandShiftIntensityd(keys=[key], offsets=1.0, prob=1.0)\n shifter.set_random_state(seed=0)\n result = shifter({key: self.imt})\n np.random.seed(0)\n expected = self.imt + np.random.uniform(low=-1.0, high=1.0)\n np.testing.assert_allclose(result[key], expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_crop.py_unittest_TEST_CASE_3._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_crop.py_unittest_TEST_CASE_3._", "embedding": null, "metadata": {"file_path": "tests/test_rand_spatial_crop.py", "file_name": "test_rand_spatial_crop.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 34, "span_ids": ["docstring"], "tokens": 312}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import RandSpatialCrop\n\nTEST_CASE_0 = [\n {\"roi_size\": [3, 3, -1], \"random_center\": True},\n np.random.randint(0, 2, size=[3, 3, 3, 4]),\n (3, 3, 3, 4),\n]\n\nTEST_CASE_1 = [{\"roi_size\": [3, 3, 3], \"random_center\": True}, np.random.randint(0, 2, size=[3, 3, 3, 3]), (3, 3, 3, 3)]\n\nTEST_CASE_2 = [\n {\"roi_size\": [3, 3, 3], \"random_center\": False},\n np.random.randint(0, 2, size=[3, 3, 3, 3]),\n (3, 3, 3, 3),\n]\n\nTEST_CASE_3 = [\n {\"roi_size\": [3, 3], \"random_center\": False},\n np.array([[[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 3, 2, 0], [0, 1, 2, 1, 0], [0, 0, 0, 0, 0]]]),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_crop.py_TestRandSpatialCrop_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_crop.py_TestRandSpatialCrop_", "embedding": null, "metadata": {"file_path": "tests/test_rand_spatial_crop.py", "file_name": "test_rand_spatial_crop.py", "file_type": "text/x-python", "category": "test", "start_line": 37, "end_line": 53, "span_ids": ["impl:9", "TestRandSpatialCrop.test_value", "TestRandSpatialCrop", "TestRandSpatialCrop.test_shape"], "tokens": 189}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRandSpatialCrop(unittest.TestCase):\n @parameterized.expand([TEST_CASE_0, TEST_CASE_1, TEST_CASE_2])\n def test_shape(self, input_param, input_data, expected_shape):\n result = RandSpatialCrop(**input_param)(input_data)\n self.assertTupleEqual(result.shape, expected_shape)\n\n @parameterized.expand([TEST_CASE_3])\n def test_value(self, input_param, input_data):\n cropper = RandSpatialCrop(**input_param)\n result = cropper(input_data)\n roi = [(2 - i // 2, 2 + i - i // 2) for i in cropper._size]\n np.testing.assert_allclose(result, input_data[:, roi[0][0] : roi[0][1], roi[1][0] : roi[1][1]])\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_crop_samples.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_crop_samples.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rand_spatial_crop_samples.py", "file_name": "test_rand_spatial_crop_samples.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 40, "span_ids": ["impl:5", "TestRandSpatialCropSamples.test_shape", "TestRandSpatialCropSamples", "docstring"], "tokens": 248}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import RandSpatialCropSamples\n\nTEST_CASE_1 = [\n {\"roi_size\": [3, 3, 3], \"num_samples\": 4, \"random_center\": True},\n np.random.randint(0, 2, size=[3, 3, 3, 3]),\n (3, 3, 3, 3),\n]\n\nTEST_CASE_2 = [\n {\"roi_size\": [3, 3, 3], \"num_samples\": 8, \"random_center\": False},\n np.random.randint(0, 2, size=[3, 3, 3, 3]),\n (3, 3, 3, 3),\n]\n\n\nclass TestRandSpatialCropSamples(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2])\n def test_shape(self, input_param, input_data, expected_shape):\n result = RandSpatialCropSamples(**input_param)(input_data)\n for item in result:\n self.assertTupleEqual(item.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_crop_samplesd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_crop_samplesd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rand_spatial_crop_samplesd.py", "file_name": "test_rand_spatial_crop_samplesd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 41, "span_ids": ["impl:5", "TestRandSpatialCropSamplesd.test_shape", "TestRandSpatialCropSamplesd", "docstring"], "tokens": 344}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import RandSpatialCropSamplesd\n\nTEST_CASE_1 = [\n {\"keys\": [\"img\", \"seg\"], \"num_samples\": 4, \"roi_size\": [3, 3, 3], \"random_center\": True},\n {\"img\": np.random.randint(0, 2, size=[3, 3, 3, 3]), \"seg\": np.random.randint(0, 2, size=[3, 3, 3, 3])},\n (3, 3, 3, 3),\n]\n\nTEST_CASE_2 = [\n {\"keys\": [\"img\", \"seg\"], \"num_samples\": 8, \"roi_size\": [3, 3, 3], \"random_center\": False},\n {\"img\": np.random.randint(0, 2, size=[3, 3, 3, 3]), \"seg\": np.random.randint(0, 2, size=[3, 3, 3, 3])},\n (3, 3, 3, 3),\n]\n\n\nclass TestRandSpatialCropSamplesd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2])\n def test_shape(self, input_param, input_data, expected_shape):\n result = RandSpatialCropSamplesd(**input_param)(input_data)\n for item in result:\n self.assertTupleEqual(item[\"img\"].shape, expected_shape)\n self.assertTupleEqual(item[\"seg\"].shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_cropd.py_unittest_TEST_CASE_3._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_cropd.py_unittest_TEST_CASE_3._", "embedding": null, "metadata": {"file_path": "tests/test_rand_spatial_cropd.py", "file_name": "test_rand_spatial_cropd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 38, "span_ids": ["docstring"], "tokens": 358}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import RandSpatialCropd\n\nTEST_CASE_0 = [\n {\"keys\": \"img\", \"roi_size\": [3, 3, -1], \"random_center\": True},\n {\"img\": np.random.randint(0, 2, size=[3, 3, 3, 5])},\n (3, 3, 3, 5),\n]\n\nTEST_CASE_1 = [\n {\"keys\": \"img\", \"roi_size\": [3, 3, 3], \"random_center\": True},\n {\"img\": np.random.randint(0, 2, size=[3, 3, 3, 3])},\n (3, 3, 3, 3),\n]\n\nTEST_CASE_2 = [\n {\"keys\": \"img\", \"roi_size\": [3, 3, 3], \"random_center\": False},\n {\"img\": np.random.randint(0, 2, size=[3, 3, 3, 3])},\n (3, 3, 3, 3),\n]\n\nTEST_CASE_3 = [\n {\"keys\": \"img\", \"roi_size\": [3, 3], \"random_center\": False},\n {\"img\": np.array([[[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 3, 2, 0], [0, 1, 2, 1, 0], [0, 0, 0, 0, 0]]])},\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_cropd.py_TestRandSpatialCropd_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_spatial_cropd.py_TestRandSpatialCropd_", "embedding": null, "metadata": {"file_path": "tests/test_rand_spatial_cropd.py", "file_name": "test_rand_spatial_cropd.py", "file_type": "text/x-python", "category": "test", "start_line": 41, "end_line": 57, "span_ids": ["TestRandSpatialCropd", "impl:9", "TestRandSpatialCropd.test_shape", "TestRandSpatialCropd.test_value"], "tokens": 200}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRandSpatialCropd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_0, TEST_CASE_1, TEST_CASE_2])\n def test_shape(self, input_param, input_data, expected_shape):\n result = RandSpatialCropd(**input_param)(input_data)\n self.assertTupleEqual(result[\"img\"].shape, expected_shape)\n\n @parameterized.expand([TEST_CASE_3])\n def test_value(self, input_param, input_data):\n cropper = RandSpatialCropd(**input_param)\n result = cropper(input_data)\n roi = [(2 - i // 2, 2 + i - i // 2) for i in cropper._size]\n np.testing.assert_allclose(result[\"img\"], input_data[\"img\"][:, roi[0][0] : roi[0][1], roi[1][0] : roi[1][1]])\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_zoom.py_unittest_TestRandZoom.test_correct_results.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_zoom.py_unittest_TestRandZoom.test_correct_results.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_rand_zoom.py", "file_name": "test_rand_zoom.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 35, "span_ids": ["TestRandZoom", "TestRandZoom.test_correct_results", "docstring"], "tokens": 262}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom parameterized import parameterized\nfrom scipy.ndimage import zoom as zoom_scipy\nfrom tests.utils import NumpyImageTestCase2D\n\nfrom monai.transforms import RandZoom\nfrom monai.utils import InterpolateMode, GridSampleMode\n\nVALID_CASES = [(0.8, 1.2, \"nearest\", False), (0.8, 1.2, InterpolateMode.NEAREST, False)]\n\n\nclass TestRandZoom(NumpyImageTestCase2D):\n @parameterized.expand(VALID_CASES)\n def test_correct_results(self, min_zoom, max_zoom, mode, keep_size):\n random_zoom = RandZoom(prob=1.0, min_zoom=min_zoom, max_zoom=max_zoom, mode=mode, keep_size=keep_size,)\n random_zoom.set_random_state(1234)\n zoomed = random_zoom(self.imt[0])\n expected = list()\n for channel in self.imt[0]:\n expected.append(zoom_scipy(channel, zoom=random_zoom._zoom, mode=\"nearest\", order=0, prefilter=False))\n expected = np.stack(expected).astype(np.float32)\n np.testing.assert_allclose(zoomed, expected, atol=1.0)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_zoom.py_TestRandZoom.test_keep_size_TestRandZoom.test_keep_size.None_2": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_zoom.py_TestRandZoom.test_keep_size_TestRandZoom.test_keep_size.None_2", "embedding": null, "metadata": {"file_path": "tests/test_rand_zoom.py", "file_name": "test_rand_zoom.py", "file_type": "text/x-python", "category": "test", "start_line": 37, "end_line": 44, "span_ids": ["TestRandZoom.test_keep_size"], "tokens": 141}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRandZoom(NumpyImageTestCase2D):\n\n def test_keep_size(self):\n random_zoom = RandZoom(prob=1.0, min_zoom=0.6, max_zoom=0.7, keep_size=True)\n zoomed = random_zoom(self.imt[0])\n self.assertTrue(np.array_equal(zoomed.shape, self.imt.shape[1:]))\n zoomed = random_zoom(self.imt[0])\n self.assertTrue(np.array_equal(zoomed.shape, self.imt.shape[1:]))\n zoomed = random_zoom(self.imt[0])\n self.assertTrue(np.array_equal(zoomed.shape, self.imt.shape[1:]))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_zoom.py_TestRandZoom.test_invalid_inputs_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_zoom.py_TestRandZoom.test_invalid_inputs_", "embedding": null, "metadata": {"file_path": "tests/test_rand_zoom.py", "file_name": "test_rand_zoom.py", "file_type": "text/x-python", "category": "test", "start_line": 46, "end_line": 61, "span_ids": ["impl:3", "TestRandZoom.test_invalid_inputs"], "tokens": 158}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRandZoom(NumpyImageTestCase2D):\n\n @parameterized.expand(\n [\n (\"no_min_zoom\", None, 1.1, \"bilinear\", TypeError),\n (\"invalid_mode\", 0.9, 1.1, \"s\", ValueError),\n (\"invalid_mode\", 0.9, 1.1, GridSampleMode.NEAREST, ValueError),\n ]\n )\n def test_invalid_inputs(self, _, min_zoom, max_zoom, mode, raises):\n with self.assertRaises(raises):\n random_zoom = RandZoom(prob=1.0, min_zoom=min_zoom, max_zoom=max_zoom, mode=mode)\n random_zoom(self.imt[0])\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_zoomd.py_unittest_TestRandZoomd.test_correct_results.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_zoomd.py_unittest_TestRandZoomd.test_correct_results.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_rand_zoomd.py", "file_name": "test_rand_zoomd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 44, "span_ids": ["TestRandZoomd", "TestRandZoomd.test_correct_results", "docstring"], "tokens": 265}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom parameterized import parameterized\nfrom scipy.ndimage import zoom as zoom_scipy\nfrom tests.utils import NumpyImageTestCase2D\n\nfrom monai.transforms import RandZoomd\n\nVALID_CASES = [(0.8, 1.2, \"nearest\", None, False)]\n\n\nclass TestRandZoomd(NumpyImageTestCase2D):\n @parameterized.expand(VALID_CASES)\n def test_correct_results(self, min_zoom, max_zoom, mode, align_corners, keep_size):\n key = \"img\"\n random_zoom = RandZoomd(\n key,\n prob=1.0,\n min_zoom=min_zoom,\n max_zoom=max_zoom,\n mode=mode,\n align_corners=align_corners,\n keep_size=keep_size,\n )\n random_zoom.set_random_state(1234)\n\n zoomed = random_zoom({key: self.imt[0]})\n expected = list()\n for channel in self.imt[0]:\n expected.append(zoom_scipy(channel, zoom=random_zoom._zoom, mode=\"nearest\", order=0, prefilter=False))\n expected = np.stack(expected).astype(np.float32)\n np.testing.assert_allclose(expected, zoomed[key], atol=1.0)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_zoomd.py_TestRandZoomd.test_keep_size_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_zoomd.py_TestRandZoomd.test_keep_size_", "embedding": null, "metadata": {"file_path": "tests/test_rand_zoomd.py", "file_name": "test_rand_zoomd.py", "file_type": "text/x-python", "category": "test", "start_line": 46, "end_line": 64, "span_ids": ["impl:3", "TestRandZoomd.test_invalid_inputs", "TestRandZoomd.test_keep_size"], "tokens": 225}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRandZoomd(NumpyImageTestCase2D):\n\n def test_keep_size(self):\n key = \"img\"\n random_zoom = RandZoomd(key, prob=1.0, min_zoom=0.6, max_zoom=0.7, keep_size=True)\n zoomed = random_zoom({key: self.imt[0]})\n self.assertTrue(np.array_equal(zoomed[key].shape, self.imt.shape[1:]))\n\n @parameterized.expand(\n [(\"no_min_zoom\", None, 1.1, \"bilinear\", TypeError), (\"invalid_order\", 0.9, 1.1, \"s\", ValueError)]\n )\n def test_invalid_inputs(self, _, min_zoom, max_zoom, mode, raises):\n key = \"img\"\n with self.assertRaises(raises):\n random_zoom = RandZoomd(key, prob=1.0, min_zoom=min_zoom, max_zoom=max_zoom, mode=mode)\n random_zoom({key: self.imt[0]})\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_randomizable.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_randomizable.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_randomizable.py", "file_name": "test_randomizable.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 49, "span_ids": ["TestRandomizable.test_state", "impl", "TestRandomizable.test_default", "RandTest.randomize", "docstring", "RandTest", "TestRandomizable", "TestRandomizable.test_seed"], "tokens": 213}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\n\nfrom monai.transforms import Randomizable\n\n\nclass RandTest(Randomizable):\n def randomize(self, data=None):\n pass\n\n\nclass TestRandomizable(unittest.TestCase):\n def test_default(self):\n inst = RandTest()\n r1 = inst.R.rand()\n self.assertTrue(isinstance(inst.R, np.random.RandomState))\n inst.set_random_state()\n r2 = inst.R.rand()\n self.assertNotAlmostEqual(r1, r2)\n\n def test_seed(self):\n inst = RandTest()\n inst.set_random_state(seed=123)\n self.assertAlmostEqual(inst.R.rand(), 0.69646918)\n inst.set_random_state(123)\n self.assertAlmostEqual(inst.R.rand(), 0.69646918)\n\n def test_state(self):\n inst = RandTest()\n inst_r = np.random.RandomState(123)\n inst.set_random_state(state=inst_r)\n self.assertAlmostEqual(inst.R.rand(), 0.69646918)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_repeat_channel.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_repeat_channel.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_repeat_channel.py", "file_name": "test_repeat_channel.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 29, "span_ids": ["TestRepeatChannel", "impl:3", "TestRepeatChannel.test_shape", "docstring"], "tokens": 127}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import RepeatChannel\n\nTEST_CASE_1 = [{\"repeats\": 3}, np.array([[[0, 1], [1, 2]]]), (3, 2, 2)]\n\n\nclass TestRepeatChannel(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1])\n def test_shape(self, input_param, input_data, expected_shape):\n result = RepeatChannel(**input_param)(input_data)\n self.assertEqual(result.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_repeat_channeld.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_repeat_channeld.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_repeat_channeld.py", "file_name": "test_repeat_channeld.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 33, "span_ids": ["TestRepeatChanneld.test_shape", "impl:3", "TestRepeatChanneld", "docstring"], "tokens": 169}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import RepeatChanneld\n\nTEST_CASE_1 = [\n {\"keys\": [\"img\"], \"repeats\": 3},\n {\"img\": np.array([[[0, 1], [1, 2]]]), \"seg\": np.array([[[0, 1], [1, 2]]])},\n (3, 2, 2),\n]\n\n\nclass TestRepeatChanneld(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1])\n def test_shape(self, input_param, input_data, expected_shape):\n result = RepeatChanneld(**input_param)(input_data)\n self.assertEqual(result[\"img\"].shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_resampler.py_unittest_TEST_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_resampler.py_unittest_TEST_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_resampler.py", "file_name": "test_resampler.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 70, "span_ids": ["docstring"], "tokens": 1324}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import Resample\nfrom monai.transforms.utils import create_grid\n\nTEST_CASES = [\n [\n dict(padding_mode=\"zeros\", as_tensor_output=False, device=None),\n {\"grid\": create_grid((2, 2)), \"img\": np.arange(4).reshape((1, 2, 2))},\n np.array([[[0.0, 1.0], [2.0, 3.0]]]),\n ],\n [\n dict(padding_mode=\"zeros\", as_tensor_output=False, device=None),\n {\"grid\": create_grid((4, 4)), \"img\": np.arange(4).reshape((1, 2, 2))},\n np.array([[[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 2.0, 3.0, 0.0], [0.0, 0.0, 0.0, 0.0]]]),\n ],\n [\n dict(padding_mode=\"border\", as_tensor_output=False, device=None),\n {\"grid\": create_grid((4, 4)), \"img\": np.arange(4).reshape((1, 2, 2))},\n np.array([[[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0], [2.0, 2.0, 3, 3.0], [2.0, 2.0, 3.0, 3.0]]]),\n ],\n [\n dict(padding_mode=\"reflection\", as_tensor_output=False, device=None),\n {\"grid\": create_grid((4, 4)), \"img\": np.arange(4).reshape((1, 2, 2)), \"mode\": \"nearest\"},\n np.array([[[3.0, 2.0, 3.0, 2.0], [1.0, 0.0, 1.0, 0.0], [3.0, 2.0, 3.0, 2.0], [1.0, 0.0, 1.0, 0.0]]]),\n ],\n [\n dict(padding_mode=\"zeros\", as_tensor_output=False, device=None),\n {\"grid\": create_grid((4, 4, 4)), \"img\": np.arange(8).reshape((1, 2, 2, 2)), \"mode\": \"bilinear\"},\n np.array(\n [\n [\n [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]],\n [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 2.0, 3.0, 0.0], [0.0, 0.0, 0.0, 0.0]],\n [[0.0, 0.0, 0.0, 0.0], [0.0, 4.0, 5.0, 0.0], [0.0, 6.0, 7.0, 0.0], [0.0, 0.0, 0.0, 0.0]],\n [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]],\n ]\n ]\n ),\n ],\n [\n dict(padding_mode=\"border\", as_tensor_output=False, device=None),\n {\"grid\": create_grid((4, 4, 4)), \"img\": np.arange(8).reshape((1, 2, 2, 2)), \"mode\": \"bilinear\"},\n np.array(\n [\n [\n [[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0], [2.0, 2.0, 3.0, 3.0], [2.0, 2.0, 3.0, 3.0]],\n [[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0], [2.0, 2.0, 3.0, 3.0], [2.0, 2.0, 3.0, 3.0]],\n [[4.0, 4.0, 5.0, 5.0], [4.0, 4.0, 5.0, 5.0], [6.0, 6.0, 7.0, 7.0], [6.0, 6.0, 7.0, 7.0]],\n [[4.0, 4.0, 5.0, 5.0], [4.0, 4.0, 5.0, 5.0], [6.0, 6.0, 7.0, 7.0], [6.0, 6.0, 7.0, 7.0]],\n ]\n ]\n ),\n ],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_resampler.py_TestResample_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_resampler.py_TestResample_", "embedding": null, "metadata": {"file_path": "tests/test_resampler.py", "file_name": "test_resampler.py", "file_type": "text/x-python", "category": "test", "start_line": 73, "end_line": 87, "span_ids": ["TestResample.test_resample", "impl:3", "TestResample"], "tokens": 143}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestResample(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_resample(self, input_param, input_data, expected_val):\n g = Resample(**input_param)\n result = g(**input_data)\n self.assertEqual(torch.is_tensor(result), torch.is_tensor(expected_val))\n if torch.is_tensor(result):\n np.testing.assert_allclose(result.cpu().numpy(), expected_val.cpu().numpy(), rtol=1e-4, atol=1e-4)\n else:\n np.testing.assert_allclose(result, expected_val, rtol=1e-4, atol=1e-4)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_resize.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_resize.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_resize.py", "file_name": "test_resize.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 56, "span_ids": ["TestResize", "impl", "TestResize.test_invalid_inputs", "TestResize.test_correct_results", "docstring"], "tokens": 333}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport skimage.transform\nfrom parameterized import parameterized\nfrom tests.utils import NumpyImageTestCase2D\n\nfrom monai.transforms import Resize\n\n\nclass TestResize(NumpyImageTestCase2D):\n def test_invalid_inputs(self):\n with self.assertRaises(ValueError):\n resize = Resize(spatial_size=(128, 128, 3), mode=\"order\")\n resize(self.imt[0])\n\n with self.assertRaises(ValueError):\n resize = Resize(spatial_size=(128,), mode=\"order\")\n resize(self.imt[0])\n\n @parameterized.expand(\n [((32, -1), \"area\"), ((32, 32), \"area\"), ((32, 32, 32), \"trilinear\"), ((256, 256), \"bilinear\")]\n )\n def test_correct_results(self, spatial_size, mode):\n resize = Resize(spatial_size, mode=mode)\n _order = 0\n if mode.endswith(\"linear\"):\n _order = 1\n if spatial_size == (32, -1):\n spatial_size = (32, 64)\n expected = list()\n for channel in self.imt[0]:\n expected.append(\n skimage.transform.resize(\n channel, spatial_size, order=_order, clip=False, preserve_range=False, anti_aliasing=False\n )\n )\n expected = np.stack(expected).astype(np.float32)\n out = resize(self.imt[0])\n np.testing.assert_allclose(out, expected, atol=0.9)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_resized.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_resized.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_resized.py", "file_name": "test_resized.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 54, "span_ids": ["TestResized", "TestResized.test_correct_results", "impl", "TestResized.test_invalid_inputs", "docstring"], "tokens": 355}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport skimage.transform\nfrom parameterized import parameterized\nfrom tests.utils import NumpyImageTestCase2D\n\nfrom monai.transforms import Resized\n\n\nclass TestResized(NumpyImageTestCase2D):\n def test_invalid_inputs(self):\n with self.assertRaises(ValueError):\n resize = Resized(keys=\"img\", spatial_size=(128, 128, 3), mode=\"order\")\n resize({\"img\": self.imt[0]})\n\n with self.assertRaises(ValueError):\n resize = Resized(keys=\"img\", spatial_size=(128,), mode=\"order\")\n resize({\"img\": self.imt[0]})\n\n @parameterized.expand([((32, -1), \"area\"), ((64, 64), \"area\"), ((32, 32, 32), \"area\"), ((256, 256), \"bilinear\")])\n def test_correct_results(self, spatial_size, mode):\n resize = Resized(\"img\", spatial_size, mode)\n _order = 0\n if mode.endswith(\"linear\"):\n _order = 1\n if spatial_size == (32, -1):\n spatial_size = (32, 64)\n expected = list()\n for channel in self.imt[0]:\n expected.append(\n skimage.transform.resize(\n channel, spatial_size, order=_order, clip=False, preserve_range=False, anti_aliasing=False\n )\n )\n expected = np.stack(expected).astype(np.float32)\n out = resize({\"img\": self.imt[0]})[\"img\"]\n np.testing.assert_allclose(out, expected, atol=0.9)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate.py_unittest_TEST_CASES_SHAPE_3D._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate.py_unittest_TEST_CASES_SHAPE_3D._", "embedding": null, "metadata": {"file_path": "tests/test_rotate.py", "file_name": "test_rotate.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 41, "span_ids": ["docstring"], "tokens": 283}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport scipy.ndimage\nfrom parameterized import parameterized\nfrom tests.utils import NumpyImageTestCase2D, NumpyImageTestCase3D\n\nfrom monai.transforms import Rotate\n\nTEST_CASES_2D = [\n (30, False, \"bilinear\", \"border\", False),\n (45, True, \"bilinear\", \"border\", False),\n (-40, True, \"nearest\", \"reflection\", False),\n (180, False, \"nearest\", \"zeros\", False),\n (-90, False, \"bilinear\", \"zeros\", True),\n]\n\nTEST_CASES_3D = [\n (-90.0, True, \"nearest\", \"border\", False),\n (45, True, \"bilinear\", \"border\", False),\n (-40, True, \"nearest\", \"reflection\", False),\n (180, False, \"nearest\", \"zeros\", False),\n (-90, False, \"bilinear\", \"zeros\", False),\n]\n\nTEST_CASES_SHAPE_3D = [\n ([-90.0, 1.0, 2.0], \"nearest\", \"border\", False),\n ([45, 0, 0], \"bilinear\", \"border\", False),\n ([-40, -20, 20], \"nearest\", \"reflection\", False),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate.py_TestRotate2D_TestRotate2D.test_correct_results.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate.py_TestRotate2D_TestRotate2D.test_correct_results.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_rotate.py", "file_name": "test_rotate.py", "file_type": "text/x-python", "category": "test", "start_line": 44, "end_line": 65, "span_ids": ["TestRotate2D.test_correct_results", "TestRotate2D"], "tokens": 233}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRotate2D(NumpyImageTestCase2D):\n @parameterized.expand(TEST_CASES_2D)\n def test_correct_results(self, angle, keep_size, mode, padding_mode, align_corners):\n rotate_fn = Rotate(angle, keep_size, mode, padding_mode, align_corners)\n rotated = rotate_fn(self.imt[0])\n if keep_size:\n np.testing.assert_allclose(self.imt[0].shape, rotated.shape)\n _order = 0 if mode == \"nearest\" else 1\n if padding_mode == \"border\":\n _mode = \"nearest\"\n elif padding_mode == \"reflection\":\n _mode = \"reflect\"\n else:\n _mode = \"constant\"\n\n expected = list()\n for channel in self.imt[0]:\n expected.append(\n scipy.ndimage.rotate(channel, -angle, (0, 1), not keep_size, order=_order, mode=_mode, prefilter=False)\n )\n expected = np.stack(expected).astype(np.float32)\n np.testing.assert_allclose(expected, rotated, atol=1e-1)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate.py_TestRotate3D_TestRotate3D.test_correct_results.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate.py_TestRotate3D_TestRotate3D.test_correct_results.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_rotate.py", "file_name": "test_rotate.py", "file_type": "text/x-python", "category": "test", "start_line": 68, "end_line": 89, "span_ids": ["TestRotate3D", "TestRotate3D.test_correct_results"], "tokens": 240}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRotate3D(NumpyImageTestCase3D):\n @parameterized.expand(TEST_CASES_3D)\n def test_correct_results(self, angle, keep_size, mode, padding_mode, align_corners):\n rotate_fn = Rotate([angle, 0, 0], keep_size, mode, padding_mode, align_corners)\n rotated = rotate_fn(self.imt[0])\n if keep_size:\n np.testing.assert_allclose(self.imt[0].shape, rotated.shape)\n _order = 0 if mode == \"nearest\" else 1\n if padding_mode == \"border\":\n _mode = \"nearest\"\n elif padding_mode == \"reflection\":\n _mode = \"reflect\"\n else:\n _mode = \"constant\"\n\n expected = list()\n for channel in self.imt[0]:\n expected.append(\n scipy.ndimage.rotate(channel, -angle, (1, 2), not keep_size, order=_order, mode=_mode, prefilter=False)\n )\n expected = np.stack(expected).astype(np.float32)\n np.testing.assert_allclose(expected, rotated, atol=1e-1)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate.py_TestRotate3D.test_correct_shape_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate.py_TestRotate3D.test_correct_shape_", "embedding": null, "metadata": {"file_path": "tests/test_rotate.py", "file_name": "test_rotate.py", "file_type": "text/x-python", "category": "test", "start_line": 91, "end_line": 109, "span_ids": ["TestRotate3D.test_correct_shape", "impl:7", "TestRotate3D.test_ill_case"], "tokens": 180}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRotate3D(NumpyImageTestCase3D):\n\n @parameterized.expand(TEST_CASES_SHAPE_3D)\n def test_correct_shape(self, angle, mode, padding_mode, align_corners):\n rotate_fn = Rotate(angle, True, align_corners=align_corners)\n rotated = rotate_fn(self.imt[0], mode=mode, padding_mode=padding_mode)\n np.testing.assert_allclose(self.imt[0].shape, rotated.shape)\n\n def test_ill_case(self):\n rotate_fn = Rotate(10, True)\n with self.assertRaises(ValueError): # wrong shape\n rotate_fn(self.imt)\n\n rotate_fn = Rotate(10, keep_size=False)\n with self.assertRaises(ValueError): # wrong mode\n rotate_fn(self.imt[0], mode=\"trilinear\")\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate90.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate90.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rotate90.py", "file_name": "test_rotate90.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 60, "span_ids": ["TestRotate90.test_k", "impl", "TestRotate90.test_rotate90_default", "TestRotate90.test_prob_k_spatial_axes", "TestRotate90.test_spatial_axes", "TestRotate90", "docstring"], "tokens": 368}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\n\nfrom monai.transforms import Rotate90\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestRotate90(NumpyImageTestCase2D):\n def test_rotate90_default(self):\n rotate = Rotate90()\n rotated = rotate(self.imt[0])\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.rot90(channel, 1, (0, 1)))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(rotated, expected))\n\n def test_k(self):\n rotate = Rotate90(k=2)\n rotated = rotate(self.imt[0])\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.rot90(channel, 2, (0, 1)))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(rotated, expected))\n\n def test_spatial_axes(self):\n rotate = Rotate90(spatial_axes=(0, 1))\n rotated = rotate(self.imt[0])\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.rot90(channel, 1, (0, 1)))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(rotated, expected))\n\n def test_prob_k_spatial_axes(self):\n rotate = Rotate90(k=2, spatial_axes=(0, 1))\n rotated = rotate(self.imt[0])\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.rot90(channel, 2, (0, 1)))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(rotated, expected))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate90d.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotate90d.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rotate90d.py", "file_name": "test_rotate90d.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 70, "span_ids": ["impl", "TestRotate90d.test_prob_k_spatial_axes", "TestRotate90d.test_rotate90_default", "TestRotate90d", "docstring", "TestRotate90d.test_spatial_axes", "TestRotate90d.test_k", "TestRotate90d.test_no_key"], "tokens": 467}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\n\nfrom monai.transforms import Rotate90d\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestRotate90d(NumpyImageTestCase2D):\n def test_rotate90_default(self):\n key = \"test\"\n rotate = Rotate90d(keys=key)\n rotated = rotate({key: self.imt[0]})\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.rot90(channel, 1, (0, 1)))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(rotated[key], expected))\n\n def test_k(self):\n key = None\n rotate = Rotate90d(keys=key, k=2)\n rotated = rotate({key: self.imt[0]})\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.rot90(channel, 2, (0, 1)))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(rotated[key], expected))\n\n def test_spatial_axes(self):\n key = \"test\"\n rotate = Rotate90d(keys=key, spatial_axes=(0, 1))\n rotated = rotate({key: self.imt[0]})\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.rot90(channel, 1, (0, 1)))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(rotated[key], expected))\n\n def test_prob_k_spatial_axes(self):\n key = \"test\"\n rotate = Rotate90d(keys=key, k=2, spatial_axes=(0, 1))\n rotated = rotate({key: self.imt[0]})\n expected = list()\n for channel in self.imt[0]:\n expected.append(np.rot90(channel, 2, (0, 1)))\n expected = np.stack(expected)\n self.assertTrue(np.allclose(rotated[key], expected))\n\n def test_no_key(self):\n key = \"unknown\"\n rotate = Rotate90d(keys=key)\n with self.assertRaisesRegex(KeyError, \"\"):\n rotate({\"test\": self.imt[0]})\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotated.py_unittest_TEST_CASES_3D._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotated.py_unittest_TEST_CASES_3D._", "embedding": null, "metadata": {"file_path": "tests/test_rotated.py", "file_name": "test_rotated.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 35, "span_ids": ["docstring"], "tokens": 210}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport scipy.ndimage\nfrom parameterized import parameterized\nfrom tests.utils import NumpyImageTestCase2D, NumpyImageTestCase3D\n\nfrom monai.transforms import Rotated\n\nTEST_CASES_2D = [\n (-30, False, \"bilinear\", \"border\", False),\n (-45, True, \"bilinear\", \"border\", False),\n (40, True, \"nearest\", \"reflection\", False),\n (-180, False, \"nearest\", \"zeros\", False),\n (90, False, \"bilinear\", \"zeros\", True),\n]\n\nTEST_CASES_3D = [\n (-30, False, \"bilinear\", \"border\", False),\n (-45, True, \"bilinear\", \"border\", False),\n (40, True, \"nearest\", \"reflection\", False),\n (-180, False, \"nearest\", \"zeros\", False),\n (90, False, \"bilinear\", \"zeros\", True),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotated.py_TestRotated2D_TestRotated2D.test_correct_results.self_assertLessEqual_np_c": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotated.py_TestRotated2D_TestRotated2D.test_correct_results.self_assertLessEqual_np_c", "embedding": null, "metadata": {"file_path": "tests/test_rotated.py", "file_name": "test_rotated.py", "file_type": "text/x-python", "category": "test", "start_line": 38, "end_line": 61, "span_ids": ["TestRotated2D.test_correct_results", "TestRotated2D"], "tokens": 319}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRotated2D(NumpyImageTestCase2D):\n @parameterized.expand(TEST_CASES_2D)\n def test_correct_results(self, angle, keep_size, mode, padding_mode, align_corners):\n rotate_fn = Rotated((\"img\", \"seg\"), angle, keep_size, (mode, \"nearest\"), padding_mode, align_corners)\n rotated = rotate_fn({\"img\": self.imt[0], \"seg\": self.segn[0]})\n if keep_size:\n np.testing.assert_allclose(self.imt[0].shape, rotated[\"img\"].shape)\n _order = 0 if mode == \"nearest\" else 1\n if padding_mode == \"border\":\n _mode = \"nearest\"\n elif padding_mode == \"reflection\":\n _mode = \"reflect\"\n else:\n _mode = \"constant\"\n expected = scipy.ndimage.rotate(\n self.imt[0, 0], -angle, (0, 1), not keep_size, order=_order, mode=_mode, prefilter=False\n )\n np.testing.assert_allclose(expected, rotated[\"img\"][0], atol=1e-3)\n\n expected = scipy.ndimage.rotate(\n self.segn[0, 0], -angle, (0, 1), not keep_size, order=0, mode=_mode, prefilter=False\n )\n expected = np.stack(expected).astype(int)\n self.assertLessEqual(np.count_nonzero(expected != rotated[\"seg\"][0]), 20)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotated.py_TestRotated3D_TestRotated3D.test_correct_results.self_assertLessEqual_np_c": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotated.py_TestRotated3D_TestRotated3D.test_correct_results.self_assertLessEqual_np_c", "embedding": null, "metadata": {"file_path": "tests/test_rotated.py", "file_name": "test_rotated.py", "file_type": "text/x-python", "category": "test", "start_line": 64, "end_line": 87, "span_ids": ["TestRotated3D", "TestRotated3D.test_correct_results"], "tokens": 323}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRotated3D(NumpyImageTestCase3D):\n @parameterized.expand(TEST_CASES_3D)\n def test_correct_results(self, angle, keep_size, mode, padding_mode, align_corners):\n rotate_fn = Rotated((\"img\", \"seg\"), [0, angle, 0], keep_size, (mode, \"nearest\"), padding_mode, align_corners)\n rotated = rotate_fn({\"img\": self.imt[0], \"seg\": self.segn[0]})\n if keep_size:\n np.testing.assert_allclose(self.imt[0].shape, rotated[\"img\"].shape)\n _order = 0 if mode == \"nearest\" else 1\n if padding_mode == \"border\":\n _mode = \"nearest\"\n elif padding_mode == \"reflection\":\n _mode = \"reflect\"\n else:\n _mode = \"constant\"\n expected = scipy.ndimage.rotate(\n self.imt[0, 0], angle, (0, 2), not keep_size, order=_order, mode=_mode, prefilter=False\n )\n np.testing.assert_allclose(expected, rotated[\"img\"][0], atol=1e-3)\n\n expected = scipy.ndimage.rotate(\n self.segn[0, 0], angle, (0, 2), not keep_size, order=0, mode=_mode, prefilter=False\n )\n expected = np.stack(expected).astype(int)\n self.assertLessEqual(np.count_nonzero(expected != rotated[\"seg\"][0]), 100)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotated.py_TestRotated3DXY_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rotated.py_TestRotated3DXY_", "embedding": null, "metadata": {"file_path": "tests/test_rotated.py", "file_name": "test_rotated.py", "file_type": "text/x-python", "category": "test", "start_line": 90, "end_line": 118, "span_ids": ["TestRotated3DXY.test_correct_results", "impl:5", "TestRotated3DXY"], "tokens": 338}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestRotated3DXY(NumpyImageTestCase3D):\n @parameterized.expand(TEST_CASES_3D)\n def test_correct_results(self, angle, keep_size, mode, padding_mode, align_corners):\n rotate_fn = Rotated((\"img\", \"seg\"), [0, 0, angle], keep_size, (mode, \"nearest\"), padding_mode, align_corners)\n rotated = rotate_fn({\"img\": self.imt[0], \"seg\": self.segn[0]})\n if keep_size:\n np.testing.assert_allclose(self.imt[0].shape, rotated[\"img\"].shape)\n _order = 0 if mode == \"nearest\" else 1\n if padding_mode == \"border\":\n _mode = \"nearest\"\n elif padding_mode == \"reflection\":\n _mode = \"reflect\"\n else:\n _mode = \"constant\"\n expected = scipy.ndimage.rotate(\n self.imt[0, 0], -angle, (0, 1), not keep_size, order=_order, mode=_mode, prefilter=False\n )\n np.testing.assert_allclose(expected, rotated[\"img\"][0], atol=1e-3)\n\n expected = scipy.ndimage.rotate(\n self.segn[0, 0], -angle, (0, 1), not keep_size, order=0, mode=_mode, prefilter=False\n )\n expected = np.stack(expected).astype(int)\n self.assertLessEqual(np.count_nonzero(expected != rotated[\"seg\"][0]), 100)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_scale_intensity.py", "file_name": "test_scale_intensity.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 38, "span_ids": ["impl", "TestScaleIntensity", "docstring", "TestScaleIntensity.test_range_scale", "TestScaleIntensity.test_factor_scale"], "tokens": 220}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom monai.transforms import ScaleIntensity\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestScaleIntensity(NumpyImageTestCase2D):\n def test_range_scale(self):\n scaler = ScaleIntensity(minv=1.0, maxv=2.0)\n result = scaler(self.imt)\n mina = np.min(self.imt)\n maxa = np.max(self.imt)\n norm = (self.imt - mina) / (maxa - mina)\n expected = (norm * (2.0 - 1.0)) + 1.0\n np.testing.assert_allclose(result, expected)\n\n def test_factor_scale(self):\n scaler = ScaleIntensity(minv=None, maxv=None, factor=0.1)\n result = scaler(self.imt)\n expected = (self.imt * (1 + 0.1)).astype(np.float32)\n np.testing.assert_allclose(result, expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_scale_intensity_range.py", "file_name": "test_scale_intensity_range.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 31, "span_ids": ["IntensityScaleIntensityRange", "impl", "IntensityScaleIntensityRange.test_image_scale_intensity_range", "docstring"], "tokens": 133}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\n\nfrom monai.transforms import ScaleIntensityRange\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass IntensityScaleIntensityRange(NumpyImageTestCase2D):\n def test_image_scale_intensity_range(self):\n scaler = ScaleIntensityRange(a_min=20, a_max=108, b_min=50, b_max=80)\n scaled = scaler(self.imt)\n expected = (self.imt - 20) / 88\n expected = expected * 30 + 50\n self.assertTrue(np.allclose(scaled, expected))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentiles.py_unittest_TestScaleIntensityRangePercentiles.test_scaling.self_assertTrue_np_allclo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentiles.py_unittest_TestScaleIntensityRangePercentiles.test_scaling.self_assertTrue_np_allclo", "embedding": null, "metadata": {"file_path": "tests/test_scale_intensity_range_percentiles.py", "file_name": "test_scale_intensity_range_percentiles.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 33, "span_ids": ["TestScaleIntensityRangePercentiles.test_scaling", "TestScaleIntensityRangePercentiles", "docstring"], "tokens": 179}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\n\nfrom monai.transforms.intensity.array import ScaleIntensityRangePercentiles\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestScaleIntensityRangePercentiles(NumpyImageTestCase2D):\n def test_scaling(self):\n img = self.imt\n lower = 10\n upper = 99\n b_min = 0\n b_max = 255\n\n a_min = np.percentile(img, lower)\n a_max = np.percentile(img, upper)\n expected = (img - a_min) / (a_max - a_min)\n expected = (expected * (b_max - b_min)) + b_min\n scaler = ScaleIntensityRangePercentiles(lower=lower, upper=upper, b_min=b_min, b_max=b_max)\n self.assertTrue(np.allclose(expected, scaler(img)))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentiles.py_TestScaleIntensityRangePercentiles.test_relative_scaling_TestScaleIntensityRangePercentiles.test_relative_scaling.self_assertTrue_np_allclo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentiles.py_TestScaleIntensityRangePercentiles.test_relative_scaling_TestScaleIntensityRangePercentiles.test_relative_scaling.self_assertTrue_np_allclo", "embedding": null, "metadata": {"file_path": "tests/test_scale_intensity_range_percentiles.py", "file_name": "test_scale_intensity_range_percentiles.py", "file_type": "text/x-python", "category": "test", "start_line": 35, "end_line": 50, "span_ids": ["TestScaleIntensityRangePercentiles.test_relative_scaling"], "tokens": 212}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestScaleIntensityRangePercentiles(NumpyImageTestCase2D):\n\n def test_relative_scaling(self):\n img = self.imt\n lower = 10\n upper = 99\n b_min = 100\n b_max = 300\n scaler = ScaleIntensityRangePercentiles(lower=lower, upper=upper, b_min=b_min, b_max=b_max, relative=True)\n\n expected_a_min = np.percentile(img, lower)\n expected_a_max = np.percentile(img, upper)\n expected_b_min = ((b_max - b_min) * (lower / 100.0)) + b_min\n expected_b_max = ((b_max - b_min) * (upper / 100.0)) + b_min\n expected_img = (img - expected_a_min) / (expected_a_max - expected_a_min)\n expected_img = (expected_img * (expected_b_max - expected_b_min)) + expected_b_min\n\n self.assertTrue(np.allclose(expected_img, scaler(img)))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentiles.py_TestScaleIntensityRangePercentiles.test_invalid_instantiation_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentiles.py_TestScaleIntensityRangePercentiles.test_invalid_instantiation_", "embedding": null, "metadata": {"file_path": "tests/test_scale_intensity_range_percentiles.py", "file_name": "test_scale_intensity_range_percentiles.py", "file_type": "text/x-python", "category": "test", "start_line": 52, "end_line": 61, "span_ids": ["TestScaleIntensityRangePercentiles.test_invalid_instantiation", "impl"], "tokens": 167}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestScaleIntensityRangePercentiles(NumpyImageTestCase2D):\n\n def test_invalid_instantiation(self):\n self.assertRaises(AssertionError, ScaleIntensityRangePercentiles, lower=-10, upper=99, b_min=0, b_max=255)\n self.assertRaises(AssertionError, ScaleIntensityRangePercentiles, lower=101, upper=99, b_min=0, b_max=255)\n self.assertRaises(AssertionError, ScaleIntensityRangePercentiles, lower=30, upper=-20, b_min=0, b_max=255)\n self.assertRaises(AssertionError, ScaleIntensityRangePercentiles, lower=30, upper=900, b_min=0, b_max=255)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentilesd.py_unittest_TestScaleIntensityRangePercentilesd.test_scaling.self_assertTrue_np_allclo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentilesd.py_unittest_TestScaleIntensityRangePercentilesd.test_scaling.self_assertTrue_np_allclo", "embedding": null, "metadata": {"file_path": "tests/test_scale_intensity_range_percentilesd.py", "file_name": "test_scale_intensity_range_percentilesd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 37, "span_ids": ["TestScaleIntensityRangePercentilesd", "TestScaleIntensityRangePercentilesd.test_scaling", "docstring"], "tokens": 201}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\n\nfrom monai.transforms.intensity.dictionary import ScaleIntensityRangePercentilesd\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestScaleIntensityRangePercentilesd(NumpyImageTestCase2D):\n def test_scaling(self):\n img = self.imt\n data = dict()\n data[\"img\"] = img\n lower = 10\n upper = 99\n b_min = 0\n b_max = 255\n\n a_min = np.percentile(img, lower)\n a_max = np.percentile(img, upper)\n expected = (img - a_min) / (a_max - a_min)\n expected = (expected * (b_max - b_min)) + b_min\n\n scaler = ScaleIntensityRangePercentilesd(keys=data.keys(), lower=lower, upper=upper, b_min=b_min, b_max=b_max)\n\n self.assertTrue(np.allclose(expected, scaler(data)[\"img\"]))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentilesd.py_TestScaleIntensityRangePercentilesd.test_relative_scaling_TestScaleIntensityRangePercentilesd.test_relative_scaling.self_assertTrue_np_allclo": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentilesd.py_TestScaleIntensityRangePercentilesd.test_relative_scaling_TestScaleIntensityRangePercentilesd.test_relative_scaling.self_assertTrue_np_allclo", "embedding": null, "metadata": {"file_path": "tests/test_scale_intensity_range_percentilesd.py", "file_name": "test_scale_intensity_range_percentilesd.py", "file_type": "text/x-python", "category": "test", "start_line": 39, "end_line": 58, "span_ids": ["TestScaleIntensityRangePercentilesd.test_relative_scaling"], "tokens": 237}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestScaleIntensityRangePercentilesd(NumpyImageTestCase2D):\n\n def test_relative_scaling(self):\n img = self.imt\n data = dict()\n data[\"img\"] = img\n lower = 10\n upper = 99\n b_min = 100\n b_max = 300\n scaler = ScaleIntensityRangePercentilesd(\n keys=data.keys(), lower=lower, upper=upper, b_min=b_min, b_max=b_max, relative=True\n )\n\n expected_a_min = np.percentile(img, lower)\n expected_a_max = np.percentile(img, upper)\n expected_b_min = ((b_max - b_min) * (lower / 100.0)) + b_min\n expected_b_max = ((b_max - b_min) * (upper / 100.0)) + b_min\n expected_img = (img - expected_a_min) / (expected_a_max - expected_a_min)\n expected_img = (expected_img * (expected_b_max - expected_b_min)) + expected_b_min\n\n self.assertTrue(np.allclose(expected_img, scaler(data)[\"img\"]))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentilesd.py_TestScaleIntensityRangePercentilesd.test_invalid_instantiation_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_range_percentilesd.py_TestScaleIntensityRangePercentilesd.test_invalid_instantiation_", "embedding": null, "metadata": {"file_path": "tests/test_scale_intensity_range_percentilesd.py", "file_name": "test_scale_intensity_range_percentilesd.py", "file_type": "text/x-python", "category": "test", "start_line": 60, "end_line": 77, "span_ids": ["TestScaleIntensityRangePercentilesd.test_invalid_instantiation", "impl"], "tokens": 189}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestScaleIntensityRangePercentilesd(NumpyImageTestCase2D):\n\n def test_invalid_instantiation(self):\n self.assertRaises(\n AssertionError, ScaleIntensityRangePercentilesd, keys=[\"img\"], lower=-1, upper=99, b_min=0, b_max=255\n )\n self.assertRaises(\n AssertionError, ScaleIntensityRangePercentilesd, keys=[\"img\"], lower=101, upper=99, b_min=0, b_max=255\n )\n self.assertRaises(\n AssertionError, ScaleIntensityRangePercentilesd, keys=[\"img\"], lower=30, upper=-2, b_min=0, b_max=255\n )\n self.assertRaises(\n AssertionError, ScaleIntensityRangePercentilesd, keys=[\"img\"], lower=30, upper=1000, b_min=0, b_max=255\n )\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_ranged.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensity_ranged.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_scale_intensity_ranged.py", "file_name": "test_scale_intensity_ranged.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 32, "span_ids": ["IntensityScaleIntensityRanged", "IntensityScaleIntensityRanged.test_image_scale_intensity_ranged", "impl", "docstring"], "tokens": 150}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\n\nfrom monai.transforms import ScaleIntensityRanged\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass IntensityScaleIntensityRanged(NumpyImageTestCase2D):\n def test_image_scale_intensity_ranged(self):\n key = \"img\"\n scaler = ScaleIntensityRanged(keys=key, a_min=20, a_max=108, b_min=50, b_max=80)\n scaled = scaler({key: self.imt})\n expected = (self.imt - 20) / 88\n expected = expected * 30 + 50\n self.assertTrue(np.allclose(scaled[key], expected))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensityd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_scale_intensityd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_scale_intensityd.py", "file_name": "test_scale_intensityd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 40, "span_ids": ["impl", "TestScaleIntensityd", "TestScaleIntensityd.test_factor_scale", "docstring", "TestScaleIntensityd.test_range_scale"], "tokens": 252}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom monai.transforms import ScaleIntensityd\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestScaleIntensityd(NumpyImageTestCase2D):\n def test_range_scale(self):\n key = \"img\"\n scaler = ScaleIntensityd(keys=[key], minv=1.0, maxv=2.0)\n result = scaler({key: self.imt})\n mina = np.min(self.imt)\n maxa = np.max(self.imt)\n norm = (self.imt - mina) / (maxa - mina)\n expected = (norm * (2.0 - 1.0)) + 1.0\n np.testing.assert_allclose(result[key], expected)\n\n def test_factor_scale(self):\n key = \"img\"\n scaler = ScaleIntensityd(keys=[key], minv=None, maxv=None, factor=0.1)\n result = scaler({key: self.imt})\n expected = (self.imt * (1 + 0.1)).astype(np.float32)\n np.testing.assert_allclose(result[key], expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_se_block.py_unittest_for_type_1_in_.for_type_2_in_.TEST_CASES_3D_append_test": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_se_block.py_unittest_for_type_1_in_.for_type_2_in_.TEST_CASES_3D_append_test", "embedding": null, "metadata": {"file_path": "tests/test_se_block.py", "file_name": "test_se_block.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 56, "span_ids": ["docstring"], "tokens": 493}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.networks.blocks import SEBlock\nfrom monai.networks.layers.factories import Act, Norm\n\nTEST_CASES = [\n [\n {\"spatial_dims\": 2, \"in_channels\": 4, \"n_chns_1\": 20, \"n_chns_2\": 30, \"n_chns_3\": 4, \"r\": 2},\n torch.randn(7, 4, 64, 48), # 4-channel 2D, batch 7\n (7, 4, 64, 48),\n ],\n [\n {\"spatial_dims\": 1, \"in_channels\": 3, \"n_chns_1\": 20, \"n_chns_2\": 30, \"n_chns_3\": 40, \"r\": 5},\n torch.randn(16, 3, 63), # 3-channel 1D, batch 16\n (16, 40, 63),\n ],\n]\n\nTEST_CASES_3D = []\nfor type_1 in (\n {\"kernel_size\": 3, \"act\": Act.PRELU, \"norm\": Norm.INSTANCE},\n {\"kernel_size\": 1, \"act\": None, \"norm\": Norm.INSTANCE},\n):\n for type_2 in (\n {\"kernel_size\": 3, \"act\": Act.PRELU, \"norm\": Norm.INSTANCE},\n {\"kernel_size\": 1, \"act\": None, \"norm\": Norm.INSTANCE},\n ):\n test_case = [\n {\n \"spatial_dims\": 3,\n \"in_channels\": 10,\n \"r\": 3,\n \"n_chns_1\": 3,\n \"n_chns_2\": 5,\n \"n_chns_3\": 11,\n \"conv_param_1\": type_1,\n \"conv_param_3\": type_2,\n },\n torch.randn(16, 10, 32, 24, 48), # 10-channel 3D, batch 16\n (16, 11, 32, 24, 48),\n ]\n TEST_CASES_3D.append(test_case)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_se_block.py_TestSEBlockLayer_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_se_block.py_TestSEBlockLayer_", "embedding": null, "metadata": {"file_path": "tests/test_se_block.py", "file_name": "test_se_block.py", "file_type": "text/x-python", "category": "test", "start_line": 59, "end_line": 75, "span_ids": ["TestSEBlockLayer.test_shape", "impl:10", "TestSEBlockLayer.test_ill_arg", "TestSEBlockLayer"], "tokens": 145}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestSEBlockLayer(unittest.TestCase):\n @parameterized.expand(TEST_CASES + TEST_CASES_3D)\n def test_shape(self, input_param, input_data, expected_shape):\n net = SEBlock(**input_param)\n net.eval()\n with torch.no_grad():\n result = net(input_data)\n self.assertEqual(result.shape, expected_shape)\n\n def test_ill_arg(self):\n with self.assertRaises(ValueError):\n SEBlock(spatial_dims=1, in_channels=4, n_chns_1=2, n_chns_2=3, n_chns_3=4, r=100)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_se_blocks.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_se_blocks.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_se_blocks.py", "file_name": "test_se_blocks.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 65, "span_ids": ["TestResidualSELayer", "impl:10", "TestChannelSELayer.test_ill_arg", "docstring", "TestChannelSELayer.test_shape", "TestChannelSELayer", "TestResidualSELayer.test_shape"], "tokens": 510}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.networks.blocks import ChannelSELayer, ResidualSELayer\n\nTEST_CASES = [ # single channel 3D, batch 16\n [{\"spatial_dims\": 2, \"in_channels\": 4, \"r\": 3}, torch.randn(7, 4, 64, 48), (7, 4, 64, 48)], # 4-channel 2D, batch 7\n [ # 4-channel 1D, batch 16\n {\"spatial_dims\": 1, \"in_channels\": 4, \"r\": 3, \"acti_type_1\": \"relu\"},\n torch.randn(16, 4, 63),\n (16, 4, 63),\n ],\n]\n\nTEST_CASES_3D = []\nfor type_1 in {\"relu\", \"relu6\", \"leakyrelu\"}:\n for type_2 in {\"prelu\", \"sigmoid\", \"relu\"}:\n test_case = [\n {\"spatial_dims\": 3, \"in_channels\": 10, \"r\": 3, \"acti_type_1\": type_1, \"acti_type_2\": type_2},\n torch.randn(16, 10, 32, 24, 48),\n (16, 10, 32, 24, 48),\n ]\n TEST_CASES_3D.append(test_case)\n\n\nclass TestChannelSELayer(unittest.TestCase):\n @parameterized.expand(TEST_CASES + TEST_CASES_3D)\n def test_shape(self, input_param, input_data, expected_shape):\n net = ChannelSELayer(**input_param)\n net.eval()\n with torch.no_grad():\n result = net(input_data)\n self.assertEqual(result.shape, expected_shape)\n\n def test_ill_arg(self):\n with self.assertRaises(ValueError):\n ChannelSELayer(spatial_dims=1, in_channels=4, r=100)\n\n\nclass TestResidualSELayer(unittest.TestCase):\n @parameterized.expand(TEST_CASES[:1])\n def test_shape(self, input_param, input_data, expected_shape):\n net = ResidualSELayer(**input_param)\n net.eval()\n with torch.no_grad():\n result = net(input_data)\n self.assertEqual(result.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_seg_loss_integration.py_unittest_TEST_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_seg_loss_integration.py_unittest_TEST_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_seg_loss_integration.py", "file_name": "test_seg_loss_integration.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 34, "span_ids": ["docstring"], "tokens": 350}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nimport torch.nn as nn\nimport torch.optim as optim\nfrom parameterized import parameterized\n\nfrom monai.losses import DiceLoss, FocalLoss, GeneralizedDiceLoss, TverskyLoss\n\nTEST_CASES = [\n [DiceLoss, {\"to_onehot_y\": True, \"squared_pred\": True}, {\"smooth\": 1e-4}],\n [DiceLoss, {\"to_onehot_y\": True, \"sigmoid\": True}, {}],\n [DiceLoss, {\"to_onehot_y\": True, \"softmax\": True}, {}],\n [FocalLoss, {\"gamma\": 1.5, \"weight\": torch.tensor([1, 2])}, {}],\n [FocalLoss, {\"gamma\": 1.5}, {}],\n [GeneralizedDiceLoss, {\"to_onehot_y\": True, \"softmax\": True}, {}],\n [GeneralizedDiceLoss, {\"to_onehot_y\": True, \"sigmoid\": True}, {}],\n [GeneralizedDiceLoss, {\"to_onehot_y\": True, \"sigmoid\": True, \"w_type\": \"simple\"}, {}],\n [GeneralizedDiceLoss, {\"to_onehot_y\": True, \"sigmoid\": True, \"w_type\": \"uniform\"}, {}],\n [TverskyLoss, {\"to_onehot_y\": True, \"softmax\": True, \"alpha\": 0.8, \"beta\": 0.2}, {}],\n [TverskyLoss, {\"to_onehot_y\": True, \"softmax\": True, \"alpha\": 1.0, \"beta\": 0.0}, {}],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_seg_loss_integration.py_TestSegLossIntegration_TestSegLossIntegration.test_convergence._define_a_one_layer_mode": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_seg_loss_integration.py_TestSegLossIntegration_TestSegLossIntegration.test_convergence._define_a_one_layer_mode", "embedding": null, "metadata": {"file_path": "tests/test_seg_loss_integration.py", "file_name": "test_seg_loss_integration.py", "file_type": "text/x-python", "category": "test", "start_line": 37, "end_line": 79, "span_ids": ["TestSegLossIntegration.setUp", "TestSegLossIntegration.test_convergence", "TestSegLossIntegration", "TestSegLossIntegration.tearDown"], "tokens": 458}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestSegLossIntegration(unittest.TestCase):\n def setUp(self):\n torch.backends.cudnn.deterministic = True\n torch.backends.cudnn.benchmark = False\n torch.manual_seed(0)\n self.device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu:0\")\n\n def tearDown(self):\n torch.backends.cudnn.deterministic = False\n torch.backends.cudnn.benchmark = True\n\n @parameterized.expand(TEST_CASES)\n def test_convergence(self, loss_type, loss_args, forward_args):\n \"\"\"\n The goal of this test is to assess if the gradient of the loss function\n is correct by testing if we can train a one layer neural network\n to segment one image.\n We verify that the loss is decreasing in almost all SGD steps.\n \"\"\"\n learning_rate = 0.001\n max_iter = 40\n\n # define a simple 3d example\n target_seg = torch.tensor(\n [\n [\n # raw 0\n [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]],\n # raw 1\n [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]],\n # raw 2\n [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]],\n ]\n ],\n device=self.device,\n )\n target_seg = torch.unsqueeze(target_seg, dim=0)\n image = 12 * target_seg + 27\n image = image.float().to(self.device)\n num_classes = 2\n num_voxels = 3 * 4 * 4\n\n # define a one layer model\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_seg_loss_integration.py_TestSegLossIntegration.test_convergence.OnelayerNet_TestSegLossIntegration.test_convergence.OnelayerNet.forward.return.x": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_seg_loss_integration.py_TestSegLossIntegration.test_convergence.OnelayerNet_TestSegLossIntegration.test_convergence.OnelayerNet.forward.return.x", "embedding": null, "metadata": {"file_path": "tests/test_seg_loss_integration.py", "file_name": "test_seg_loss_integration.py", "file_type": "text/x-python", "category": "test", "start_line": 80, "end_line": 93, "span_ids": ["TestSegLossIntegration.test_convergence"], "tokens": 185}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestSegLossIntegration(unittest.TestCase):\n\n @parameterized.expand(TEST_CASES)\n def test_convergence(self, loss_type, loss_args, forward_args):\n # ... other code\n class OnelayerNet(nn.Module):\n def __init__(self):\n super(OnelayerNet, self).__init__()\n self.layer_1 = nn.Linear(num_voxels, 200)\n self.acti = nn.ReLU()\n self.layer_2 = nn.Linear(200, num_voxels * num_classes)\n\n def forward(self, x):\n x = x.view(-1, num_voxels)\n x = self.layer_1(x)\n x = self.acti(x)\n x = self.layer_2(x)\n x = x.view(-1, num_classes, 3, 4, 4)\n return x\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_seg_loss_integration.py_TestSegLossIntegration.test_convergence._initialise_the_network_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_seg_loss_integration.py_TestSegLossIntegration.test_convergence._initialise_the_network_", "embedding": null, "metadata": {"file_path": "tests/test_seg_loss_integration.py", "file_name": "test_seg_loss_integration.py", "file_type": "text/x-python", "category": "test", "start_line": 95, "end_line": 141, "span_ids": ["impl:3", "TestSegLossIntegration.test_convergence"], "tokens": 353}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestSegLossIntegration(unittest.TestCase):\n\n @parameterized.expand(TEST_CASES)\n def test_convergence(self, loss_type, loss_args, forward_args):\n\n # initialise the network\n net = OnelayerNet().to(self.device)\n\n # initialize the loss\n loss = loss_type(**loss_args)\n\n # initialize a SGD optimizer\n optimizer = optim.Adam(net.parameters(), lr=learning_rate)\n\n loss_history = []\n init_output = None\n\n # train the network\n for iter_i in range(max_iter):\n # set the gradient to zero\n optimizer.zero_grad()\n\n # forward pass\n output = net(image)\n if init_output is None:\n init_output = torch.argmax(output, 1).detach().cpu().numpy()\n\n loss_val = loss(output, target_seg, **forward_args)\n\n if iter_i % 10 == 0:\n pred = torch.argmax(output, 1).detach().cpu().numpy()\n gt = target_seg.detach().cpu().numpy()[:, 0]\n print(f\"{loss_type.__name__} iter: {iter_i}, acc: {np.sum(pred == gt) / np.prod(pred.shape)}\")\n\n # backward pass\n loss_val.backward()\n optimizer.step()\n\n # stats\n loss_history.append(loss_val.item())\n\n pred = torch.argmax(output, 1).detach().cpu().numpy()\n target = target_seg.detach().cpu().numpy()[:, 0]\n # initial predictions are bad\n self.assertTrue(not np.allclose(init_output, target))\n # final predictions are good\n np.testing.assert_allclose(pred, target)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_set_determinism.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_set_determinism.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_set_determinism.py", "file_name": "test_set_determinism.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 50, "span_ids": ["impl", "TestSetDeterminism.test_values", "TestSetDeterminism", "docstring"], "tokens": 282}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport torch\nimport numpy as np\nfrom monai.utils import set_determinism, get_seed\n\n\nclass TestSetDeterminism(unittest.TestCase):\n def test_values(self):\n # check system default flags\n self.assertTrue(not torch.backends.cudnn.deterministic)\n self.assertTrue(get_seed() is None)\n # set default seed\n set_determinism()\n self.assertTrue(get_seed() is not None)\n self.assertTrue(torch.backends.cudnn.deterministic)\n self.assertTrue(not torch.backends.cudnn.benchmark)\n # resume default\n set_determinism(None)\n self.assertTrue(not torch.backends.cudnn.deterministic)\n self.assertTrue(not torch.backends.cudnn.benchmark)\n self.assertTrue(get_seed() is None)\n # test seeds\n seed = 255\n set_determinism(seed=seed)\n self.assertEqual(seed, get_seed())\n a = np.random.randint(seed)\n b = torch.randint(seed, (1,))\n set_determinism(seed=seed)\n c = np.random.randint(seed)\n d = torch.randint(seed, (1,))\n self.assertEqual(a, c)\n self.assertEqual(b, d)\n self.assertTrue(torch.backends.cudnn.deterministic)\n self.assertTrue(not torch.backends.cudnn.benchmark)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_shift_intensity.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_shift_intensity.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_shift_intensity.py", "file_name": "test_shift_intensity.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 29, "span_ids": ["TestShiftIntensity.test_value", "TestShiftIntensity", "impl", "docstring"], "tokens": 99}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom monai.transforms import ShiftIntensity\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestShiftIntensity(NumpyImageTestCase2D):\n def test_value(self):\n shifter = ShiftIntensity(offset=1.0)\n result = shifter(self.imt)\n expected = self.imt + 1.0\n np.testing.assert_allclose(result, expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_shift_intensityd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_shift_intensityd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_shift_intensityd.py", "file_name": "test_shift_intensityd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 30, "span_ids": ["TestShiftIntensityd", "TestShiftIntensityd.test_value", "impl", "docstring"], "tokens": 116}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom monai.transforms import ShiftIntensityd\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestShiftIntensityd(NumpyImageTestCase2D):\n def test_value(self):\n key = \"img\"\n shifter = ShiftIntensityd(keys=[key], offset=1.0)\n result = shifter({key: self.imt})\n expected = self.imt + 1.0\n np.testing.assert_allclose(result[key], expected)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_simple_aspp.py_unittest_TEST_ILL_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_simple_aspp.py_unittest_TEST_ILL_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_simple_aspp.py", "file_name": "test_simple_aspp.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 64, "span_ids": ["docstring"], "tokens": 562}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport torch\nfrom monai.networks.blocks import SimpleASPP\nfrom parameterized import parameterized\n\nTEST_CASES = [\n [ # 32-channel 2D, batch 7\n {\"spatial_dims\": 2, \"in_channels\": 32, \"conv_out_channels\": 3},\n torch.randn(7, 32, 18, 20),\n (7, 12, 18, 20),\n ],\n [ # 4-channel 1D, batch 16\n {\"spatial_dims\": 1, \"in_channels\": 4, \"conv_out_channels\": 8},\n torch.randn(16, 4, 17),\n (16, 32, 17),\n ],\n [ # 3-channel 3D, batch 16\n {\"spatial_dims\": 3, \"in_channels\": 3, \"conv_out_channels\": 2},\n torch.randn(16, 3, 17, 18, 19),\n (16, 8, 17, 18, 19),\n ],\n [ # 3-channel 3D, batch 16\n {\n \"spatial_dims\": 3,\n \"in_channels\": 3,\n \"conv_out_channels\": 2,\n \"kernel_sizes\": (1, 3, 3),\n \"dilations\": (1, 2, 4),\n },\n torch.randn(16, 3, 17, 18, 19),\n (16, 6, 17, 18, 19),\n ],\n]\n\nTEST_ILL_CASES = [\n [ # 3-channel 3D, batch 16, wrong k and d sizes.\n {\"spatial_dims\": 3, \"in_channels\": 3, \"conv_out_channels\": 2, \"kernel_sizes\": (1, 3, 3), \"dilations\": (1, 2)},\n torch.randn(16, 3, 17, 18, 19),\n ValueError,\n ],\n [ # 3-channel 3D, batch 16, wrong k and d sizes.\n {\n \"spatial_dims\": 3,\n \"in_channels\": 3,\n \"conv_out_channels\": 2,\n \"kernel_sizes\": (1, 3, 4),\n \"dilations\": (1, 2, 3),\n },\n torch.randn(16, 3, 17, 18, 19),\n NotImplementedError, # unknown padding k=4, d=3\n ],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_simple_aspp.py_TestChannelSELayer_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_simple_aspp.py_TestChannelSELayer_", "embedding": null, "metadata": {"file_path": "tests/test_simple_aspp.py", "file_name": "test_simple_aspp.py", "file_type": "text/x-python", "category": "test", "start_line": 67, "end_line": 84, "span_ids": ["TestChannelSELayer.test_shape", "impl:5", "TestChannelSELayer", "TestChannelSELayer.test_ill_args"], "tokens": 123}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestChannelSELayer(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_shape(self, input_param, input_data, expected_shape):\n net = SimpleASPP(**input_param)\n net.eval()\n with torch.no_grad():\n result = net(input_data)\n self.assertEqual(result.shape, expected_shape)\n\n @parameterized.expand(TEST_ILL_CASES)\n def test_ill_args(self, input_param, input_data, error_type):\n with self.assertRaises(error_type):\n SimpleASPP(**input_param)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_simulatedelay.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_simulatedelay.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_simulatedelay.py", "file_name": "test_simulatedelay.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 33, "span_ids": ["TestSimulateDelay.test_value", "TestSimulateDelay", "impl", "docstring"], "tokens": 161}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport time\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms.utility.array import SimulateDelay\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestSimulateDelay(NumpyImageTestCase2D):\n @parameterized.expand([(0.45,), (1,)])\n def test_value(self, delay_test_time: float):\n resize = SimulateDelay(delay_time=delay_test_time)\n start: float = time.time()\n result = resize(self.imt[0])\n stop: float = time.time()\n measured_approximate: float = stop - start\n np.testing.assert_allclose(delay_test_time, measured_approximate, rtol=0.5)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_simulatedelayd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_simulatedelayd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_simulatedelayd.py", "file_name": "test_simulatedelayd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 33, "span_ids": ["TestSimulateDelay.test_value", "TestSimulateDelay", "impl", "docstring"], "tokens": 172}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport time\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms.utility.dictionary import SimulateDelayd\nfrom tests.utils import NumpyImageTestCase2D\n\n\nclass TestSimulateDelay(NumpyImageTestCase2D):\n @parameterized.expand([(0.45,), (1,)])\n def test_value(self, delay_test_time: float):\n resize = SimulateDelayd(keys=\"imgd\", delay_time=delay_test_time)\n start: float = time.time()\n _ = resize({\"imgd\": self.imt[0]})\n stop: float = time.time()\n measured_approximate: float = stop - start\n np.testing.assert_allclose(delay_test_time, measured_approximate, rtol=0.5)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_sliding_window_inference.py_unittest_TEST_CASE_7._1_3_16_15_7_4_1": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_sliding_window_inference.py_unittest_TEST_CASE_7._1_3_16_15_7_4_1", "embedding": null, "metadata": {"file_path": "tests/test_sliding_window_inference.py", "file_name": "test_sliding_window_inference.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 33, "span_ids": ["docstring"], "tokens": 396}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.inferers import sliding_window_inference\n\nTEST_CASE_0 = [(1, 3, 16, 15, 7), (4, -1, 7), 3, 0.25, \"constant\"] # 3D small roi\n\nTEST_CASE_1 = [(1, 3, 16, 15, 7), (4, 10, 7), 3, 0.25, \"constant\"] # 3D small roi\n\nTEST_CASE_2 = [(1, 3, 16, 15, 7), (20, 22, 23), 10, 0.25, \"constant\"] # 3D large roi\n\nTEST_CASE_3 = [(1, 3, 15, 7), (2, 6), 1000, 0.25, \"constant\"] # 2D small roi, large batch\n\nTEST_CASE_4 = [(1, 3, 16, 7), (80, 50), 7, 0.25, \"constant\"] # 2D large roi\n\nTEST_CASE_5 = [(1, 3, 16, 15, 7), (20, 22, 23), 10, 0.5, \"constant\"] # 3D large overlap\n\nTEST_CASE_6 = [(1, 3, 16, 7), (80, 50), 7, 0.5, \"gaussian\"] # 2D large overlap, gaussian\n\nTEST_CASE_7 = [(1, 3, 16, 15, 7), (4, 10, 7), 3, 0.25, \"gaussian\"]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_sliding_window_inference.py__3D_small_roi_gaussian_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_sliding_window_inference.py__3D_small_roi_gaussian_", "embedding": null, "metadata": {"file_path": "tests/test_sliding_window_inference.py", "file_name": "test_sliding_window_inference.py", "file_type": "text/x-python", "category": "test", "start_line": 33, "end_line": 54, "span_ids": ["TestSlidingWindowInference", "docstring:18", "impl:17", "TestSlidingWindowInference.test_sliding_window_default"], "tokens": 192}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": " # 3D small roi, gaussian\n\n\nclass TestSlidingWindowInference(unittest.TestCase):\n @parameterized.expand(\n [TEST_CASE_0, TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5, TEST_CASE_6, TEST_CASE_7]\n )\n def test_sliding_window_default(self, image_shape, roi_shape, sw_batch_size, overlap, mode):\n inputs = torch.ones(*image_shape)\n device = torch.device(\"cpu:0\")\n\n def compute(data):\n return data + 1\n\n result = sliding_window_inference(inputs.to(device), roi_shape, sw_batch_size, compute, overlap, mode=mode)\n expected_val = np.ones(image_shape, dtype=np.float32) + 1\n self.assertTrue(np.allclose(result.numpy(), expected_val))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacing.py_unittest_TEST_CASES": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacing.py_unittest_TEST_CASES", "embedding": null, "metadata": {"file_path": "tests/test_spacing.py", "file_name": "test_spacing.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 141, "span_ids": ["docstring"], "tokens": 39}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.transforms import Spacing\nfrom monai.utils import ensure_tuple\n\nTEST_CASES =\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacing.py_TestSpacingCase_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacing.py_TestSpacingCase_", "embedding": null, "metadata": {"file_path": "tests/test_spacing.py", "file_name": "test_spacing.py", "file_type": "text/x-python", "category": "test", "start_line": 144, "end_line": 163, "span_ids": ["TestSpacingCase.test_spacing", "impl:3", "TestSpacingCase", "TestSpacingCase.test_ill_pixdim"], "tokens": 216}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestSpacingCase(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_spacing(self, init_param, img, data_param, expected_output):\n res = Spacing(**init_param)(img, **data_param)\n np.testing.assert_allclose(res[0], expected_output, atol=1e-6)\n sr = len(res[0].shape) - 1\n if isinstance(init_param[\"pixdim\"], float):\n init_param[\"pixdim\"] = [init_param[\"pixdim\"]] * sr\n init_pixdim = ensure_tuple(init_param[\"pixdim\"])\n init_pixdim = init_param[\"pixdim\"][:sr]\n np.testing.assert_allclose(init_pixdim[:sr], np.sqrt(np.sum(np.square(res[2]), axis=0))[:sr])\n\n def test_ill_pixdim(self):\n with self.assertRaises(ValueError):\n Spacing(pixdim=(-1, 2.0))(np.zeros((1, 1)))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacingd.py_unittest_TestSpacingDCase.test_spacingd_3d.None_2": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacingd.py_unittest_TestSpacingDCase.test_spacingd_3d.None_2", "embedding": null, "metadata": {"file_path": "tests/test_spacingd.py", "file_name": "test_spacingd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 26, "span_ids": ["TestSpacingDCase.test_spacingd_3d", "TestSpacingDCase", "docstring"], "tokens": 171}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\n\nfrom monai.transforms import Spacingd\n\n\nclass TestSpacingDCase(unittest.TestCase):\n def test_spacingd_3d(self):\n data = {\"image\": np.ones((2, 10, 15, 20)), \"image_meta_dict\": {\"affine\": np.eye(4)}}\n spacing = Spacingd(keys=\"image\", pixdim=(1, 2, 1.4))\n res = spacing(data)\n self.assertEqual((\"image\", \"image_meta_dict\"), tuple(sorted(res)))\n np.testing.assert_allclose(res[\"image\"].shape, (2, 10, 8, 15))\n np.testing.assert_allclose(res[\"image_meta_dict\"][\"affine\"], np.diag([1, 2, 1.4, 1.0]))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacingd.py_TestSpacingDCase.test_spacingd_2d_TestSpacingDCase.test_spacingd_2d.None_2": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacingd.py_TestSpacingDCase.test_spacingd_2d_TestSpacingDCase.test_spacingd_2d.None_2", "embedding": null, "metadata": {"file_path": "tests/test_spacingd.py", "file_name": "test_spacingd.py", "file_type": "text/x-python", "category": "test", "start_line": 28, "end_line": 34, "span_ids": ["TestSpacingDCase.test_spacingd_2d"], "tokens": 141}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestSpacingDCase(unittest.TestCase):\n\n def test_spacingd_2d(self):\n data = {\"image\": np.ones((2, 10, 20)), \"image_meta_dict\": {\"affine\": np.eye(3)}}\n spacing = Spacingd(keys=\"image\", pixdim=(1, 2, 1.4))\n res = spacing(data)\n self.assertEqual((\"image\", \"image_meta_dict\"), tuple(sorted(res)))\n np.testing.assert_allclose(res[\"image\"].shape, (2, 10, 10))\n np.testing.assert_allclose(res[\"image_meta_dict\"][\"affine\"], np.diag((1, 2, 1)))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacingd.py_TestSpacingDCase.test_interp_all_TestSpacingDCase.test_interp_all.None_2": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacingd.py_TestSpacingDCase.test_interp_all_TestSpacingDCase.test_interp_all.None_2", "embedding": null, "metadata": {"file_path": "tests/test_spacingd.py", "file_name": "test_spacingd.py", "file_type": "text/x-python", "category": "test", "start_line": 36, "end_line": 47, "span_ids": ["TestSpacingDCase.test_interp_all"], "tokens": 193}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestSpacingDCase(unittest.TestCase):\n\n def test_interp_all(self):\n data = {\n \"image\": np.arange(20).reshape((2, 1, 10)),\n \"seg\": np.ones((2, 1, 10)),\n \"image_meta_dict\": {\"affine\": np.eye(4)},\n \"seg_meta_dict\": {\"affine\": np.eye(4)},\n }\n spacing = Spacingd(keys=(\"image\", \"seg\"), mode=\"nearest\", pixdim=(1, 0.2,))\n res = spacing(data)\n self.assertEqual((\"image\", \"image_meta_dict\", \"seg\", \"seg_meta_dict\"), tuple(sorted(res)))\n np.testing.assert_allclose(res[\"image\"].shape, (2, 1, 46))\n np.testing.assert_allclose(res[\"image_meta_dict\"][\"affine\"], np.diag((1, 0.2, 1, 1)))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacingd.py_TestSpacingDCase.test_interp_sep_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spacingd.py_TestSpacingDCase.test_interp_sep_", "embedding": null, "metadata": {"file_path": "tests/test_spacingd.py", "file_name": "test_spacingd.py", "file_type": "text/x-python", "category": "test", "start_line": 49, "end_line": 65, "span_ids": ["TestSpacingDCase.test_interp_sep", "impl"], "tokens": 205}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestSpacingDCase(unittest.TestCase):\n\n def test_interp_sep(self):\n data = {\n \"image\": np.ones((2, 1, 10)),\n \"seg\": np.ones((2, 1, 10)),\n \"image_meta_dict\": {\"affine\": np.eye(4)},\n \"seg_meta_dict\": {\"affine\": np.eye(4)},\n }\n spacing = Spacingd(keys=(\"image\", \"seg\"), mode=(\"bilinear\", \"nearest\"), pixdim=(1, 0.2,))\n res = spacing(data)\n self.assertEqual((\"image\", \"image_meta_dict\", \"seg\", \"seg_meta_dict\"), tuple(sorted(res)))\n np.testing.assert_allclose(res[\"image\"].shape, (2, 1, 46))\n np.testing.assert_allclose(res[\"image_meta_dict\"][\"affine\"], np.diag((1, 0.2, 1, 1)))\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spatial_crop.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spatial_crop.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_spatial_crop.py", "file_name": "test_spatial_crop.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 43, "span_ids": ["impl:9", "TestSpatialCrop.test_shape", "TestSpatialCrop", "docstring"], "tokens": 382}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import SpatialCrop\n\nTEST_CASE_1 = [\n {\"roi_center\": [1, 1, 1], \"roi_size\": [2, 2, 2]},\n np.random.randint(0, 2, size=[3, 3, 3, 3]),\n (3, 2, 2, 2),\n]\n\nTEST_CASE_2 = [{\"roi_start\": [0, 0, 0], \"roi_end\": [2, 2, 2]}, np.random.randint(0, 2, size=[3, 3, 3, 3]), (3, 2, 2, 2)]\n\nTEST_CASE_3 = [{\"roi_start\": [0, 0], \"roi_end\": [2, 2]}, np.random.randint(0, 2, size=[3, 3, 3, 3]), (3, 2, 2, 3)]\n\nTEST_CASE_4 = [\n {\"roi_start\": [0, 0, 0, 0, 0], \"roi_end\": [2, 2, 2, 2, 2]},\n np.random.randint(0, 2, size=[3, 3, 3, 3]),\n (3, 2, 2, 2),\n]\n\n\nclass TestSpatialCrop(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4])\n def test_shape(self, input_param, input_data, expected_shape):\n result = SpatialCrop(**input_param)(input_data)\n self.assertTupleEqual(result.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spatial_cropd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spatial_cropd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_spatial_cropd.py", "file_name": "test_spatial_cropd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 51, "span_ids": ["TestSpatialCropd.test_shape", "impl:9", "TestSpatialCropd", "docstring"], "tokens": 438}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import SpatialCropd\n\nTEST_CASE_1 = [\n {\"keys\": [\"img\"], \"roi_center\": [1, 1, 1], \"roi_size\": [2, 2, 2]},\n {\"img\": np.random.randint(0, 2, size=[3, 3, 3, 3])},\n (3, 2, 2, 2),\n]\n\nTEST_CASE_2 = [\n {\"keys\": [\"img\"], \"roi_start\": [0, 0, 0], \"roi_end\": [2, 2, 2]},\n {\"img\": np.random.randint(0, 2, size=[3, 3, 3, 3])},\n (3, 2, 2, 2),\n]\n\nTEST_CASE_3 = [\n {\"keys\": [\"img\"], \"roi_start\": [0, 0], \"roi_end\": [2, 2]},\n {\"img\": np.random.randint(0, 2, size=[3, 3, 3, 3])},\n (3, 2, 2, 3),\n]\n\nTEST_CASE_4 = [\n {\"keys\": [\"img\"], \"roi_start\": [0, 0, 0, 0, 0], \"roi_end\": [2, 2, 2, 2, 2]},\n {\"img\": np.random.randint(0, 2, size=[3, 3, 3, 3])},\n (3, 2, 2, 2),\n]\n\n\nclass TestSpatialCropd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4])\n def test_shape(self, input_param, input_data, expected_shape):\n result = SpatialCropd(**input_param)(input_data)\n self.assertTupleEqual(result[\"img\"].shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spatial_pad.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spatial_pad.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_spatial_pad.py", "file_name": "test_spatial_pad.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 48, "span_ids": ["TestSpatialPad.test_pad_shape", "TestSpatialPad", "impl:7", "docstring"], "tokens": 331}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import SpatialPad\n\nTEST_CASE_1 = [\n {\"spatial_size\": [15, 8, 8], \"method\": \"symmetric\", \"mode\": \"constant\"},\n np.zeros((3, 8, 8, 4)),\n np.zeros((3, 15, 8, 8)),\n]\n\nTEST_CASE_2 = [\n {\"spatial_size\": [15, 8, 8], \"method\": \"end\", \"mode\": \"constant\"},\n np.zeros((3, 8, 8, 4)),\n np.zeros((3, 15, 8, 8)),\n]\n\nTEST_CASE_3 = [\n {\"spatial_size\": [15, 4, -1], \"method\": \"symmetric\", \"mode\": \"constant\"},\n np.zeros((3, 8, 8, 4)),\n np.zeros((3, 15, 8, 4)),\n]\n\n\nclass TestSpatialPad(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_pad_shape(self, input_param, input_data, expected_val):\n padder = SpatialPad(**input_param)\n result = padder(input_data)\n np.testing.assert_allclose(result.shape, expected_val.shape)\n result = padder(input_data, mode=input_param[\"mode\"])\n np.testing.assert_allclose(result.shape, expected_val.shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spatial_padd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spatial_padd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_spatial_padd.py", "file_name": "test_spatial_padd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 52, "span_ids": ["impl:9", "TestSpatialPadd.test_pad_shape", "TestSpatialPadd", "docstring"], "tokens": 418}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import SpatialPadd\n\nTEST_CASE_1 = [\n {\"keys\": [\"img\"], \"spatial_size\": [15, 8, 8], \"method\": \"symmetric\", \"mode\": \"constant\"},\n {\"img\": np.zeros((3, 8, 8, 4))},\n np.zeros((3, 15, 8, 8)),\n]\n\nTEST_CASE_2 = [\n {\"keys\": [\"img\"], \"spatial_size\": [15, 8, 8], \"method\": \"end\", \"mode\": \"constant\"},\n {\"img\": np.zeros((3, 8, 8, 4))},\n np.zeros((3, 15, 8, 8)),\n]\n\nTEST_CASE_3 = [\n {\"keys\": [\"img\"], \"spatial_size\": [15, 8, 8], \"method\": \"end\", \"mode\": {\"constant\"}},\n {\"img\": np.zeros((3, 8, 8, 4))},\n np.zeros((3, 15, 8, 8)),\n]\n\nTEST_CASE_4 = [\n {\"keys\": [\"img\"], \"spatial_size\": [15, 8, -1], \"method\": \"end\", \"mode\": {\"constant\"}},\n {\"img\": np.zeros((3, 8, 4, 4))},\n np.zeros((3, 15, 8, 4)),\n]\n\n\nclass TestSpatialPadd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4])\n def test_pad_shape(self, input_param, input_data, expected_val):\n padder = SpatialPadd(**input_param)\n result = padder(input_data)\n np.testing.assert_allclose(result[\"img\"].shape, expected_val.shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_split_channel.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_split_channel.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_split_channel.py", "file_name": "test_split_channel.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 32, "span_ids": ["TestSplitChannel", "TestSplitChannel.test_shape", "impl:5", "docstring"], "tokens": 198}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport torch\nfrom parameterized import parameterized\nfrom monai.transforms import SplitChannel\n\nTEST_CASE_1 = [{\"to_onehot\": False}, torch.randint(0, 2, size=(4, 3, 3, 4)), (4, 1, 3, 4)]\n\nTEST_CASE_2 = [{\"to_onehot\": True, \"num_classes\": 3}, torch.randint(0, 3, size=(4, 1, 3, 4)), (4, 1, 3, 4)]\n\n\nclass TestSplitChannel(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2])\n def test_shape(self, input_param, test_data, expected_shape):\n result = SplitChannel(**input_param)(test_data)\n for data in result:\n self.assertTupleEqual(data.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_split_channeld.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_split_channeld.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_split_channeld.py", "file_name": "test_split_channeld.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 47, "span_ids": ["TestSplitChanneld.test_shape", "TestSplitChanneld", "impl:7", "docstring"], "tokens": 397}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport torch\nfrom parameterized import parameterized\nfrom monai.transforms import SplitChanneld\n\nTEST_CASE_1 = [\n {\"keys\": [\"pred\"], \"output_postfixes\": [\"cls1\", \"cls2\", \"cls3\"], \"to_onehot\": False},\n {\"pred\": torch.randint(0, 2, size=(4, 3, 3, 4))},\n (4, 1, 3, 4),\n]\n\nTEST_CASE_2 = [\n {\"keys\": [\"pred\"], \"output_postfixes\": [\"cls1\", \"cls2\", \"cls3\"], \"to_onehot\": True, \"num_classes\": 3},\n {\"pred\": torch.randint(0, 3, size=(4, 1, 3, 4))},\n (4, 1, 3, 4),\n]\n\nTEST_CASE_3 = [\n {\"keys\": [\"pred\", \"label\"], \"output_postfixes\": [\"cls1\", \"cls2\", \"cls3\"], \"to_onehot\": True, \"num_classes\": 3},\n {\"pred\": torch.randint(0, 3, size=(4, 1, 3, 4)), \"label\": torch.randint(0, 3, size=(4, 1, 3, 4))},\n (4, 1, 3, 4),\n]\n\n\nclass TestSplitChanneld(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_shape(self, input_param, test_data, expected_shape):\n result = SplitChanneld(**input_param)(test_data)\n for k, v in result.items():\n if \"cls\" in k:\n self.assertTupleEqual(v.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_squeezedim.py_unittest_TEST_CASE_6._dim_0_5_np_random_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_squeezedim.py_unittest_TEST_CASE_6._dim_0_5_np_random_", "embedding": null, "metadata": {"file_path": "tests/test_squeezedim.py", "file_name": "test_squeezedim.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 32, "span_ids": ["docstring"], "tokens": 262}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import SqueezeDim\n\nTEST_CASE_1 = [{\"dim\": None}, np.random.rand(1, 2, 1, 3), (2, 3)]\n\nTEST_CASE_2 = [{\"dim\": 2}, np.random.rand(1, 2, 1, 8, 16), (1, 2, 8, 16)]\n\nTEST_CASE_3 = [{\"dim\": -1}, np.random.rand(1, 1, 16, 8, 1), (1, 1, 16, 8)]\n\nTEST_CASE_4 = [{}, np.random.rand(1, 2, 1, 3), (2, 1, 3)]\n\nTEST_CASE_4_PT = [{}, torch.rand(1, 2, 1, 3), (2, 1, 3)]\n\nTEST_CASE_5 = [{\"dim\": -2}, np.random.rand(1, 1, 16, 8, 1)]\n\nTEST_CASE_6 = [{\"dim\": 0.5}, np.random.rand(1, 1, 16, 8, 1)]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_squeezedim.py_TestSqueezeDim_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_squeezedim.py_TestSqueezeDim_", "embedding": null, "metadata": {"file_path": "tests/test_squeezedim.py", "file_name": "test_squeezedim.py", "file_type": "text/x-python", "category": "test", "start_line": 35, "end_line": 49, "span_ids": ["impl:15", "TestSqueezeDim.test_invalid_inputs", "TestSqueezeDim.test_shape", "TestSqueezeDim"], "tokens": 137}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestSqueezeDim(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_4_PT])\n def test_shape(self, input_param, test_data, expected_shape):\n result = SqueezeDim(**input_param)(test_data)\n self.assertTupleEqual(result.shape, expected_shape)\n\n @parameterized.expand([TEST_CASE_5, TEST_CASE_6])\n def test_invalid_inputs(self, input_param, test_data):\n with self.assertRaises(ValueError):\n SqueezeDim(**input_param)(test_data)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_squeezedimd.py_unittest_TEST_CASE_6._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_squeezedimd.py_unittest_TEST_CASE_6._", "embedding": null, "metadata": {"file_path": "tests/test_squeezedimd.py", "file_name": "test_squeezedimd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 58, "span_ids": ["impl:11", "docstring"], "tokens": 576}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import SqueezeDimd\n\nTEST_CASE_1 = [\n {\"keys\": [\"img\", \"seg\"], \"dim\": None},\n {\"img\": np.random.rand(1, 2, 1, 3), \"seg\": np.random.randint(0, 2, size=[1, 2, 1, 3])},\n (2, 3),\n]\n\nTEST_CASE_2 = [\n {\"keys\": [\"img\", \"seg\"], \"dim\": 2},\n {\"img\": np.random.rand(1, 2, 1, 8, 16), \"seg\": np.random.randint(0, 2, size=[1, 2, 1, 8, 16])},\n (1, 2, 8, 16),\n]\n\nTEST_CASE_3 = [\n {\"keys\": [\"img\", \"seg\"], \"dim\": -1},\n {\"img\": np.random.rand(1, 1, 16, 8, 1), \"seg\": np.random.randint(0, 2, size=[1, 1, 16, 8, 1])},\n (1, 1, 16, 8),\n]\n\nTEST_CASE_4 = [\n {\"keys\": [\"img\", \"seg\"]},\n {\"img\": np.random.rand(1, 2, 1, 3), \"seg\": np.random.randint(0, 2, size=[1, 2, 1, 3])},\n (2, 1, 3),\n]\n\nTEST_CASE_4_PT = [\n {\"keys\": [\"img\", \"seg\"], \"dim\": 0},\n {\"img\": torch.rand(1, 2, 1, 3), \"seg\": torch.randint(0, 2, size=[1, 2, 1, 3])},\n (2, 1, 3),\n]\n\nTEST_CASE_5 = [\n {\"keys\": [\"img\", \"seg\"], \"dim\": -2},\n {\"img\": np.random.rand(1, 1, 16, 8, 1), \"seg\": np.random.randint(0, 2, size=[1, 1, 16, 8, 1])},\n]\n\nTEST_CASE_6 = [\n {\"keys\": [\"img\", \"seg\"], \"dim\": 0.5},\n {\"img\": np.random.rand(1, 1, 16, 8, 1), \"seg\": np.random.randint(0, 2, size=[1, 1, 16, 8, 1])},\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_squeezedimd.py_TestSqueezeDim_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_squeezedimd.py_TestSqueezeDim_", "embedding": null, "metadata": {"file_path": "tests/test_squeezedimd.py", "file_name": "test_squeezedimd.py", "file_type": "text/x-python", "category": "test", "start_line": 61, "end_line": 76, "span_ids": ["impl:15", "TestSqueezeDim.test_invalid_inputs", "TestSqueezeDim.test_shape", "TestSqueezeDim"], "tokens": 156}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestSqueezeDim(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_4_PT])\n def test_shape(self, input_param, test_data, expected_shape):\n result = SqueezeDimd(**input_param)(test_data)\n self.assertTupleEqual(result[\"img\"].shape, expected_shape)\n self.assertTupleEqual(result[\"seg\"].shape, expected_shape)\n\n @parameterized.expand([TEST_CASE_5, TEST_CASE_6])\n def test_invalid_inputs(self, input_param, test_data):\n with self.assertRaises(ValueError):\n SqueezeDimd(**input_param)(test_data)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_threshold_intensity.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_threshold_intensity.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_threshold_intensity.py", "file_name": "test_threshold_intensity.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 34, "span_ids": ["TestThresholdIntensity.test_value", "TestThresholdIntensity", "impl:7", "docstring"], "tokens": 267}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import ThresholdIntensity\n\nTEST_CASE_1 = [{\"threshold\": 5, \"above\": True, \"cval\": 0}, (0, 0, 0, 0, 0, 0, 6, 7, 8, 9)]\n\nTEST_CASE_2 = [{\"threshold\": 5, \"above\": False, \"cval\": 0}, (0, 1, 2, 3, 4, 0, 0, 0, 0, 0)]\n\nTEST_CASE_3 = [{\"threshold\": 5, \"above\": True, \"cval\": 5}, (5, 5, 5, 5, 5, 5, 6, 7, 8, 9)]\n\n\nclass TestThresholdIntensity(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_value(self, input_param, expected_value):\n test_data = np.arange(10)\n result = ThresholdIntensity(**input_param)(test_data)\n np.testing.assert_allclose(result, expected_value)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_threshold_intensityd.py_unittest_TEST_CASE_3._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_threshold_intensityd.py_unittest_TEST_CASE_3._", "embedding": null, "metadata": {"file_path": "tests/test_threshold_intensityd.py", "file_name": "test_threshold_intensityd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 30, "span_ids": ["docstring"], "tokens": 231}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport numpy as np\nfrom parameterized import parameterized\nfrom monai.transforms import ThresholdIntensityd\n\nTEST_CASE_1 = [\n {\"keys\": [\"image\", \"label\", \"extra\"], \"threshold\": 5, \"above\": True, \"cval\": 0},\n (0, 0, 0, 0, 0, 0, 6, 7, 8, 9),\n]\n\nTEST_CASE_2 = [\n {\"keys\": [\"image\", \"label\", \"extra\"], \"threshold\": 5, \"above\": False, \"cval\": 0},\n (0, 1, 2, 3, 4, 0, 0, 0, 0, 0),\n]\n\nTEST_CASE_3 = [\n {\"keys\": [\"image\", \"label\", \"extra\"], \"threshold\": 5, \"above\": True, \"cval\": 5},\n (5, 5, 5, 5, 5, 5, 6, 7, 8, 9),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_threshold_intensityd.py_TestThresholdIntensityd_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_threshold_intensityd.py_TestThresholdIntensityd_", "embedding": null, "metadata": {"file_path": "tests/test_threshold_intensityd.py", "file_name": "test_threshold_intensityd.py", "file_type": "text/x-python", "category": "test", "start_line": 33, "end_line": 45, "span_ids": ["TestThresholdIntensityd", "TestThresholdIntensityd.test_value", "impl:7"], "tokens": 133}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestThresholdIntensityd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_value(self, input_param, expected_value):\n test_data = {\"image\": np.arange(10), \"label\": np.arange(10), \"extra\": np.arange(10)}\n result = ThresholdIntensityd(**input_param)(test_data)\n np.testing.assert_allclose(result[\"image\"], expected_value)\n np.testing.assert_allclose(result[\"label\"], expected_value)\n np.testing.assert_allclose(result[\"extra\"], expected_value)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_to_numpy.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_to_numpy.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_to_numpy.py", "file_name": "test_to_numpy.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 40, "span_ids": ["TestToNumpy", "impl", "TestToNumpy.test_tensor_input", "TestToNumpy.test_numpy_input", "docstring"], "tokens": 216}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport torch\nimport numpy as np\nfrom monai.transforms import ToNumpy\n\n\nclass TestToNumpy(unittest.TestCase):\n def test_numpy_input(self):\n test_data = np.array([[1, 2], [3, 4]])\n test_data = np.rot90(test_data)\n self.assertFalse(test_data.flags[\"C_CONTIGUOUS\"])\n result = ToNumpy()(test_data)\n self.assertTrue(isinstance(result, np.ndarray))\n self.assertTrue(result.flags[\"C_CONTIGUOUS\"])\n np.testing.assert_allclose(result, test_data)\n\n def test_tensor_input(self):\n test_data = torch.tensor([[1, 2], [3, 4]])\n test_data = test_data.rot90()\n self.assertFalse(test_data.is_contiguous())\n result = ToNumpy()(test_data)\n self.assertTrue(isinstance(result, np.ndarray))\n self.assertTrue(result.flags[\"C_CONTIGUOUS\"])\n np.testing.assert_allclose(result, test_data.numpy())\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_to_numpyd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_to_numpyd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_to_numpyd.py", "file_name": "test_to_numpyd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 40, "span_ids": ["impl", "TestToNumpyd.test_tensor_input", "TestToNumpyd.test_numpy_input", "TestToNumpyd", "docstring"], "tokens": 238}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport torch\nimport numpy as np\nfrom monai.transforms import ToNumpyd\n\n\nclass TestToNumpyd(unittest.TestCase):\n def test_numpy_input(self):\n test_data = np.array([[1, 2], [3, 4]])\n test_data = np.rot90(test_data)\n self.assertFalse(test_data.flags[\"C_CONTIGUOUS\"])\n result = ToNumpyd(keys=\"img\")({\"img\": test_data})[\"img\"]\n self.assertTrue(isinstance(result, np.ndarray))\n self.assertTrue(result.flags[\"C_CONTIGUOUS\"])\n np.testing.assert_allclose(result, test_data)\n\n def test_tensor_input(self):\n test_data = torch.tensor([[1, 2], [3, 4]])\n test_data = test_data.rot90()\n self.assertFalse(test_data.is_contiguous())\n result = ToNumpyd(keys=\"img\")({\"img\": test_data})[\"img\"]\n self.assertTrue(isinstance(result, np.ndarray))\n self.assertTrue(result.flags[\"C_CONTIGUOUS\"])\n np.testing.assert_allclose(result, test_data.numpy())\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_to_onehot.py_unittest_TEST_CASE_4._no_channel_0D_batch": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_to_onehot.py_unittest_TEST_CASE_4._no_channel_0D_batch", "embedding": null, "metadata": {"file_path": "tests/test_to_onehot.py", "file_name": "test_to_onehot.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 41, "span_ids": ["docstring"], "tokens": 437}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.networks import one_hot\n\nTEST_CASE_1 = [ # single channel 2D, batch 3, shape (2, 1, 2, 2)\n {\"labels\": torch.tensor([[[[0, 1], [1, 2]]], [[[2, 1], [1, 0]]]]), \"num_classes\": 3},\n (2, 3, 2, 2),\n]\n\nTEST_CASE_2 = [ # single channel 1D, batch 2, shape (2, 1, 4)\n {\"labels\": torch.tensor([[[1, 2, 2, 0]], [[2, 1, 0, 1]]]), \"num_classes\": 3},\n (2, 3, 4),\n np.array([[[0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 1, 0]], [[0, 0, 1, 0], [0, 1, 0, 1], [1, 0, 0, 0]]]),\n]\n\nTEST_CASE_3 = [ # single channel 0D, batch 2, shape (2, 1)\n {\"labels\": torch.tensor([[1.0], [2.0]]), \"num_classes\": 3},\n (2, 3),\n np.array([[0, 1, 0], [0, 0, 1]]),\n]\n\nTEST_CASE_4 = [ # no channel 0D, batch 3, shape (3)\n {\"labels\": torch.tensor([1, 2, 0]), \"num_classes\": 3, \"dtype\": torch.long},\n (3, 3),\n np.array([[0, 1, 0], [0, 0, 1], [1, 0, 0]]),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_to_onehot.py_TestToOneHot_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_to_onehot.py_TestToOneHot_", "embedding": null, "metadata": {"file_path": "tests/test_to_onehot.py", "file_name": "test_to_onehot.py", "file_type": "text/x-python", "category": "test", "start_line": 44, "end_line": 61, "span_ids": ["impl:9", "TestToOneHot.test_shape", "TestToOneHot"], "tokens": 140}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestToOneHot(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4])\n def test_shape(self, input_data, expected_shape, expected_result=None):\n result = one_hot(**input_data)\n self.assertEqual(result.shape, expected_shape)\n if expected_result is not None:\n self.assertTrue(np.allclose(expected_result, result.numpy()))\n\n if \"dtype\" in input_data:\n self.assertEqual(result.dtype, input_data[\"dtype\"])\n else:\n # by default, expecting float type\n self.assertEqual(result.dtype, torch.float)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_tversky_loss.py_unittest_TEST_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_tversky_loss.py_unittest_TEST_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_tversky_loss.py", "file_name": "test_tversky_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 102, "span_ids": ["docstring"], "tokens": 1499}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.losses import TverskyLoss\n\nTEST_CASES = [\n [ # shape: (1, 1, 2, 2), (1, 1, 2, 2)\n {\"include_background\": True, \"sigmoid\": True},\n {\n \"input\": torch.tensor([[[[1.0, -1.0], [-1.0, 1.0]]]]),\n \"target\": torch.tensor([[[[1.0, 0.0], [1.0, 1.0]]]]),\n \"smooth\": 1e-6,\n },\n 0.307576,\n ],\n [ # shape: (2, 1, 2, 2), (2, 1, 2, 2)\n {\"include_background\": True, \"sigmoid\": True},\n {\n \"input\": torch.tensor([[[[1.0, -1.0], [-1.0, 1.0]]], [[[1.0, -1.0], [-1.0, 1.0]]]]),\n \"target\": torch.tensor([[[[1.0, 1.0], [1.0, 1.0]]], [[[1.0, 0.0], [1.0, 0.0]]]]),\n \"smooth\": 1e-4,\n },\n 0.416657,\n ],\n [ # shape: (2, 2, 3), (2, 1, 3)\n {\"include_background\": False, \"to_onehot_y\": True},\n {\n \"input\": torch.tensor([[[1.0, 1.0, 0.0], [0.0, 0.0, 1.0]], [[1.0, 0.0, 1.0], [0.0, 1.0, 0.0]]]),\n \"target\": torch.tensor([[[0.0, 0.0, 1.0]], [[0.0, 1.0, 0.0]]]),\n \"smooth\": 0.0,\n },\n 0.0,\n ],\n [ # shape: (2, 2, 3), (2, 1, 3)\n {\"include_background\": True, \"to_onehot_y\": True, \"sigmoid\": True},\n {\n \"input\": torch.tensor([[[-1.0, 0.0, 1.0], [1.0, 0.0, -1.0]], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]]),\n \"target\": torch.tensor([[[1.0, 0.0, 0.0]], [[1.0, 1.0, 0.0]]]),\n \"smooth\": 1e-4,\n },\n 0.435050,\n ],\n [ # shape: (2, 2, 3), (2, 1, 3)\n {\"include_background\": True, \"to_onehot_y\": True, \"sigmoid\": True, \"reduction\": \"sum\"},\n {\n \"input\": torch.tensor([[[-1.0, 0.0, 1.0], [1.0, 0.0, -1.0]], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]]),\n \"target\": torch.tensor([[[1.0, 0.0, 0.0]], [[1.0, 1.0, 0.0]]]),\n \"smooth\": 1e-4,\n },\n 1.74013,\n ],\n [ # shape: (2, 2, 3), (2, 1, 3)\n {\"include_background\": True, \"to_onehot_y\": True, \"softmax\": True},\n {\n \"input\": torch.tensor([[[-1.0, 0.0, 1.0], [1.0, 0.0, -1.0]], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]]),\n \"target\": torch.tensor([[[1.0, 0.0, 0.0]], [[1.0, 1.0, 0.0]]]),\n \"smooth\": 1e-4,\n },\n 0.383713,\n ],\n [ # shape: (2, 2, 3), (2, 1, 3)\n {\"include_background\": True, \"to_onehot_y\": True, \"softmax\": True, \"reduction\": \"none\"},\n {\n \"input\": torch.tensor([[[-1.0, 0.0, 1.0], [1.0, 0.0, -1.0]], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]]),\n \"target\": torch.tensor([[[1.0, 0.0, 0.0]], [[1.0, 1.0, 0.0]]]),\n \"smooth\": 1e-4,\n },\n [[0.210961, 0.295339], [0.599952, 0.428547]],\n ],\n [ # shape: (1, 1, 2, 2), (1, 1, 2, 2)\n {\"include_background\": True, \"sigmoid\": True, \"alpha\": 0.3, \"beta\": 0.7},\n {\n \"input\": torch.tensor([[[[1.0, -1.0], [-1.0, 1.0]]]]),\n \"target\": torch.tensor([[[[1.0, 0.0], [1.0, 1.0]]]]),\n \"smooth\": 1e-6,\n },\n 0.3589,\n ],\n [ # shape: (1, 1, 2, 2), (1, 1, 2, 2)\n {\"include_background\": True, \"sigmoid\": True, \"alpha\": 0.7, \"beta\": 0.3},\n {\n \"input\": torch.tensor([[[[1.0, -1.0], [-1.0, 1.0]]]]),\n \"target\": torch.tensor([[[[1.0, 0.0], [1.0, 1.0]]]]),\n \"smooth\": 1e-6,\n },\n 0.247366,\n ],\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_tversky_loss.py_TestTverskyLoss_TestTverskyLoss.test_ill_shape.None_2.TverskyLoss_reduction_Non": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_tversky_loss.py_TestTverskyLoss_TestTverskyLoss.test_ill_shape.None_2.TverskyLoss_reduction_Non", "embedding": null, "metadata": {"file_path": "tests/test_tversky_loss.py", "file_name": "test_tversky_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 105, "end_line": 120, "span_ids": ["TestTverskyLoss.test_ill_shape", "TestTverskyLoss", "TestTverskyLoss.test_shape"], "tokens": 210}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestTverskyLoss(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_shape(self, input_param, input_data, expected_val):\n result = TverskyLoss(**input_param).forward(**input_data)\n np.testing.assert_allclose(result.detach().cpu().numpy(), expected_val, rtol=1e-4)\n\n def test_ill_shape(self):\n loss = TverskyLoss()\n with self.assertRaisesRegex(AssertionError, \"\"):\n loss.forward(torch.ones((2, 2, 3)), torch.ones((4, 5, 6)))\n chn_input = torch.ones((1, 1, 3))\n chn_target = torch.ones((1, 1, 3))\n with self.assertRaisesRegex(ValueError, \"\"):\n TverskyLoss(reduction=\"unknown\")(chn_input, chn_target)\n with self.assertRaisesRegex(ValueError, \"\"):\n TverskyLoss(reduction=None)(chn_input, chn_target)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_tversky_loss.py_TestTverskyLoss.test_input_warnings_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_tversky_loss.py_TestTverskyLoss.test_input_warnings_", "embedding": null, "metadata": {"file_path": "tests/test_tversky_loss.py", "file_name": "test_tversky_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 122, "end_line": 138, "span_ids": ["impl:3", "TestTverskyLoss.test_input_warnings"], "tokens": 155}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestTverskyLoss(unittest.TestCase):\n\n def test_input_warnings(self):\n chn_input = torch.ones((1, 1, 3))\n chn_target = torch.ones((1, 1, 3))\n with self.assertWarns(Warning):\n loss = TverskyLoss(include_background=False)\n loss.forward(chn_input, chn_target)\n with self.assertWarns(Warning):\n loss = TverskyLoss(softmax=True)\n loss.forward(chn_input, chn_target)\n with self.assertWarns(Warning):\n loss = TverskyLoss(to_onehot_y=True)\n loss.forward(chn_input, chn_target)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_unet.py_unittest_TEST_CASE_5._4_channel_3D_batch_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_unet.py_unittest_TEST_CASE_5._4_channel_3D_batch_", "embedding": null, "metadata": {"file_path": "tests/test_unet.py", "file_name": "test_unet.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 99, "span_ids": ["impl:9", "docstring"], "tokens": 745}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.networks.layers import Norm, Act\nfrom monai.networks.nets import UNet\n\n\nTEST_CASE_0 = [ # single channel 2D, batch 16, no residual\n {\n \"dimensions\": 2,\n \"in_channels\": 1,\n \"out_channels\": 3,\n \"channels\": (16, 32, 64),\n \"strides\": (2, 2),\n \"num_res_units\": 0,\n },\n torch.randn(16, 1, 32, 32),\n (16, 3, 32, 32),\n]\n\nTEST_CASE_1 = [ # single channel 2D, batch 16\n {\n \"dimensions\": 2,\n \"in_channels\": 1,\n \"out_channels\": 3,\n \"channels\": (16, 32, 64),\n \"strides\": (2, 2),\n \"num_res_units\": 1,\n },\n torch.randn(16, 1, 32, 32),\n (16, 3, 32, 32),\n]\n\nTEST_CASE_2 = [ # single channel 3D, batch 16\n {\n \"dimensions\": 3,\n \"in_channels\": 1,\n \"out_channels\": 3,\n \"channels\": (16, 32, 64),\n \"strides\": (2, 2),\n \"num_res_units\": 1,\n },\n torch.randn(16, 1, 32, 24, 48),\n (16, 3, 32, 24, 48),\n]\n\nTEST_CASE_3 = [ # 4-channel 3D, batch 16\n {\n \"dimensions\": 3,\n \"in_channels\": 4,\n \"out_channels\": 3,\n \"channels\": (16, 32, 64),\n \"strides\": (2, 2),\n \"num_res_units\": 1,\n },\n torch.randn(16, 4, 32, 64, 48),\n (16, 3, 32, 64, 48),\n]\n\nTEST_CASE_4 = [ # 4-channel 3D, batch 16, batch normalisation\n {\n \"dimensions\": 3,\n \"in_channels\": 4,\n \"out_channels\": 3,\n \"channels\": (16, 32, 64),\n \"strides\": (2, 2),\n \"num_res_units\": 1,\n \"norm\": Norm.BATCH,\n },\n torch.randn(16, 4, 32, 64, 48),\n (16, 3, 32, 64, 48),\n]\n\nTEST_CASE_5 = [ # 4-channel 3D, batch 16, LeakyReLU activation\n {\n \"dimensions\": 3,\n \"in_channels\": 4,\n \"out_channels\": 3,\n \"channels\": (16, 32, 64),\n \"strides\": (2, 2),\n \"num_res_units\": 1,\n \"act\": (Act.LEAKYRELU, {\"negative_slope\": 0.2}),\n },\n torch.randn(16, 4, 32, 64, 48),\n (16, 3, 32, 64, 48),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_unet.py_TEST_CASE_6_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_unet.py_TEST_CASE_6_", "embedding": null, "metadata": {"file_path": "tests/test_unet.py", "file_name": "test_unet.py", "file_type": "text/x-python", "category": "test", "start_line": 101, "end_line": 130, "span_ids": ["impl:9", "TestUNET", "TestUNET.test_shape", "impl:17"], "tokens": 257}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "TEST_CASE_6 = [ # 4-channel 3D, batch 16, LeakyReLU activation explicit\n {\n \"dimensions\": 3,\n \"in_channels\": 4,\n \"out_channels\": 3,\n \"channels\": (16, 32, 64),\n \"strides\": (2, 2),\n \"num_res_units\": 1,\n \"act\": (torch.nn.LeakyReLU, {\"negative_slope\": 0.2}),\n },\n torch.randn(16, 4, 32, 64, 48),\n (16, 3, 32, 64, 48),\n]\n\nCASES = [TEST_CASE_0, TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5, TEST_CASE_6]\n\n\nclass TestUNET(unittest.TestCase):\n @parameterized.expand(CASES)\n def test_shape(self, input_param, input_data, expected_shape):\n net = UNet(**input_param)\n net.eval()\n with torch.no_grad():\n result = net.forward(input_data)\n self.assertEqual(result.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_upsample_block.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_upsample_block.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_upsample_block.py", "file_name": "test_upsample_block.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 73, "span_ids": ["impl:3", "TestUpsample", "docstring", "impl:13", "TestUpsample.test_shape"], "tokens": 604}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport torch\nfrom monai.networks.blocks import UpSample\nfrom parameterized import parameterized\n\nTEST_CASES = [\n [{\"spatial_dims\": 2, \"in_channels\": 4}, torch.randn(7, 4, 32, 48), (7, 4, 64, 96)], # 4-channel 2D, batch 7\n [\n {\"spatial_dims\": 1, \"in_channels\": 4, \"out_channels\": 3},\n torch.randn(16, 4, 63),\n (16, 3, 126),\n ], # 4-channel 1D, batch 16\n [\n {\"spatial_dims\": 1, \"in_channels\": 4, \"out_channels\": 8, \"with_conv\": True, \"align_corners\": False},\n torch.randn(16, 4, 20),\n (16, 8, 40),\n ], # 4-channel 1D, batch 16\n [\n {\"spatial_dims\": 3, \"in_channels\": 4, \"mode\": \"bilinear\"},\n torch.randn(16, 4, 32, 24, 48),\n (16, 4, 64, 48, 96),\n ], # 4-channel 3D, batch 16\n [\n {\"spatial_dims\": 3, \"in_channels\": 1, \"with_conv\": False, \"scale_factor\": 3, \"align_corners\": False},\n torch.randn(16, 1, 10, 15, 20),\n (16, 1, 30, 45, 60),\n ], # 1-channel 3D, batch 16\n]\n\nTEST_CASES_EQ = []\nfor s in range(1, 5):\n expected_shape = (16, 5, 4 * s, 5 * s, 6 * s)\n for t in (False, True):\n test_case = [\n {\n \"spatial_dims\": 3,\n \"in_channels\": 3,\n \"out_channels\": 5,\n \"with_conv\": t,\n \"scale_factor\": s,\n \"align_corners\": True,\n },\n torch.randn(16, 3, 4, 5, 6),\n ]\n test_case.append(expected_shape)\n TEST_CASES_EQ.append(test_case)\n\n\nclass TestUpsample(unittest.TestCase):\n @parameterized.expand(TEST_CASES + TEST_CASES_EQ)\n def test_shape(self, input_param, input_data, expected_shape):\n net = UpSample(**input_param)\n net.eval()\n with torch.no_grad():\n result = net(input_data)\n self.assertEqual(result.shape, expected_shape)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zipdataset.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zipdataset.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_zipdataset.py", "file_name": "test_zipdataset.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 57, "span_ids": ["Dataset_.__init__", "Dataset_.__getitem__", "impl", "Dataset_.__len__", "TestZipDataset", "Dataset_", "TestZipDataset.test_value", "docstring", "impl:9"], "tokens": 362}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\nimport torch\nfrom parameterized import parameterized\nfrom monai.data import ZipDataset\n\n\nclass Dataset_(torch.utils.data.Dataset):\n def __init__(self, length, index_only=True):\n self.len = length\n self.index_only = index_only\n\n def __len__(self):\n return self.len\n\n def __getitem__(self, index):\n if self.index_only:\n return index\n else:\n return 1, 2, index\n\n\nTEST_CASE_1 = [[Dataset_(5), Dataset_(5), Dataset_(5)], None, [0, 0, 0], 5]\n\nTEST_CASE_2 = [[Dataset_(3), Dataset_(4), Dataset_(5)], None, [0, 0, 0], 3]\n\nTEST_CASE_3 = [[Dataset_(3), Dataset_(4, index_only=False), Dataset_(5)], None, [0, 1, 2, 0, 0], 3]\n\nTEST_CASE_4 = [\n [Dataset_(3), Dataset_(4, index_only=False), Dataset_(5)],\n lambda x: [i + 1 for i in x],\n [1, 2, 3, 1, 1],\n 3,\n]\n\n\nclass TestZipDataset(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4])\n def test_value(self, datasets, transform, expected_output, expected_length):\n test_dataset = ZipDataset(datasets=datasets, transform=transform)\n self.assertEqual(test_dataset[0], expected_output)\n self.assertEqual(len(test_dataset), expected_length)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom.py_unittest_INVALID_CASES._None_None_bilinear": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom.py_unittest_INVALID_CASES._None_None_bilinear", "embedding": null, "metadata": {"file_path": "tests/test_zoom.py", "file_name": "test_zoom.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 23, "span_ids": ["docstring"], "tokens": 112}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\nfrom parameterized import parameterized\nfrom scipy.ndimage import zoom as zoom_scipy\nfrom tests.utils import NumpyImageTestCase2D\n\nfrom monai.transforms import Zoom\n\nVALID_CASES = [(1.5, \"nearest\"), (1.5, \"nearest\"), (0.8, \"bilinear\"), (0.8, \"area\")]\n\nINVALID_CASES = [((None, None), \"bilinear\", TypeError), ((0.9, 0.9), \"s\", ValueError)]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom.py_TestZoom_TestZoom.test_correct_results.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom.py_TestZoom_TestZoom.test_correct_results.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_zoom.py", "file_name": "test_zoom.py", "file_type": "text/x-python", "category": "test", "start_line": 26, "end_line": 38, "span_ids": ["TestZoom", "TestZoom.test_correct_results"], "tokens": 152}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestZoom(NumpyImageTestCase2D):\n @parameterized.expand(VALID_CASES)\n def test_correct_results(self, zoom, mode):\n zoom_fn = Zoom(zoom=zoom, mode=mode, keep_size=False)\n zoomed = zoom_fn(self.imt[0])\n _order = 0\n if mode.endswith(\"linear\"):\n _order = 1\n expected = list()\n for channel in self.imt[0]:\n expected.append(zoom_scipy(channel, zoom=zoom, mode=\"nearest\", order=_order, prefilter=False))\n expected = np.stack(expected).astype(np.float32)\n np.testing.assert_allclose(zoomed, expected, atol=1.0)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom.py_TestZoom.test_keep_size_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom.py_TestZoom.test_keep_size_", "embedding": null, "metadata": {"file_path": "tests/test_zoom.py", "file_name": "test_zoom.py", "file_type": "text/x-python", "category": "test", "start_line": 40, "end_line": 58, "span_ids": ["TestZoom.test_keep_size", "TestZoom.test_invalid_inputs", "impl:5"], "tokens": 195}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestZoom(NumpyImageTestCase2D):\n\n def test_keep_size(self):\n zoom_fn = Zoom(zoom=[0.6, 0.6], keep_size=True, align_corners=True)\n zoomed = zoom_fn(self.imt[0], mode=\"bilinear\")\n np.testing.assert_allclose(zoomed.shape, self.imt.shape[1:])\n\n zoom_fn = Zoom(zoom=[1.3, 1.3], keep_size=True)\n zoomed = zoom_fn(self.imt[0])\n np.testing.assert_allclose(zoomed.shape, self.imt.shape[1:])\n\n @parameterized.expand(INVALID_CASES)\n def test_invalid_inputs(self, zoom, mode, raises):\n with self.assertRaises(raises):\n zoom_fn = Zoom(zoom=zoom, mode=mode)\n zoom_fn(self.imt[0])\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom_affine.py_unittest_VALID_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom_affine.py_unittest_VALID_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_zoom_affine.py", "file_name": "test_zoom_affine.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 47, "span_ids": ["docstring"], "tokens": 643}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport nibabel as nib\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.data.utils import zoom_affine\n\nVALID_CASES = [\n (\n np.array([[2, 1, 4], [-1, -3, 5], [0, 0, 1]]),\n (10, 20, 30),\n np.array([[8.94427191, -8.94427191, 0], [-4.47213595, -17.88854382, 0], [0.0, 0.0, 1.0]]),\n ),\n (\n np.array([[1, 0, 0, 4], [0, 2, 0, 5], [0, 0, 3, 6], [0, 0, 0, 1]]),\n (10, 20, 30),\n np.array([[10, 0, 0, 0], [0, 20, 0, 0], [0, 0, 30, 0], [0, 0, 0, 1]]),\n ),\n (\n np.array([[1, 0, 0, 4], [0, 2, 0, 5], [0, 0, 3, 6], [0, 0, 0, 1]]),\n (10, 20),\n np.array([[10, 0, 0, 0], [0, 20, 0, 0], [0, 0, 3, 0], [0, 0, 0, 1]]),\n ),\n (\n np.array([[1, 0, 0, 4], [0, 2, 0, 5], [0, 0, 3, 6], [0, 0, 0, 1]]),\n (10,),\n np.array([[10, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 1]]),\n ),\n (\n [[1, 0, 10], [0, 1, 20], [0, 0, 1]]\n @ ([[0, -1, 0], [1, 0, 0], [0, 0, 1]] @ np.array([[2, 0.3, 0], [0, 3, 0], [0, 0, 1]])),\n (4, 5, 6),\n ([[0, -1, 0], [1, 0, 0], [0, 0, 1]] @ np.array([[4, 0, 0], [0, 5, 0], [0, 0, 1]])),\n ),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom_affine.py_DIAGONAL_CASES_DIAGONAL_CASES._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom_affine.py_DIAGONAL_CASES_DIAGONAL_CASES._", "embedding": null, "metadata": {"file_path": "tests/test_zoom_affine.py", "file_name": "test_zoom_affine.py", "file_type": "text/x-python", "category": "test", "start_line": 49, "end_line": 61, "span_ids": ["impl:3"], "tokens": 291}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "DIAGONAL_CASES = [\n (\n np.array([[-1, 0, 0, 4], [0, 2, 0, 5], [0, 0, 3, 6], [0, 0, 0, 1]]),\n (10, 20, 30),\n np.array([[10, 0, 0, 0], [0, 20, 0, 0], [0, 0, 30, 0], [0, 0, 0, 1]]),\n ),\n (np.array([[2, 1, 4], [-1, -3, 5], [0, 0, 1]]), (10, 20, 30), np.array([[10, 0, 0], [0, 20, 0], [0.0, 0.0, 1.0]])),\n ( # test default scale from affine\n np.array([[2, 1, 4], [-1, -3, 5], [0, 0, 1]]),\n (10,),\n np.array([[10, 0, 0], [0, 3.162278, 0], [0.0, 0.0, 1.0]]),\n ),\n]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom_affine.py_TestZoomAffine_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoom_affine.py_TestZoomAffine_", "embedding": null, "metadata": {"file_path": "tests/test_zoom_affine.py", "file_name": "test_zoom_affine.py", "file_type": "text/x-python", "category": "test", "start_line": 64, "end_line": 81, "span_ids": ["TestZoomAffine.test_diagonal", "TestZoomAffine.test_correct", "impl:5", "TestZoomAffine"], "tokens": 211}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestZoomAffine(unittest.TestCase):\n @parameterized.expand(VALID_CASES)\n def test_correct(self, affine, scale, expected):\n output = zoom_affine(affine, scale, diagonal=False)\n ornt_affine = nib.orientations.ornt2axcodes(nib.orientations.io_orientation(output))\n ornt_output = nib.orientations.ornt2axcodes(nib.orientations.io_orientation(affine))\n np.testing.assert_array_equal(ornt_affine, ornt_output)\n np.testing.assert_allclose(output, expected, rtol=1e-6, atol=1e-6)\n\n @parameterized.expand(DIAGONAL_CASES)\n def test_diagonal(self, affine, scale, expected):\n output = zoom_affine(affine, scale, diagonal=True)\n np.testing.assert_allclose(output, expected, rtol=1e-6, atol=1e-6)\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoomd.py_unittest_INVALID_CASES._no_zoom_None_bilin": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoomd.py_unittest_INVALID_CASES._no_zoom_None_bilin", "embedding": null, "metadata": {"file_path": "tests/test_zoomd.py", "file_name": "test_zoomd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 24, "span_ids": ["docstring"], "tokens": 111}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import unittest\n\nimport numpy as np\n\nfrom scipy.ndimage import zoom as zoom_scipy\nfrom parameterized import parameterized\n\nfrom monai.transforms import Zoomd\nfrom tests.utils import NumpyImageTestCase2D\n\nVALID_CASES = [(1.5, \"nearest\", False), (0.3, \"bilinear\", False), (0.8, \"bilinear\", False)]\n\nINVALID_CASES = [(\"no_zoom\", None, \"bilinear\", TypeError), (\"invalid_order\", 0.9, \"s\", ValueError)]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoomd.py_TestZoomd_TestZoomd.test_correct_results.np_testing_assert_allclos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoomd.py_TestZoomd_TestZoomd.test_correct_results.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_zoomd.py", "file_name": "test_zoomd.py", "file_type": "text/x-python", "category": "test", "start_line": 27, "end_line": 40, "span_ids": ["TestZoomd.test_correct_results", "TestZoomd"], "tokens": 169}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestZoomd(NumpyImageTestCase2D):\n @parameterized.expand(VALID_CASES)\n def test_correct_results(self, zoom, mode, keep_size):\n key = \"img\"\n zoom_fn = Zoomd(key, zoom=zoom, mode=mode, keep_size=keep_size,)\n zoomed = zoom_fn({key: self.imt[0]})\n _order = 0\n if mode.endswith(\"linear\"):\n _order = 1\n expected = list()\n for channel in self.imt[0]:\n expected.append(zoom_scipy(channel, zoom=zoom, mode=\"nearest\", order=_order, prefilter=False))\n expected = np.stack(expected).astype(np.float32)\n np.testing.assert_allclose(expected, zoomed[key], atol=1.0)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoomd.py_TestZoomd.test_keep_size_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zoomd.py_TestZoomd.test_keep_size_", "embedding": null, "metadata": {"file_path": "tests/test_zoomd.py", "file_name": "test_zoomd.py", "file_type": "text/x-python", "category": "test", "start_line": 42, "end_line": 62, "span_ids": ["TestZoomd.test_keep_size", "impl:5", "TestZoomd.test_invalid_inputs"], "tokens": 210}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class TestZoomd(NumpyImageTestCase2D):\n\n def test_keep_size(self):\n key = \"img\"\n zoom_fn = Zoomd(key, zoom=0.6, keep_size=True)\n zoomed = zoom_fn({key: self.imt[0]})\n self.assertTrue(np.array_equal(zoomed[key].shape, self.imt.shape[1:]))\n\n zoom_fn = Zoomd(key, zoom=1.3, keep_size=True)\n zoomed = zoom_fn({key: self.imt[0]})\n self.assertTrue(np.array_equal(zoomed[key].shape, self.imt.shape[1:]))\n\n @parameterized.expand(INVALID_CASES)\n def test_invalid_inputs(self, _, zoom, mode, raises):\n key = \"img\"\n with self.assertRaises(raises):\n zoom_fn = Zoomd(key, zoom=zoom, mode=mode)\n zoom_fn({key: self.imt[0]})\n\n\nif __name__ == \"__main__\":\n unittest.main()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/utils.py_os_skip_if_quick.return.unittest_skipIf_is_quick_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/utils.py_os_skip_if_quick.return.unittest_skipIf_is_quick_", "embedding": null, "metadata": {"file_path": "tests/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 30, "span_ids": ["skip_if_quick", "docstring"], "tokens": 113}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "import os\nimport tempfile\nimport unittest\nfrom subprocess import PIPE, Popen\n\nimport numpy as np\nimport torch\nfrom monai.data import create_test_image_2d, create_test_image_3d\nfrom monai.utils import optional_import\n\nnib, _ = optional_import(\"nibabel\")\n\nquick_test_var = \"QUICKTEST\"\n\n\ndef skip_if_quick(obj):\n is_quick = os.environ.get(quick_test_var, \"\").lower() == \"true\"\n\n return unittest.skipIf(is_quick, \"Skipping slow tests\")(obj)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/utils.py_make_nifti_image_make_nifti_image.return.image_name": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/utils.py_make_nifti_image_make_nifti_image.return.image_name", "embedding": null, "metadata": {"file_path": "tests/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 33, "end_line": 45, "span_ids": ["make_nifti_image"], "tokens": 110}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def make_nifti_image(array, affine=None):\n \"\"\"\n Create a temporary nifti image on the disk and return the image name.\n User is responsible for deleting the temporary file when done with it.\n \"\"\"\n if affine is None:\n affine = np.eye(4)\n test_image = nib.Nifti1Image(array, affine)\n\n temp_f, image_name = tempfile.mkstemp(suffix=\".nii.gz\")\n nib.save(test_image, image_name)\n os.close(temp_f)\n return image_name", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/utils.py_NumpyImageTestCase2D_TorchImageTestCase2D.setUp.self.segn.torch_tensor_self_segn_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/utils.py_NumpyImageTestCase2D_TorchImageTestCase2D.setUp.self.segn.torch_tensor_self_segn_", "embedding": null, "metadata": {"file_path": "tests/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 48, "end_line": 67, "span_ids": ["NumpyImageTestCase2D", "TorchImageTestCase2D.setUp", "TorchImageTestCase2D", "NumpyImageTestCase2D.setUp"], "tokens": 192}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class NumpyImageTestCase2D(unittest.TestCase):\n im_shape = (128, 64)\n input_channels = 1\n output_channels = 4\n num_classes = 3\n\n def setUp(self):\n im, msk = create_test_image_2d(self.im_shape[0], self.im_shape[1], 4, 20, 0, self.num_classes)\n\n self.imt = im[None, None]\n self.seg1 = (msk[None, None] > 0).astype(np.float32)\n self.segn = msk[None, None]\n\n\nclass TorchImageTestCase2D(NumpyImageTestCase2D):\n def setUp(self):\n NumpyImageTestCase2D.setUp(self)\n self.imt = torch.tensor(self.imt)\n self.seg1 = torch.tensor(self.seg1)\n self.segn = torch.tensor(self.segn)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/utils.py_NumpyImageTestCase3D_expect_failure_if_no_gpu.if_not_torch_cuda_is_avai.else_.return.test": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/utils.py_NumpyImageTestCase3D_expect_failure_if_no_gpu.if_not_torch_cuda_is_avai.else_.return.test", "embedding": null, "metadata": {"file_path": "tests/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 70, "end_line": 96, "span_ids": ["NumpyImageTestCase3D.setUp", "TorchImageTestCase3D.setUp", "expect_failure_if_no_gpu", "TorchImageTestCase3D", "NumpyImageTestCase3D"], "tokens": 230}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class NumpyImageTestCase3D(unittest.TestCase):\n im_shape = (64, 48, 80)\n input_channels = 1\n output_channels = 4\n num_classes = 3\n\n def setUp(self):\n im, msk = create_test_image_3d(self.im_shape[0], self.im_shape[1], self.im_shape[2], 4, 20, 0, self.num_classes)\n\n self.imt = im[None, None]\n self.seg1 = (msk[None, None] > 0).astype(np.float32)\n self.segn = msk[None, None]\n\n\nclass TorchImageTestCase3D(NumpyImageTestCase3D):\n def setUp(self):\n NumpyImageTestCase3D.setUp(self)\n self.imt = torch.tensor(self.imt)\n self.seg1 = torch.tensor(self.seg1)\n self.segn = torch.tensor(self.segn)\n\n\ndef expect_failure_if_no_gpu(test):\n if not torch.cuda.is_available():\n return unittest.expectedFailure(test)\n else:\n return test", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/utils.py_query_memory_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/utils.py_query_memory_", "embedding": null, "metadata": {"file_path": "tests/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 99, "end_line": 118, "span_ids": ["query_memory", "impl:4"], "tokens": 194}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def query_memory(n=2):\n \"\"\"\n Find best n idle devices and return a string of device ids.\n \"\"\"\n bash_string = \"nvidia-smi --query-gpu=utilization.gpu,temperature.gpu,memory.used --format=csv,noheader,nounits\"\n\n try:\n p1 = Popen(bash_string.split(), stdout=PIPE)\n output, error = p1.communicate()\n free_memory = [x.split(\",\") for x in output.decode(\"utf-8\").split(\"\\n\")[:-1]]\n free_memory = np.asarray(free_memory, dtype=np.float).T\n ids = np.lexsort(free_memory)[:n]\n except (FileNotFoundError, TypeError, IndexError):\n ids = range(n) if isinstance(n, int) else []\n return \",\".join([f\"{int(x)}\" for x in ids])\n\n\nif __name__ == \"__main__\":\n print(query_memory())", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py__Version_0_18_get_root.return.root": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py__Version_0_18_get_root.return.root", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1, "end_line": 333, "span_ids": ["VersioneerConfig", "imports", "get_root", "docstring"], "tokens": 522}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "# Version: 0.18\n\nfrom __future__ import print_function\n\ntry:\n import configparser\nexcept ImportError:\n import ConfigParser as configparser\nimport errno\nimport json\nimport os\nimport re\nimport subprocess\nimport sys\n\n\nclass VersioneerConfig:\n \"\"\"Container for Versioneer configuration parameters.\"\"\"\n\n\ndef get_root():\n \"\"\"Get the project root directory.\n\n We require that all commands are run from the project root, i.e. the\n directory that contains setup.py, setup.cfg, and versioneer.py .\n \"\"\"\n root = os.path.realpath(os.path.abspath(os.getcwd()))\n setup_py = os.path.join(root, \"setup.py\")\n versioneer_py = os.path.join(root, \"versioneer.py\")\n if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)):\n # allow 'python path/to/setup.py COMMAND'\n root = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0])))\n setup_py = os.path.join(root, \"setup.py\")\n versioneer_py = os.path.join(root, \"versioneer.py\")\n if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)):\n err = (\n \"Versioneer was unable to run the project root directory. \"\n \"Versioneer requires setup.py to be executed from \"\n \"its immediate directory (like 'python setup.py COMMAND'), \"\n \"or in a way that lets it use sys.argv[0] to find the root \"\n \"(like 'python path/to/setup.py COMMAND').\"\n )\n raise VersioneerBadRootError(err)\n try:\n # Certain runtime workflows (setup.py install/develop in a setuptools\n # tree) execute all dependencies in a single python process, so\n # \"versioneer\" may be imported multiple times, and python's shared\n # module-import table will cache the first one. So we can't use\n # os.path.dirname(__file__), as that will find whichever\n # versioneer.py was first imported, even in later projects.\n me = os.path.realpath(os.path.abspath(__file__))\n me_dir = os.path.normcase(os.path.splitext(me)[0])\n vsr_dir = os.path.normcase(os.path.splitext(versioneer_py)[0])\n if me_dir != vsr_dir:\n print(\"Warning: build in %s is using versioneer.py from %s\" % (os.path.dirname(me), versioneer_py))\n except NameError:\n pass\n return root", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_config_from_root_get_config_from_root.return.cfg": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_config_from_root_get_config_from_root.return.cfg", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 336, "end_line": 363, "span_ids": ["get_config_from_root"], "tokens": 294}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def get_config_from_root(root):\n \"\"\"Read the project setup.cfg file to determine Versioneer config.\"\"\"\n # This might raise EnvironmentError (if setup.cfg is missing), or\n # configparser.NoSectionError (if it lacks a [versioneer] section), or\n # configparser.NoOptionError (if it lacks \"VCS=\"). See the docstring at\n # the top of versioneer.py for instructions on writing your setup.cfg .\n setup_cfg = os.path.join(root, \"setup.cfg\")\n parser = configparser.SafeConfigParser()\n with open(setup_cfg, \"r\") as f:\n parser.readfp(f)\n VCS = parser.get(\"versioneer\", \"VCS\") # mandatory\n\n def get(parser, name):\n if parser.has_option(\"versioneer\", name):\n return parser.get(\"versioneer\", name)\n return None\n\n cfg = VersioneerConfig()\n cfg.VCS = VCS\n cfg.style = get(parser, \"style\") or \"\"\n cfg.versionfile_source = get(parser, \"versionfile_source\")\n cfg.versionfile_build = get(parser, \"versionfile_build\")\n cfg.tag_prefix = get(parser, \"tag_prefix\")\n if cfg.tag_prefix in (\"''\", '\"\"'):\n cfg.tag_prefix = \"\"\n cfg.parentdir_prefix = get(parser, \"parentdir_prefix\")\n cfg.verbose = get(parser, \"verbose\")\n return cfg", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_NotThisMethod_register_vcs_handler.return.decorate": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_NotThisMethod_register_vcs_handler.return.decorate", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 366, "end_line": 385, "span_ids": ["impl:3", "NotThisMethod", "register_vcs_handler"], "tokens": 128}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class NotThisMethod(Exception):\n \"\"\"Exception raised if a method is not valid for the current scenario.\"\"\"\n\n\n# these dictionaries contain VCS-specific tools\nLONG_VERSION_PY = {}\nHANDLERS = {}\n\n\ndef register_vcs_handler(vcs, method): # decorator\n \"\"\"Decorator to mark a method as the handler for a particular VCS.\"\"\"\n\n def decorate(f):\n \"\"\"Store f in HANDLERS[vcs][method].\"\"\"\n if vcs not in HANDLERS:\n HANDLERS[vcs] = {}\n HANDLERS[vcs][method] = f\n return f\n\n return decorate", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_run_command_run_command.return.stdout_p_returncode": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_run_command_run_command.return.stdout_p_returncode", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 388, "end_line": 420, "span_ids": ["run_command"], "tokens": 289}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=None):\n \"\"\"Call the given command(s).\"\"\"\n assert isinstance(commands, list)\n p = None\n for c in commands:\n try:\n dispcmd = str([c] + args)\n # remember shell=False, so use git.cmd on windows, not just git\n p = subprocess.Popen(\n [c] + args, cwd=cwd, env=env, stdout=subprocess.PIPE, stderr=(subprocess.PIPE if hide_stderr else None)\n )\n break\n except EnvironmentError:\n e = sys.exc_info()[1]\n if e.errno == errno.ENOENT:\n continue\n if verbose:\n print(\"unable to run %s\" % dispcmd)\n print(e)\n return None, None\n else:\n if verbose:\n print(\"unable to find command, tried %s\" % (commands,))\n return None, None\n stdout = p.communicate()[0].strip()\n if sys.version_info[0] >= 3:\n stdout = stdout.decode()\n if p.returncode != 0:\n if verbose:\n print(\"unable to run %s (error)\" % dispcmd)\n print(\"stdout was %s\" % stdout)\n return None, p.returncode\n return stdout, p.returncode", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_git_get_keywords_git_get_keywords.return.keywords": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_git_get_keywords_git_get_keywords.return.keywords", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 948, "end_line": 974, "span_ids": ["git_get_keywords"], "tokens": 255}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "@register_vcs_handler(\"git\", \"get_keywords\")\ndef git_get_keywords(versionfile_abs):\n \"\"\"Extract version information from the given file.\"\"\"\n # the code embedded in _version.py can just fetch the value of these\n # keywords. When used from setup.py, we don't want to import _version.py,\n # so we do it with a regexp instead. This function is not used from\n # _version.py.\n keywords = {}\n try:\n f = open(versionfile_abs, \"r\")\n for line in f.readlines():\n if line.strip().startswith(\"git_refnames =\"):\n mo = re.search(r'=\\s*\"(.*)\"', line)\n if mo:\n keywords[\"refnames\"] = mo.group(1)\n if line.strip().startswith(\"git_full =\"):\n mo = re.search(r'=\\s*\"(.*)\"', line)\n if mo:\n keywords[\"full\"] = mo.group(1)\n if line.strip().startswith(\"git_date =\"):\n mo = re.search(r'=\\s*\"(.*)\"', line)\n if mo:\n keywords[\"date\"] = mo.group(1)\n f.close()\n except EnvironmentError:\n pass\n return keywords", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_git_versions_from_keywords_git_versions_from_keywords.return._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_git_versions_from_keywords_git_versions_from_keywords.return._", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 977, "end_line": 1036, "span_ids": ["git_versions_from_keywords"], "tokens": 725}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "@register_vcs_handler(\"git\", \"keywords\")\ndef git_versions_from_keywords(keywords, tag_prefix, verbose):\n \"\"\"Get version information from git keywords.\"\"\"\n if not keywords:\n raise NotThisMethod(\"no keywords at all, weird\")\n date = keywords.get(\"date\")\n if date is not None:\n # git-2.2.0 added \"%cI\", which expands to an ISO-8601 -compliant\n # datestamp. However we prefer \"%ci\" (which expands to an \"ISO-8601\n # -like\" string, which we must then edit to make compliant), because\n # it's been around since git-1.5.3, and it's too difficult to\n # discover which version we're using, or to work around using an\n # older one.\n date = date.strip().replace(\" \", \"T\", 1).replace(\" \", \"\", 1)\n refnames = keywords[\"refnames\"].strip()\n if refnames.startswith(\"$Format\"):\n if verbose:\n print(\"keywords are unexpanded, not using\")\n raise NotThisMethod(\"unexpanded keywords, not a git-archive tarball\")\n refs = set([r.strip() for r in refnames.strip(\"()\").split(\",\")])\n # starting in git-1.8.3, tags are listed as \"tag: foo-1.0\" instead of\n # just \"foo-1.0\". If we see a \"tag: \" prefix, prefer those.\n TAG = \"tag: \"\n tags = set([r[len(TAG) :] for r in refs if r.startswith(TAG)])\n if not tags:\n # Either we're using git < 1.8.3, or there really are no tags. We use\n # a heuristic: assume all version tags have a digit. The old git %d\n # expansion behaves like git log --decorate=short and strips out the\n # refs/heads/ and refs/tags/ prefixes that would let us distinguish\n # between branches and tags. By ignoring refnames without digits, we\n # filter out many common branch names like \"release\" and\n # \"stabilization\", as well as \"HEAD\" and \"master\".\n tags = set([r for r in refs if re.search(r\"\\d\", r)])\n if verbose:\n print(\"discarding '%s', no digits\" % \",\".join(refs - tags))\n if verbose:\n print(\"likely tags: %s\" % \",\".join(sorted(tags)))\n for ref in sorted(tags):\n # sorting will prefer e.g. \"2.0\" over \"2.0rc1\"\n if ref.startswith(tag_prefix):\n r = ref[len(tag_prefix) :]\n if verbose:\n print(\"picking %s\" % r)\n return {\n \"version\": r,\n \"full-revisionid\": keywords[\"full\"].strip(),\n \"dirty\": False,\n \"error\": None,\n \"date\": date,\n }\n # no suitable tags, so version is \"0+unknown\", but full hex is still there\n if verbose:\n print(\"no suitable tags, using unknown + full revision id\")\n return {\n \"version\": \"0+unknown\",\n \"full-revisionid\": keywords[\"full\"].strip(),\n \"dirty\": False,\n \"error\": \"no suitable tags\",\n \"date\": None,\n }", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_git_pieces_from_vcs_git_pieces_from_vcs.return.pieces": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_git_pieces_from_vcs_git_pieces_from_vcs.return.pieces", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1039, "end_line": 1122, "span_ids": ["git_pieces_from_vcs"], "tokens": 871}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "@register_vcs_handler(\"git\", \"pieces_from_vcs\")\ndef git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):\n \"\"\"Get version from 'git describe' in the root of the source tree.\n\n This only gets called if the git-archive 'subst' keywords were *not*\n expanded, and _version.py hasn't already been rewritten with a short\n version string, meaning we're inside a checked out source tree.\n \"\"\"\n GITS = [\"git\"]\n if sys.platform == \"win32\":\n GITS = [\"git.cmd\", \"git.exe\"]\n\n out, rc = run_command(GITS, [\"rev-parse\", \"--git-dir\"], cwd=root, hide_stderr=True)\n if rc != 0:\n if verbose:\n print(\"Directory %s not under git control\" % root)\n raise NotThisMethod(\"'git rev-parse --git-dir' returned error\")\n\n # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]\n # if there isn't one, this yields HEX[-dirty] (no NUM)\n describe_out, rc = run_command(\n GITS, [\"describe\", \"--tags\", \"--dirty\", \"--always\", \"--long\", \"--match\", \"%s*\" % tag_prefix], cwd=root\n )\n # --long was added in git-1.5.5\n if describe_out is None:\n raise NotThisMethod(\"'git describe' failed\")\n describe_out = describe_out.strip()\n full_out, rc = run_command(GITS, [\"rev-parse\", \"HEAD\"], cwd=root)\n if full_out is None:\n raise NotThisMethod(\"'git rev-parse' failed\")\n full_out = full_out.strip()\n\n pieces = {}\n pieces[\"long\"] = full_out\n pieces[\"short\"] = full_out[:7] # maybe improved later\n pieces[\"error\"] = None\n\n # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty]\n # TAG might have hyphens.\n git_describe = describe_out\n\n # look for -dirty suffix\n dirty = git_describe.endswith(\"-dirty\")\n pieces[\"dirty\"] = dirty\n if dirty:\n git_describe = git_describe[: git_describe.rindex(\"-dirty\")]\n\n # now we have TAG-NUM-gHEX or HEX\n\n if \"-\" in git_describe:\n # TAG-NUM-gHEX\n mo = re.search(r\"^(.+)-(\\d+)-g([0-9a-f]+)$\", git_describe)\n if not mo:\n # unparseable. Maybe git-describe is misbehaving?\n pieces[\"error\"] = \"unable to parse git-describe output: '%s'\" % describe_out\n return pieces\n\n # tag\n full_tag = mo.group(1)\n if not full_tag.startswith(tag_prefix):\n if verbose:\n fmt = \"tag '%s' doesn't start with prefix '%s'\"\n print(fmt % (full_tag, tag_prefix))\n pieces[\"error\"] = \"tag '%s' doesn't start with prefix '%s'\" % (full_tag, tag_prefix)\n return pieces\n pieces[\"closest-tag\"] = full_tag[len(tag_prefix) :]\n\n # distance: number of commits since tag\n pieces[\"distance\"] = int(mo.group(2))\n\n # commit: short hex revision ID\n pieces[\"short\"] = mo.group(3)\n\n else:\n # HEX: no tags\n pieces[\"closest-tag\"] = None\n count_out, rc = run_command(GITS, [\"rev-list\", \"HEAD\", \"--count\"], cwd=root)\n pieces[\"distance\"] = int(count_out) # total number of commits\n\n # commit date: see ISO-8601 comment in git_versions_from_keywords()\n date = run_command(GITS, [\"show\", \"-s\", \"--format=%ci\", \"HEAD\"], cwd=root)[0].strip()\n pieces[\"date\"] = date.strip().replace(\" \", \"T\", 1).replace(\" \", \"\", 1)\n\n return pieces", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_do_vcs_install_do_vcs_install.run_command_GITS_add_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_do_vcs_install_do_vcs_install.run_command_GITS_add_", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1125, "end_line": 1160, "span_ids": ["do_vcs_install"], "tokens": 300}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def do_vcs_install(manifest_in, versionfile_source, ipy):\n \"\"\"Git-specific installation logic for Versioneer.\n\n For Git, this means creating/changing .gitattributes to mark _version.py\n for export-subst keyword substitution.\n \"\"\"\n GITS = [\"git\"]\n if sys.platform == \"win32\":\n GITS = [\"git.cmd\", \"git.exe\"]\n files = [manifest_in, versionfile_source]\n if ipy:\n files.append(ipy)\n try:\n me = __file__\n if me.endswith(\".pyc\") or me.endswith(\".pyo\"):\n me = os.path.splitext(me)[0] + \".py\"\n versioneer_file = os.path.relpath(me)\n except NameError:\n versioneer_file = \"versioneer.py\"\n files.append(versioneer_file)\n present = False\n try:\n f = open(\".gitattributes\", \"r\")\n for line in f.readlines():\n if line.strip().startswith(versionfile_source):\n if \"export-subst\" in line.strip().split()[1:]:\n present = True\n f.close()\n except EnvironmentError:\n pass\n if not present:\n f = open(\".gitattributes\", \"a+\")\n f.write(\"%s export-subst\\n\" % versionfile_source)\n f.close()\n files.append(\".gitattributes\")\n run_command(GITS, [\"add\", \"--\"] + files)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_versions_from_parentdir_versions_from_parentdir.raise_NotThisMethod_root": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_versions_from_parentdir_versions_from_parentdir.raise_NotThisMethod_root", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1163, "end_line": 1188, "span_ids": ["versions_from_parentdir"], "tokens": 211}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def versions_from_parentdir(parentdir_prefix, root, verbose):\n \"\"\"Try to determine the version from the parent directory name.\n\n Source tarballs conventionally unpack into a directory that includes both\n the project name and a version string. We will also support searching up\n two directory levels for an appropriately named parent directory\n \"\"\"\n rootdirs = []\n\n for i in range(3):\n dirname = os.path.basename(root)\n if dirname.startswith(parentdir_prefix):\n return {\n \"version\": dirname[len(parentdir_prefix) :],\n \"full-revisionid\": None,\n \"dirty\": False,\n \"error\": None,\n \"date\": None,\n }\n else:\n rootdirs.append(root)\n root = os.path.dirname(root) # up a level\n\n if verbose:\n print(\"Tried directories %s but none started with prefix %s\" % (str(rootdirs), parentdir_prefix))\n raise NotThisMethod(\"rootdir doesn't start with parentdir_prefix\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_SHORT_VERSION_PY_versions_from_file.return.json_loads_mo_group_1_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_SHORT_VERSION_PY_versions_from_file.return.json_loads_mo_group_1_", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1191, "end_line": 1221, "span_ids": ["versions_from_file", "impl:8"], "tokens": 236}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "SHORT_VERSION_PY = \"\"\"\n# This file was generated by 'versioneer.py' (0.18) from\n# revision-control system data, or from the parent directory name of an\n# unpacked source archive. Distribution tarballs contain a pre-generated copy\n# of this file.\n\nimport json\n\nversion_json = '''\n%s\n''' # END VERSION_JSON\n\n\ndef get_versions():\n return json.loads(version_json)\n\"\"\"\n\n\ndef versions_from_file(filename):\n \"\"\"Try to determine the version from _version.py if present.\"\"\"\n try:\n with open(filename) as f:\n contents = f.read()\n except EnvironmentError:\n raise NotThisMethod(\"unable to read _version.py\")\n mo = re.search(r\"version_json = '''\\n(.*)''' # END VERSION_JSON\", contents, re.M | re.S)\n if not mo:\n mo = re.search(r\"version_json = '''\\r\\n(.*)''' # END VERSION_JSON\", contents, re.M | re.S)\n if not mo:\n raise NotThisMethod(\"no version_json in _version.py\")\n return json.loads(mo.group(1))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_write_to_version_file_plus_or_dot.return._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_write_to_version_file_plus_or_dot.return._", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1224, "end_line": 1238, "span_ids": ["plus_or_dot", "write_to_version_file"], "tokens": 134}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def write_to_version_file(filename, versions):\n \"\"\"Write the given version number to the given _version.py file.\"\"\"\n os.unlink(filename)\n contents = json.dumps(versions, sort_keys=True, indent=1, separators=(\",\", \": \"))\n with open(filename, \"w\") as f:\n f.write(SHORT_VERSION_PY % contents)\n\n print(\"set %s to '%s'\" % (filename, versions[\"version\"]))\n\n\ndef plus_or_dot(pieces):\n \"\"\"Return a + if we don't already have one, else return a .\"\"\"\n if \"+\" in pieces.get(\"closest-tag\", \"\"):\n return \".\"\n return \"+\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_pep440_render_pep440_pre.return.rendered": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_pep440_render_pep440_pre.return.rendered", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1241, "end_line": 1278, "span_ids": ["render_pep440_pre", "render_pep440"], "tokens": 316}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def render_pep440(pieces):\n \"\"\"Build up version string, with post-release \"local version identifier\".\n\n Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you\n get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty\n\n Exceptions:\n 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty]\n \"\"\"\n if pieces[\"closest-tag\"]:\n rendered = pieces[\"closest-tag\"]\n if pieces[\"distance\"] or pieces[\"dirty\"]:\n rendered += plus_or_dot(pieces)\n rendered += \"%d.g%s\" % (pieces[\"distance\"], pieces[\"short\"])\n if pieces[\"dirty\"]:\n rendered += \".dirty\"\n else:\n # exception #1\n rendered = \"0+untagged.%d.g%s\" % (pieces[\"distance\"], pieces[\"short\"])\n if pieces[\"dirty\"]:\n rendered += \".dirty\"\n return rendered\n\n\ndef render_pep440_pre(pieces):\n \"\"\"TAG[.post.devDISTANCE] -- No -dirty.\n\n Exceptions:\n 1: no tags. 0.post.devDISTANCE\n \"\"\"\n if pieces[\"closest-tag\"]:\n rendered = pieces[\"closest-tag\"]\n if pieces[\"distance\"]:\n rendered += \".post.dev%d\" % pieces[\"distance\"]\n else:\n # exception #1\n rendered = \"0.post.dev%d\" % pieces[\"distance\"]\n return rendered", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_pep440_post_render_pep440_post.return.rendered": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_pep440_post_render_pep440_post.return.rendered", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1281, "end_line": 1305, "span_ids": ["render_pep440_post"], "tokens": 217}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def render_pep440_post(pieces):\n \"\"\"TAG[.postDISTANCE[.dev0]+gHEX] .\n\n The \".dev0\" means dirty. Note that .dev0 sorts backwards\n (a dirty tree will appear \"older\" than the corresponding clean one),\n but you shouldn't be releasing software with -dirty anyways.\n\n Exceptions:\n 1: no tags. 0.postDISTANCE[.dev0]\n \"\"\"\n if pieces[\"closest-tag\"]:\n rendered = pieces[\"closest-tag\"]\n if pieces[\"distance\"] or pieces[\"dirty\"]:\n rendered += \".post%d\" % pieces[\"distance\"]\n if pieces[\"dirty\"]:\n rendered += \".dev0\"\n rendered += plus_or_dot(pieces)\n rendered += \"g%s\" % pieces[\"short\"]\n else:\n # exception #1\n rendered = \"0.post%d\" % pieces[\"distance\"]\n if pieces[\"dirty\"]:\n rendered += \".dev0\"\n rendered += \"+g%s\" % pieces[\"short\"]\n return rendered", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_pep440_old_render_pep440_old.return.rendered": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_pep440_old_render_pep440_old.return.rendered", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1308, "end_line": 1327, "span_ids": ["render_pep440_old"], "tokens": 144}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def render_pep440_old(pieces):\n \"\"\"TAG[.postDISTANCE[.dev0]] .\n\n The \".dev0\" means dirty.\n\n Eexceptions:\n 1: no tags. 0.postDISTANCE[.dev0]\n \"\"\"\n if pieces[\"closest-tag\"]:\n rendered = pieces[\"closest-tag\"]\n if pieces[\"distance\"] or pieces[\"dirty\"]:\n rendered += \".post%d\" % pieces[\"distance\"]\n if pieces[\"dirty\"]:\n rendered += \".dev0\"\n else:\n # exception #1\n rendered = \"0.post%d\" % pieces[\"distance\"]\n if pieces[\"dirty\"]:\n rendered += \".dev0\"\n return rendered", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_git_describe_render_git_describe.return.rendered": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_git_describe_render_git_describe.return.rendered", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1330, "end_line": 1347, "span_ids": ["render_git_describe"], "tokens": 129}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def render_git_describe(pieces):\n \"\"\"TAG[-DISTANCE-gHEX][-dirty].\n\n Like 'git describe --tags --dirty --always'.\n\n Exceptions:\n 1: no tags. HEX[-dirty] (note: no 'g' prefix)\n \"\"\"\n if pieces[\"closest-tag\"]:\n rendered = pieces[\"closest-tag\"]\n if pieces[\"distance\"]:\n rendered += \"-%d-g%s\" % (pieces[\"distance\"], pieces[\"short\"])\n else:\n # exception #1\n rendered = pieces[\"short\"]\n if pieces[\"dirty\"]:\n rendered += \"-dirty\"\n return rendered", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_git_describe_long_render_git_describe_long.return.rendered": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_git_describe_long_render_git_describe_long.return.rendered", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1350, "end_line": 1367, "span_ids": ["render_git_describe_long"], "tokens": 133}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def render_git_describe_long(pieces):\n \"\"\"TAG-DISTANCE-gHEX[-dirty].\n\n Like 'git describe --tags --dirty --always -long'.\n The distance/hash is unconditional.\n\n Exceptions:\n 1: no tags. HEX[-dirty] (note: no 'g' prefix)\n \"\"\"\n if pieces[\"closest-tag\"]:\n rendered = pieces[\"closest-tag\"]\n rendered += \"-%d-g%s\" % (pieces[\"distance\"], pieces[\"short\"])\n else:\n # exception #1\n rendered = pieces[\"short\"]\n if pieces[\"dirty\"]:\n rendered += \"-dirty\"\n return rendered", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_VersioneerBadRootError._The_project_root_direc": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_render_VersioneerBadRootError._The_project_root_direc", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1370, "end_line": 1409, "span_ids": ["VersioneerBadRootError", "render"], "tokens": 295}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def render(pieces, style):\n \"\"\"Render the given version pieces into the requested style.\"\"\"\n if pieces[\"error\"]:\n return {\n \"version\": \"unknown\",\n \"full-revisionid\": pieces.get(\"long\"),\n \"dirty\": None,\n \"error\": pieces[\"error\"],\n \"date\": None,\n }\n\n if not style or style == \"default\":\n style = \"pep440\" # the default\n\n if style == \"pep440\":\n rendered = render_pep440(pieces)\n elif style == \"pep440-pre\":\n rendered = render_pep440_pre(pieces)\n elif style == \"pep440-post\":\n rendered = render_pep440_post(pieces)\n elif style == \"pep440-old\":\n rendered = render_pep440_old(pieces)\n elif style == \"git-describe\":\n rendered = render_git_describe(pieces)\n elif style == \"git-describe-long\":\n rendered = render_git_describe_long(pieces)\n else:\n raise ValueError(\"unknown style '%s'\" % style)\n\n return {\n \"version\": rendered,\n \"full-revisionid\": pieces[\"long\"],\n \"dirty\": pieces[\"dirty\"],\n \"error\": None,\n \"date\": pieces.get(\"date\"),\n }\n\n\nclass VersioneerBadRootError(Exception):\n \"\"\"The project root directory is unknown or missing key files.\"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_versions_get_versions.return._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_versions_get_versions.return._", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1412, "end_line": 1488, "span_ids": ["get_versions"], "tokens": 619}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def get_versions(verbose=False):\n \"\"\"Get the project version from whatever source is available.\n\n Returns dict with two keys: 'version' and 'full'.\n \"\"\"\n if \"versioneer\" in sys.modules:\n # see the discussion in cmdclass.py:get_cmdclass()\n del sys.modules[\"versioneer\"]\n\n root = get_root()\n cfg = get_config_from_root(root)\n\n assert cfg.VCS is not None, \"please set [versioneer]VCS= in setup.cfg\"\n handlers = HANDLERS.get(cfg.VCS)\n assert handlers, \"unrecognized VCS '%s'\" % cfg.VCS\n verbose = verbose or cfg.verbose\n assert cfg.versionfile_source is not None, \"please set versioneer.versionfile_source\"\n assert cfg.tag_prefix is not None, \"please set versioneer.tag_prefix\"\n\n versionfile_abs = os.path.join(root, cfg.versionfile_source)\n\n # extract version from first of: _version.py, VCS command (e.g. 'git\n # describe'), parentdir. This is meant to work for developers using a\n # source checkout, for users of a tarball created by 'setup.py sdist',\n # and for users of a tarball/zipball created by 'git archive' or github's\n # download-from-tag feature or the equivalent in other VCSes.\n\n get_keywords_f = handlers.get(\"get_keywords\")\n from_keywords_f = handlers.get(\"keywords\")\n if get_keywords_f and from_keywords_f:\n try:\n keywords = get_keywords_f(versionfile_abs)\n ver = from_keywords_f(keywords, cfg.tag_prefix, verbose)\n if verbose:\n print(\"got version from expanded keyword %s\" % ver)\n return ver\n except NotThisMethod:\n pass\n\n try:\n ver = versions_from_file(versionfile_abs)\n if verbose:\n print(\"got version from file %s %s\" % (versionfile_abs, ver))\n return ver\n except NotThisMethod:\n pass\n\n from_vcs_f = handlers.get(\"pieces_from_vcs\")\n if from_vcs_f:\n try:\n pieces = from_vcs_f(cfg.tag_prefix, root, verbose)\n ver = render(pieces, cfg.style)\n if verbose:\n print(\"got version from VCS %s\" % ver)\n return ver\n except NotThisMethod:\n pass\n\n try:\n if cfg.parentdir_prefix:\n ver = versions_from_parentdir(cfg.parentdir_prefix, root, verbose)\n if verbose:\n print(\"got version from parentdir %s\" % ver)\n return ver\n except NotThisMethod:\n pass\n\n if verbose:\n print(\"unable to compute version\")\n\n return {\n \"version\": \"0+unknown\",\n \"full-revisionid\": None,\n \"dirty\": None,\n \"error\": \"unable to compute version\",\n \"date\": None,\n }", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_version_get_cmdclass.from_distutils_core_impor": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_version_get_cmdclass.from_distutils_core_impor", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1491, "end_line": 1516, "span_ids": ["get_cmdclass", "get_version"], "tokens": 302}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def get_version():\n \"\"\"Get the short version string for this project.\"\"\"\n return get_versions()[\"version\"]\n\n\ndef get_cmdclass():\n \"\"\"Get the custom setuptools/distutils subclasses used by Versioneer.\"\"\"\n if \"versioneer\" in sys.modules:\n del sys.modules[\"versioneer\"]\n # this fixes the \"python setup.py develop\" case (also 'install' and\n # 'easy_install .'), in which subdependencies of the main project are\n # built (using setup.py bdist_egg) in the same python process. Assume\n # a main project A and a dependency B, which use different versions\n # of Versioneer. A's setup.py imports A's Versioneer, leaving it in\n # sys.modules by the time B's setup.py is executed, causing B to run\n # with the wrong versioneer. Setuptools wraps the sub-dep builds in a\n # sandbox that restores sys.modules to it's pre-build state, so the\n # parent is protected against the child's \"import versioneer\". By\n # removing ourselves from sys.modules here, before the child build\n # happens, we protect the child from the parent's versioneer too.\n # Also see https://github.com/warner/python-versioneer/issues/52\n\n cmds = {}\n\n # we add \"version\" to both distutils and setuptools\n from distutils.core import Command\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_cmdclass.cmd_version_get_cmdclass.cmd_version.run.if_vers_error_.print_error_s_vers": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_cmdclass.cmd_version_get_cmdclass.cmd_version.run.if_vers_error_.print_error_s_vers", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1518, "end_line": 1536, "span_ids": ["get_cmdclass"], "tokens": 152}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def get_cmdclass():\n # ... other code\n\n class cmd_version(Command):\n description = \"report generated version string\"\n user_options = []\n boolean_options = []\n\n def initialize_options(self):\n pass\n\n def finalize_options(self):\n pass\n\n def run(self):\n vers = get_versions(verbose=True)\n print(\"Version: %s\" % vers[\"version\"])\n print(\" full-revisionid: %s\" % vers.get(\"full-revisionid\"))\n print(\" dirty: %s\" % vers.get(\"dirty\"))\n print(\" date: %s\" % vers.get(\"date\"))\n if vers[\"error\"]:\n print(\" error: %s\" % vers[\"error\"])\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_cmdclass.cmds_version_cmd_ver_get_cmdclass.if_cx_Freeze_in_sys_mod.del_cmds_build_py_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_cmdclass.cmds_version_cmd_ver_get_cmdclass.if_cx_Freeze_in_sys_mod.del_cmds_build_py_", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1538, "end_line": 1611, "span_ids": ["get_cmdclass"], "tokens": 676}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def get_cmdclass():\n # ... other code\n\n cmds[\"version\"] = cmd_version\n\n # we override \"build_py\" in both distutils and setuptools\n #\n # most invocation pathways end up running build_py:\n # distutils/build -> build_py\n # distutils/install -> distutils/build ->..\n # setuptools/bdist_wheel -> distutils/install ->..\n # setuptools/bdist_egg -> distutils/install_lib -> build_py\n # setuptools/install -> bdist_egg ->..\n # setuptools/develop -> ?\n # pip install:\n # copies source tree to a tempdir before running egg_info/etc\n # if .git isn't copied too, 'git describe' will fail\n # then does setup.py bdist_wheel, or sometimes setup.py install\n # setup.py egg_info -> ?\n\n # we override different \"build_py\" commands for both environments\n if \"setuptools\" in sys.modules:\n from setuptools.command.build_py import build_py as _build_py\n else:\n from distutils.command.build_py import build_py as _build_py\n\n class cmd_build_py(_build_py):\n def run(self):\n root = get_root()\n cfg = get_config_from_root(root)\n versions = get_versions()\n _build_py.run(self)\n # now locate _version.py in the new build/ directory and replace\n # it with an updated value\n if cfg.versionfile_build:\n target_versionfile = os.path.join(self.build_lib, cfg.versionfile_build)\n print(\"UPDATING %s\" % target_versionfile)\n write_to_version_file(target_versionfile, versions)\n\n cmds[\"build_py\"] = cmd_build_py\n\n if \"cx_Freeze\" in sys.modules: # cx_freeze enabled?\n from cx_Freeze.dist import build_exe as _build_exe\n\n # nczeczulin reports that py2exe won't like the pep440-style string\n # as FILEVERSION, but it can be used for PRODUCTVERSION, e.g.\n # setup(console=[{\n # \"version\": versioneer.get_version().split(\"+\", 1)[0], # FILEVERSION\n # \"product_version\": versioneer.get_version(),\n # ...\n\n class cmd_build_exe(_build_exe):\n def run(self):\n root = get_root()\n cfg = get_config_from_root(root)\n versions = get_versions()\n target_versionfile = cfg.versionfile_source\n print(\"UPDATING %s\" % target_versionfile)\n write_to_version_file(target_versionfile, versions)\n\n _build_exe.run(self)\n os.unlink(target_versionfile)\n with open(cfg.versionfile_source, \"w\") as f:\n LONG = LONG_VERSION_PY[cfg.VCS]\n f.write(\n LONG\n % {\n \"DOLLAR\": \"$\",\n \"STYLE\": cfg.style,\n \"TAG_PREFIX\": cfg.tag_prefix,\n \"PARENTDIR_PREFIX\": cfg.parentdir_prefix,\n \"VERSIONFILE_SOURCE\": cfg.versionfile_source,\n }\n )\n\n cmds[\"build_exe\"] = cmd_build_exe\n del cmds[\"build_py\"]\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_cmdclass.if_py2exe_in_sys_module_get_cmdclass.None_4.else_.from_distutils_command_sd": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_cmdclass.if_py2exe_in_sys_module_get_cmdclass.None_4.else_.from_distutils_command_sd", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1613, "end_line": 1649, "span_ids": ["get_cmdclass"], "tokens": 327}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def get_cmdclass():\n # ... other code\n\n if \"py2exe\" in sys.modules: # py2exe enabled?\n try:\n from py2exe.distutils_buildexe import py2exe as _py2exe # py3\n except ImportError:\n from py2exe.build_exe import py2exe as _py2exe # py2\n\n class cmd_py2exe(_py2exe):\n def run(self):\n root = get_root()\n cfg = get_config_from_root(root)\n versions = get_versions()\n target_versionfile = cfg.versionfile_source\n print(\"UPDATING %s\" % target_versionfile)\n write_to_version_file(target_versionfile, versions)\n\n _py2exe.run(self)\n os.unlink(target_versionfile)\n with open(cfg.versionfile_source, \"w\") as f:\n LONG = LONG_VERSION_PY[cfg.VCS]\n f.write(\n LONG\n % {\n \"DOLLAR\": \"$\",\n \"STYLE\": cfg.style,\n \"TAG_PREFIX\": cfg.tag_prefix,\n \"PARENTDIR_PREFIX\": cfg.parentdir_prefix,\n \"VERSIONFILE_SOURCE\": cfg.versionfile_source,\n }\n )\n\n cmds[\"py2exe\"] = cmd_py2exe\n\n # we override different \"sdist\" commands for both environments\n if \"setuptools\" in sys.modules:\n from setuptools.command.sdist import sdist as _sdist\n else:\n from distutils.command.sdist import sdist as _sdist\n # ... other code", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_cmdclass.cmd_sdist_get_cmdclass.return.cmds": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_get_cmdclass.cmd_sdist_get_cmdclass.return.cmds", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1651, "end_line": 1673, "span_ids": ["get_cmdclass"], "tokens": 218}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def get_cmdclass():\n # ... other code\n\n class cmd_sdist(_sdist):\n def run(self):\n versions = get_versions()\n self._versioneer_generated_versions = versions\n # unless we update this, the command will keep using the old\n # version\n self.distribution.metadata.version = versions[\"version\"]\n return _sdist.run(self)\n\n def make_release_tree(self, base_dir, files):\n root = get_root()\n cfg = get_config_from_root(root)\n _sdist.make_release_tree(self, base_dir, files)\n # now locate _version.py in the new base_dir directory\n # (remembering that it may be a hardlink) and replace it with an\n # updated value\n target_versionfile = os.path.join(base_dir, cfg.versionfile_source)\n print(\"UPDATING %s\" % target_versionfile)\n write_to_version_file(target_versionfile, self._versioneer_generated_versions)\n\n cmds[\"sdist\"] = cmd_sdist\n\n return cmds", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_CONFIG_ERROR_INIT_PY_SNIPPET._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_CONFIG_ERROR_INIT_PY_SNIPPET._", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1676, "end_line": 1717, "span_ids": ["impl:10"], "tokens": 243}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "CONFIG_ERROR = \"\"\"\nsetup.cfg is missing the necessary Versioneer configuration. You need\na section like:\n\n [versioneer]\n VCS = git\n style = pep440\n versionfile_source = src/myproject/_version.py\n versionfile_build = myproject/_version.py\n tag_prefix =\n parentdir_prefix = myproject-\n\nYou will also need to edit your setup.py to use the results:\n\n import versioneer\n setup(version=versioneer.get_version(),\n cmdclass=versioneer.get_cmdclass(), ...)\n\nPlease read the docstring in ./versioneer.py for configuration instructions,\nedit setup.cfg, and re-run the installer or 'python versioneer.py setup'.\n\"\"\"\n\nSAMPLE_CONFIG = \"\"\"\n# See the docstring in versioneer.py for instructions. Note that you must\n# re-run 'versioneer.py setup' after changing this section, and commit the\n# resulting files.\n\n[versioneer]\n#VCS = git\n#style = pep440\n#versionfile_source =\n#versionfile_build =\n#tag_prefix =\n#parentdir_prefix =\n\n\"\"\"\n\nINIT_PY_SNIPPET = \"\"\"\nfrom ._version import get_versions\n__version__ = get_versions()['version']\ndel get_versions\n\"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_do_setup_do_setup.return.0": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_do_setup_do_setup.return.0", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1720, "end_line": 1799, "span_ids": ["do_setup"], "tokens": 762}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def do_setup():\n \"\"\"Main VCS-independent setup function for installing Versioneer.\"\"\"\n root = get_root()\n try:\n cfg = get_config_from_root(root)\n except (EnvironmentError, configparser.NoSectionError, configparser.NoOptionError) as e:\n if isinstance(e, (EnvironmentError, configparser.NoSectionError)):\n print(\"Adding sample versioneer config to setup.cfg\", file=sys.stderr)\n with open(os.path.join(root, \"setup.cfg\"), \"a\") as f:\n f.write(SAMPLE_CONFIG)\n print(CONFIG_ERROR, file=sys.stderr)\n return 1\n\n print(\" creating %s\" % cfg.versionfile_source)\n with open(cfg.versionfile_source, \"w\") as f:\n LONG = LONG_VERSION_PY[cfg.VCS]\n f.write(\n LONG\n % {\n \"DOLLAR\": \"$\",\n \"STYLE\": cfg.style,\n \"TAG_PREFIX\": cfg.tag_prefix,\n \"PARENTDIR_PREFIX\": cfg.parentdir_prefix,\n \"VERSIONFILE_SOURCE\": cfg.versionfile_source,\n }\n )\n\n ipy = os.path.join(os.path.dirname(cfg.versionfile_source), \"__init__.py\")\n if os.path.exists(ipy):\n try:\n with open(ipy, \"r\") as f:\n old = f.read()\n except EnvironmentError:\n old = \"\"\n if INIT_PY_SNIPPET not in old:\n print(\" appending to %s\" % ipy)\n with open(ipy, \"a\") as f:\n f.write(INIT_PY_SNIPPET)\n else:\n print(\" %s unmodified\" % ipy)\n else:\n print(\" %s doesn't exist, ok\" % ipy)\n ipy = None\n\n # Make sure both the top-level \"versioneer.py\" and versionfile_source\n # (PKG/_version.py, used by runtime code) are in MANIFEST.in, so\n # they'll be copied into source distributions. Pip won't be able to\n # install the package without this.\n manifest_in = os.path.join(root, \"MANIFEST.in\")\n simple_includes = set()\n try:\n with open(manifest_in, \"r\") as f:\n for line in f:\n if line.startswith(\"include \"):\n for include in line.split()[1:]:\n simple_includes.add(include)\n except EnvironmentError:\n pass\n # That doesn't cover everything MANIFEST.in can do\n # (http://docs.python.org/2/distutils/sourcedist.html#commands), so\n # it might give some false negatives. Appending redundant 'include'\n # lines is safe, though.\n if \"versioneer.py\" not in simple_includes:\n print(\" appending 'versioneer.py' to MANIFEST.in\")\n with open(manifest_in, \"a\") as f:\n f.write(\"include versioneer.py\\n\")\n else:\n print(\" 'versioneer.py' already in MANIFEST.in\")\n if cfg.versionfile_source not in simple_includes:\n print(\" appending versionfile_source ('%s') to MANIFEST.in\" % cfg.versionfile_source)\n with open(manifest_in, \"a\") as f:\n f.write(\"include %s\\n\" % cfg.versionfile_source)\n else:\n print(\" versionfile_source already in MANIFEST.in\")\n\n # Make VCS-specific changes. For git, this means creating/changing\n # .gitattributes to mark _version.py for export-subst keyword\n # substitution.\n do_vcs_install(manifest_in, cfg.versionfile_source, ipy)\n return 0", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_scan_setup_py_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/versioneer.py_scan_setup_py_", "embedding": null, "metadata": {"file_path": "versioneer.py", "file_name": "versioneer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 1802, "end_line": 1846, "span_ids": ["scan_setup_py", "impl:16"], "tokens": 351}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "def scan_setup_py():\n \"\"\"Validate the contents of setup.py against Versioneer's expectations.\"\"\"\n found = set()\n setters = False\n errors = 0\n with open(\"setup.py\", \"r\") as f:\n for line in f.readlines():\n if \"import versioneer\" in line:\n found.add(\"import\")\n if \"versioneer.get_cmdclass()\" in line:\n found.add(\"cmdclass\")\n if \"versioneer.get_version()\" in line:\n found.add(\"get_version\")\n if \"versioneer.VCS\" in line:\n setters = True\n if \"versioneer.versionfile_source\" in line:\n setters = True\n if len(found) != 3:\n print(\"\")\n print(\"Your setup.py appears to be missing some important items\")\n print(\"(but I might be wrong). Please make sure it has something\")\n print(\"roughly like the following:\")\n print(\"\")\n print(\" import versioneer\")\n print(\" setup( version=versioneer.get_version(),\")\n print(\" cmdclass=versioneer.get_cmdclass(), ...)\")\n print(\"\")\n errors += 1\n if setters:\n print(\"You should remove lines like 'versioneer.VCS = ' and\")\n print(\"'versioneer.versionfile_source = ' . This configuration\")\n print(\"now lives in setup.cfg, and should be removed from setup.py\")\n print(\"\")\n errors += 1\n return errors\n\n\nif __name__ == \"__main__\":\n cmd = sys.argv[1]\n if cmd == \"setup\":\n errors = do_setup()\n errors += scan_setup_py()\n if errors:\n sys.exit(1)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}}}