{"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_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_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_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_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_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_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_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_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_main_": {"doc_hash": "44270ca53bd9a413fd269dc702eb297ff2f7e4e7867521e0ea29b779343ce7f0"}, "/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": "ea50bf1016bbc22883910bd280f3120fa70203a1186a0d8f4783ce70d7316d98"}, "/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": "88048d526fa05bd3ef01e43e86557e9071f0a2a5e078d618798a23d26f9485f6"}, "/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": "0900263e0e22234729dc6248c32fca7f8a189de6a49c00cfb3a18b36c91f1d03"}, "/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": "3554493f2c6d60ea028a9e23f3ef3e80b6d3cf478e7ca85545853cc6ef25a792"}, "/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": "34f027587d989f31a7f10166f70805f39ea5d1b6289b892e0d025e96284f42d2"}, "/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": "2d4aed7e46fd8c6c10e36edd29295746da2ccb91d30d4280fc0651daef061af3"}, "/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": "b83c677b2d8fa2c28ad44b0d6c22598db429fb88a6c2437911828d316d820dab"}, "/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": "c620faa14aaa7dca6c82a3060e161fc88439f0f0d723cc3ead59fae3c23b08db"}, "/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": "354872053e958a8850287f097445a2dd05437bb82d3e81745996ea881b83c18e"}, "/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": "a3a2aaa4c7441ac901fce76dd8fac8195d44a26c20d26183caf773f8a60d8fae"}, "/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": "52c2d2e1e334267f451cd24f9a5ed4430f09b0a1d94facb9d380830c2432b3a7"}, "/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": "1e6ac7b50253286b7ebdee9420381fd778af4f84fdb783aba5dc401434aed9b1"}, "/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": "a6aa873ffff28f32a43d2698c4dde831b77cf300f33f4092b73422d9be678a16"}, "/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": "e3e9edd9eec2458bc8b6b4552b01e288779f016c7216061c102f59584d963c6f"}, "/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": "f4cfd896fdcdf600d59cc306463842c48dd15f51ea413aa9e1fa7d96c2388152"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/__init__.py_os_": {"doc_hash": "cb20a3678f20faaa8eac4f361071817cf3c5eae32776c7b7d7b51a2da836c530"}, "/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/datasets.py_DecathlonDataset_DecathlonDataset._": {"doc_hash": "9572b43b98b5db6d4f81ec822ab62a47112a30f0c4599c5aca5d7185f3c121d6"}, "/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": "3d4f419babd1fee38e9973a240dd4614fc4b13020a5fd7e3e4a1ab3f9bdc2f8a"}, "/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": "7f2953cb54d8f73509cccbf826ac057e63a025270074740eac1b8bd8ea0aa596"}, "/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": "0d944eaade6e42a2c8c21cd3f351d65f915ddf4f65b81c1151f1aee0dda5dee0"}, "/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": "1193689f1946ffc030e195f4bc7f4219d0aed5dd48398b8bad6cb645f326a383"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/config/deviceconfig.py_print_config_": {"doc_hash": "e87bcd52d97572c08f3e747c0959b8571beaafaab4826766e3a660ace406f8b7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/__init__.py_CSVSaver_": {"doc_hash": "078de6a740c725f37be977473254fa94d99e75d8cd8f1092b70a04a68498dd7e"}, "/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": "1d84fdd857b21359de85d94ca038d894f78c8ebf968d89cb781290f70380c85b"}, "/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": "612a346e202ac65703977c39cd27e0dfcc4c75b52c160388cb93115fb73bfe4b"}, "/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": "48bc93e1fdbb5580b020e80f13db9712f1024a9ac2e57c7b3db933a0d9e1a136"}, "/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_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_load_decathalon_datalist_": {"doc_hash": "cd77f992752c09da60769ea4384f042d2afd48f328f37af5d3d7db94e096ae37"}, "/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_NiftiDataset.__getitem___": {"doc_hash": "7cf0e9d5d63544e10ad6f46f325c8cc7d7d5eddea7244e4f6337464a3862cd98"}, "/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": "4ef5b78b4a4166f5ac97dccabea50ad3a992fb8f5207b7126e76f0d4772a6985"}, "/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": "eba1502e4b6855d51ab92fb93255a6088885ad15055d7c2aec8569053a255c31"}, "/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": "46f302d5ea45e598e2d51e1920479a0e099eeb191be168d20b52cf165a3fdee8"}, "/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": "daf513aaf6f96534070b422044a8b157f8216c90dd132ded6543813aa82904d6"}, "/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": "cc31e6a14771296865f9b659725de6e0f3feeb6b344de80f765791f24f06da81"}, "/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": "c7a67cb7f68122f66aca7b7f0454d994ade0cc34707d9012a65b61eb4795c51f"}, "/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": "8e25a169cc0d28ada1b4cc9c065ec88b204b2b5ba01653481e4550db76d97ba2"}, "/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": "764ac48a0ac3381e5a8d11509706324546ed706000e80b79deb32bb979487ba5"}, "/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": "09adc8f4e58daea6dce225e9c42840a852e09fe7e201242e435e94f04f01ca60"}, "/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": "dd7afd5ecdebaa8870848d82d3ad314664f1ca8855cc2da77ee72aedcccbf56a"}, "/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": "aca8dd7011d5d9cb096d76871b1b19617b0966e9796c56e0f49ab8e7ec2513b0"}, "/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": "35fe64943f900259d20a8956ca9cf3002209eadeeebfa11e12ae91a7894ab06d"}, "/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": "71d6c03268f650f0e1d60d3f72eca58182c0e311ec246bf03f3c2eb6d79a7610"}, "/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": "bba57837a85dacfcfc3b2df0e0243a9de35b7ca5febc850ade70fb381c7887af"}, "/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": "9ff69fa927db88e197a057bf28739bd9cb0d7eb06a225017ea2024497e32ccc9"}, "/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": "07ad1478e2149724f343d190b7f4f97e7e50a685bc66d18057de186884ec02c2"}, "/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": "2c6505165e0156e96917918b3d49bfc58ace4bc550ad8e9a7e0f1524b2853e70"}, "/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": "145e11768a018d78103b87435af90ea3f1ee351e79cfcc67cd6bf15a2924225e"}, "/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": "b8d2e1e95218d9e4765ebc5732d1adef0eeb3a829a6d872e59a3352d3973079f"}, "/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": "b543ac748d26487efe1dd2ff63007066236c8936a05fc2bc814c9599e40ee305"}, "/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": "5d3af0cd1d40cba1c78f7874e517ee7bb1c98a48e595e947fb78022048a451a8"}, "/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": "be09b6053b99fbc21d41b0bc644a2c32f50993b62b53654865f97ed7c46ab683"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_EnsembleEvaluator._iteration_": {"doc_hash": "f6377ec40906eb6cd381b324605aabebcc398868bc6e8a4d7b26d2369f3fc4c8"}, "/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": "912180221de1de21ff89a84443dd752d1e201bc05402a299d7212a67bb44c76b"}, "/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": "51861ac58dad679fee117ea7fba629534bac9bc16c687b389d35196738ffa20e"}, "/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": "41b478ffaf278e0481cd3dd034cefbee37f37427190a82f2a84a039debb9c56a"}, "/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": "01fb26dea844877d7b13b549002f7990909e9d3907e10624516bd511bf64c1c6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/workflow.py_Workflow_Workflow._": {"doc_hash": "e83878d1e7600f8d107a494fd255708481e35dbc7d1c2668b987c3aaf4b022e9"}, "/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": "347aba94e45f0a64fd434725745490f4e9f12804c58ff22112c9c137be05f780"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/workflow.py_Workflow._iteration_": {"doc_hash": "fbe2fba07d935eecd1f2740f9d5f7870f18517d0d74ee061142ec37c4bdb2f4d"}, "/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_saver.py_CheckpointSaver_CheckpointSaver._": {"doc_hash": "2e886d085e2d756982f08b3ea09a3ed6bfe7efc196fc4f7a8ae44d27d7a7f454"}, "/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": "bc885a62490040767bf5e41ac29760760c058197178ba21d23cfbc81ab837543"}, "/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": "cebcb1dd467255ba80392a282d73ca2cd398a7ad1bc8d65b41bdd345f051c469"}, "/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": "987c5c6a6117caffecc10c876b5f852ad05a8236a6f0ca9b23427cc1d6b43f7d"}, "/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": "ac579b9215289a6fac628af996ed08a512cb06d6a7720d25473c84dc81a32a06"}, "/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": "81cece50d267df57e3612306cbc8de3a5a341bd1492dda41509ba534d401e986"}, "/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": "9139e835b85d0cad0520c9cbd8a0e304d5b596f014d828fed19fa47b70f7470f"}, "/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": "7ff8d36ea080b0cbfcc0336f05e9e970571e53c69e75d7df3bef66abf602ed52"}, "/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": "60ec4c8b12f1a69ac9bcea86466a1a7d58ebd23f82e34595499f007da43f5b90"}, "/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": "ff6798bd1ec4b9175d5f261fc7aecc24997e0851d3927156f342ab22ab72df8c"}, "/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": "34bd3ca83ad13cfed25ad53801270cf9fb92c8d6ad485ba6f4a7719c3eb94df9"}, "/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._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_TensorBoardStatsHandler_TensorBoardStatsHandler.__init__.self.tag_name.tag_name": {"doc_hash": "1271fe3e45d6ffa7c52457b362e4ff06c13d56fba2a4705a40c125ee0a7bb8f2"}, "/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": "5793df53e7d9f79287a8eb189948086d26afcfa17c3313ea43ed4c145e8fe554"}, "/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": "f9fe6715b512edc8f26b1be590df7ba3ebab1152118f3a8f1225880828008549"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/inferer.py_SlidingWindowInferer_": {"doc_hash": "464834f0d955662ab266d7acfbff240b815def600d2d403597d728398c381e35"}, "/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": "325441a7613ce0bc8915843c1af2a8b99f91c1d9cfc2c4a66b0f05c3493234af"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/__init__.py_Dice_": {"doc_hash": "2d5ca0cceba1f872330b557d677ab91527f4bb18d11c1af3c235ae8f6b2445fe"}, "/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": "929d16c2bdc45e17364eea2445a26e38996eade512c2966c5440e215ba51d06a"}, "/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": "544b2283ad80b97a71cb88f3e7caf490a38b516b1ef2d936678bf811a97452eb"}, "/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/tversky.py_TverskyLoss.forward_": {"doc_hash": "c93a08894d296136e5c6fcf5457b622291be65e3e4177d07cadd634a56509421"}, "/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": "04b51421e2547a4c90a3c79314542c9c8cc8703234b83be2ea54fdf4305851c1"}, "/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": "5bc8bbe6a3f6ca4d2f5fa90e901bdb02cc406af52f1c5be7c277e38a19d2e7d5"}, "/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": "faaa792529ff7845c8828fd98cefba32b6e55f5c67bdd48c7a55bcb3cdfd4fc7"}, "/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": "0f82b92b67d340a4e411ae20c350bea8d8f917988055b79c611dfeaf41e5bd66"}, "/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_ResidualSELayer_ResidualSELayer.forward.return.x_super_forward_x_": {"doc_hash": "e3e99cf7a7a7e462f4c5d37e184cc663553f5bdc3d6d909a89255d26ceeddfcc"}, "/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_gaussian_1d_": {"doc_hash": "41ebf500ad63fc8d1d0d488b81397fcfa61e9e2241e4daded87c409f03befa16"}, "/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": "0938f8f461e8599c093a74e53001746375a36cf124aa4b4484a1421e2d1f3497"}, "/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": "642c4ff14bb7576a4dfa0a923a7ae85fdf24f68ace664d71e211b20f42e6efcd"}, "/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": "17a5229487126898d258349eb9f54ab64d798a00cc975135a5fdf7e5cfb82591"}, "/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": "46c15ba02ebd30c2bce26b49269b2113055fedcafd2276c4f42ebcd03179874f"}, "/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": "bb8dd315437b6541bf5af123262b0cf533590dcb57de517557800e5185d2af4a"}, "/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": "7ad3b1ff762f4f21032df8d211228e554c0fddc414522bbf90eabc83c1ac607f"}, "/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": "b2a468731895e710cbcafe56b4af11d0f8edabb3e976111ebe4d6743bce68d3c"}, "/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": "f7ccc05de4644310159d48b100ebfd1eafc2a5a5b7c0481e394e828d7a1a866c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/classifier.py_Critic_": {"doc_hash": "7029f9bf43211c9b7ae9752c0ef5c8952b771645f055a851e06ee833f9576c6c"}, "/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": "776100b38a58d8c94198ca0c7ecf58b3fe51a0cf10bd1019bf37dcbfd8b9ddd6"}, "/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": "de58d6a825da91f4ba9ac313d55438ecc0979bf9fbf867ccf5db5b5c6b84f967"}, "/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": "6a10fef7cc8d79fb27c9e9a60321e802e000731cd14701b480cc8b33d34e03b9"}, "/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": "227531728e699f37f906e1a900e7b711f8199e9fe61f936f8f0bf0850f4ab50c"}, "/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": "cc80a4f3f2427c15d592aa4a79511ea461df52e96b658ef26e37c5937007d7b5"}, "/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": "0b4b0e5f3e033d87e74010cbbd17e9b157514932cca6d305eca1d489672938bd"}, "/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": "52f2d39f0cd31601c71546bcafa251ed8779699703f9217871b1203a8e77898e"}, "/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": "90207e4cb3b260b52b0aac332b4935e2bd49922d175c3a89c7fe84173aa38f5f"}, "/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": "df5733097150a3ada77d090b0097d7c6f42587e13aa5d642d3f5c5dca1408358"}, "/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": "5f7897c3117a12fd14dec71b5f42e87a1a1e87717e09e0d366789a2f760bb6a1"}, "/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": "ddf65dbf89c01711f86c8799688f085b2ba736808f2cd0bcd1aa0632c9aa2e4b"}, "/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": "ebec1dd60ae29043742bf0c3e791d444b1042543b6a1ed809144bff4e83a30a9"}, "/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": "ea77ddccc641443b4a808bc67407483a0970fe92238a6d917d118695e0e39ed6"}, "/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": "8c1a32cc0df09b560e409dbb0989deb8ef34dfc935b482e990fc4ac08e7c7ca8"}, "/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": "3ab3e8a26a49b8f8b764ce658df50e519455e8e25da1368d8409828e8fffd799"}, "/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": "f1204beb03a20d381c3479a440123026dc729fb2281b8a33e6fca82e69933af5"}, "/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": "f0480cf147cfaff5df8dedfa70f4f6d93d2ffe0e302279bbcfc4d7b305ddc366"}, "/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": "a91f8ac1d3743447289da8bf2338daa420ef4904d4fc727de58e300f61a8af03"}, "/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": "e472ddeadced68f1707d4a7103f1939cf050ca44e6884d7592d0f16827966095"}, "/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": "2c76e35889050fac8b55cfabf89b58ee11623333d06e8e6f959149f9003e5fec"}, "/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": "cabd129328f820504d799f7cda8b74f0f2d80309d29e6821fc645e129b75476e"}, "/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": "b30d403661f86428b2820598fcc68b74134d5115e6f8cd1c49775d5cdbb9dbfe"}, "/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": "b06844c1c17dddd86f3e86c0805179521e0f49f7a98706626f27cc52e7b8a84e"}, "/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": "ae0ce09120a7675ed5a13c0cc783a6856ab75ce0e16bc35a3da75d4c80c0c232"}, "/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": "1a75e90f0359ebda16625c79b6f0c15b96561ecb2302eb856e18995947175048"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_MapTransform.__call___": {"doc_hash": "4bec4fb68a1e8637a8e1aed6bf1fc5665d0b2422950acaeec9f9605f6437390d"}, "/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_SpatialPad._determine_data_pad_width_SpatialPad._determine_data_pad_width.if_self_method_Method_.else_.return._0_max_self_spatial_siz": {"doc_hash": "f4b45f03d700fcb0535700f950a7a2ee3d9e8699170bafe7cfd165c41ad720e2"}, "/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": "4b3aac2b728fbea6ac20bed7c85eccc2dec303b14501ad38347f546af5805d8d"}, "/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": "2acf58ea199dfa18b027a4a15f372ec698853a10f0afd55c0c670d6990160b7c"}, "/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": "85f64a334e3c42a591fd99576c01f3b457132cf5a90430f3ec055ab08288af0b"}, "/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": "531098005a3b221ddfa0b190ffbd004e6bf7ebc7619a82b3c72c16b0649921bb"}, "/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": "45d51563137b5ed0142e4c11faf1baf54e3f0a716ce210004cc4206d108971bc"}, "/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": "fadf8b89cdf0cc75f29fac72180fcccd6b2e01b6ca3d15ba2ca2750bd1ec872a"}, "/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": "0875d75c07206990dace57a4a6dd717b4770685eeeba9f425ccb9c328ff0fe60"}, "/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": "505a50e1662b318ed42d04db720d8a627b7e3df1d11fee89f36dd696f625edee"}, "/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": "ab4e7b3629d633f68c44b60c975dc003a4871e29489fe4f59c6c40e22f2e11e2"}, "/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": "3f82432099066e331a37617e737f709e78359e4f28ff04a7949d52905f28f738"}, "/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": "5b827c083eabae27e3cb30f6d2fec013aa0cf4744b047bcd48c39c3d6ff49869"}, "/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": "a36703249a6767a7584d7d8fb6df1d83d5278c0e9a2429169f2541db9d8f6fd9"}, "/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": "7a58d05ef72d8c286395e2ceb2ad8d8fe3a38b8442a30565c20c1b26e0d8356e"}, "/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_RandSpatialCropSamplesd_RandSpatialCropSamplesd.__call__.return._self_cropper_data_for__": {"doc_hash": "9a309e5754e621cfd5083e6e2156e0dbf68ef6c533b6a720775c657a7b5e5063"}, "/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": "d95d59a514ed7c6d049e2ecfae67845cab14de2229d496f90bca2ddbb86970ac"}, "/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": "93706b17b8131616714bf69ab7f30b22bfa6636629f8e150f9f193d627ce179c"}, "/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": "cbd50203d5c6cc77e724da0aecc84dd02482f2a2d188cceb10d628d54aac6c45"}, "/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_RandScaleIntensity_RandScaleIntensity.__call__.return.scaler_img_": {"doc_hash": "db4ab26080c6bf6e97277fdd7890472b008179f1f1e42b3f948ef6c2028204fc"}, "/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": "533789fdac21bb3186ff5aaada23446ee742f645d91e86d19cff57b4fdd6c52a"}, "/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": "e8dcfad1645003386ac24d49fb1dc46d9ab90b04d9d6edf4b6319bfe3f5271c6"}, "/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": "75816f57b3109205763f7b47da12afc61005a2820271cb6d17667eb33b52b40a"}, "/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": "79c7f0de5608bc5b329fe71e22073014bf4f745ad27274388cfbb5547a1df989"}, "/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": "b9a407e75a70edebf09a0e0ae157692cf7ec6a25a6a417c4a4235c464b0530f1"}, "/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": "282554196215acae03236fbb8f747f6ceaaa9c9f5e64cc56059b32107255eab5"}, "/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": "e2c477e142c12a8bbeac2fd946408c33cd7377173cf04a1ba0686a95e43002b8"}, "/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": "05955878dfccd963439c1bc8cadecf6abec514d7023b458452874100768228bf"}, "/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": "4b6f41e40e6da7d4b7b0d6c407388e1c0009fd40e2a3b50e190002d7cab7ca6b"}, "/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": "a1cf1a6d3501875f7efba2f668158bdf1d434a749ccccc89f58f635b0c758d01"}, "/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": "419557755443177654f838305064c25c2659359e3f50714524786b4c42780f24"}, "/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": "9f651219ca51434b092089729d7e36ba09099351a523c5ff7354bbb1a5492f81"}, "/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": "bad6144ec90ef45cf9c8cc6f719007594227fee7a98e9edfd607e292dda95c0c"}, "/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": "2ef0ae6a718e835401d45bfab1a7e0f97c6e7e65f91c3545163bec6a8f5371ff"}, "/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": "3de77a6eb72620a81d441baaaca7420ed1961618ee0aa6e2f152519fb62efb44"}, "/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": "10858b64add0cf91342d678cf369c3f8ff32334aa3716874c1ab73da71659fb5"}, "/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": "540a7292462f70418a9ad432d4dfc4216024885879f296fd9d900cc9b0a9b975"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandGaussianNoiseD_": {"doc_hash": "d0ad76229c8906d1671bb6fbe13aa00c1161cfda4331a11c2ae4606ed14f1ef4"}, "/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_LoadNifti.__call___LoadNifti.__call__.return.img_array_compatible_met": {"doc_hash": "61121b82c50fd6508e311a2ed196f174f586856dfb770b2a0bc412f35286babd"}, "/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": "793ce11c3a33ed0737fad3edf49a2f5b058a8901fb16a8b81912a64a9c2ffcba"}, "/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": "4c063f1a7d2446495b001c39ff424453b15c18c88959a05c2666412b3162ff15"}, "/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": "1f5c5d2f278bcbba1c4eeddd46b25814657fb9cb95ad66fca780c2bda3c7f9e3"}, "/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": "d2f137f605896b4c7a67777e2667033e81bc0da5ac496a057b13221b022bd654"}, "/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": "72df2d3a20909fb889e685708838ac35e611e627d7ee01084084afaf0413112f"}, "/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": "0eecb358c52e770aec198ca6cc1660d3f5fbca2967526d6d045857f857efe22c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_LoadNumpyd_": {"doc_hash": "01823ebe74152eebf2e537e6bdc6413a9e6696e6787d5ba9455f90fed7cec5d7"}, "/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_SplitChannel.__call___SplitChannel.__call__.return.outputs": {"doc_hash": "d91b9584461bc5e9f735ecad981192e50afecd8f60bb32570bc703c8fceaa3c5"}, "/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": "9f650e586c21947d5c241114bcbf47514fd00e862b0e54260aad33b020cac84f"}, "/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": "a9e3240198a7c13b2e9dfe892d3a6113d75382ca6ae66aaa02d0fe9012357852"}, "/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": "85bc9b0d0e4f667ca86c75f0664049e9c352ac1eb3c26beefb76e759b0826d26"}, "/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": "13d908937a6d2ae49ba51e8c5fb7b1bf458a61f3dce2fa1a33a953bb7e910f6a"}, "/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": "de5ecc0b7185aec4b08236336c5f81f0ff2377afcb6febb090b95cec1ebdbdae"}, "/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": "39bbebc071a029d0beb5949182bd12b8b9d8ae2de0a5ed4580611dc3e4cadbd9"}, "/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": "c78b59c1894b5bf619dfc8edd8e805259df645008ef9c2f3ea0f7b16811b6c16"}, "/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": "8bffd806b32417cacc34d5ce6ee85daa42b8b4d16bce0742c972b44633735e40"}, "/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": "ff3c26d78d83b83ab588ac0a57d13fffadeb57ec25ef120b694978a2ec16ae25"}, "/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": "5e129a610e382747e0ad56b340d2a7bc9f89207d2f4863161a7ef1b5b9ff131b"}, "/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": "539082bbbe4c555e09873787c51e50984acbc569a2a2a219d71678282acd60f6"}, "/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_Spacing_Spacing.__init__.self.dtype.dtype": {"doc_hash": "a7416c19f4f5a804c54ff9d5962de6be906f1d55e5bae10b4eba66e92058dbdf"}, "/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": "3178c69b74047cc9ea274a61460fe02e0959eed353a98bd680de3e2cf07e2b08"}, "/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": "60b2772e4f9a724747f03ff288e7b10f7b804e340633ac3e9de00ca83a96905b"}, "/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": "302583c77288c8465ee6adcd134ca44189c310326e39705ddba2364ea5a37f59"}, "/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": "a46a218fe8b4f5e91f4214ed26f4a3d96368b7da9ebb19c8905962b691f9744d"}, "/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": "f76a80d5c448a852da9087553249cf66120a6c801ccb5c741bbce2c5f8f72a60"}, "/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": "0e08b5adbd782d14039f471ee11870aae34b773ea6ce2cb0d029d15700f38c13"}, "/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": "fac8d0b529e9d9641e3be424b6c2857ef2db7ad15949b3eb41d2dc0504bc8ada"}, "/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": "d8bc0427b8779a154258777dee2b8ae53ba6a3723438a286109b779920d03cc5"}, "/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": "901f45e48aac5b37940ec8782404783662196712af7abdbb0a002aeaeb03a4ac"}, "/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": "53e74789a8b860ec0824c21010e7e0524c30e4a496e12a27320508de26506a2e"}, "/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": "89ac8bbf25428a5833401d661169b357a90aa01fca82051af0b029eba2e87062"}, "/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": "0948a1b1421c96f20ea5d198fdb6222709bb304042a82da77c842a24f0af81fa"}, "/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": "7b31cc62b0bbcc09ab75579b4f9a80054d89770c0fcd6ac13c7da36e6d628d12"}, "/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": "98299b8394be249215f5be606132dcf86c981a2aa1f2b1098a4bce5eef0b6098"}, "/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": "74901a2c5fb354cc9736577078c55a773c51d2f96ca473bd714ba3a16db02d20"}, "/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": "4ec82a842d9af81c4f5a1822365f79e45e6636edc86f658954a483930b655eb1"}, "/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": "09bf40255ce499586e831f916872138a109173adbfb80020b3c1268fe23984ae"}, "/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": "0bf8ead7fa41190d82427f5e21ca4309aa1e69a7da98125484bbcf3464416b7c"}, "/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": "79e1fef698ed9137b191bf60d33a82e660ced774a4bc21fe6a2d737e14956de8"}, "/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": "cc5f1f05fd363563dd52381f961e07687a852269726de2666458fee24d5215cd"}, "/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": "361c1789c34567d7d284f79c57eb097a4fe8b80e9ac92d56f58f8b6b4022509d"}, "/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": "916142e00aaa44ab0ce7fd48a9e1912b6741b7af02054f97ea8746919c289881"}, "/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": "af1593fc8f3c493955c921380b79fa434493bfb1178f50f982a7b3caa8a24419"}, "/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": "3620d9f1e3d32b98c6588b68bc34d9ec249b836d122a2ee381534d1dd558ecf6"}, "/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": "12da7cc59495d1be04b5f104c7a9b70c729c44e3cb67c9d055ae1bf13357667a"}, "/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": "5016f5284a8ebcdccb6f850195b91001b03ce5d7ccfdd994319ed09ed493e643"}, "/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": "76cd4d60742d5966913dede3811bbf6905862b1b721e309fd9f046aa6e227ca7"}, "/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": "91f0c22865c824088f5dd16633ca08d311d9ffcce844933f412e47effed92fc8"}, "/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": "a5252b05a2dcb9199ef5075e811c3eb92769232655af50f5c4e16292bb126d03"}, "/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": "d16b3f257e3faf551cd5e2f7d8838fb0f4ada79f1cb5e4bc23eb4ddd01c3ae40"}, "/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": "038c4ff74ccdd7f388568eb2a4eaf588c0fcf68fc055a353b36486b3096790d5"}, "/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": "1f97dba3bf7cc39b0a0fef8354c55d70a314dec947a0fe7c5e09c57e1373f624"}, "/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": "1957233c45240443809aef13984ff0fb66a564b8ae67cd25c699089d78de9731"}, "/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": "0644a9bf01a7cc4ba8243df63e960f4c5940a9b1f13f1c3b2d931b12f97ed2eb"}, "/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": "8ed78d9075f1ef2851ef544ab210e6e3dbfe05cbe39df90e7ef5e7dddcf3879f"}, "/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": "d7e7e7931ce7140fcda31fc8aa965c3eea4aa521c43db3ba317e5542047e415d"}, "/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_AsChannelFirst_AsChannelFirst.__call__.return.np_moveaxis_img_self_cha": {"doc_hash": "fd80c56297d7a8acb332bd63a3cce6596e707734c416412344ef94648f560f3a"}, "/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": "4fb49149328389750de9ae65dda8a901374434f89d5952374465883edbb25ac7"}, "/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": "21aa4dd289ffe6e2797421779768d988df16caf0452d41222b99381d1a815936"}, "/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": "c836b976af76f6abeb6e372f7d32f4daa922192c32e14d04ebb74ce980f2b6fe"}, "/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": "43a7709843b0fa0b6936b7e97b4bb84e8b9e066cc94efadd4cfb86cb91fe0790"}, "/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": "ab8c2619b5f016b0c13d0b99f984143c8e458f7f6555809d700637640b7e504c"}, "/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": "99d90d4d42a22465731f3baca5c0ac722b6dada24b561b644139abccc6532a0e"}, "/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": "9f0ec4da56ffb85190c7a1d2e2cb06db8eb189a617b4422e15e852f3468c0b90"}, "/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": "558f5209af5505403bf6b4874f6653d427e1dd35476bbaed2e2f35fd91874cda"}, "/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": "63a60686088e40ff5bde832357c83add15a3984353b590e9c37b408bc8b4a35e"}, "/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": "325ea44d6f6478ad001326d8f91c4f8e0a32deedc115209539ad9edac852c847"}, "/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": "ad39985e744c75c5b80c70da2969d5580ba82e6e4621f667ed2e553f41e81ac2"}, "/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": "f9a32fb131513b08a02b77f43a01e4a69795ba222ac83f9c38c4ef41da68aa7d"}, "/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": "ba14bd7ad6c972e11e4473e8ebdd43a5457a3736e420f3b0c627c662f95f9671"}, "/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": "b31625369ad5889e8ee553bcc564e8d44422a4706d5e6a0b22349f6a00a7be4d"}, "/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": "3a47241d19761d0b49e01279a8b0e75968cf3af09ca77aa5c85f64251485db35"}, "/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": "f585ea6f7d78fec9739028396dfa7426a567879080cd5157791920721a6f9da5"}, "/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": "093d30b4e98be2251b320078ba7a3c9a2ebaa6506bb9eb1bb9ff7555d62c3bca"}, "/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": "c913849bf3ea58c4127776a2193073ecb93358843390c091eb3977e2fe91d7ab"}, "/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": "08421c7c60c53061ba4723e362dd6617b54564bbbdf5d3fd48cae567ed82c9fa"}, "/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": "74f126cb303e2be6ee53f1b50f2260e94864045007dfec07efd2d31eeea36002"}, "/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": "4b54720fa4b385fe6819209db282208160c4c0e7a211a3c0f63dd8ab0e18cacd"}, "/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": "cc2c580c2aa154862c565e7af7c72d7c4eab78a56549eb8c55a722ea7497f0cc"}, "/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": "a9c6ededf3ff1382d49ac39f50d6280ebc76b71a78da5d79d661b98a3159ec2d"}, "/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": "adfd5cc41f25b2fd13f8b5734caecba782319a758a7e40274066a8c209cba9c1"}, "/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": "a9639862017e744cf732eb383b5bfbfd778351378543fc8e71388e77338b9228"}, "/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_rescale_array_rescale_array._rescale_by_minv_and_max": {"doc_hash": "0b13223f755835160a238178632082f25cc07b51899c367d852828a68b21dcfd"}, "/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": "4a944730fe148300dca3b662ea0a1ddc5016096ce1a2ad898e482b2503d43fe9"}, "/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": "8e092c1442386af0e367dd46b312e6d563ae4af49be32f7ded0c327d9018d34b"}, "/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": "3f0059e98dbd4e04a98dbbc567ae3d8afaab95f4774b2bbb061d0ae2d20d1c8d"}, "/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": "82544ef344edaa3db91bef8f331f79429992af3e91396b708135448189356105"}, "/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": "20cb64bf10b7610dd4a026bddd37b2fa9244a4fa6fdb500b6d8118048b3f92b5"}, "/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": "ddfdb5a89c386f984574e99920e60d1ec0452be9384b10f292d1c5171657796f"}, "/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": "2216002bf98d130ab6ea2937da5080294b261e5083c2aed82372b41b50807187"}, "/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": "80fa2a62168472fa4fffcdc461d146eb12dc1cfe431951ee56cd5a62476d7587"}, "/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": "e70813750298044d0d06f2ab4ae7688486bd550bcbf84d95733ecbc71503ffa6"}, "/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": "5720ba61c50f12f4bc443d81bf4c7988aa851811af973e7ea4f791923c66592a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/aliases.py_resolve_name_": {"doc_hash": "f0b571d8fea7e4e78398b3d836c14e3a87ec4d79383258e72a47ffde69f6653a"}, "/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": "4c264211a9b98f2550dc6670e58f5ac06e0c0baac21398b9b9ab1e2cfb609663"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/decorators.py_MethodReplacer_": {"doc_hash": "393bef41bbe8d89f7c06c6463164583be0b41fb615eb9275f69a7d602dc95617"}, "/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_fall_back_tuple_fall_back_tuple.return.tuple_use_the_default": {"doc_hash": "740465a3c968d4fbc08ef6676116e79b74d987d719bfef89cad59aa2302b6f73"}, "/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": "2e1053772f77a9259c8105be9d5c43ff0e38d994f9a0ff1faecd1d57d7bf9b63"}, "/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": "e0af41c24c5879be133f9e300613b510f35860af44655f50d0c8c3decc36b05a"}, "/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": "2a4e5342ab72ff2cbf919c5a0f387104a3857b4f72c64a9aa56eadf7cebb647f"}, "/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_make_animated_gif_summary_make_animated_gif_summary.return.summary_op": {"doc_hash": "8fe68ca8f2a5c8bfb9f43f42aa76465e0ef24ddbaf1a61a9ad13c51154bc3e9e"}, "/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": "0dab65be7bedac6e4f0afa5d4bdfe2ee23264da7ca20d1c806a57677d3b9cdb2"}, "/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": "aedaac02c569e22223ae419682b39b9aa57d8083d7af4fd137400ab03b990729"}, "/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": "dfcee4bd98a38bb354ccd2a3b3ce83947246f1437f6dca0da47ccd1424a42ecf"}, "/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": "13b8c80f1c213091c2c3ec1f10737c7d76cb7f20bde0d8002af90045fd522da8"}, "/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": "0950ec2a224512b07173e4267e6c37f2dd2cd161f7a9c1994f5955be72acd925"}, "/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": "1260813797c7973f356ad443ea4050caa933686928dbcfc6bbedffc6ca14f4f7"}, "/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/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": "c29e9087b4dce8441f3a68914856e30504f4938320595a8eb76c5c7f5d9b83f0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_activations.py_unittest_": {"doc_hash": "ff87b9b0acb477bfa18bf2981781a1748d1022da0895333cf954aeed2b634b0c"}, "/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": "3c66bcbbacd993d8e37c93d3dc55eb2b554d1b4544a71f1761e3ab787e11dfb2"}, "/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_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": "c7d40e184132e887c18244c6946c91240fa75ced95b4ec7fee88d49f779a24b6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adjust_contrast.py_unittest_": {"doc_hash": "8057367f6dd6b93d7f8409562201f4c2e83dc61e92b613a90cbb4663d533641c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adjust_contrastd.py_unittest_": {"doc_hash": "9eb87071c8a78da6e13358350193ca074813c4b86a4173a881780e2172f9623e"}, "/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": "e48ba93f6040f4c15a4c29ebef42c1bdbaf96b35cbdd15ffba51e11745d4971b"}, "/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_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": "a394c41b41911fffd90952ddcb56d955671ef05f3fbf92c7342ecbe35728c042"}, "/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": "785f89049dd335efcca6f3f20a161ca73933542b9d93bc9cce2d29bed6a9afe6"}, "/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": "361ad8e307d5d6dc0cf2d6e324f43ac2f5620ec17ad5d7dc2eeed1d36f19a5a1"}, "/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": "fb4153dfa933bc110bea8dab911e4197b0d460271c13ec08aea15753aa171308"}, "/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": "7c61bff95e70624885022f8eac0c43134ef7096db8a1273dc4f16405852e4b63"}, "/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": "95241b9f889b4c1d90ca0b0bc8c34a7f24fecf3da2477477b4efe4a0cb3a57b7"}, "/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": "11b4ab0410cbca9b5c40e46198cea229113b23bf4b8717f21adc74dbe23efa23"}, "/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": "318e26b3378c951f5058dedff77a4ded60f775c58c5451782503231bea21607b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_border_padd.py_unittest_": {"doc_hash": "ec5796d6d76576a97ed81e27495eba61cf0d904f1d5b90eff5f27f396c14c4ce"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cachedataset_parallel.py_TestCacheDatasetParallel_": {"doc_hash": "f66a985327c137988e43c824e792c1dc96176df33fbdce9e81697976a2b9985b"}, "/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": "3874d5c19e9850acb445cb056296c09d1ade19ee2a0d11cbf196a5c8cfacf40b"}, "/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": "c17f465a9a9eac1ecde64ddc987aa41f0a51218c13a956756350316b9b5678f7"}, "/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": "20a6bf845f27546e644be9ca6fd22d3fa3bc0be01f1ca7eec5d3f364d2752c85"}, "/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": "d6175485275484de30cab6749b06283530d7b0c8366732b43174e3986f2fd52d"}, "/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_compose.py_unittest_TestCompose.test_dict_compose.self_assertDictEqual_c_": {"doc_hash": "076be8f8728abf4f7270cc3fdd0eef59194389c4d60958f7c8d35e9850a3fceb"}, "/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_TestComputeMeanDice_TestComputeMeanDice._DiceMetric_class_tests": {"doc_hash": "aab6726be83ef54933f674fe7f9731b4d6557adab09cf70f0a7fa487285133de"}, "/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": "5365487cf64c65d6ddbca49787f6a89d6e792aa73e9bde147c544a835816525c"}, "/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": "b6c73a1584293328beb8b757ea5e89eced653a5dd8a38cd3a37d1778c88dfd8e"}, "/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_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": "ebeb1f534aa51b93e54c29991915754a8ad223386a23e4ff3a4699ee1f8ebe7c"}, "/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": "6e47335733c3dbf51c76b2b8e23b0fd284d3556c5fcdba47c4898f135e365d19"}, "/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": "ae533a4199a1c3707bfea761e7a3eac91e2433ed9c4475e77f0eefb11caa1770"}, "/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_data_stats.py_TestDataStats_": {"doc_hash": "11e9a25492d9d1808011ddfb4953ecfb481aa3cd760b81231ed741ccca435043"}, "/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": "58e004c4e8e6b5078f8cd167d1035d99bd3c4cd36a3667547626da456aefce0d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dataloader.py_unittest_": {"doc_hash": "b307a6e1a93a8283b1d4f79d4f5c46ca28e39773ff90d99c11e39b6f95913563"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_densenet.py_TestDENSENET_": {"doc_hash": "35f359735dbb5e7c155c8fb4bf47f45fbfb5473878c600ec3984c9a930d55357"}, "/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": "18301066f509955b8930a5459fd2061d204763b5ce667dfd90bdbf9507fe140f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_divisible_pad.py_unittest_": {"doc_hash": "3fb883fbc498bf828fe679601f9d241362f79e33b52cd5bd58372fdbede6920e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_divisible_padd.py_unittest_": {"doc_hash": "398ea5bde6843254c7b8819dcc193aec47c610aa8524532052d719decc57ef65"}, "/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": "d5b4ff39df62a8740762a0eab664de0e2e67c74eb0f53ad98ebfbeba0cf652a0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_downsample_block.py_unittest_": {"doc_hash": "737aaec83d2859a989ed0b97c574998b8a2bdc871f36d572e26942af5ea3169b"}, "/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": "e87579b090534464f4ad814c93adc9ca1fd1b069338fe4517495233a2ce603ba"}, "/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": "07d4727af87525061c477f42f5a6667391b13327cd1083ee3852f2ef170a6909"}, "/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_TestHandlerCheckpointLoader.test_save_single_device_load_multi_devices_": {"doc_hash": "05fc64af56915cdf5c9b3ed1127d4dda2fc2a43aab3f407eaecbea152de60078"}, "/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": "caaedbadd3f843a01a22bcc6004aa02fe1d856c84878e855d6220f122a4c6bb1"}, "/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": "1bf1d675c73c2f418511ec754988be431966f520ff0a435c43c6ae2cf1a74b93"}, "/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": "08ad2572cf56868397bda3586650be97364c962dbd344506a5ab59591496ab52"}, "/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": "0dfb8e2714c725a80b9f3d9d26bc6a18a3d6cf2d9b1b399833c7f5b5d589663a"}, "/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": "532d4a295624e5205cd8a27739a84ede9f2ff3b9c952af7fa638492d923e1fe5"}, "/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": "40ad9e758af8f39662f867ee78445dd7d14f3df84a5e3df1bfc6f2226e95c54f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_validation.py_unittest_": {"doc_hash": "51869902b9b6ad5ce628a0d33961fb2fd51df5422d40b140994a8b6ce7296d28"}, "/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_integration_classification_2d.py_os_MedNISTDataset.__getitem__.return.self_transforms_self_imag": {"doc_hash": "1d7b98278877c5d77f4dbbf571aba64320b3dc132313c81cf66e4cb5d42c6538"}, "/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": "a967d7f7319bf4c25041e3a64351457848922874b5e9ab083eb1cd1107a671b0"}, "/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": "2952335a20c567e06e98a1eb93c6a2e4d43ee1611819c5c961137b63d8df5793"}, "/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": "30254577fb5c3becc5c2430079a8d471fb8aa461392a17080bfb265f189be29c"}, "/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": "06446424017aea6d7c4c372b6be44196f23e5d349414258f1ae00f4adf5c192c"}, "/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": "2969f90f5795bf4f95ed7a1a001b398b5c1020de9b8484b923721ada5e9a3649"}, "/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": "6ac01f3fbbbe99c3223c5578dda8e62b5dfbfae9350d5a8e6fec8daf06812b35"}, "/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": "792a006b04154bb999bcc9f56db656af50e8222d38036cee8db707739babd2eb"}, "/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": "04f4e25b58e54f27a101166ebca136249a80527d1a27ce37ca993fa652ce673d"}, "/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_run_training_test_run_training_test.val_handlers._": {"doc_hash": "8d230912a15499a73cf271beff8eec38e2ad58a88177e414e7e949d67fcd6dc9"}, "/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": "5dfd93a13d8dd721f573fb1febee0f534ec8adb483c8170fd522479ec4d45c8d"}, "/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": "3f566ccc5a35648b295e798f1575cd16c88e3cdb1120d14b5510268a05021087"}, "/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": "37fb7c58831a13e08d7479b1911e4b0c631af1ef98145245d6c7bea6e89f491f"}, "/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": "bdf554f93bb83fd0a2d2d0b4148c563db39990c7fedf6333f57f932d7f24bb53"}, "/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": "4e020e583fafbb564ef9cd7aa8fe2611e2b429b04596f075239d15cc4fb69ae1"}, "/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": "2b38d605ec24002402dba51174973f26a531739fde7de4ed5ea40b5a6d6055c5"}, "/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": "7142618ad0c5e1af24197b61855ca9055b305b628893bfade4f4dc8e6271f868"}, "/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": "4fae35c910b35b22450badda3029e334c1d7ca609bd9778d04efb0ab54979731"}, "/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": "959b8b79ce55d397d0aff4d4723e53ed873c8e3d47e09e2834bde39b24879563"}, "/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": "ee4bd3ea12ddb291c3e6329a0f9d209af1fd1b6084f70acfcb5c09430c3f4291"}, "/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": "f50c421ad20b950310543d4edcca261d92ab126361bfe60cbd53fcfc2aeeb379"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_nifti.py_TestLoadNifti_": {"doc_hash": "9769fd33fedee96f72f0c86fa46ea0c4d2b5de64ed74699f147e293e50721dd1"}, "/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": "b0c8a574fd810cc42b5379b76d55bf31cc7659b7c247afcab43f6642ad2e0f7d"}, "/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": "e5495f7a5a24c083c1e6f965f8a47cca6644f6651f18caf19d2d614dbd9c4d52"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_png.py_TestLoadPNG_": {"doc_hash": "6bc5d9057475c486f42ba3b10b2aef9d41ba6f2a50854b28fff86a38a825e73c"}, "/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": "349b199430cf531fafa0030e50d84d0a643505254d9463df63e1435fc3f22727"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mask_intensity.py_unittest_": {"doc_hash": "e6bd3b539ae0630510d6fcfa1347dc8ce780482405701a7e2070c1c5c5d11193"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mask_intensityd.py_unittest_": {"doc_hash": "0ea1986fc8d3697176320da37875b8d4ba942bdf42eab2e8a3601f5af2fd6db0"}, "/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": "4e7d96f5f435be9fdabbf32f531956bad1371c84a562de508057528a44b4049e"}, "/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": "1f5a02f3bea4a16d9b50b97aecb26e2a27b432adbc67fbf3b9a46d348d6f4360"}, "/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_nifti_dataset.py_os_RandTest.__call__.return.data_self__a": {"doc_hash": "2402c24472075ae70627ca1de4537c973678812d322a35ce943017a80ebc0bf7"}, "/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": "afb68eff5e92578578f94d55e82df3d07ad17462db6717510a10e101ef1ec12b"}, "/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": "4a96d30888cc1d0896376458ba5298ca38bd1d759b7e221eb49daf1560910f20"}, "/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_5d_": {"doc_hash": "d4a5629e6fd9055c4b2b1d01aeae4dc3a158947e1e7203005d920aea4eeb55fe"}, "/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": "a2b887c8cde6c5cce771574fa5d2a55fa0a24071eab789b2b88388e467f72b43"}, "/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": "71e6cf528bec178a7ce8ca809bba541507557b8441790b7e5c47f3a625ff9026"}, "/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": "f5dcbc567ad75c56700713b4cb1dd3e256d4c558a1a4a3cb534f0eefe422be8e"}, "/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_TestDataset_": {"doc_hash": "baa744ef85044c67bc2baf09d636a672620959132d4e86582044b0f334dd77db"}, "/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": "d9a1dae3663783b43e9341379ed38b38d8216b2f04ece15f88731e0cd8491647"}, "/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": "3cc600bd8e91cc696086617d4a64ca43e58f04b1aaf16028515a4c4d777f1b5a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_png_rw.py_os_": {"doc_hash": "1a9b73383e8e779a4d339aa10aaa6111432425b926f554225473202c29685cf1"}, "/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": "2b62ae4f6cb5a6831dc847cea303f65bac43ee922db99d1e666fd1985770ebd1"}, "/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": "adc4fa9caf249af05ec82ff93cacb15ef671e055205e2124e10c8afd625dd465"}, "/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": "7d98c4d49e281e353a5461ad0cd51ff274b1ca83562985699d54734aa26f78b4"}, "/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": "c13308dc4a5b6aaaf09b5259b4d8736f39f16c4280da803c447feeeb84b54783"}, "/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": "a77126c35eb9c5e56cae93fcbd2465846aa5ab54b557fb8e92e5679061240795"}, "/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": "0393980172ea050ca4ad28a0e8641e296b6907d586ca1119202f6e6012ad3951"}, "/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": "e6566beb65d4bba32936510a0fc175bc12c6ef61075bc9244cc4be289bc2c033"}, "/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": "19474c8dd646551505d4761564fcb5393dde54d13cd67eeddf9938a0155ab7b4"}, "/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": "747ae60944ee69b69c27cf47b479f42330e1bbe04633abbc10da3986c8b2f5f4"}, "/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": "604fabb0dbdcef750a5f04cd7a364c745cd3ec6e6b7cd1e80361ea5a1ae534ee"}, "/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": "4f004802cdfb93fc20ba17b8144abdad714d55cc3c4e393bb5c42b82f0bad8a2"}, "/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": "9515aa31b7dbc8ab539234d86d9b23bf504184a73b657e7bf684a20e9507eeee"}, "/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": "521117df25849daaa8b78991df01a1f9e54c1f0f5fe452236468fbefe61e3454"}, "/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": "576e2d355739332c69b2ab15d12d6217b74f68b4892f204e64557c2cd30cf264"}, "/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": "54d1897f278ec42d6e011431a3ab96d9725f0ca1187b07fe4541a3bd6d1d882f"}, "/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": "c19139d84cb83bf163ed8d43670e1461d2067c108448f44910df2ec46b66ce44"}, "/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": "1252f289f2b1fda2f603c629fa3d6d41b9dd7a63f0b1c781fdc4f67be6f6245c"}, "/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": "a54d23efaca49d77fafdeb62f150d211776a803ea8201e6df38727fa1b48b131"}, "/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": "4f74d1dd272637f04b3b6f76c6da524be374b6fb483d26a8c0d9c55934415e83"}, "/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": "169acb328b139d0595a10a426ef1a0d9427a1d0673dd896e1c8508901549f9ec"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_repeat_channeld.py_unittest_": {"doc_hash": "20100ed0385a51b96c1e30d0c89b367e049c85a38bcb89d1c0804d7d9ddee587"}, "/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": "23d6c809bf8c0355d60c027782735e9fa488a8ff2e2054440e53455e99931039"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_resized.py_unittest_": {"doc_hash": "1dd5be2cee894fc8f378ebf0e3ec803bcc7f20100e2cdd3cfbb0ac83ffb8a0e9"}, "/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": "4998c4cb113c135432cc4fbfb882ef2736a74e878164c03f8d6483fc6646e643"}, "/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": "6e687850ce41759768a6460c3752903304879225b02305860d2965aa14b3ba02"}, "/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": "74523071e15a901151bcd20b5e885f1d92e3bf189b8804657bc6824a51ad011e"}, "/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": "080d6a596041731a7d1b0fbd1048e0f181a6d232bd4c1dc632e901f28f54f508"}, "/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": "825cba8ed4d0d835d45f55d78750d3dce51817b35cf2de8894d8094474c29b03"}, "/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": "0ab0b438629a8ca1754f3df95028a57bba70d94e64c7ec9627ebfa615851ab70"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_shift_intensity.py_unittest_": {"doc_hash": "eafcfe0ffa84f851d775de4ce015593b3658e1062cb38273ba8b338da7b32ee4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_shift_intensityd.py_unittest_": {"doc_hash": "ce64070f3124c46bc0d833360c533654e7f9476efe6b1130a4ba71fe3893e752"}, "/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": "833249d5950ec59777bc3626e12e0a46071595bde73b39e3c2d014ddcd053e8d"}, "/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_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": "14cf60cffb711c96d016d7e091aecc4d6b13705a34810667106c3875a70d510c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spatial_cropd.py_unittest_": {"doc_hash": "48cd8fe933d2ad55315502c11a5b7eaa372a93232069087fe61266f14712ad07"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spatial_pad.py_unittest_": {"doc_hash": "df61fac2fae4f7913a19c47ffa45edff34aaefbf57f4f14d2e414cbf327cd21d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_spatial_padd.py_unittest_": {"doc_hash": "77f9041461dbf4785e5cc33b4dbc96295d600516e82b7581b8adee870ed9e01c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_split_channel.py_unittest_": {"doc_hash": "c8524316f10bba99cb20b547f665b86cf0f89d6187f219c8932e0f5a30c2cdec"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_split_channeld.py_unittest_": {"doc_hash": "d6887e275b7b95fbcce17c9b763547fb04cb5bb4b7af1e923887b57d0ae4bf54"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_squeezedim.py_TestSqueezeDim_": {"doc_hash": "44c0af1d49b45a8b3285cc6683a2c87402fc928c0b289fa1530ec17e11d3e72a"}, "/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": "23db653c6a59bcb945b0f48e7a2500836205a03aa5054c7273c9ddd60b5e01ad"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_squeezedimd.py_TestSqueezeDim_": {"doc_hash": "dafd8491cda6edaac7a92227fe4aecd6c1076bae4afb78d62def82fe1fb78b07"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_threshold_intensity.py_unittest_": {"doc_hash": "e79e4ba960fc33eff5c251dc18936ed295281ba9030c1e1ad9d61c45be09fee3"}, "/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": "f9e2b7808eee0e25a6b0744d6b481e458dcedd1a643c312f0eba68f9a37d37cd"}, "/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": "0b69d12b4ff760fd418fb13e6398464631d978cd64008190c24535ce9ba76c5f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_to_numpyd.py_unittest_": {"doc_hash": "fa305f5dc7e8f1c7ba6c219bf84e139a406ccfe41403966179e0fb8d7d499ca3"}, "/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_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": "613e55e8ef8fbda8e471b30e7bf7d91be99c08288f6b8ff94f70ddf3e9b5f66a"}, "/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": "bf6e9ea48e3328b5f1662737484a3f7e4ed72f4cc0c6b105d6b484c81d640839"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_zipdataset.py_unittest_": {"doc_hash": "24f2cce5c6aea27317d7819a945ce878a17c6f234d5cdce8dd89464df2006036"}, "/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": "01e77fd22239f60bb70e62fb607f2dae168d07a980bee5d6a5fe076444333483"}, "/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": "57196f15633094b2368b4f3ad13141c112982b85f03eade8333b3d7f191c85c2"}, "/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": "617bf358544f2f1cab9a1da78c4af06daa0c5575c26054cd53410e60fded1479"}, "/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"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_evaluation_array.py_logging_main.model_eval_": {"doc_hash": "3a78b0aa3fb9edf6c781a6b918798720736262f1a096dce24cfdc09c03133580"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_evaluation_dict.py_logging_main.model_eval_": {"doc_hash": "b91ca4525acd2c8fa79ecda3dd35ad3e5fc6d9496d713eb41486a96c3eb023ef"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_array.py_logging_main.images._": {"doc_hash": "7a1952f597cd45b75c1c80ea5590433d65167baadf217a3c886b64934e9a083b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_training_dict.py_logging_main.images._": {"doc_hash": "b3091ee408487acc448e1d489a05347eca5afce984a1efca0075e72dd1e40aed"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_evaluation_array.py_logging_main.val_stats_handler_attach_": {"doc_hash": "7e923760584ebe8954ac0e2ddba7b179d312fee66468807e47f5286fdf1cd875"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_evaluation_dict.py_logging_main._add_stats_event_handler": {"doc_hash": "7c6fe2257b1ced6374736b56b4c84330c24e12130863fabb712e002f5826dcbc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_array.py_logging_from_monai_transforms_imp": {"doc_hash": "4e814512b9ada72ae3a5bbe1419f9e777f5854e6c7bf53de45746e0505ab27fd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d_ignite/densenet_training_dict.py_logging_from_monai_transforms_imp": {"doc_hash": "5c2f6fa3145ec8342f776effe87bb77110ee571a21e776991cd271064997cab2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_ddp.py_argparse_from_monai_transforms_imp": {"doc_hash": "8f99eef7a72c36e1af076457aff1973c9a627cee143bc9ead32ad1f414bc89d0"}, "/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.model_eval_": {"doc_hash": "b20bab8f556815a161b80bedad7c0a053e194f7d7afa3cad13d0ea82adc5000e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_ddp.py_evaluate.with_torch_no_grad__evaluate.with_torch_no_grad_.dist_destroy_process_grou": {"doc_hash": "2837ff4fd8c5444269fbac927e9bc4d43998b4c815b052ff78c1cef5a0e8ccd0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_horovod.py_argparse_from_monai_transforms_imp": {"doc_hash": "4b5c2e5947ed0e81806a8a459fae846d1aaa75ebc3583a9fd732516921439e59"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_horovod.py_evaluate_evaluate.model_eval_": {"doc_hash": "97235153eebc2c6fbca15abd1f4b93fa997bcbb9939e2d71d35889db6ff45305"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_horovod.py_evaluate.with_torch_no_grad__evaluate.with_torch_no_grad_.if_hvd_rank_0_.print_evaluation_metric_": {"doc_hash": "bca3c7f885f24a70d14ad701e805743df6d4018212dd74055e8074862159a376"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_horovod.py_main_": {"doc_hash": "67de12efc7408beae397f91eb8923db3c62de2b9bb8607ddfbcd47eaa8e34602"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_workflows.py_argparse_from_monai_transforms_imp": {"doc_hash": "182259ad18b06fc90a3a55827a1ed7426e146257da269ab3afa4af57d60b2bfd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_workflows.py_evaluate_evaluate.if_dist_get_rank_0_.val_handlers_extend_": {"doc_hash": "576cd913faa3f8c032c498586fd2e5c8f3d105993d7ed908795319155570f0b0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_workflows.py_evaluate.evaluator_evaluate.dist_destroy_process_grou": {"doc_hash": "a37d952a714eabb29a17dc87d89db5a7935857800eb2488d773da363e90fe5ac"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_workflows.py_main_": {"doc_hash": "3ed730870981c4d2a151ef20abdf129fcb73993f088836fe5c05f2f718a2913c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_ddp.py_argparse_from_monai_transforms_imp": {"doc_hash": "37083388cd5d90ca658f59829e92c520437665327744f5a0c30c2ebb8728a87c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_horovod.py_argparse_from_monai_transforms_imp": {"doc_hash": "433ef7c25244b3171a59fd3acf9ee9f19baf6822e69d5d728aaa0977992b0824"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_horovod.py_train_train.model.monai_networks_nets_UNet_": {"doc_hash": "9144bf6643a046df8eb10b1b36b2ea58bd305f170a45765726dbe7efd3fe1712"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_horovod.py_train.loss_function_train.if_hvd_rank_0_.torch_save_model_state_di": {"doc_hash": "656b38af58852beff5b95417a97dd183eae9589ef9013b85d2daf6c9598c3ed9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_horovod.py_main_": {"doc_hash": "c7fa1d74654087dbcad53eced1ac6987d9ea538b1cd6e53f3d958725860b3d71"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_workflows.py_argparse_from_monai_transforms_imp": {"doc_hash": "92dbabf136a4148f64d7a3a16c5ba54b334d3310c72fa82fa30d546a6021e807"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_workflows.py_train_train.train_post_transforms.Compose_": {"doc_hash": "3490a248c436d694a860b37276c75b4a6ea91f15831ffc546bb442488ddae78d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_workflows.py_train.train_handlers_train.dist_destroy_process_grou": {"doc_hash": "ca0e9971a7051de1c51196e88a11993d59753e45838a1f2ce86614c3f6eace27"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_workflows.py_main_": {"doc_hash": "84704d1db0d1488c9123c242bdd330d568c8949ab7b3bbee6d30471c3a18a0ed"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_evaluation_array.py_logging_from_monai_transforms_imp": {"doc_hash": "49972a38004a589ea47f2a9810631aa108521c6adf9c53720c3deec7e4906200"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_evaluation_dict.py_logging_from_monai_transforms_imp": {"doc_hash": "3983da72816df1b0c48d0b1608d5ce91f3dfcc13db342529078500957b3be6c2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_array.py_logging_from_monai_visualize_impo": {"doc_hash": "aeb369671483d9450a20e7f2c23e8af831e024bc32b187b51cef2216ae358a64"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_dict.py_logging_from_monai_visualize_impo": {"doc_hash": "32b89e0c31632ee2f061e36f0f90ff94a6fcb166cb49785e4e468f68a60cf3d6"}, "/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._create_UNet_DiceLoss_a": {"doc_hash": "27d9f56bf5922ef436c1a6e89e8c4fc46895073ec22e7da5dffb39a23a8dd53a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d/unet_training_dict.py_main.device_": {"doc_hash": "2a36a5e7599d2803a5a1a3c7949cd29e257152d54ea37b4682ca04c38204299d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_evaluation_array.py_logging_from_monai_transforms_imp": {"doc_hash": "e2518f4b37f03243846179f4910caad47332c368522b8b13472d57d9da4e8542"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_evaluation_dict.py_logging_from_monai_transforms_imp": {"doc_hash": "6ee7dbf3119992a690e2b531fbb47f24da2370ead1363dcf40e82476296a9404"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_array.py_logging_from_monai_transforms_imp": {"doc_hash": "834c8155025d5b2d5b99370b449786168946dd3fbe697d22f290839921df4a5d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/segmentation_3d_ignite/unet_training_dict.py_logging_from_monai_transforms_imp": {"doc_hash": "2f29c78d2616ff75ab27ad480875ca57687dcdf6290e34294a676e838d8df3a5"}, "/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._create_UNet_DiceLoss_a": {"doc_hash": "9925d7965c284ea9c1a7bbde3e360d655cecbc8269d275925a9f11cb6eb30e33"}, "/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.net_main._add_handler_to_draw_the": {"doc_hash": "fda7637e26bb542a2cad58d0e4d6514067864d1fe5635333e6d033fc1803924f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/synthesis/gan_evaluation.py_logging_save_generator_fakes.for_i_image_in_enumerate.png_writer_write_png_img_": {"doc_hash": "77b323f757979676911e8a9d8ba1ecb54c7a2ffa55ccd220f825d3c69baef316"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/synthesis/gan_evaluation.py_main_": {"doc_hash": "6c9d65b6165a8817f0b2f991f8ef135433542c9de00a0493eac4c130b5cbf68e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/synthesis/gan_training.py_logging_from_monai_utils_misc_imp": {"doc_hash": "caffe92a780dd84771cef5836f5bbbd2a5b24a186a74931ad9a3b2fdf425f21d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/synthesis/gan_training.py_main_main.fake_label.0": {"doc_hash": "415a7be069609d125392ff6ebe7cbbcb1b9cd9448048d7489cd6b99f3020264a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/synthesis/gan_training.py_main.discriminator_loss_main.discriminator_loss.return._genloss_realloss_2": {"doc_hash": "c42dbe857acff93e2b381a638f236c60fb2e801639a1809750fdf329c427b7c7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/synthesis/gan_training.py_main.generator_loss_": {"doc_hash": "051215527f55f2fb277ac1864ae285b55b255ce5f370c8047edc061e3566a999"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_evaluation_dict.py_logging_from_monai_transforms_imp": {"doc_hash": "504e860625ff534ece70aca2c2d92a7acb0715bec017b547dc5d0790abfbfafd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_training_dict.py_logging_from_monai_transforms_imp": {"doc_hash": "7fd5db82b64a4888696690242439defadd97501354707734af4e2379d3f33e70"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/__init__.py_from_datasets_import__": {"doc_hash": "5e21a437cc12362763685185d29fdbc1b5e70830db713599c74825ab5c37c3f6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_os_MedNISTDataset.dataset_folder_name._MedNIST_": {"doc_hash": "8710b7d874d978f7dace87410843f3f1f3f9469028726613a9315ff9c8c98c21"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_MedNISTDataset.__init___MedNISTDataset.randomize.self.rann.self_R_random_": {"doc_hash": "967e5fb3889be098fe5ffe56ebcb0f334bf4b06fdee9f9532f55af52d9f22bc2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_MedNISTDataset._generate_data_list_MedNISTDataset._generate_data_list.return.data": {"doc_hash": "ea475d327276d2908742c4dc7abde381123f1c13d44c7f4dd87c16dc274ea306"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/utils.py_hashlib_check_md5.return.True": {"doc_hash": "3ed42b7877c782ae1c4b2254acd0a37668fab25211a60b56906523d65d8603e1"}, "/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_ValueError_Unsuppo": {"doc_hash": "093e7dc03f6fd3b36c2310c1632906491bc12600c692671d1cd73f95ebffb640"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/config/type_definitions.py_from_typing_import_Collec_": {"doc_hash": "5b8752431fc33966c8992b5287111eced6e039a3dcab741222499848f7843061"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/csv_saver.py_csv_CSVSaver.__init__.self._data_index.0": {"doc_hash": "bebcfb25bbe459a84c41fa061955a99abb79beba0e6fe2977b1acce7ae0cf393"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_hashlib_Dataset.__getitem__.return.data": {"doc_hash": "5bc45437d5183b8030e05382e14305ba75ac5f508605cadf059b02af5d1a444e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/dataset.py_ZipDataset_ZipDataset.__getitem__.return.tuple_data_": {"doc_hash": "32f7c4cb27597799e64cc18ad7996e2f35da758b964e8a3c108356c9ccd2ff4b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/decathalon_datalist.py_json__compute_path_2.if_isinstance_element_st.else_.raise_TypeError_f_element": {"doc_hash": "9f4089b37aeaa9d16fc0e40574f0b696909588a8e284c84cc27db6d63808b51c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/decathalon_datalist.py__append_paths__append_paths.return.items": {"doc_hash": "c4a118f936758c97f797016bfdef13d87f505a37bedc652d0bfe9de3b8f9c029"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/grid_dataset.py_math_GridPatchDataset.__init__.self.pad_opts.pad_opts": {"doc_hash": "554c703e44d5a215afe584d90346dd2aa45f9e747da407115ced2fd371115691"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_reader.py_from_typing_import_Any_C_NiftiDataset.randomize.self._seed.self_R_randint_np_iinfo_n": {"doc_hash": "1dc7300f3d3f876ed44e47c66b2d6005749dbb5543b25b8e08bda7338a13f724"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/nifti_saver.py_from_typing_import_Dict__NiftiSaver.__init__.self._data_index.0": {"doc_hash": "65f0f9e900dfafe5413c200a6675d14ba87bbfbaca43657f85b2d4ac0fc52e0e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/png_saver.py_from_typing_import_Dict__PNGSaver.__init__.self._data_index.0": {"doc_hash": "52f04f7c99a2fd71b357327bbcace3fb2524d8997d00157f074aa8f0c3beb17d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/utils.py_math_get_random_patch.return.tuple_slice_mc_mc_ps_": {"doc_hash": "f6f25944b66ecbf2f77204677245105be13be0c17580fc8e2f2488aebca7ca68"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/__init__.py_from_evaluator_import__": {"doc_hash": "d72a9640daaef329cbd31345bffcd38b2ee1df3c548808ca6dc343cac9d39540"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/evaluator.py_from_typing_import_TYPE_C_if_TYPE_CHECKING_.else_.Metric___optional_impo": {"doc_hash": "49c0ae7c30ddcd0ff820ed30de8a25f4061c01655cea27ce0d38c76981c67fdd"}, "/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_TYPE_C__default_eval_transform.return.y_pred_y": {"doc_hash": "a2a209a9aeb04b0bf1bfc5d0084bbe48c7f746775907a2bf5bda5568c7d77fc6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_from_typing_import_TYPE_C_if_TYPE_CHECKING_.else_.Metric___optional_impo": {"doc_hash": "b8b56b61103c564dc6f58374398afd33545b563817ecce5d319bc0e4092a36ec"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_SupervisedTrainer._iteration_SupervisedTrainer._iteration.return._Keys_IMAGE_inputs_Keys": {"doc_hash": "30f69e43668272fc38970c4b36c50fc7dbeb30d39ad64e13fcbda5c80aa04bda"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_GanTrainer_GanTrainer._": {"doc_hash": "0d63541759e2691174a0ad304f8e73efa4b521ba924f73fe36e0bc0c207d63da"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_GanTrainer.__init___GanTrainer.__init__.self.g_update_latents.g_update_latents": {"doc_hash": "aea14886df4cc7cbcc27a0e8e2a636bad5cb69fbbd248ccc0525a63bd25e0e96"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_GanTrainer._iteration_": {"doc_hash": "2a19c29ba92e52762ea1d2ea959d6ddd4e8d58ba976af6eefde00e4e0e8f9b38"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/utils.py_from_typing_import_Dict__GanKeys.DLOSS._d_loss_": {"doc_hash": "1dd31a2864708721a3a7234d8373316dc8383ebb823e7f9eef6542e343cac278"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/utils.py_get_devices_spec_get_devices_spec.return.devices": {"doc_hash": "567853941fa9643c29488a407f1f4f788b2be2572878254bc5200ca306d585b9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/utils.py_default_prepare_batch_": {"doc_hash": "146f786d0d19a20726461ca6cc194fd04597c7be4e014dd1aecee7f521d7aaa8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/workflow.py_from_typing_import_TYPE_C_if_TYPE_CHECKING_.else_.Metric___optional_impo": {"doc_hash": "7822bf328b8d628cd20f56db9e66223bb715504c7eefd8032be2e1d022057a75"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_loader.py_logging_if_TYPE_CHECKING_.else_.Engine___optional_impo": {"doc_hash": "eabed87a8895150f99a562c808efebe90bc4940f45270450b06508c535c17c50"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_loader.py_CheckpointLoader_CheckpointLoader.attach.engine_add_event_handler_": {"doc_hash": "0c26615b07856560b7d809fe341252f1f99ec65d6d2d5b0dc1172f8122950f54"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_loader.py_CheckpointLoader.__call___": {"doc_hash": "38ddcb01eb21384619adb49a831c176b520314b2cc1c212b123e255566628f0b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_logging_if_TYPE_CHECKING_.else_.Engine___optional_impo": {"doc_hash": "d62beb82f6e83697f2d26a5230923db264f18706e2aa582ff51ef49cbb913274"}, "/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.exception_raised.raise_e": {"doc_hash": "3c40fb8f269bd5acde37509aacfb7887925ded641ee498156f18461e39778b80"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_saver.py_CheckpointSaver.metrics_completed_": {"doc_hash": "86110b876b6da45d69885ca9c6ec46c456e2cde31928a42c4a9dd37143910b98"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/classification_saver.py_logging_ClassificationSaver.__init__.self._name.name": {"doc_hash": "f236362a33dcdc6cf9004d4dc714b68d4d64ec6d938b62e83e6e08cff43ecc59"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/classification_saver.py_ClassificationSaver.attach_": {"doc_hash": "1402772bf52684bddcbf48747a3d77ba538f4cda0ce9104cb041c4eb2c0b0b96"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/lr_schedule_handler.py_logging_if_TYPE_CHECKING_.else_.Engine___optional_impo": {"doc_hash": "de0e4a3f25e55e361ddac85f7f08fd5cc8c0a45ed541cbdadaaaf9ab0f939307"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/metric_logger.py_from_collections_import_d_MetricLogger.attach.engine_add_event_handler_": {"doc_hash": "aadd60a97986a60e0eacd1bfc5b29b1b5d0ee3c472c9bc3ae808257476c85949"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/metric_logger.py_MetricLogger.__call___": {"doc_hash": "849ad65e556b923f712b4d82290f163ff26dad61a8e4a75d59508e4474a27dc8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/roc_auc.py_ROCAUC.update_ROCAUC.update.self__targets_append_y_cl": {"doc_hash": "0f646e654d8ae4643ce18db1d7726f7d6131338214bf790d6e021f24b7d6e9d6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/roc_auc.py_ROCAUC.compute_": {"doc_hash": "963949027f661807f87a19df2c3c99644070a2f0425cbc83e12b95bb5adf355d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/segmentation_saver.py_logging_if_TYPE_CHECKING_.else_.Engine___optional_impo": {"doc_hash": "cfe5a4e14b42124e6b157f5bb61a2e9435ee610a04d2680bfee43c997270984a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_logging_DEFAULT_TAG._Loss_": {"doc_hash": "ec447c2f8de156cbb8a98f47a9f0e777bab8f908c694efe279801f8f6dd051da"}, "/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.iteration_completed.if_self_iteration_print_l.else_.self__default_iteration_p": {"doc_hash": "93c2b7b2e6753c4ae0906e07825a48515b1f99903895a74dfb7b9e61031c27da"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler.exception_raised_StatsHandler.exception_raised.raise_e": {"doc_hash": "ac1f266768d7d2dd65f715e3e08841062d8f91f8e8a15a4974ddaf624357deca"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/tensorboard_handlers.py_warnings_DEFAULT_TAG._Loss_": {"doc_hash": "984f836fdf8d56167597c89590d4b5701a2254de675ef4faa547995d27024d9e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/utils.py_from_typing_import_TYPE_C_": {"doc_hash": "d88920deec025b4354ed46dd0204d854c0765bbf6d116c5f8f1cf781f6533ab8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/__init__.py_from_inferer_import__": {"doc_hash": "d9adb6b69ed6266016fd56a9aa04e43c80fe54873e164ed256ffa085b45425d4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/inferer.py_from_abc_import_ABC_abst_SimpleInferer.__call__.return.network_inputs_": {"doc_hash": "775ab5287ca0b347e787ee764fe244f6ea7df80baf7603b648fcde755c691693"}, "/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._TODO_Enable_batch_size": {"doc_hash": "82f999e32d3a8e086bd70c58b2e5de719285c5ae233261313c6a7397b96f8c02"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/utils.py_sliding_window_inference.if_batch_size_1__sliding_window_inference.count_map.torch_zeros_output_shape_": {"doc_hash": "92e1c4a55c1072ae4a0dd00dcce4085ec6b65d910ab66918e545cba383a72cad"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/utils.py_sliding_window_inference.for_window_id_slice_inde_sliding_window_inference._2D": {"doc_hash": "5a4287186db6c11aa7655cd41bb0724d99035ee5dc7775e4feb5f53cc3f35891"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_warnings_DiceLoss._": {"doc_hash": "a9919c3754f40c3742ec23faabd1d1305e8235c8f71f11923c2fd35cac5e1afe"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_DiceLoss.__init___DiceLoss.__init__.self.jaccard.jaccard": {"doc_hash": "83fd86b911045f87f676b6dbaaa18e099a845b87db1b668f0457e259e7084fd2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_MaskedDiceLoss_MaskedDiceLoss._": {"doc_hash": "d5cff4072b4bb2cb9eaf088e6f177765cf8828f43c1a1335a9e8d97ee7dfc2b8"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_MaskedDiceLoss.forward_MaskedDiceLoss.forward.return.super_forward_input_inp": {"doc_hash": "3f2f11051e2c2b7b7f95fd7b8ff2f39bcc58f6285525161c5f41fa8624f0d7eb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedDiceLoss.forward_GeneralizedDiceLoss.forward.return.f": {"doc_hash": "3b39654e2fc82f38f4afcf9e7239214e8a9e5eed7fe2c74d0bc76b1a82b8df76"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedWassersteinDiceLoss_GeneralizedWassersteinDiceLoss.__init__.self.num_classes.self_m_size_0_": {"doc_hash": "ff2681fb6684448e0477227fb9138872bd2a78e309916d2367afac87ed71ec03"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedWassersteinDiceLoss.forward_GeneralizedWassersteinDiceLoss.forward.return.wass_dice_loss_mean_": {"doc_hash": "3daa4ff81fa12b4bbc703001fc5e5375931a8b7f252530c72b2cc40154c0a1fb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedWassersteinDiceLoss.wasserstein_distance_map_GeneralizedWassersteinDiceLoss.wasserstein_distance_map.return.wasserstein_map": {"doc_hash": "b67f162775b28157871faa86792daf4e66376feb282741393e12568c603e6845"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedWassersteinDiceLoss.compute_generalized_true_positive_GeneralizedWassersteinDiceLoss.compute_generalized_true_positive.return.generalized_true_pos": {"doc_hash": "340f6967ee51beaa9617fe8319a614baeec72396bd358f7410d2dea13ccbaf08"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedWassersteinDiceLoss.compute_denominator_": {"doc_hash": "2e507a1450c7a3b9030fca4377d8dbbbee76de8a771581dfed484ff9ac284ba6"}, "/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.if_self_weight_is_not_Non.logpt.logpt_at": {"doc_hash": "fbc825ba6a31f937dd590b14fddf89853ac406bdea699eb181e9f7657cf344c7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/focal_loss.py_FocalLoss.forward._Compute_the_loss_mini_b_": {"doc_hash": "deac6191ed0f77c6025c25cd4e6c861ee7f09450a2c743dd39109501ea1758eb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/tversky.py_warnings_TverskyLoss.__init__.self.beta.beta": {"doc_hash": "5bd4c4e436af6467975e34371397888baff88b0fa3a4c67e148de36e981f201d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/__init__.py_DiceMetric_": {"doc_hash": "55ab7f5cbdb8ca3858f58e725b00742d5ff2657ba88b1206daf31216284e9294"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/meandice.py_warnings_DiceMetric.__init__._keep_track_for_valid_el": {"doc_hash": "44653ef9252a4c92169b58545958e2b05c937cf9b4b0078e10c58cc6f304e542"}, "/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_other_act_is_not_None_.y_pred.other_act_y_pred_": {"doc_hash": "4a74c3d92142f856f8301fe45562a570e59e68c7dda86edf36c6c28a9d4ba065"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/meandice.py_compute_meandice.if_n_classes_1__": {"doc_hash": "a15d11146be3aa8a61e587ae6abe0348d44fdd90cbdc496d8aea697d336bef9c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/rocauc.py_warnings__calculate.return.auc_nneg_n_nneg_": {"doc_hash": "d9cb3b5cf3373f16dd779be728586bd34975f1a8a98ce043eb5e92dcd86b3967"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/aspp.py_from_typing_import_Sequen_": {"doc_hash": "a284751cae3b5d10d80e9d84c51104f6f852f6c0df0e0f001ec543e0c43b2b5e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/convolutions.py_from_typing_import_Option_Convolution._": {"doc_hash": "19fd720f358ea2cfc43dcf426787f15f50277b5bc6f8f688fb4f78ab8d18af59"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/convolutions.py_Convolution.__init___Convolution.__init__.if_not_conv_only_.if_act_is_not_None_.self_add_module_act_ac": {"doc_hash": "807a079521a38110c49da6dd800c80da917de81a385dd60d6a3407ba5051ee38"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/convolutions.py_ResidualUnit_ResidualUnit._": {"doc_hash": "d6515c256718b1e84c1667d8d2c9b8a1fb38e3c62e07763df3f9f9648f094e52"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/convolutions.py_ResidualUnit.__init___": {"doc_hash": "f11759a43e0a2ba6709f565084d7d997986a5715d059669d32dc9e974d72a7cd"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/fcn.py_from_typing_import_Type_GCN.forward.return.x": {"doc_hash": "cc04d2c23535ed53a80ae85645e46c4f20ebeffd7292a0634559f733caa1d5df"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/fcn.py_Refine_Refine.forward.return.out": {"doc_hash": "5fa20cfd35feb2159591deaaaae9ce4072647551cf3b242aecec3f4be227cc12"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/fcn.py_FCN_FCN.__init__.if_self_upsample_mode_.self.up_conv.UpSample_": {"doc_hash": "f7c3155c635c7781dd1359c76e2b68c851a5b3cdbb201ca34b50c401be6c02ca"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/fcn.py_FCN.forward_FCN.forward.return.out": {"doc_hash": "e7355dc03778c29ae76c7b07e1712d2db6cb9b78540bb932c539cfacce526c89"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/fcn.py_MCFCN_": {"doc_hash": "8ec4310b28f356b0668963f18bd8a1c1bc9d001462e6114decd3c0dc74e1ca0b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/segresnet_block.py_nn_get_norm_layer.if_norm_name_not_in_bat.else_.return.norm": {"doc_hash": "761f1f792eeadfa0fda6b2ba4a7992495339e3b0b840fcdfae816ec5205e16f0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/segresnet_block.py_get_conv_layer_get_upsample_layer.return.up_module": {"doc_hash": "15341a9c78fb215ed3030b620754f364b5f7185c3708f49be6d48cf405d0d64b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/segresnet_block.py_ResBlock_": {"doc_hash": "37126616d1b097a64cd3c53b9fbab41e1ac8b037116d8f07816e1b70e71e9a46"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/squeeze_and_excitation.py_math_ChannelSELayer.forward.return.x_y": {"doc_hash": "fa6bc24220f21a77117701d34fcd71aa766cf607e2f8c4e4794cb91165c719ee"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/squeeze_and_excitation.py_SEBlock_SEBlock.__init__.if_acti_type_final_is_not.self.act.Act_act_final_act_fina": {"doc_hash": "6c355d20f1c28494b4e3e0c2d6fc1b5bc76ee936c071ee069a8ce49865e02645"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/squeeze_and_excitation.py_SEBlock.forward_SEBlock.forward.return.x": {"doc_hash": "43b58e75e62938f5eb78f4d825f877109be13642e2a0fadc1147dfd03d069b66"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/squeeze_and_excitation.py_SEBottleneck_SEBottleneck.__init__.super_SEBottleneck_self_": {"doc_hash": "6676fcf0c6b446cde200f51f23efe0de813e11e8a20a02c5b97a1320836c83cb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/squeeze_and_excitation.py_SEResNetBottleneck_SEResNetBottleneck.__init__.super_SEResNetBottleneck_": {"doc_hash": "8948988429b8627954706cc725af49b4fd257dd4e7dbdd52e7a4f9cf31cbf72b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/squeeze_and_excitation.py_SEResNeXtBottleneck_": {"doc_hash": "85c8bf652be7e273c486c78826d285a9dd4714272e3c3cb926636800cd81228a"}, "/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_UpSample.forward.return.torch_as_tensor_self_upsa": {"doc_hash": "514b59ffc9c1745c49fb35a2873a3ff18b840ed96ca0128934da1a44a113383f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/upsample.py_SubpixelUpsample_": {"doc_hash": "3552fe716f86a08ce74caa3276a39e7356450264f63ae75482a615deb23c6d69"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/convutils.py_from_typing_import_Sequen_same_padding.return.padding_if_len_padding_": {"doc_hash": "b9315224f67146eb852ae2fd24298a79a7e957727f4ec4a25e1544f65da31421"}, "/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.out_shape_if_len_out_shap": {"doc_hash": "da51e109ca1ec3569ec79482b71583605fe9f1214ffd3fd84ae5fd4388e4c51c"}, "/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_adaptive_maxpooling_factory.return.types_dim_1_": {"doc_hash": "6e3065ff20634fcb87d1ae7cd47c1d5993b846753691a78fd058df8cc4e28852"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py_avgpooling_factory_": {"doc_hash": "1f20bd18dd7042022c155507c900dae813f45a1ae82ffe1da4867399e95839ce"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_math_Flatten.forward.return.x_view_x_size_0_1_": {"doc_hash": "faf21a1cbcc87c1271e94dedbdd52edcb9f04a62db45454c0ad29f8f3ea6284f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_GaussianFilter.forward_GaussianFilter.forward.return._conv_x_sp_dim_1_": {"doc_hash": "1cb428eb5e36f322a120786137e65f4f32d104bc5b0e348ce829c40349fe7777"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_LLTMFunction_LLTMFunction.backward.return.d_input_d_weights_d_bia": {"doc_hash": "359707eefc99480a40e49cac5f6f0c2d1b21b8c74cd995cea9463d2af4a08b8e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_LLTM_": {"doc_hash": "8beb7974cd465385d9c664f2336ef6c6eda6ebb9d957e5f97bc229271d49a516"}, "/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.dst_size.src_size": {"doc_hash": "3900b5aa471a4ccbee48e37166518f9527b4a672ee416f91a3510ab5520b0f22"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/spatial_transforms.py_AffineTransform.forward._default_to_the_src_shap_": {"doc_hash": "425cc3bda1ccdbe0dc609dbf1fbd96efbc0526de4afbed9e5ba48be3693ea10e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/__init__.py_AHNet_": {"doc_hash": "72de70ca59ebd1411b90ebe0c152fe7a260004a94c17f20a907dfcf3042abb04"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_math_Bottleneck3x3x1.__init__.self.pool.pool_type_kernel_size_1_": {"doc_hash": "8be01e015e287a3c39684577df126327204711faf8629ffb3c92c4c6281b4b66"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_Bottleneck3x3x1.forward_Bottleneck3x3x1.forward.return.out": {"doc_hash": "1b0102c31efcc220393815798521f4633a01db2295ae54b324867abe4ad03ab6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_Projection_Projection.__init__.self_add_module_conv_c": {"doc_hash": "43e8c4c588e3a03608835d468b10f538c0d9ae07edd5dc973fcbd33a1968488c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_DenseBlock_DenseBlock.__init__.for_i_in_range_num_layers.self_add_module_denselay": {"doc_hash": "38205f4c566797c2266a3547869aa47f2d7606aa2a96716106711c26180574ca"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_UpTransition_UpTransition.__init__.if_upsample_mode_tran.else_.self_add_module_up_nn_": {"doc_hash": "c3bbe1c76cabdb1413e768384c2896f2e248d966a40baeea70b323fa2ce4a014"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_Final_Final.__init__.if_upsample_mode_tran.else_.self_add_module_up_nn_": {"doc_hash": "e4461b9c92b0bbd95b2032c31df3576fcb5d838c526d7cf520ced2350c4498b2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_Pseudo3DLayer_Pseudo3DLayer.__init__.self.dropout_prob.dropout_prob": {"doc_hash": "928f9cdfe5ef3f55f3adebedb0a470822ef0fb509731b92c53ec61500c043f8c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_Pseudo3DLayer.forward_Pseudo3DLayer.forward.return.torch_cat_inx_new_featu": {"doc_hash": "8837fb828ecfe03213a24c61bc58386327f6db87a7c644090961fbdbadcf13c2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_PSP_PSP.__init__.if_self_upsample_mode_.self.up8.conv_trans_type_": {"doc_hash": "585dc8bd91e41bf465810445a636b709ba415d467d3223b088c929e81903ec48"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_PSP.forward_PSP.forward.return.x": {"doc_hash": "09eaa2902dad2b9b2524b91eb84a3163dadf3a0aa7f91c93f3c92618a8506625"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_AHNet_AHNet._": {"doc_hash": "52afa38d3431cd9e2f08ef942013c39058e11a3485fd31f3a36a75c5f410aafa"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_AHNet.__init___AHNet.__init__.for_m_in_self_modules_.if_isinstance_m_conv_ty.elif_isinstance_m_norm_t.m_bias_data_zero__": {"doc_hash": "051a07d226ea2f4bc665dd41834bcd61c28b1bad26c2ead3eda25653e0bb1dc0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_AHNet._make_layer_AHNet._make_layer.return.nn_Sequential_layers_": {"doc_hash": "71ba19585927dcb1fa088df6843d6775f3b91054b9e332d3c4e9bd7bb284cca4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_AHNet.forward_AHNet.forward.return.self_final_x_": {"doc_hash": "7a2aa036188d8406f3d3943dcf28c37acbdd95a8249af23e73b44fbc44daa02d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_AHNet.copy_from_": {"doc_hash": "efbd196a9cc88dcc1f4c8b8c10fe0acb82a0e4f6c4b314c6570aa13b5e96964f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/highresnet.py_from_typing_import_Dict__DEFAULT_LAYER_PARAMS_3D._": {"doc_hash": "baefb7450200340cff44a7367285624b19dd8fd8ed2c8365ffe22f9096db630c"}, "/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.torch_as_tensor_self_laye": {"doc_hash": "53d7c185752d6376177949ea6c2b8445227737db1c4b5707700966c5892c0334"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/unet.py_from_typing_import_Sequen_UNet.__init__.self.model._create_block_in_channels": {"doc_hash": "f4e7c20207184c4becaa734dbc585de9d6f6b75c472bd1e13a3a0abee815b04b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/vnet.py_from_typing_import_Dict__get_acti_layer.return.act_type_act_args_": {"doc_hash": "bed721fca00b2f6a71c611d525a215769faeb089dcd2ea9d9f48b4f3ae7c8576"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/vnet.py_LUConv__make_nconv.return.nn_Sequential_layers_": {"doc_hash": "f4d1bbad4c53b2ff19d4059fdf3f33ca223ed8fb78df667a8657900a83ec2ec3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/vnet.py_InputTransition_InputTransition.forward.return.out": {"doc_hash": "56a60bad9b25a4145aa0453fe82da265d879c79b84d672c886556986c2a92490"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/vnet.py_DownTransition_DownTransition.forward.return.out": {"doc_hash": "0dfc9931d799031c2b549adfc7466e30feff59fc6a429b65cd36d81a78fa69f5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/vnet.py_UpTransition_UpTransition.forward.return.out": {"doc_hash": "cc07d55c3b9cd0dde08e8b70eb25b92d367b37bcd53fad3a9a486f97ac5b5c24"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/vnet.py_OutputTransition_OutputTransition.forward.return.out": {"doc_hash": "6aeb84c428641e451538371951c3ebb6d775d84138f83cbc8f0e63cf1ed02be6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/vnet.py_VNet_VNet.__init__.self.out_tr.OutputTransition_spatial_": {"doc_hash": "8a8fc9b2b7862acc0ab5462eae274a4441afd60b6b3cada41b6a7b5344c4c0c9"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/vnet.py_VNet.forward_": {"doc_hash": "4768544f0ae8b416c2e6880dc36ca0d9911ea500695c4046139a7b10bbeb7d47"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_normal_init_normal_init.if_getattr_m_weight_N.elif_cname_find_BatchNor.nn_init_constant__m_bias_": {"doc_hash": "fe91485b445b2a78ae6a1252b156a3553b016e24e92d48a9d2512c26e59efdfa"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_icnr_init_icnr_init.conv_weight_data_copy__ke": {"doc_hash": "01bffed4129fbbde7349e2502ad3c5b1ce6628aa1867c38b2984d3d7a584ad7d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_pixelshuffle_": {"doc_hash": "042aa8bb63c25b4bcbf544e27d60bf184558d2f2c9ca5ee0145f7d8bde9c5046"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/__init__.py_from_adaptors_import__": {"doc_hash": "526c7643c817193353ee631f1516c8ababf6aa17131735035f6644ea18093d5a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/adaptors.py_from_typing_import_Callab_adaptor.map_only_names.return._v_ditems_k_for_k_v_in": {"doc_hash": "eccd38bc7edf027f93b2196bf0b11fe7df718dc8f7508c4b4307c5d489636fc1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_warnings_Transform._": {"doc_hash": "6d19d01625fb82d519bbac9bc64d19bb43fe06d65a2f3125a545b6eb5527ce2b"}, "/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_TypeError_f_keys_mu": {"doc_hash": "6e3e6f4abf3c7f89779ab1abff0182eee3fcdf92a0515f93744c43de83e7f9ad"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_from_typing_import_Any_C_SpatialPad.__init__.self.mode.NumpyPadMode_mode_": {"doc_hash": "cbaddc25cd764ea0c856bc030421d6ad4ab83c56d4bb7ab55b442012f31fa0ca"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandCropByPosNegLabel_RandCropByPosNegLabel.__init__.self.centers.None": {"doc_hash": "e6229469c81cb7df777763642d95949d7560c0e723a0231ffb3580dce0f1d561"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandCropByPosNegLabel.randomize_": {"doc_hash": "063933cc8a8aae681e634f4cefd6bb3b1edae8236af9a5f18e597f9930385ee7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_from_typing_import_Any_C_NumpyPadModeSequence.Union_Sequence_Union_Nump": {"doc_hash": "d023fc9310f539e59acd173f7588b73d43aaad3162bac71abf0aa2b99d401b50"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandSpatialCropd.randomize_RandSpatialCropd.randomize.if_self_random_center_.self._slices._slice_None_get_rand": {"doc_hash": "698c84bc1a8834daa666ae343e658d98f80cd570878bba336c80614e07d6607f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/dictionary.py_RandSpatialCropd.__call___RandSpatialCropd.__call__.return.d": {"doc_hash": "2e7377b91617804298882a7137f9d74972cbbc9c5587325e6e352a754d2993ea"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_from_collections_abc_impo_RandGaussianNoise.__call__.return.img_self__noise_astype_": {"doc_hash": "f15c03c94a2b75ab3fa8bb1f67b36a7bac8e214b0d0b5f1aeea45dd0a92cec3c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ShiftIntensity_RandShiftIntensity.__call__.return.shifter_img_": {"doc_hash": "73aa6fa9d56463636be5f0d29893ecfbd4aa6c6cd8ae5e38e17836df5d471c92"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensity_ScaleIntensity.__init__.self.factor.factor": {"doc_hash": "881e797d2203fbd55a1812c4d6424ae4a97c1b27ad8e792109eec1f5db0930bb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensity.__call___ScaleIntensity.__call__.if_self_minv_is_not_None_.else_.raise_ValueError_Incompa": {"doc_hash": "703c776c5e4db5cb787085d66caf48d52ab2adea6ad7a17f3ccbab238102c57b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_MaskIntensity_MaskIntensity.__init__.self.mask_data.mask_data": {"doc_hash": "292d313a3406c6b79a4510e765302df90849ec022c06bc1ccf905353d5dc1ba1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_MaskIntensity.__call___MaskIntensity.__call__.return.img_mask_data_": {"doc_hash": "2604e28634b50b9275957a3d49438a74f50f693d61dc686f9c6e572bb946485d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_GaussianSmooth_GaussianSmooth.__call__.return.gaussian_filter_input_dat": {"doc_hash": "beb96a09c9b50e22b15b45e3141b0002b4df7a5d680f619a65143f2a47a1c972"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_RandGaussianSmooth_RandGaussianSmooth.__call__.return.GaussianSmooth_sigma_sigm": {"doc_hash": "1be6605df04e68b72b2ad0cbe61960640d9407ba611ece84c78cb23c781463ae"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_GaussianSharpen_GaussianSharpen.__init__.self.alpha.alpha": {"doc_hash": "f5c22db34b64ddea40f28296c9c021aac6b389862972662eaba99e61f0db1e67"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_GaussianSharpen.__call___GaussianSharpen.__call__.return._blurred_f_self_alpha_": {"doc_hash": "9a7c1bdd779d625a0db995391e09dbeadfbafdf019d9e57c86e0c66a9b37f733"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_RandGaussianSharpen_RandGaussianSharpen.__init__.self._do_transform.False": {"doc_hash": "d3aea95200fc6938ba0f19922666552e1d12b1933ba5507295a4614da3ae8687"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_RandGaussianSharpen.randomize_RandGaussianSharpen.randomize.self.a.self_R_uniform_low_self_a": {"doc_hash": "1d6471c3ef9ba6af13adcff1f19f988a0e21df9644f5d159683b704aa2921402"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_RandGaussianSharpen.__call___": {"doc_hash": "adb933d8acaa3a79e4e3454e11d8382e0cd407d4ff82a6aff4d7268f8152ab30"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_from_collections_abc_impo_from_monai_utils_import_e": {"doc_hash": "913d8b85337c83ffa0062372bc851194843e13825f5c8f7c110aec2ff0d6a50d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandGaussianNoised_RandGaussianNoised.__call__.return.d": {"doc_hash": "f991558e956cefb57926a7a43f9895ab495edaf3b148287aed0c95dfb63c0a87"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_GaussianSmoothd_GaussianSmoothd.__call__.return.d": {"doc_hash": "8a3da22d2445bb77eda16565c1095a13e70f8d97fd8568a7be801b1b4fa94002"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandGaussianSmoothd_RandGaussianSmoothd.__call__.return.d": {"doc_hash": "67eaa15c1a4469d34f7ac252f7dd434f7e2906329a1de9423693c22d2bf3a207"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_GaussianSharpend_GaussianSharpend.__call__.return.d": {"doc_hash": "d71f6ea4601433913dc7b16af1b3dfd7649d0681e96c211875d51a244abda8c0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandGaussianSharpend_RandGaussianSharpend.__init__.self._do_transform.False": {"doc_hash": "e20ee84b5279c62cf9cad5f2409899cf1c86742b995817d6e49a6adbd3f5918a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandGaussianSharpend.randomize_RandGaussianSharpend.randomize.self.a.self_R_uniform_low_self_a": {"doc_hash": "a7ecb71ab636934631eed96c5ee1330d9e3e0fe32c49ba7d1c1b44c6de57b47f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandGaussianSharpend.__call___RandGaussianSharpend.__call__.return.d": {"doc_hash": "dbb660566d5dbc9b581f0094122adc36bae7e65579c7c68b0be4e6cc70ed8a46"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/array.py_from_pathlib_import_Path_LoadNifti.__init__.self.dtype.dtype": {"doc_hash": "61ae313dca01c4c951d770f5c9200862562906499fd0167f5006aeaeafdb0b10"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/io/dictionary.py_from_typing_import_Callab_LoadDatad.__init__.self.overwriting.overwriting": {"doc_hash": "cad1d68e39cfb6856986808d7eb6ccfc9bdb83a83baca3f73e41ccfba584eec6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_warnings_SplitChannel.__init__.self.num_classes.num_classes": {"doc_hash": "44bdc7d90cc0ca4c94b5830865e998f09baf4e01d8cbe9aef10a9c9555844bf0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_MeanEnsemble.__call___MeanEnsemble.__call__.return.torch_mean_img__dim_0_": {"doc_hash": "c042e246bec273a952c3e6c7136b20b2949d84590a748d8039ac1363509cc042"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_VoteEnsemble_VoteEnsemble.__init__.self.num_classes.num_classes": {"doc_hash": "b92c0f792c11b730be7935e6f79c85453c3d2d4ae9ef348916cca758015b91cb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_VoteEnsemble.__call___": {"doc_hash": "674dea7e829c3ba15589f9fe2bbb262449f8b4ea506cf17af803866fa9303b99"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_from_typing_import_Callab_SplitChanneld.__init__.self.splitter.SplitChannel_": {"doc_hash": "6826335e6cfa7a51cf8f59d2f15b270f269dedee69b1ff2a549ab6cf909e990c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_SplitChanneld.__call___SplitChanneld.__call__.return.d": {"doc_hash": "f71a43f84d61de2b697107bcb6efc032109314cf2a66444f3b105efc45847a98"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_Ensembled_Ensembled.__call__.return.d": {"doc_hash": "29b2d96cf5b9d393ed592ba04d5cb3982cb8d977816e28d7997783ead8f5ab4e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_MeanEnsembled_MeanEnsembled.__init__.super___init___keys_en": {"doc_hash": "d25cfbea91aeaad8e79cb61ec14ed720637724a547690bfbf6c2e50035fe705a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_VoteEnsembled_": {"doc_hash": "86b757bd70fa2b0821260673918ba3a446b888e06cc53fd8e65c57867f156a7d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_warnings_if_get_torch_version_tupl.else_._torch_interp.torch_nn_functional_inter": {"doc_hash": "19c1328224b68de712987d19588280f7195d5a5fa22be269e2c5b0fe2218b1f4"}, "/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__._resample": {"doc_hash": "5395d057e25c453f976bf236bbe459c355ed1c229a9a48eebc4c90bfd8b846e4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_Spacing.__call__.affine_xform_Spacing.__call__.return.output_data_affine_new_": {"doc_hash": "312a0ac16925189f1354a91e58111658b10f49ff644698b070f3f60671bada3f"}, "/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.dtype.dtype": {"doc_hash": "1704aabff77cf0e6e312225f1c585dde3490e45de19e3c95902cb8744a0209f4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandRotate_RandRotate.__init__.self.z.0_0": {"doc_hash": "b0dae1a80f83088beb3a3b67f7a22aea335c2a6dfff24c5270886a0647f837b7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/array.py_RandRotate.randomize_RandRotate.__call__.return.rotator_img_": {"doc_hash": "9be48e03d319ab48f0195fb106889e47257615d07a9166e8fe7b0b0812e51d63"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_from_typing_import_Any_D_InterpolateModeSequence.Union_Sequence_Union_Inte": {"doc_hash": "dac5a941cc32ddf63e8d01416f1f0c05fe9fa678ca013762abdf18cd865fb535"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Spacingd_Spacingd._": {"doc_hash": "df8fe3e92db0bc6650a0bbc52acd434d5f24ab2f7441000465c166372a4017d0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Spacingd.__init___Spacingd.__init__.self.meta_key_postfix.meta_key_postfix": {"doc_hash": "eb8ae90f01e73676608906ee67941022940d8ef6244b75074ad931b73849094e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Orientationd_Orientationd.__init__.self.meta_key_postfix.meta_key_postfix": {"doc_hash": "a062a11fbe39b93adc86b4d52cb249dcec597a3c6b503920e171342d373a42bc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/spatial/dictionary.py_Orientationd.__call___Orientationd.__call__.return.d": {"doc_hash": "6cb3c41d17fc8a5de7c31e7491423a2ee35c9d09650fc4ad8ca60613a07a817b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_logging_Identity.__call__.return.np_asanyarray_img_": {"doc_hash": "a115e92e49000b99febd26738eb81e9fcaa35080e276d6bb8a88948c8998e1a7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_CastToType_CastToType.__call__.if_isinstance_img_np_nda.else_.raise_TypeError_f_img_mus": {"doc_hash": "6fea5a601feb3e1010d33f226dd670047509db44bf035cb6d79d4e5f66af592c"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_Lambda_Lambda.__init__.self.func.func": {"doc_hash": "bfc418f114ad75439f76e887d6e3d36bbee2a4fd86219b49fa10c9076863e9e3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_Lambda.__call___Lambda.__call__.if_self_func_is_not_None_.else_.raise_ValueError_Incompa": {"doc_hash": "ca2c247f011aa706a06878f5163d96ce821e768d18b6b604136ac2ca49509ccb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_copy_from_monai_utils_import_e": {"doc_hash": "20bdccde435f8331f9235b286adfb5a5f56334b4aa7f048abc2346c4f2a5bc2f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utils.py_random_zero_margins.return.True": {"doc_hash": "e8d50b1367aec7e3a26fe4619827262e2a9a17a5aa8ee2d4f742c3e9ac15e7f2"}, "/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.if_image_is_not_None_.else_.bg_indices.np_nonzero_label_flat_0": {"doc_hash": "a0415e8360e2df3797901098f6227c6b04930872af9e6130e6d93e32518a5516"}, "/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.if_not_len_fg_indices_or_generate_pos_neg_label_crop_centers.return.centers": {"doc_hash": "730a28e3c19d0cb8a6dfe205da557f3864faab747070c49ae2d154e3d65fc6e1"}, "/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": "d7917fe586f2d468eabeb3ae25c3c5e38f3b613c2cf47eb293c0c4e6ebe170ac"}, "/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_Unsupp": {"doc_hash": "6255f6459e4ea470c261da77e2cdb3bfb9a928e359bdc0ff4b7f97cf94e50ef5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/aliases.py_importlib_alias.return._outer": {"doc_hash": "eee83857579bede7f32851a344c2838dcba27eebec234a872154a2d857849509"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_collections.abc_ensure_tuple_size.return.tuple_tup_dim_": {"doc_hash": "2f3e2e9d2590f0e2310121144f4c1c1a66dc54382a3393265587a5331e3fd5a9"}, "/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": "04a5f536601501263c2379627db87ffa965716ff1035bfedf57033f9b69a4e2d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_set_determinism_set_determinism.if_seed_is_not_None_.else_.torch.backends.cudnn.deterministic.False": {"doc_hash": "10d25e7440db2571d41dc51f09c6c81064f458ea910149ebf0faecae85d1ffaf"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_list_to_dict_": {"doc_hash": "ee1f7b37db82eaebe66d4b09857003da7bbdd8feefb032f8a411ed470da46b50"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/visualize/img2tensorboard.py_from_typing_import_TYPE_C_if_TYPE_CHECKING_.else_.SummaryWriter___option": {"doc_hash": "4e9f048fce9843b721a4b25b55fd6fd0dce91fc8f086a470fabed1b6731c5ab4"}, "/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_value_image_summ": {"doc_hash": "ecd89a2b123bd5285abd9a26da914495fb9781b3f06da2137c3ef8dd259611de"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/research/lamp-automated-model-parallelism/train.py_os_torch.backends.cudnn.enabled.True": {"doc_hash": "4932fb63b5e7a41df77f386ebd8065459d4bb2ff6b487036c5e315d44974469f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/setup.py_warnings_get_extensions.return.ext_modules": {"doc_hash": "53363e5262e7c7426b02c9d869e2782e0590153708d8c960d19289ceac6db9a3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/setup.py_get_cmds_": {"doc_hash": "e9ec19f1ad306c9445e8117078cf71b73bb16e025948e3a61aecb295a4bb4ee0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_adaptors.py_itertools_TestAdaptors.test_single_in_single_out.None_4": {"doc_hash": "4b24f84b2c5da28cbf0631f80106ca066879e35bb2864966145d9f6e1f63c056"}, "/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.with_self_assertRaises_Va.to_norm_affine_affine_sr": {"doc_hash": "860e5aab62199adb26a0d6d1c124577538fd42a1638331d3b1926697040472b3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_ahnet.py_unittest_TestFCN.test_fcn_shape.with_torch_no_grad_.self_assertEqual_result_s": {"doc_hash": "5e58d53d25ff5dbf27d2a4256e379ad41f1624b9a582a1ad175a5415778368fb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_ahnet.py_TestMCFCN_": {"doc_hash": "118b56059f1218964c7d31bfb5f8db217fe9df526f4b5f32d7b66de8d1086c4d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_arraydataset.py_TestArrayDataset_TestArrayDataset.test_shape.with_tempfile_TemporaryDi.None_13": {"doc_hash": "1c3216e3224ebe6b027e32d06f896b90c6eedf3daedcf2f9c316f72ebc2a875b"}, "/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.with_tempfile_TemporaryDi.np_testing_assert_allclos": {"doc_hash": "3ed7e0f15f78a727944dda70b4973d70cb8e0bc45d783a0d46278d5a15bbc77e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_arraydataset.py_TestArrayDataset.test_dataloading_img_TestArrayDataset.test_dataloading_img.with_tempfile_TemporaryDi.None_6": {"doc_hash": "7e076b7cf34f319af8d59f5c0dc3079954c66ea9dae8744198897486ffb44a8f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_arraydataset.py_TestArrayDataset.test_dataloading_img_label_": {"doc_hash": "6e1184cada0bc3b1cb9e0bee9402f29db41eab8b479991c468669a3c9471752e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cachedataset.py_os_": {"doc_hash": "ec966822935cfb64cdf64c3174d2985bd448b9ff7e1079108f14bc18cd8e3a45"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cachedataset_parallel.py_os_TEST_CASE_3._4_100_None_": {"doc_hash": "3bf8aa24392971a91ce8b47c813323790d4e1d58cb7363ec3258b417fdde76b3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_check_md5.py_os_": {"doc_hash": "a09e8223e543c75a0dede71b2d59943bd33fc027638f6c97c1bea8ba8f25bcee"}, "/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_10._y_1_1_2_2_y_pr": {"doc_hash": "287f5c19380bf7dfaebdf2c70f285187c64ccff81e9d5c1b0d1b3acab1a4fa9d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_roc_auc.py_unittest_TEST_CASE_7._": {"doc_hash": "4e2d57676d491c98ba68bcb8124d23e65998e6a2eba027e04ce0815b5f3cd817"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_roc_auc.py_TEST_CASE_8_": {"doc_hash": "73754afc87dac785e25457d843cbb4130b9561d6c9bedfe5185738b45f792c51"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_convolutions.py_from_monai_networks_block_TestConvolution2D.test_transpose2.self_assertEqual_out_shap": {"doc_hash": "8fa4e7ceaf072aeb228d1dcd0b8ce88f4c9d1cd31feb35478bb68789bdfcf58b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_csv_saver.py_csv_": {"doc_hash": "513d041e18f2f473405b42bbe36d44913f777fe38c4d399631e8be1bc826ab5e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_stats.py_logging_TEST_CASE_7._": {"doc_hash": "b1060c3615aff6e11077fdec4b539892cb27038bca918a08c7f591aae3ae31eb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_data_statsd.py_logging_TEST_CASE_6._": {"doc_hash": "88b97e529a5530efbc8477ab29897e5b3ecaedb95daca6527f2ba8fae580ae80"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dataset.py_os_": {"doc_hash": "918ab8f08d4d7a7ad46456590b75025dfce420dd5daac31b7244287194a16f0e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_decathlondataset.py_os_": {"doc_hash": "0ec46edb82ed4b068c9132d4e08e3c310e07642fea15b223aa7608ce09984e31"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_delete_itemsd.py_sys_": {"doc_hash": "66ace30d1a1d65cb4e583168b961b88c10d7be0d029d264bfe64afa3887cc529"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_densenet.py_unittest_TEST_CASE_3._4_channel_1D_batch_": {"doc_hash": "96ba6f59e536409beb3fcdef8ea7037e9fa7c1183a99729aedfd13850961c8ed"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_ensemble_evaluator.py_unittest_": {"doc_hash": "b5b7b0f58cec8768ecdd804987b40b4d862cfb44c7feaabe1a68f00b574fe945"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_sharpen.py_unittest_": {"doc_hash": "2d6e84fe1afbee27935abafdb8a0fc9e4e82e4d2c758404262f5f6e6ceadb79e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_sharpend.py_unittest_": {"doc_hash": "33ddd2240be60052b49d816d114e72f2cd1eb73a1e7093b158568b379ff25dbc"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_smooth.py_unittest_": {"doc_hash": "c3585ce10a043678ca091bdf02d7417012b9acbb28e36665a26ac3a68dd55450"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_smoothd.py_unittest_": {"doc_hash": "2661ec56675e44b1a46d95ecebc01d0206b3636609cefe235851d6bb6d415e9b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generalized_wasserstein_dice_loss.py_unittest_TestGeneralizedWassersteinDiceLoss.test_bin_seg_2d.None_2": {"doc_hash": "31dbb738170220931ea02661e98053ef7baf0237da16012a44de6019d06b1bfe"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generalized_wasserstein_dice_loss.py_TestGeneralizedWassersteinDiceLoss.test_empty_class_2d_": {"doc_hash": "5bac2c79dc9f13bcf20292416d4f5a2ed07f13daa9c8409e65bf29a031cb0698"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_loader.py_logging_TestHandlerCheckpointLoader.test_one_save_one_load.with_tempfile_TemporaryDi.torch_testing_assert_allc": {"doc_hash": "6813683a9d04a42452c245c756b3614eb313f911d86c4be6e2055a482da93772"}, "/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.with_tempfile_TemporaryDi.torch_testing_assert_allc": {"doc_hash": "edb8c6fb894c7bdbd9d1be164deab4c441d26249842323324d889bfdadbdd3c5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_saver.py_logging_TEST_CASE_5._True_False_None_1_Tr": {"doc_hash": "b7ac396d9fe58ef1ad2c6f0a64efb33b2a980d2d1cb74f01db023e32e9567945"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_saver.py_TestHandlerCheckpointSaver_TestHandlerCheckpointSaver.test_file.with_tempfile_TemporaryDi.for_filename_in_filenames.self_assertTrue_os_path_e": {"doc_hash": "ae0a6a52287f4a1f89a7dd7ce59503cd04055cfcfd464930d771ce209618068a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_saver.py_TestHandlerCheckpointSaver.test_exception_": {"doc_hash": "e13d5954a30d06c82f5addf1ae293cec2d1a84fedb0eef2e656e96b444cf8288"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_classification_saver.py_csv_": {"doc_hash": "458ff14118822fb2d8e5dd38f69460659abbe101ff955e6297bb0bc381f6ebad"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_lr_scheduler.py_logging_": {"doc_hash": "e65853e99b78a75edc28cbe231b7f99aaabc138f8bc9ddc6ca7fb63f6609ebcf"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_rocauc_dist.py_np_": {"doc_hash": "427769299ba48ace1a1c5fa11cfea0ffd91c622231f75ce8d32bac90337273e2"}, "/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.with_tempfile_TemporaryDi.for_i_in_range_8_.self_assertTrue_os_path_e": {"doc_hash": "938c2c3ef5e6f7973a9f80d78fc71159a7d51d00002f86ec6d83a4169b35221e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_stats.py_logging_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": "1ce46e0694e6cb2b791e715c2c09bdbb6255fb6dfa0facd2f9d26644cd63ac78"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_tb_stats.py_glob_TestHandlerTBStats.test_metrics_print.with_tempfile_TemporaryDi.self_assertTrue_len_glob_": {"doc_hash": "97cbd8cf7a6a6d5493b612a72547ca64e1fcd971ba268bf94f328d315555e018"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_img2tensorboard.py_unittest_": {"doc_hash": "f33e08e5a858de42f9da71eb6ec1e4c4740ad154c35328f8f57927938f49c91a"}, "/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.loss_function.monai_losses_DiceLoss_sig": {"doc_hash": "c2d7c5d794f3e5c9a648c9690eb0950af8ea9902662fd50cb14d7a6e7395c205"}, "/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.optimizer_run_training_test.return.epoch_loss_values_best_m": {"doc_hash": "de3c2200d2f7f242f03d34e5fa68a7db7adc22652a068034e8b9617a2b4b9fa3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_sliding_window.py_TestIntegrationSlidingWindow_": {"doc_hash": "c67bba2c2d5416fec45eaaf8f15413ec8a7203aeba8829b938848e804cc87077"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows.py_logging_from_tests_utils_import_s": {"doc_hash": "6d7f5671e7265943e9029919cb017558f21ea7ae78e67f63a5342198b95e59b3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows_gan.py_logging_from_tests_utils_import_s": {"doc_hash": "ed696139b2796b29094d7edd3f3e6729dc17e326915570543464f645593c1ab2"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows_gan.py_run_training_test_run_training_test.return.trainer_state": {"doc_hash": "aebe1f4bd5fbf7900c3975e1c37ca98c94e447398a9d6f684e27a3b17695a8d0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows_gan.py_IntegrationWorkflowsGAN_": {"doc_hash": "8996ef8561bbbe549822b55cdd659f809550c51548e5cead99dd2bc46a25a568"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_list_to_dict.py_unittest_": {"doc_hash": "9f5d4c471ac1aba7bce8e991b587d2814446ed4fca665753b69afa67f121a361"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_lltm.py_unittest_TEST_CASE_1._": {"doc_hash": "fcf3b3f7d6eb28f0a7440144cd790a901ea3ae2cbd762ec9e5ee747bc542cb0f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_lltm.py_TestLLTM_TestLLTM.test_value.None_3": {"doc_hash": "49103d3b0705a954bbef62fcec48751d10c5586661c5d5d5ba6ac414a7387d2d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_lltm.py_TestLLTM.test_value_cuda_": {"doc_hash": "e5d280d245ce864b8bd3482aaad4e505ef03e0a108037d2ff0a1bd54cc65740a"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_decathalon_datalist.py_json_TestLoadDecathalonDatalist.test_seg_values.with_tempfile_TemporaryDi.None_1": {"doc_hash": "9aa7b4075ec1512988aa20aa69d9ec7a3d782b53d06a1fc7a9aa75d8b09c5abf"}, "/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.with_tempfile_TemporaryDi.None_1": {"doc_hash": "bb2617328359674d5e038f56b30a656f0f97dd4fc9cc6f93999de20cb8494113"}, "/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.with_tempfile_TemporaryDi.None_1": {"doc_hash": "c0682b946b04b72eaecb7496d879aad9929ec7db01e86a35c5f97269afcc972b"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_nifti.py_os_TEST_CASE_5._as_closest_canonical_": {"doc_hash": "99b3f09fc7d773cae3afb515737abf3d72e47870ca2c4189a5e1e874a0f21030"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_niftid.py_os_": {"doc_hash": "579fb7a4e1f2797af479b8d89f1dae24e0b523a8831ae81044ad8ef7a5fbc8a4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpy.py_os_TestLoadNumpy.test_npy.np_testing_assert_allclos": {"doc_hash": "1f3b33cfaa35d5ab7ed75294222fafb971eea4e1e074c7963fe0a8dcb3095c46"}, "/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.np_testing_assert_allclos": {"doc_hash": "0a2f86aa532ee46cb58bbd6a98e3af87a96ed40332ace36b3e09a5d5d53ab48e"}, "/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.np_testing_assert_allclos": {"doc_hash": "49e095b480411083355c0a83e7e5908fd91dac7354ee9c4f40342da833cf4357"}, "/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.np_testing_assert_allclos": {"doc_hash": "f3a4a697abaaf3d122cb4aad1b3ee0d840cd8bfee03f47de310574c312b1c3f6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_numpyd.py_os_TestLoadNumpyd.test_npy.np_testing_assert_allclos": {"doc_hash": "5dff22383336d48299b25e2c5ebfadb360489b71188aacd5dce436a4305bcb6a"}, "/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.np_testing_assert_allclos": {"doc_hash": "fcb3c8cb1e3630969c8f7000aeef5a7dc7603ede5d28b0b3a238b64c59a22967"}, "/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.np_testing_assert_allclos": {"doc_hash": "bc0986417bf50f5675e01e98bcb7b27a817e09717564c6d99244c10035566e8c"}, "/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.np_testing_assert_allclos": {"doc_hash": "7e89423c3f4896be73314e3b3b04b044f7fafae8f4d2208d14b743b17150c468"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_png.py_os_TEST_CASE_3._128_128_test_image": {"doc_hash": "e389bc681cb303f58e4bdcbe72a0dc3c32c49cca4c11c714b4f630d5ca632dde"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_pngd.py_os_": {"doc_hash": "0b81065873132a639f0d8347f69fbb0021232d9556203037675486ba9aafb31e"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mednistdataset.py_os_": {"doc_hash": "001a9bdf3500797ea9b13f45f2e279831ae953a0d6c16a6e4257e0ff4588ab17"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_dataset.py_TestNiftiDataset_": {"doc_hash": "74108f4e3f6f93f662b86ae717121139d6df833be73e071daea6c46fd1e36d72"}, "/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.with_tempfile_TemporaryDi.None_5": {"doc_hash": "2752947fc53c72ea49910bef82fdf1da559782610d49c712c3eab5ef418d088a"}, "/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.with_tempfile_TemporaryDi.None_5": {"doc_hash": "292a1e0ec91df9bf9c2e7c6d7ab61e067e1514cd96b3c02360b66e0b77cd8844"}, "/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.with_tempfile_TemporaryDi.None_5": {"doc_hash": "b92183ed5c9f20b0bd0901a63bea750b629aec41a916df99eaa6913d9e9abf0e"}, "/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.with_tempfile_TemporaryDi.for_i_in_range_8_.self_assertTrue_os_path_e": {"doc_hash": "e7404e67f51a43ac0cdc2c7ffec2c068ed5d2e129c7271fe873b6c59a46d981c"}, "/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.with_tempfile_TemporaryDi.for_i_in_range_8_.self_assertTrue_os_path_e": {"doc_hash": "1048a174530308202bb8eb912d4f5cf25a610adeb72fee3c10dde273acb5fe53"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_persistentdataset.py_os_TEST_CASE_3._None_128_128_128_": {"doc_hash": "ac43cde68721493b4be61951ec6dfbd1d192dfd9a5bc547c06e791ca3fdc7568"}, "/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.with_tempfile_TemporaryDi.for_i_in_range_8_.self_assertTrue_os_path_e": {"doc_hash": "abdceaca801bd357ae8ea411f38c226b48df8d8a4893481186d34daf975ce8ea"}, "/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.with_tempfile_TemporaryDi.for_i_in_range_8_.self_assertTrue_os_path_e": {"doc_hash": "d696ba2b7cdf2eda3c0a6f5510f00fb6a79bfe7e10a4448b49dcca569323c507"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_gaussian_sharpen.py_unittest_TEST_CASE_2._": {"doc_hash": "b90ea932ee830ef7ff6a5b08573c6a3d6475c1efdf8b73757002a4cc2732f192"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_gaussian_sharpen.py_TEST_CASE_3_": {"doc_hash": "7d6d6f4149e1323ba82555648c381f7a877b7105bc7e63d004060281627bc9b4"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_gaussian_sharpend.py_unittest_TEST_CASE_2._": {"doc_hash": "2e2aef1cdff69ccc09b58664212ea5a540a045c24a30cefdf06e1e56294ef030"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_gaussian_sharpend.py_TEST_CASE_3_": {"doc_hash": "4d0f9ed90c41dbbaa59ccb8a2e7d0c6c2d04c8dafce7ebd0754ef2731eb8bdf0"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_gaussian_smooth.py_unittest_": {"doc_hash": "3de0155e8ee54f91bf4237b983584781f839cacbc30f32618f6c1f64129d9449"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_gaussian_smoothd.py_unittest_": {"doc_hash": "1d9c695aff18a2da2ae963baf0ec46d8be4bf11cfee0a522ea0790f961287e45"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_segresnet.py_unittest_": {"doc_hash": "f1feba705c9fac1f95c17b4443ab74f936318efecc5043f2f4cf32db05d04275"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_segresnet_block.py_unittest_for_spatial_dims_in_range.for_in_channels_in_range_.for_kernel_size_in_1_3_.TEST_CASE_RESBLOCK_append": {"doc_hash": "bae35eedc886848f0415e434094495e634fbe5a152113aacaadafcaa9d0cce80"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_segresnet_block.py_TestResBlock_": {"doc_hash": "827ce2db9bfd06cc40577f990e605feaf73a6e6457e2aff378ea437e07e13df6"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_senet.py_unittest_TEST_CASE_6._se_resnext101_32x4d_in": {"doc_hash": "83fd12c48b62ef85ad56d6104d63b7c2f8e7fcc5343b125f3b63f46cbf223750"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_senet.py_TestSENET_": {"doc_hash": "ce4faea0f2635006d23da33dc1ecd4840deb55aeddec306218b2cd254e76e930"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_simulatedelay.py_time_": {"doc_hash": "b2ccf1f26142c91a873463983b2662ed184dbea8f739a20bb2dd0f23759546bb"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_simulatedelayd.py_time_": {"doc_hash": "77af87875b52e1a337609b10d82adb559ed7c0925be2dee09691bb0f72be8d57"}, "/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_8._": {"doc_hash": "32a7986558c4efaa5b02e851c5f6df506247e3a1bb1377f5beb943ccfa4cfdb1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_sliding_window_inference.py__test_inference_on_gpu_i_": {"doc_hash": "b994ea3db7496d7824405199adc2e7095ddabf01ea71a851373a944a7fdf06c7"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_squeezedim.py_unittest_TEST_CASE_6._TypeError_dim_0_5_": {"doc_hash": "09055449c38d36386992a3251aded809b446b8a0cfa79ace6ae9e854a6fc1ec5"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_subpixel_upsample.py_unittest_": {"doc_hash": "7fd98c2fbb66951a5f9ea612d6b6fd082a1ab554d9b3d452656a2fa0ea00ddb9"}, "/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": "133c6940076eba103dd104dd837e35e5083b56531e1f044709b0fe475a306fdf"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_vnet.py_unittest_TEST_CASE_VNET_3D_3._": {"doc_hash": "83ce907118a2cec729f1d7b33839bb605596ff7f2f2032b1c9339886f59ff0a3"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_vnet.py_TestVNet_": {"doc_hash": "baa6d04a9d2ffae7d5e8fc968ad87e743b34f596be556dba01bb8d1eb79c2e4d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_vote_ensemble.py_unittest_TEST_CASE_5._": {"doc_hash": "a8e7b184578fbcfcf423dd125e381ac3c93eba26cf027ea41a7812ca0126524f"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_vote_ensemble.py_TestVoteEnsemble_": {"doc_hash": "a589eec99bc313d609d1bc0137d350d6050ca217e27e7e58fcb2908934bd9b7d"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_vote_ensembled.py_unittest_TEST_CASE_5._": {"doc_hash": "deee61d060ab7b2f04cf6893621ba1cece37c2eefbed28a99ba51bb2cc431fae"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_vote_ensembled.py_TestVoteEnsembled_": {"doc_hash": "f03f3215db9623ba1ef2bcc0fd759f93dd2dc5f6e5fc578556094472336c9786"}}, "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_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_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_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_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_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_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_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_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_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": 148, "end_line": 167, "span_ids": ["impl", "main"], "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": "def main():\n parser = argparse.ArgumentParser()\n parser.add_argument(\"-d\", \"--dir\", default=\"./testdata\", type=str, help=\"directory to create random data\")\n # must parse the command-line argument: ``--local_rank=LOCAL_PROCESS_RANK``, which will be provided by DDP\n parser.add_argument(\"--local_rank\", type=int)\n args = parser.parse_args()\n\n evaluate(args=args)\n\n\n# usage example(refer to https://github.com/pytorch/pytorch/blob/master/torch/distributed/launch.py):\n\n# python -m torch.distributed.launch --nproc_per_node=NUM_GPUS_PER_NODE\n# --nnodes=NUM_NODES --node_rank=INDEX_CURRENT_NODE\n# --master_addr=\"192.168.1.1\" --master_port=1234\n# unet_evaluation_ddp.py -d DIR_OF_TESTDATA\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_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": 75, "end_line": 139, "span_ids": ["train"], "tokens": 753}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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(args):\n # disable logging for processes execpt 0 on every node\n if args.local_rank != 0:\n f = open(os.devnull, \"w\")\n sys.stdout = sys.stderr = f\n elif not os.path.exists(args.dir):\n # create 40 random image, mask paris for training\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 # initialize the distributed training process, every GPU runs in a process\n dist.init_process_group(backend=\"nccl\", init_method=\"env://\")\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\"),\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)\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, batch_size=2, shuffle=False, num_workers=2, pin_memory=True, sampler=train_sampler,\n )\n\n # create UNet, DiceLoss and Adam optimizer\n device = torch.device(f\"cuda:{args.local_rank}\")\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=[args.local_rank])\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": 140, "end_line": 167, "span_ids": ["train"], "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": "def train(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 dist.get_rank() == 0:\n # all processes should see same parameters as they all start from same\n # random parameters and gradients are synchronized in backward passes,\n # therefore, saving it in one process is sufficient\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": 170, "end_line": 189, "span_ids": ["impl", "main"], "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": "def main():\n parser = argparse.ArgumentParser()\n parser.add_argument(\"-d\", \"--dir\", default=\"./testdata\", type=str, help=\"directory to create random data\")\n # must parse the command-line argument: ``--local_rank=LOCAL_PROCESS_RANK``, which will be provided by DDP\n parser.add_argument(\"--local_rank\", type=int)\n args = parser.parse_args()\n\n train(args=args)\n\n\n# usage example(refer to https://github.com/pytorch/pytorch/blob/master/torch/distributed/launch.py):\n\n# python -m torch.distributed.launch --nproc_per_node=NUM_GPUS_PER_NODE\n# --nnodes=NUM_NODES --node_rank=INDEX_CURRENT_NODE\n# --master_addr=\"192.168.1.1\" --master_port=1234\n# unet_training_ddp.py -d DIR_OF_TESTDATA\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_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": 90, "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(tempdir):\n config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\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\n\nif __name__ == \"__main__\":\n with tempfile.TemporaryDirectory() as tempdir:\n main(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/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": 104, "span_ids": ["impl", "main"], "tokens": 748}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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(tempdir):\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\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\"),\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\n\nif __name__ == \"__main__\":\n with tempfile.TemporaryDirectory() as tempdir:\n main(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/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": 104, "span_ids": ["main"], "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 main(tempdir):\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 pairs\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": 105, "end_line": 168, "span_ids": ["impl", "main"], "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": "def main(tempdir):\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\n print(f\"train completed, best_metric: {best_metric:.4f} at epoch: {best_metric_epoch}\")\n writer.close()\n\n\nif __name__ == \"__main__\":\n with tempfile.TemporaryDirectory() as tempdir:\n main(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/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": 114, "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(tempdir):\n config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\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\n\nif __name__ == \"__main__\":\n with tempfile.TemporaryDirectory() as tempdir:\n main(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/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": 120, "span_ids": ["impl", "main"], "tokens": 820}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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(tempdir):\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n\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\"),\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\n\nif __name__ == \"__main__\":\n with tempfile.TemporaryDirectory() as tempdir:\n main(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/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": 96, "span_ids": ["main"], "tokens": 769}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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(tempdir):\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 pairs\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": 97, "end_line": 161, "span_ids": ["impl", "main"], "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": "def main(tempdir):\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\n\nif __name__ == \"__main__\":\n with tempfile.TemporaryDirectory() as tempdir:\n main(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/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": 185, "end_line": 201, "span_ids": ["impl", "main"], "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": "def main(tempdir):\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\n\nif __name__ == \"__main__\":\n with tempfile.TemporaryDirectory() as tempdir:\n main(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/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": 119, "span_ids": ["impl", "main"], "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": "def main(tempdir):\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 pairs\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\"),\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 # if no FP16 support in GPU or PyTorch version < 1.6, will not enable AMP evaluation\n amp=True if monai.config.get_torch_version_tuple() >= (1, 6) else False,\n )\n evaluator.run()\n\n\nif __name__ == \"__main__\":\n with tempfile.TemporaryDirectory() as tempdir:\n main(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/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": 110, "span_ids": ["main"], "tokens": 773}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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(tempdir):\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 pairs\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\"),\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\"),\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": 112, "end_line": 178, "span_ids": ["impl", "main"], "tokens": 672}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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(tempdir):\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 # if no FP16 support in GPU or PyTorch version < 1.6, will not enable AMP evaluation\n amp=True if monai.config.get_torch_version_tuple() >= (1, 6) else False,\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 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 # if no FP16 support in GPU or PyTorch version < 1.6, will not enable AMP training\n amp=True if monai.config.get_torch_version_tuple() >= (1, 6) else False,\n )\n trainer.run()\n\n\nif __name__ == \"__main__\":\n with tempfile.TemporaryDirectory() as tempdir:\n main(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/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": 34, "span_ids": ["docstring"], "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": "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\n# handlers_* have some external decorators the users may not have installed\n# *.so files and folder \"_C\" may not exist when the cpp extensions are not compiled\nexcludes = \"(^(handlers))|((\\\\.so)$)|(_C)\"\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/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": 134, "end_line": 187, "span_ids": ["DecathlonDataset"], "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": "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 Raises:\n ValueError: When ``root_dir`` is not a directory.\n ValueError: When ``task`` is not one of [\"Task01_BrainTumour\", \"Task02_Heart\",\n \"Task03_Liver\", \"Task04_Hippocampus\", \"Task05_Prostate\", \"Task06_Lung\", \"Task07_Pancreas\",\n \"Task08_HepaticVessel\", \"Task09_Spleen\", \"Task10_Colon\"].\n RuntimeError: When ``dataset_dir`` doesn't exist and downloading is not selected (``download=False``).\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 \"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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": 214, "end_line": 247, "span_ids": ["DecathlonDataset.__init__", "DecathlonDataset.randomize"], "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": "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 directory 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.keys())}.\")\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\"Cannot 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": 249, "end_line": 266, "span_ids": ["DecathlonDataset._generate_data_list"], "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 DecathlonDataset(Randomizable, CacheDataset):\n\n def _generate_data_list(self, dataset_dir: str) -> List[Dict]:\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_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": 51, "end_line": 100, "span_ids": ["download_url"], "tokens": 487}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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: When the MD5 validation of the ``filepath`` existing file fails.\n RuntimeError: When a network issue or denied permission prevents the\n file download from ``url`` to ``filepath``.\n URLError: See urllib.request.urlretrieve.\n HTTPError: See urllib.request.urlretrieve.\n ContentTooShortError: See urllib.request.urlretrieve.\n IOError: See urllib.request.urlretrieve.\n RuntimeError: When the MD5 validation of the ``url`` downloaded file fails.\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 failed: filepath={filepath}, expected MD5={md5_value}.\")\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(\n f\"Download of file from {url} to {filepath} failed due to network issue or denied permission.\"\n )\n else:\n\n def _process_hook(blocknum: int, blocksize: int, totalsize: int):\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: 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_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 numpy as np\nimport torch\n\nimport monai\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": 122, "span_ids": ["print_config", "set_visible_devices", "get_torch_version_tuple"], "tokens": 241}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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\n Args:\n file: `print()` text stream file. 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/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 ArrayDataset, CacheDataset, Dataset, PersistentDataset, ZipDataset\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_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": 81, "span_ids": ["DataLoader.__init__", "DataLoader", "docstring"], "tokens": 644}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 DataLoader as _TorchDataLoader\nfrom torch.utils.data import Dataset, Sampler\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[call-overload]\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_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": 155, "end_line": 204, "span_ids": ["PersistentDataset._pre_first_random_cachecheck", "PersistentDataset.__getitem__"], "tokens": 502}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 = None\n if self.cache_dir is not None:\n cache_dir_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 = 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": 279, "end_line": 304, "span_ids": ["CacheDataset._load_cache_item", "CacheDataset._load_cache_item_thread"], "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": "class CacheDataset(Dataset):\n\n def _load_cache_item(self, item: Any, transforms: Sequence[Callable]):\n \"\"\"\n Args:\n item: input item to load and transform to generate dataset for model.\n transforms: transforms to execute operations on input item.\n \"\"\"\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[int, Any, Sequence[Callable]]) -> None:\n \"\"\"\n Args:\n args: tuple with contents (i, item, transforms).\n i: the index to load the cached item to.\n item: input item to load and transform to generate dataset for model.\n transforms: transforms to execute operations on input item.\n \"\"\"\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_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_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": 71, "end_line": 116, "span_ids": ["load_decathalon_datalist"], "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": "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) -> List[Dict]:\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: When ``data_list_file_path`` does not point to a file.\n ValueError: When ``data_list_key`` is not specified in the data list file.\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_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_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": 81, "end_line": 121, "span_ids": ["NiftiDataset.__getitem__"], "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 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 # use tuple instead of list as the default collate_fn callback of MONAI DataLoader flattens nested lists\n return tuple(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_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": 71, "end_line": 120, "span_ids": ["NiftiSaver.save"], "tokens": 546}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 align_corners=self.align_corners,\n dtype=self.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": 89, "span_ids": ["write_nifti", "docstring"], "tokens": 1029}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 GridSampleMode, GridSamplePadMode, optional_import\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 align_corners: bool = False,\n dtype: Optional[np.dtype] = np.float64,\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 align_corners: Geometrically, we consider the pixels of the input as squares rather than points.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision.\n If None, use the data type of input data. To be compatible with other modules,\n the output data type is always ``np.float32``.\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": 90, "end_line": 126, "span_ids": ["write_nifti"], "tokens": 559}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 align_corners: bool = False,\n dtype: Optional[np.dtype] = np.float64,\n) -> None:\n assert isinstance(data, np.ndarray), \"input data must be numpy array.\"\n dtype = dtype or data.dtype\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(np.float32), 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(np.float32), 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=align_corners, 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": 127, "end_line": 154, "span_ids": ["write_nifti"], "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": "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 align_corners: bool = False,\n dtype: Optional[np.dtype] = np.float64,\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_np = data.reshape(list(spatial_shape) + [-1])\n data_np = np.moveaxis(data_np, -1, 0) # channel first for pytorch\n data_torch = affine_xform(\n torch.as_tensor(np.ascontiguousarray(data_np).astype(dtype)).unsqueeze(0),\n torch.as_tensor(np.ascontiguousarray(transform).astype(dtype)),\n spatial_size=output_spatial_shape_[:3],\n )\n data_np = data_torch.squeeze(0).detach().cpu().numpy()\n data_np = np.moveaxis(data_np, 0, -1) # channel last for nifti\n data_np = data_np.reshape(list(data_np.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_torch = affine_xform(\n torch.as_tensor(np.ascontiguousarray(data).astype(dtype)[None, None]),\n torch.as_tensor(np.ascontiguousarray(transform).astype(dtype)),\n spatial_size=output_spatial_shape_[: len(data.shape)],\n )\n data_np = data_torch.squeeze(0).squeeze(0).detach().cpu().numpy()\n\n results_img = nib.Nifti1Image(data_np.astype(np.float32), 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_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": 104, "span_ids": ["PNGSaver.save"], "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 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: When ``data`` channels is not one of [1, 3, 4].\n\n See Also\n :py:meth:`monai.data.png_writer.write_png`\n\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(f\"Unsupported number of channels: {data.shape[0]}, available options are [1, 3, 4]\")\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": 806}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 InterpolateMode, ensure_tuple_rep, optional_import\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: When ``scale`` is not one of [255, 65535].\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: {scale}, available options are [255, 65535]\")\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": 79, "span_ids": ["create_test_image_2d", "docstring"], "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": "from typing import Optional, Tuple\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) -> Tuple[np.ndarray, np.ndarray]:\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 Args:\n width: width of the image.\n height: height of the image.\n num_objs: number of circles to generate. Defaults to `12`.\n rad_max: maximum circle radius. Defaults to `30`.\n noise_max: if greater than 0 then noise will be added to the image taken from\n the uniform distribution on range `[0,noise_max)`. Defaults to `0`.\n num_seg_classes: number of classes for segmentations. Defaults to `5`.\n channel_dim: if None, create an image without channel dimension, otherwise create\n an image with channel dimension as first dim or last dim. Defaults to `None`.\n random_state: the random generator to use. Defaults to `np.random`.\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 if channel_dim == 0:\n noisyimage = noisyimage[None]\n labels = labels[None]\n else:\n noisyimage = noisyimage[..., None]\n labels = labels[..., None]\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": 82, "end_line": 140, "span_ids": ["create_test_image_3d"], "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": "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) -> Tuple[np.ndarray, np.ndarray]:\n \"\"\"\n Return a noisy 3D image and segmentation.\n\n Args:\n height: height of the image.\n width: width of the image.\n depth: depth of the image.\n num_objs: number of circles to generate. Defaults to `12`.\n rad_max: maximum circle radius. Defaults to `30`.\n noise_max: if greater than 0 then noise will be added to the image taken from\n the uniform distribution on range `[0,noise_max)`. Defaults to `0`.\n num_seg_classes: number of classes for segmentations. Defaults to `5`.\n channel_dim: if None, create an image without channel dimension, otherwise create\n an image with channel dimension as first dim or last dim. Defaults to `None`.\n random_state: the random generator to use. Defaults to `np.random`.\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_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": 53, "end_line": 80, "span_ids": ["iter_patch_slices"], "tokens": 313}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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(\n dims: Sequence[int], patch_size: Union[Sequence[int], int], start_pos: Sequence[int] = ()\n) -> Generator[Tuple[slice, ...], None, None]:\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": 83, "end_line": 144, "span_ids": ["dense_patch_slices"], "tokens": 653}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 Raises:\n ValueError: When ``image_size`` length is not one of [2, 3].\n\n Returns:\n a list of slice objects defining each patch\n\n \"\"\"\n num_spatial_dims = len(image_size)\n if num_spatial_dims not in (2, 3):\n raise ValueError(f\"Unsupported image_size length: {len(image_size)}, available options are [2, 3]\")\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 = list()\n for i in range(num_spatial_dims):\n if scan_interval[i] == 0:\n scan_num.append(1)\n else:\n num = int(math.ceil(float(image_size[i]) / scan_interval[i]))\n scan_dim = first(d for d in range(num) if d * scan_interval[i] + patch_size[i] >= image_size[i])\n scan_num.append(scan_dim + 1)\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": 147, "end_line": 195, "span_ids": ["iter_patch"], "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 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) -> Generator[np.ndarray, None, None]:\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": 198, "end_line": 209, "span_ids": ["get_valid_patch_size"], "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 get_valid_patch_size(image_size: Sequence[int], patch_size: Union[Sequence[int], int]) -> Tuple[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": 238, "end_line": 256, "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": 259, "end_line": 294, "span_ids": ["rectify_header_sform_qform"], "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": "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 Args:\n img_nii: nifti image object\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": 297, "end_line": 343, "span_ids": ["zoom_affine"], "tokens": 531}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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: np.ndarray, scale: Sequence[float], diagonal: bool = True) -> np.ndarray:\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 Raises:\n ValueError: When ``affine`` is not a square matrix.\n ValueError: When ``scale`` contains a nonpositive scalar.\n\n Returns:\n the updated `n x n` affine.\n\n \"\"\"\n\n affine = np.array(affine, dtype=float, copy=True)\n if len(affine) != len(affine[0]):\n raise ValueError(f\"affine must be n x n, got {len(affine)} x {len(affine[0])}.\")\n scale_np = np.array(scale, dtype=float, copy=True)\n if np.any(scale_np <= 0):\n raise ValueError(\"scale must contain only positive numbers.\")\n d = len(affine) - 1\n if len(scale_np) < d: # defaults based on affine\n norm = np.sqrt(np.sum(np.square(affine), 0))[:-1]\n scale_np = np.append(scale_np, norm[len(scale_np) :])\n scale_np = scale_np[:d]\n scale_np[scale_np == 0] = 1.0\n if diagonal:\n return np.diag(np.append(scale_np, [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_np)\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": 346, "end_line": 379, "span_ids": ["compute_shape_offset"], "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": "def compute_shape_offset(\n spatial_shape: np.ndarray, in_affine: np.ndarray, out_affine: np.ndarray\n) -> Tuple[np.ndarray, np.ndarray]:\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 Args:\n spatial_shape: input array's shape\n in_affine (matrix): 2D affine matrix\n out_affine (matrix): 2D affine matrix\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": 382, "end_line": 422, "span_ids": ["to_affine_nd"], "tokens": 501}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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: Union[np.ndarray, int], affine: np.ndarray) -> np.ndarray:\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 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 Raises:\n ValueError: When ``affine`` dimensions is not 2.\n ValueError: When ``r`` is nonpositive.\n\n Returns:\n an (r+1) x (r+1) matrix\n\n \"\"\"\n affine_np = np.array(affine, dtype=np.float64)\n if affine_np.ndim != 2:\n raise ValueError(f\"affine must have 2 dimensions, got {affine_np.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_np) - 1), 1)\n new_affine[:d, :d] = affine_np[:d, :d]\n if d > 1:\n new_affine[:d, -1] = affine_np[: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": 462, "end_line": 510, "span_ids": ["compute_importance_map"], "tokens": 474}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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) -> torch.Tensor:\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 Raises:\n ValueError: When ``mode`` is not one of [\"constant\", \"gaussian\"].\n\n Returns:\n Tensor of size patch_size.\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(f'Unsupported mode: {mode}, available options are [\"constant\", \"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/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": 94, "span_ids": ["Evaluator.get_validation_stats", "Evaluator.__init__", "Evaluator", "Evaluator.run"], "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": "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 amp: whether to enable auto-mixed-precision evaluation, default is False.\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 amp: bool = False,\n ) -> None:\n super().__init__(\n device=device,\n max_epochs=1,\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 amp=amp,\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, 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": 97, "end_line": 148, "span_ids": ["SupervisedEvaluator.__init__", "SupervisedEvaluator"], "tokens": 495}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 amp: whether to enable auto-mixed-precision evaluation, default is False.\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 amp: bool = False,\n ) -> None:\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 amp=amp,\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": 150, "end_line": 182, "span_ids": ["SupervisedEvaluator._iteration"], "tokens": 296}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: Dict[str, torch.Tensor]) -> 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: When ``batchdata`` is None.\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 if self.amp:\n with torch.cuda.amp.autocast():\n predictions = self.inferer(inputs, self.network)\n else:\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": 185, "end_line": 241, "span_ids": ["EnsembleEvaluator", "EnsembleEvaluator.__init__"], "tokens": 557}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 amp: whether to enable auto-mixed-precision evaluation, default is False.\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 amp: bool = False,\n ) -> None:\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 amp=amp,\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": 243, "end_line": 281, "span_ids": ["EnsembleEvaluator._iteration"], "tokens": 348}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: Dict[str, torch.Tensor]) -> 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: When ``batchdata`` is None.\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 = {Keys.IMAGE: inputs, Keys.LABEL: targets}\n for idx, network in enumerate(self.networks):\n network.eval()\n with torch.no_grad():\n if self.amp:\n with torch.cuda.amp.autocast():\n predictions.update({self.pred_keys[idx]: self.inferer(inputs, network)})\n else:\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_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": 43, "end_line": 89, "span_ids": ["create_multigpu_supervised_trainer"], "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": "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 distributed: bool = False,\n) -> Engine:\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 distributed: whether convert model to `DistributedDataParallel`, if have multiple devices, use\n the first device as output device.\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 if distributed:\n net = DistributedDataParallel(net, device_ids=devices_)\n elif len(devices_) > 1:\n net = 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": 92, "end_line": 137, "span_ids": ["create_multigpu_supervised_evaluator"], "tokens": 450}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 distributed: bool = False,\n) -> Engine:\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,)`\n which fits output expected by metrics. If you change it you should use `output_transform` in metrics.\n distributed: whether convert model to `DistributedDataParallel`, if have multiple devices, use\n the first device as output device.\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 distributed:\n net = DistributedDataParallel(net, device_ids=devices_)\n elif len(devices_) > 1:\n net = 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_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": 51, "span_ids": ["Trainer.run", "Trainer.get_train_stats", "Trainer"], "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 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 self.scaler = torch.cuda.amp.GradScaler() if self.amp else None\n super().run()\n\n def get_train_stats(self) -> Dict[str, 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": 54, "end_line": 115, "span_ids": ["SupervisedTrainer.__init__", "SupervisedTrainer"], "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 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 trainer to run.\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 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 amp: whether to enable auto-mixed-precision training, default is False.\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 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 amp: bool = False,\n ) -> None:\n # set up Ignite engine and environments\n super().__init__(\n device=device,\n max_epochs=max_epochs,\n data_loader=train_data_loader,\n prepare_batch=prepare_batch,\n iteration_update=iteration_update,\n post_transform=post_transform,\n key_metric=key_train_metric,\n additional_metrics=additional_metrics,\n handlers=train_handlers,\n amp=amp,\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/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": 33, "end_line": 66, "span_ids": ["Workflow"], "tokens": 450}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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[valid-type, misc] # 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 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 amp: whether to enable auto-mixed-precision training or inference, default is False.\n\n Raises:\n TypeError: When ``device`` is not a ``torch.Device``.\n TypeError: When ``data_loader`` is not a ``torch.utils.data.DataLoader``.\n TypeError: When ``key_metric`` is not a ``Optional[dict]``.\n TypeError: When ``additional_metrics`` is not a ``Optional[dict]``.\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": 68, "end_line": 157, "span_ids": ["Workflow.__init__", "Workflow.run"], "tokens": 755}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 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 amp: bool = False,\n ) -> None:\n if iteration_update is not None:\n super().__init__(iteration_update)\n else:\n super().__init__(self._iteration)\n if not isinstance(device, torch.device):\n raise TypeError(f\"device must be a torch.device but is {type(device).__name__}.\")\n if not isinstance(data_loader, DataLoader):\n raise TypeError(f\"data_loader must be a torch.utils.data.DataLoader but is {type(data_loader).__name__}.\")\n sampler = data_loader.__dict__[\"sampler\"]\n if isinstance(sampler, DistributedSampler):\n\n @self.on(Events.EPOCH_STARTED)\n def set_sampler_epoch(engine: Engine):\n sampler.set_epoch(engine.state.epoch)\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 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) -> None:\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 TypeError(f\"key_metric must be None or a dict but is {type(key_metric).__name__}.\")\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 TypeError(\n f\"additional_metrics must be None or a dict but is {type(additional_metrics).__name__}.\"\n )\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) -> None:\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 self.amp = amp\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": 159, "end_line": 173, "span_ids": ["Workflow._iteration"], "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 Workflow(IgniteEngine):\n\n def _iteration(self, engine: Engine, batchdata: Dict[str, torch.Tensor]):\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: When the subclass does not override this method.\n\n \"\"\"\n raise NotImplementedError(f\"Subclass {self.__class__.__name__} must implement this 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_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": 25, "end_line": 65, "span_ids": ["CheckpointSaver"], "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 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 If checkpoints are to be saved when an exception is raised, put this handler before\n `StatsHandler` in the handler list, because the logic with Ignite can only trigger\n the first attached handler for `EXCEPTION_RAISED` event.\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": 67, "end_line": 139, "span_ids": ["CheckpointSaver.__init__"], "tokens": 544}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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,\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(\n f\"Incompatible values: save_key_metric=True and key_metric_name={key_metric_name}.\"\n )\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": 141, "end_line": 157, "span_ids": ["CheckpointSaver.attach"], "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 CheckpointSaver:\n\n def attach(self, engine: Engine) -> None:\n \"\"\"\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n \"\"\"\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": 159, "end_line": 170, "span_ids": ["CheckpointSaver.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 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 Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\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/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": 26, "end_line": 85, "span_ids": ["LrScheduleHandler.__init__", "LrScheduleHandler", "LrScheduleHandler.__call__", "LrScheduleHandler.attach"], "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 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[[Engine], Any] = 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 TypeError: When ``step_transform`` is not ``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 TypeError(f\"step_transform must be callable but is {type(step_transform).__name__}.\")\n self.step_transform = step_transform\n\n self._name = name\n\n def attach(self, engine: Engine) -> None:\n \"\"\"\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n \"\"\"\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 \"\"\"\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n \"\"\"\n args = ensure_tuple(self.step_transform(engine))\n self.lr_scheduler.step(*args)\n if self.print_lr:\n self.logger.info(f\"Current learning rate: {self.lr_scheduler._last_lr[0]}\") # type: ignore[union-attr]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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 MetricReduction, exact_version, optional_import\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": 76, "span_ids": ["MeanDice", "MeanDice.__init__", "MeanDice.reset"], "tokens": 498}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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[valid-type, misc] # 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 other_act: Optional[Callable] = None,\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 other_act: callable function to replace `sigmoid` as activation layer if needed, Defaults to ``None``.\n for example: `other_act = torch.tanh`.\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 other_act=other_act,\n logit_thresh=logit_thresh,\n reduction=MetricReduction.MEAN,\n )\n self._sum = 0.0\n self._num_examples = 0\n\n @reinit__is_reduced\n def reset(self) -> None:\n self._sum = 0.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": 78, "end_line": 109, "span_ids": ["MeanDice.compute", "MeanDice.update"], "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 MeanDice(Metric):\n\n @reinit__is_reduced\n def update(self, output: Sequence[torch.Tensor]) -> None:\n \"\"\"\n Args:\n output: sequence with contents [y_pred, y].\n\n Raises:\n ValueError: When ``output`` length is not 2. MeanDice metric can only support y_pred and y.\n\n \"\"\"\n if len(output) != 2:\n raise ValueError(f\"output must have length 2, got {len(output)}.\")\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 \"\"\"\n Raises:\n NotComputableError: When ``compute`` is called before an ``update`` occurs.\n\n \"\"\"\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/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": 73, "span_ids": ["ROCAUC.reset", "ROCAUC", "ROCAUC.__init__", "docstring"], "tokens": 653}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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\nimport torch.distributed as dist\n\nfrom monai.metrics import compute_roc_auc\nfrom monai.utils import Average, exact_version, optional_import\n\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\")\n\n\nclass ROCAUC(Metric): # type: ignore[valid-type, misc] # 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 other_act: callable function to replace `softmax` as activation layer if needed, Defaults to ``None``.\n for example: `other_act = lambda x: torch.log_softmax(x)`.\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\n Note:\n ROCAUC expects y to be comprised of 0's and 1's.\n 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 other_act: Optional[Callable] = None,\n average: Union[Average, str] = Average.MACRO,\n output_transform: Callable = lambda x: x,\n ) -> None:\n super().__init__(output_transform)\n self.to_onehot_y = to_onehot_y\n self.softmax = softmax\n self.other_act = other_act\n self.average: Average = Average(average)\n\n @reinit__is_reduced\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/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": 109, "end_line": 131, "span_ids": ["SegmentationSaver.__call__", "SegmentationSaver.attach"], "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 SegmentationSaver:\n\n def attach(self, engine: Engine) -> None:\n \"\"\"\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n \"\"\"\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 Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\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_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": 30, "end_line": 86, "span_ids": ["StatsHandler.__init__", "StatsHandler"], "tokens": 582}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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[[Engine], Any]] = None,\n iteration_print_logger: Optional[Callable[[Engine], Any]] = 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._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_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": 32, "end_line": 79, "span_ids": ["TensorBoardStatsHandler.__init__", "TensorBoardStatsHandler"], "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": "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[[Engine, SummaryWriter], Any]] = None,\n iteration_event_writer: Optional[Callable[[Engine, SummaryWriter], Any]] = 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": 238, "end_line": 303, "span_ids": ["TensorBoardImageHandler.__call__", "TensorBoardImageHandler.attach"], "tokens": 644}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 \"\"\"\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n \"\"\"\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 \"\"\"\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n\n Raises:\n TypeError: When ``output_transform(engine.state.output)[0]`` type is not in\n ``Optional[Union[numpy.ndarray, torch.Tensor]]``.\n TypeError: When ``batch_transform(engine.state.batch)[1]`` type is not in\n ``Optional[Union[numpy.ndarray, torch.Tensor]]``.\n TypeError: When ``output_transform(engine.state.output)`` type is not in\n ``Optional[Union[numpy.ndarray, torch.Tensor]]``.\n\n \"\"\"\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 TypeError(\n \"output_transform(engine.state.output)[0] must be None or one of \"\n f\"(numpy.ndarray, torch.Tensor) but is {type(show_images).__name__}.\"\n )\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 TypeError(\n \"batch_transform(engine.state.batch)[1] must be None or one of \"\n f\"(numpy.ndarray, torch.Tensor) but is {type(show_labels).__name__}.\"\n )\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 TypeError(\n \"output_transform(engine.state.output) must be None or one of \"\n f\"(numpy.ndarray, torch.Tensor) but is {type(show_outputs).__name__}.\"\n )\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/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": 65, "span_ids": ["ValidationHandler.__init__", "ValidationHandler.__call__", "docstring", "ValidationHandler.attach", "ValidationHandler"], "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": "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 TypeError: When ``validator`` is not a ``monai.engines.evaluator.Evaluator``.\n\n \"\"\"\n if not isinstance(validator, Evaluator):\n raise TypeError(f\"validator must be a monai.engines.evaluator.Evaluator but is {type(validator).__name__}.\")\n self.validator = validator\n self.interval = interval\n self.epoch_level = epoch_level\n\n def attach(self, engine: Engine) -> None:\n \"\"\"\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n \"\"\"\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 \"\"\"\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n \"\"\"\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/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": 63, "end_line": 111, "span_ids": ["SlidingWindowInferer", "SlidingWindowInferer.__init__", "SlidingWindowInferer.__call__"], "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": "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: torch.nn.Module) -> torch.Tensor:\n \"\"\"\n Unified callable function API of Inferers.\n\n Args:\n inputs: model input data for inference.\n 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__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": 164, "end_line": 178, "span_ids": ["_get_scan_interval"], "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_scan_interval(\n image_size: Sequence[int], roi_size: Sequence[int], num_spatial_dims: int, overlap: float\n) -> Tuple[int, ...]:\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": 23, "span_ids": ["docstring"], "tokens": 61}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 (\n Dice,\n DiceLoss,\n GeneralizedDiceLoss,\n GeneralizedWassersteinDiceLoss,\n MaskedDiceLoss,\n dice,\n generalized_dice,\n)\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_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": 88, "end_line": 157, "span_ids": ["DiceLoss.forward"], "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": "class DiceLoss(_Loss):\n\n def forward(self, input: torch.Tensor, target: torch.Tensor, smooth: float = 1e-5) -> torch.Tensor:\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: When ``self.reduction`` is not one of [\"mean\", \"sum\", \"none\"].\n\n \"\"\"\n if self.sigmoid:\n input = torch.sigmoid(input)\n\n n_pred_ch = input.shape[1]\n if self.softmax:\n if n_pred_ch == 1:\n warnings.warn(\"single channel prediction, `softmax=True` ignored.\")\n else:\n input = torch.softmax(input, 1)\n\n if self.other_act is not None:\n input = self.other_act(input)\n\n if self.to_onehot_y:\n if n_pred_ch == 1:\n warnings.warn(\"single channel prediction, `to_onehot_y=True` ignored.\")\n else:\n target = one_hot(target, num_classes=n_pred_ch)\n\n if not self.include_background:\n if n_pred_ch == 1:\n warnings.warn(\"single channel prediction, `include_background=False` ignored.\")\n else:\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: torch.Tensor = 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'Unsupported reduction: {self.reduction}, available options are [\"mean\", \"sum\", \"none\"].')\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_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": 201, "end_line": 263, "span_ids": ["GeneralizedDiceLoss.__init__", "GeneralizedDiceLoss"], "tokens": 722}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 other_act: Optional[Callable] = None,\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 other_act: if don't want to use `sigmoid` or `softmax`, use other callable function to execute\n other activation layers, Defaults to ``None``. for example:\n `other_act = torch.tanh`.\n squared_pred: use squared versions of targets and predictions in the denominator or not.\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 TypeError: When ``other_act`` is not an ``Optional[Callable]``.\n ValueError: When more than 1 of [``sigmoid=True``, ``softmax=True``, ``other_act is not None``].\n Incompatible values.\n\n \"\"\"\n super().__init__(reduction=LossReduction(reduction).value)\n if other_act is not None and not callable(other_act):\n raise TypeError(f\"other_act must be None or callable but is {type(other_act).__name__}.\")\n if int(sigmoid) + int(softmax) + int(other_act is not None) > 1:\n raise ValueError(\"Incompatible values: more than 1 of [sigmoid=True, softmax=True, other_act is not None].\")\n self.include_background = include_background\n self.to_onehot_y = to_onehot_y\n self.sigmoid = sigmoid\n self.softmax = softmax\n self.other_act = other_act\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/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/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": 84, "end_line": 150, "span_ids": ["TverskyLoss.forward"], "tokens": 563}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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) -> torch.Tensor:\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: When ``self.reduction`` is not one of [\"mean\", \"sum\", \"none\"].\n\n \"\"\"\n if self.sigmoid:\n input = torch.sigmoid(input)\n\n n_pred_ch = input.shape[1]\n if self.softmax:\n if n_pred_ch == 1:\n warnings.warn(\"single channel prediction, `softmax=True` ignored.\")\n else:\n input = torch.softmax(input, 1)\n\n if self.other_act is not None:\n input = self.other_act(input)\n\n if self.to_onehot_y:\n if n_pred_ch == 1:\n warnings.warn(\"single channel prediction, `to_onehot_y=True` ignored.\")\n else:\n target = one_hot(target, num_classes=n_pred_ch)\n\n if not self.include_background:\n if n_pred_ch == 1:\n warnings.warn(\"single channel prediction, `include_background=False` ignored.\")\n else:\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 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: torch.Tensor = 1.0 - numerator / denominator\n\n if self.reduction == LossReduction.SUM.value:\n return torch.sum(score) # 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 torch.mean(score)\n raise ValueError(f'Unsupported reduction: {self.reduction}, available options are [\"mean\", \"sum\", \"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/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": 75, "end_line": 144, "span_ids": ["DiceMetric.__call__"], "tokens": 738}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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) -> torch.Tensor:\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.\n y: ground truth to compute mean dice metric, the first dim is batch.\n\n Raises:\n ValueError: When ``self.reduction`` is not one of\n [\"mean\", \"sum\", \"mean_batch\", \"sum_batch\", \"mean_channel\", \"sum_channel\" \"none\"].\n\n \"\"\"\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 other_act=self.other_act,\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(\n f\"Unsupported reduction: {self.reduction}, available options are \"\n '[\"mean\", \"sum\", \"mean_batch\", \"sum_batch\", \"mean_channel\", \"sum_channel\" \"none\"].'\n )\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/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": 55, "end_line": 109, "span_ids": ["compute_roc_auc"], "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 compute_roc_auc(\n y_pred: torch.Tensor,\n y: torch.Tensor,\n to_onehot_y: bool = False,\n softmax: bool = False,\n other_act: Optional[Callable] = None,\n average: Union[Average, str] = Average.MACRO,\n) -> Union[np.ndarray, List[float], float]:\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 other_act: callable function to replace `softmax` as activation layer if needed, Defaults to ``None``.\n for example: `other_act = lambda x: torch.log_softmax(x)`.\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: When ``y_pred`` dimension is not one of [1, 2].\n ValueError: When ``y`` dimension is not one of [1, 2].\n ValueError: When ``softmax=True`` and ``other_act is not None``. Incompatible values.\n TypeError: When ``other_act`` is not an ``Optional[Callable]``.\n ValueError: When ``average`` is not one of [\"macro\", \"weighted\", \"micro\", \"none\"].\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": 111, "end_line": 148, "span_ids": ["compute_roc_auc"], "tokens": 456}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 other_act: Optional[Callable] = None,\n average: Union[Average, str] = Average.MACRO,\n) -> Union[np.ndarray, List[float], float]:\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 and other_act is not None:\n raise ValueError(\"Incompatible values: softmax=True and other_act is not None.\")\n if softmax:\n y_pred = y_pred.float().softmax(dim=1)\n if other_act is not None:\n if not callable(other_act):\n raise TypeError(f\"other_act must be None or callable but is {type(other_act).__name__}.\")\n y_pred = other_act(y_pred)\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(\n f'Unsupported average: {average}, available options are [\"macro\", \"weighted\", \"micro\", \"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/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": 26, "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": "from .aspp import SimpleASPP\nfrom .convolutions import Convolution, ResidualUnit\nfrom .downsample import MaxAvgPool\nfrom .fcn import FCN, GCN, MCFCN, Refine\nfrom .segresnet_block import ResBlock\nfrom .squeeze_and_excitation import (\n ChannelSELayer,\n ResidualSELayer,\n SEBlock,\n SEBottleneck,\n SEResNetBottleneck,\n SEResNeXtBottleneck,\n)\nfrom .upsample import SubpixelUpsample, 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/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_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": 81, "end_line": 121, "span_ids": ["ResidualSELayer.__init__", "ResidualSELayer", "ResidualSELayer.forward"], "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 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,\n spatial_dims: int,\n in_channels: int,\n r: int = 2,\n acti_type_1: Union[Tuple[str, Dict], str] = \"leakyrelu\",\n acti_type_2: Union[Tuple[str, Dict], str] = \"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) -> 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/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_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": 67, "end_line": 91, "span_ids": ["gaussian_1d"], "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": "def gaussian_1d(sigma: float, truncated: float = 4.0) -> np.ndarray:\n \"\"\"\n one dimensional gaussian kernel.\n\n Args:\n sigma: std of the kernel\n truncated: tail length\n\n Raises:\n ValueError: When ``sigma`` is nonpositive.\n\n Returns:\n 1D numpy array\n\n \"\"\"\n if sigma <= 0:\n raise ValueError(f\"sigma must be positive, got {sigma}.\")\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": 275}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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, Tuple, Type, Union\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) -> Tuple[str, ...]:\n \"\"\"\n Produces all factory names.\n \"\"\"\n\n return tuple(self.factories)\n\n def add_factory_callable(self, name: str, func: Callable) -> None:\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": 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": "class LayerFactory:\n\n def factory_function(self, name: str) -> Callable:\n \"\"\"\n Decorator for adding a factory function with the given name.\n \"\"\"\n\n def _add(func: Callable) -> 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 TypeError: When ``factory_name`` is not a ``str``.\n\n \"\"\"\n\n if not isinstance(factory_name, str):\n raise TypeError(f\"factory_name must a str but is {type(factory_name).__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": 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": "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 Raises:\n TypeError: When ``args`` type is not in ``Union[str, Tuple[Union[str, Callable], dict]]``.\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 \"\"\"\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 TypeError(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/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": 52, "end_line": 71, "span_ids": ["Reshape.__init__", "Reshape", "Reshape.forward"], "tokens": 187}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: int) -> 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: torch.Tensor) -> torch.Tensor:\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": 74, "end_line": 92, "span_ids": ["GaussianFilter", "GaussianFilter.__init__"], "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": "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 = [cast(int, (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/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 GridSampleMode, GridSamplePadMode, ensure_tuple\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/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": 62, "span_ids": ["Classifier.__init__", "Classifier", "docstring"], "tokens": 469}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 Act, Norm, 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 \"\"\"\n Args:\n in_shape: tuple of integers stating the dimension of the input tensor (minus batch dimension)\n classes: integer 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 last_act: name defining the last activation layer\n \"\"\"\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": 65, "end_line": 97, "span_ids": ["Discriminator.__init__", "Discriminator"], "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 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 \"\"\"\n Args:\n in_shape: tuple of integers stating the dimension of the input tensor (minus batch dimension)\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 last_act: name defining the last activation layer\n \"\"\"\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": 100, "end_line": 141, "span_ids": ["Critic", "Critic.forward", "Critic.__init__", "Critic._get_final_layer"], "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": "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 \"\"\"\n Args:\n in_shape: tuple of integers stating the dimension of the input tensor (minus batch dimension)\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__(in_shape, 1, channels, strides, kernel_size, num_res_units, act, norm, dropout, bias, None)\n\n def _get_final_layer(self, in_shape: Sequence[int]):\n return nn.Flatten()\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\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": 54, "span_ids": ["_DenseLayer.__init__", "_DenseLayer.forward", "_DenseLayer", "docstring"], "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": "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, Norm, Pool\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 \"\"\"\n Args:\n spatial_dims: number of spatial dimensions of the input image.\n in_channels: number of the input channel.\n growth_rate: how many filters to add each layer (k in paper).\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 \"\"\"\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: torch.Tensor) -> torch.Tensor:\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": 57, "end_line": 75, "span_ids": ["_DenseBlock.__init__", "_DenseBlock"], "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": "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 \"\"\"\n Args:\n spatial_dims: number of spatial dimensions of the input image.\n layers: number of layers in the block.\n in_channels: number of the input channel.\n bn_size: multiplicative factor for number of bottle neck layers.\n (i.e. bn_size * k features in the bottleneck layer)\n growth_rate: how many filters to add each layer (k in paper).\n dropout_prob: dropout rate after each dense layer.\n \"\"\"\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": 78, "end_line": 95, "span_ids": ["_Transition", "_Transition.__init__"], "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 _Transition(nn.Sequential):\n def __init__(self, spatial_dims: int, in_channels: int, out_channels: int) -> None:\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 \"\"\"\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": 98, "end_line": 114, "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": 116, "end_line": 192, "span_ids": ["DenseNet.__init__", "DenseNet.forward"], "tokens": 703}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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)),\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_(torch.as_tensor(m.weight))\n elif isinstance(m, norm_type):\n nn.init.constant_(torch.as_tensor(m.weight), 1)\n nn.init.constant_(torch.as_tensor(m.bias), 0)\n elif isinstance(m, nn.Linear):\n nn.init.constant_(torch.as_tensor(m.bias), 0)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\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": 35, "span_ids": ["Generator", "docstring"], "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": "from typing import Optional, Sequence, Union\n\nimport numpy as np\nimport torch\nimport torch.nn as nn\n\nfrom monai.networks.blocks import Convolution, ResidualUnit\nfrom monai.networks.layers.factories import Act, Norm\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": 37, "end_line": 97, "span_ids": ["Generator.__init__"], "tokens": 653}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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()\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": 99, "end_line": 148, "span_ids": ["Generator.forward", "Generator._get_layer"], "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 Generator(nn.Module):\n\n def _get_layer(\n self, in_channels: int, out_channels: int, strides: int, is_last: bool\n ) -> Union[Convolution, nn.Sequential]:\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: torch.Tensor) -> torch.Tensor:\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_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": 89, "end_line": 159, "span_ids": ["HighResBlock.__init__", "HighResBlock", "HighResBlock.forward"], "tokens": 763}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: Union[Sequence[int], int] = 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 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 kernels: each integer k in `kernels` corresponds to a convolution layer with kernel size k.\n dilation: spacing between kernel elements.\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: When ``channel_matching=pad`` and ``in_channels > out_channels``. Incompatible values.\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('Incompatible values: channel_matching=\"pad\" and in_channels > out_channels.')\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: torch.Tensor) -> torch.Tensor:\n x_conv: torch.Tensor = self.layers(x)\n if self.project is not None:\n return x_conv + torch.as_tensor(self.project(x))\n if self.pad is not None:\n return x_conv + torch.as_tensor(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": 162, "end_line": 183, "span_ids": ["HighResNet"], "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": "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: 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": 185, "end_line": 265, "span_ids": ["HighResNet.forward", "HighResNet.__init__"], "tokens": 582}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: Sequence[Dict] = 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: torch.Tensor) -> torch.Tensor:\n return torch.as_tensor(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": 91, "span_ids": ["Regressor", "Regressor.__init__", "docstring"], "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": "from typing import Optional, Sequence, Union\n\nimport numpy as np\nimport torch\nimport torch.nn as nn\n\nfrom monai.networks.blocks import Convolution, ResidualUnit\nfrom monai.networks.layers.convutils import calculate_out_shape, same_padding\nfrom monai.networks.layers.factories import Act, Norm\nfrom monai.networks.layers.simplelayers import Reshape\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 ) -> None:\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": 93, "end_line": 143, "span_ids": ["Regressor.forward", "Regressor._get_final_layer", "Regressor._get_layer"], "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 Regressor(nn.Module):\n\n def _get_layer(\n self, in_channels: int, out_channels: int, strides: int, is_last: bool\n ) -> Union[ResidualUnit, Convolution]:\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: Sequence[int]):\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: torch.Tensor) -> torch.Tensor:\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_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": 102, "end_line": 142, "span_ids": ["UNet._get_down_layer", "UNet._get_bottom_layer"], "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": "@export(\"monai.networks.nets\")\n@alias(\"Unet\")\nclass UNet(nn.Module):\n\n def _get_down_layer(\n self, in_channels: int, out_channels: int, strides: int, is_top: bool\n ) -> Union[ResidualUnit, Convolution]:\n \"\"\"\n Args:\n in_channels: number of input channels.\n out_channels: number of output channels.\n strides: convolution stride.\n is_top: True if this is the top block.\n \"\"\"\n if self.num_res_units > 0:\n return ResidualUnit(\n self.dimensions,\n in_channels,\n out_channels,\n strides=strides,\n kernel_size=self.kernel_size,\n subunits=self.num_res_units,\n act=self.act,\n norm=self.norm,\n dropout=self.dropout,\n )\n else:\n return Convolution(\n self.dimensions,\n in_channels,\n out_channels,\n strides=strides,\n kernel_size=self.kernel_size,\n act=self.act,\n norm=self.norm,\n dropout=self.dropout,\n )\n\n def _get_bottom_layer(self, in_channels: int, out_channels: int) -> Union[ResidualUnit, Convolution]:\n \"\"\"\n Args:\n in_channels: number of input channels.\n out_channels: number of output channels.\n \"\"\"\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": 144, "end_line": 192, "span_ids": ["UNet.forward", "impl", "UNet._get_up_layer"], "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": "@export(\"monai.networks.nets\")\n@alias(\"Unet\")\nclass UNet(nn.Module):\n\n def _get_up_layer(\n self, in_channels: int, out_channels: int, strides: int, is_top: bool\n ) -> Union[Convolution, nn.Sequential]:\n \"\"\"\n Args:\n in_channels: number of input channels.\n out_channels: number of output channels.\n strides: convolution stride.\n is_top: True if this is the top block.\n \"\"\"\n conv: Union[Convolution, nn.Sequential]\n\n conv = Convolution(\n self.dimensions,\n in_channels,\n out_channels,\n strides=strides,\n kernel_size=self.up_kernel_size,\n act=self.act,\n norm=self.norm,\n dropout=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 strides=1,\n kernel_size=self.kernel_size,\n subunits=1,\n act=self.act,\n norm=self.norm,\n dropout=self.dropout,\n last_conv_only=is_top,\n )\n conv = nn.Sequential(conv, ru)\n\n return conv\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\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": 49, "span_ids": ["one_hot", "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": "import warnings\nfrom typing import Any, Callable, Optional, Sequence, cast\n\nimport torch\nimport torch.nn as nn\n\nfrom monai.utils import ensure_tuple_size\n\n\ndef one_hot(labels: torch.Tensor, num_classes: int, dtype: torch.dtype = torch.float, dim: int = 1) -> torch.Tensor:\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 `dim` is bigger, add singelton dim at the end\n if labels.ndimension() < dim + 1:\n shape = ensure_tuple_size(labels.shape, dim + 1, 1)\n labels = labels.reshape(*shape)\n\n sh = list(labels.shape)\n\n assert sh[dim] == 1, \"labels should have a channel with length equals to one.\"\n sh[dim] = num_classes\n\n o = torch.zeros(size=sh, dtype=dtype, device=labels.device)\n labels = o.scatter_(dim=dim, 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": 52, "end_line": 79, "span_ids": ["predict_segmentation", "slice_channels"], "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 slice_channels(tensor: torch.Tensor, *slicevals: Optional[int]) -> torch.Tensor:\n slices = [slice(None)] * len(tensor.shape)\n slices[1] = slice(*slicevals)\n\n return tensor[slices]\n\n\ndef predict_segmentation(\n logits: torch.Tensor, mutually_exclusive: bool = False, threshold: float = 0.0\n) -> torch.Tensor:\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: 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 (cast(torch.Tensor, 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 (cast(torch.Tensor, 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": 82, "end_line": 114, "span_ids": ["normalize_transform"], "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": "def normalize_transform(\n shape: Sequence[int],\n device: Optional[torch.device] = None,\n dtype: Optional[torch.dtype] = None,\n align_corners: bool = False,\n) -> torch.Tensor:\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: input spatial shape\n device: device on which the returned affine will be allocated.\n 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": 117, "end_line": 149, "span_ids": ["to_norm_affine"], "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": "def to_norm_affine(\n affine: torch.Tensor, src_size: Sequence[int], dst_size: Sequence[int], align_corners: bool = False\n) -> torch.Tensor:\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: Nxdxd batched square matrix\n src_size: source image spatial shape\n dst_size: 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 TypeError: When ``affine`` is not a ``torch.Tensor``.\n ValueError: When ``affine`` is not Nxdxd.\n ValueError: When ``src_size`` or ``dst_size`` dimensions differ from ``affine``.\n\n \"\"\"\n if not torch.is_tensor(affine):\n raise TypeError(f\"affine must be a torch.Tensor but is {type(affine).__name__}.\")\n if affine.ndimension() != 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(f\"affine suggests {sr}D, got src={len(src_size)}D, dst={len(dst_size)}D.\")\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/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": 244, "end_line": 268, "span_ids": ["FunctionSignature.__repr__", "FunctionSignature", "FunctionSignature.__str__", "FunctionSignature.__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 FunctionSignature:\n def __init__(self, function: Callable) -> 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) -> str:\n s = \" str:\n return self.__repr__()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_Transform.__call___Transform.__call__.raise_NotImplementedError": {"__data__": {"id_": "/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", "embedding": null, "metadata": {"file_path": "monai/transforms/compose.py", "file_name": "compose.py", "file_type": "text/x-python", "category": "implementation", "start_line": 45, "end_line": 71, "span_ids": ["Transform.__call__"], "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 Transform(ABC):\n\n @abstractmethod\n def __call__(self, data: Any):\n \"\"\"\n ``data`` is an element which often comes from an iteration over an\n iterable, such as :py:class:`torch.utils.data.Dataset`. This method should\n return an updated version of ``data``.\n To simplify the input validations, most of the transforms assume that\n\n - ``data`` is a Numpy ndarray, PyTorch Tensor or string\n - the data shape can be:\n\n #. string data without shape, `LoadNifti` and `LoadPNG` transforms expect file paths\n #. most of the pre-processing transforms expect: ``(num_channels, spatial_dim_1[, spatial_dim_2, ...])``,\n except that `AddChannel` expects (spatial_dim_1[, spatial_dim_2, ...]) and\n `AsChannelFirst` 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 This method can optionally take additional arguments to help execute transformation operation.\n\n Raises:\n NotImplementedError: When the subclass does not override this method.\n\n \"\"\"\n raise NotImplementedError(f\"Subclass {self.__class__.__name__} must implement this 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_Randomizable_Randomizable.R.np_random_RandomState_": {"__data__": {"id_": "/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_", "embedding": null, "metadata": {"file_path": "monai/transforms/compose.py", "file_name": "compose.py", "file_type": "text/x-python", "category": "implementation", "start_line": 75, "end_line": 93, "span_ids": ["Randomizable"], "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 Randomizable(ABC):\n \"\"\"\n An interface for handling random state locally, currently based on a class variable `R`,\n which is an instance of `np.random.RandomState`.\n This is mainly for randomized data augmentation transforms. For example::\n\n class RandShiftIntensity(Randomizable):\n def randomize():\n self._offset = self.R.uniform(low=0, high=100)\n def __call__(self, img):\n self.randomize()\n return img + self._offset\n\n transform = RandShiftIntensity()\n transform.set_random_state(seed=0)\n\n \"\"\"\n\n R: np.random.RandomState = np.random.RandomState()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_Randomizable.set_random_state_Randomizable.set_random_state.return.self": {"__data__": {"id_": "/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", "embedding": null, "metadata": {"file_path": "monai/transforms/compose.py", "file_name": "compose.py", "file_type": "text/x-python", "category": "implementation", "start_line": 94, "end_line": 125, "span_ids": ["Randomizable.set_random_state"], "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 Randomizable(ABC):\n\n def set_random_state(\n self, seed: Optional[int] = None, state: Optional[np.random.RandomState] = None\n ) -> \"Randomizable\":\n \"\"\"\n Set the random state locally, to control the randomness, the derived\n classes should use :py:attr:`self.R` instead of `np.random` to introduce random\n factors.\n\n Args:\n seed: set the random state with an integer seed.\n state: set the random state with a `np.random.RandomState` object.\n\n Raises:\n TypeError: When ``state`` is not an ``Optional[np.random.RandomState]``.\n\n Returns:\n a Randomizable instance.\n\n \"\"\"\n if seed is not None:\n _seed = id(seed) if not isinstance(seed, int) else seed\n self.R = np.random.RandomState(_seed)\n return self\n\n if state is not None:\n if not isinstance(state, np.random.RandomState):\n raise TypeError(f\"state must be None or a np.random.RandomState but is {type(state).__name__}.\")\n self.R = state\n return self\n\n self.R = np.random.RandomState()\n return self", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_Randomizable.randomize_Randomizable.randomize.raise_NotImplementedError": {"__data__": {"id_": "/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", "embedding": null, "metadata": {"file_path": "monai/transforms/compose.py", "file_name": "compose.py", "file_type": "text/x-python", "category": "implementation", "start_line": 127, "end_line": 141, "span_ids": ["Randomizable.randomize"], "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 Randomizable(ABC):\n\n @abstractmethod\n def randomize(self, data: Any) -> 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: When the subclass does not override this method.\n\n \"\"\"\n raise NotImplementedError(f\"Subclass {self.__class__.__name__} must implement this 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": 144, "end_line": 209, "span_ids": ["Compose.__init__", "Compose"], "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 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: Optional[Union[Sequence[Callable], Callable]] = 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": 211, "end_line": 233, "span_ids": ["Compose.__call__", "Compose.randomize", "Compose.set_random_state"], "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 Compose(Randomizable):\n\n def set_random_state(self, seed: Optional[int] = None, state: Optional[np.random.RandomState] = None) -> \"Compose\":\n for _transform in self.transforms:\n if not isinstance(_transform, Randomizable):\n continue\n _transform.set_random_state(seed, state)\n return self\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.__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": 269, "end_line": 298, "span_ids": ["MapTransform.__call__"], "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 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 Raises:\n NotImplementedError: When the subclass does not override this method.\n\n returns:\n An updated dictionary version of ``data`` by applying the transform.\n\n \"\"\"\n raise NotImplementedError(f\"Subclass {self.__class__.__name__} must implement this 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_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": 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 SpatialPad(Transform):\n\n def _determine_data_pad_width(self, data_shape: Sequence[int]) -> List[Tuple[int, int]]:\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": 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 SpatialPad(Transform):\n\n def __call__(self, img: np.ndarray, mode: Optional[Union[NumpyPadMode, str]] = None) -> np.ndarray:\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": 149, "span_ids": ["BorderPad.__call__"], "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 BorderPad(Transform):\n\n def __call__(self, img: np.ndarray, mode: Optional[Union[NumpyPadMode, str]] = None) -> np.ndarray:\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: When ``self.spatial_border`` contains a nonnegative int.\n ValueError: When ``self.spatial_border`` length is not one of\n [1, len(spatial_shape), 2*len(spatial_shape)].\n\n \"\"\"\n spatial_shape = img.shape[1:]\n spatial_border = ensure_tuple(self.spatial_border)\n for b in spatial_border:\n if not isinstance(b, int) or b < 0:\n raise ValueError(f\"self.spatial_border must contain only nonnegative ints, got {spatial_border}.\")\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(\n f\"Unsupported spatial_border length: {len(spatial_border)}, available options are \"\n f\"[1, len(spatial_shape)={len(spatial_shape)}, 2*len(spatial_shape)={2*len(spatial_shape)}].\"\n )\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": 173, "end_line": 191, "span_ids": ["DivisiblePad.__call__"], "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 DivisiblePad(Transform):\n\n def __call__(self, img: np.ndarray, mode: Optional[Union[NumpyPadMode, str]] = None) -> np.ndarray:\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": 232, "end_line": 243, "span_ids": ["SpatialCrop.__call__"], "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 SpatialCrop(Transform):\n\n def __call__(self, img: np.ndarray) -> np.ndarray:\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": 246, "end_line": 266, "span_ids": ["CenterSpatialCrop", "CenterSpatialCrop.__call__", "CenterSpatialCrop.__init__"], "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": "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: np.ndarray) -> np.ndarray:\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": 292, "end_line": 311, "span_ids": ["RandSpatialCrop.randomize", "RandSpatialCrop.__call__"], "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": "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: np.ndarray) -> np.ndarray:\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 assert self._size is not None\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": 314, "end_line": 354, "span_ids": ["RandSpatialCropSamples.__call__", "RandSpatialCropSamples", "RandSpatialCropSamples.__init__", "RandSpatialCropSamples.randomize"], "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": "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 Raises:\n ValueError: When ``num_samples`` is nonpositive.\n\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(f\"num_samples must be positive, got {num_samples}.\")\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: np.ndarray) -> List[np.ndarray]:\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": 357, "end_line": 403, "span_ids": ["CropForeground.__init__", "CropForeground", "CropForeground.__call__"], "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 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: np.ndarray) -> np.ndarray:\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/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": 32, "end_line": 68, "span_ids": ["SpatialPadd", "SpatialPadd.__init__", "SpatialPadd.__call__"], "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": "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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 71, "end_line": 113, "span_ids": ["BorderPadd.__init__", "BorderPadd.__call__", "BorderPadd"], "tokens": 559}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 116, "end_line": 149, "span_ids": ["DivisiblePadd.__init__", "DivisiblePadd", "DivisiblePadd.__call__"], "tokens": 406}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 152, "end_line": 183, "span_ids": ["SpatialCropd", "SpatialCropd.__call__", "SpatialCropd.__init__"], "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 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 186, "end_line": 205, "span_ids": ["CenterSpatialCropd.__call__", "CenterSpatialCropd", "CenterSpatialCropd.__init__"], "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 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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_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": 261, "end_line": 303, "span_ids": ["RandSpatialCropSamplesd", "RandSpatialCropSamplesd.__call__", "RandSpatialCropSamplesd.__init__", "RandSpatialCropSamplesd.randomize"], "tokens": 445}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 Raises:\n ValueError: When ``num_samples`` is nonpositive.\n\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(f\"num_samples must be positive, got {num_samples}.\")\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: Mapping[Hashable, np.ndarray]) -> List[Dict[Hashable, np.ndarray]]:\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": 306, "end_line": 351, "span_ids": ["CropForegroundd.__init__", "CropForegroundd", "CropForegroundd.__call__"], "tokens": 520}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 354, "end_line": 411, "span_ids": ["RandCropByPosNegLabeld.randomize", "RandCropByPosNegLabeld", "RandCropByPosNegLabeld.__init__"], "tokens": 691}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 with `neg` together to calculate the ratio ``pos / (pos + neg)`` for the probability\n to pick a foreground voxel as a center rather than a background voxel.\n neg: used with `pos` together to calculate the ratio ``pos / (pos + neg)`` for the probability\n to pick a 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: When ``pos`` or ``neg`` are negative.\n ValueError: When ``pos=0`` and ``neg=0``. Incompatible values.\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: Union[Tuple[int, ...], Sequence[int], int] = spatial_size\n if pos < 0 or neg < 0:\n raise ValueError(f\"pos and neg must be nonnegative, got pos={pos} neg={neg}.\")\n if pos + neg == 0:\n raise ValueError(\"Incompatible values: pos=0 and neg=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: Optional[List[List[np.ndarray]]] = 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": 413, "end_line": 431, "span_ids": ["RandCropByPosNegLabeld.__call__"], "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 RandCropByPosNegLabeld(Randomizable, MapTransform):\n\n def __call__(self, data: Mapping[Hashable, np.ndarray]) -> List[Dict[Hashable, np.ndarray]]:\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 assert isinstance(self.spatial_size, tuple)\n assert self.centers is not None\n results: List[Dict[Hashable, np.ndarray]] = [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_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": 148, "end_line": 183, "span_ids": ["RandScaleIntensity.__init__", "RandScaleIntensity", "RandScaleIntensity.randomize", "RandScaleIntensity.__call__"], "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 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: np.ndarray) -> np.ndarray:\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": 218, "end_line": 237, "span_ids": ["NormalizeIntensity._normalize", "NormalizeIntensity.__call__"], "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 NormalizeIntensity(Transform):\n\n def _normalize(self, img: np.ndarray) -> np.ndarray:\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: np.ndarray) -> np.ndarray:\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": 240, "end_line": 261, "span_ids": ["ThresholdIntensity", "ThresholdIntensity.__call__", "ThresholdIntensity.__init__"], "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": "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: np.ndarray) -> np.ndarray:\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": 284, "end_line": 297, "span_ids": ["ScaleIntensityRange.__call__"], "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": "class ScaleIntensityRange(Transform):\n\n def __call__(self, img: np.ndarray) -> np.ndarray:\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": 300, "end_line": 321, "span_ids": ["AdjustContrast.__init__", "AdjustContrast", "AdjustContrast.__call__"], "tokens": 184}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: np.ndarray) -> np.ndarray:\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": 324, "end_line": 362, "span_ids": ["RandAdjustContrast.randomize", "RandAdjustContrast", "RandAdjustContrast.__call__", "RandAdjustContrast.__init__"], "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": "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: np.ndarray) -> np.ndarray:\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n self.randomize()\n assert self.gamma_value is not None\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": 432, "end_line": 451, "span_ids": ["ScaleIntensityRangePercentiles.__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 ScaleIntensityRangePercentiles(Transform):\n\n def __call__(self, img: np.ndarray) -> np.ndarray:\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/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": 80, "end_line": 99, "span_ids": ["ShiftIntensityd", "ShiftIntensityd.__call__", "ShiftIntensityd.__init__"], "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": "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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 102, "end_line": 140, "span_ids": ["RandShiftIntensityd.randomize", "RandShiftIntensityd.__init__", "RandShiftIntensityd.__call__", "RandShiftIntensityd"], "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 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 143, "end_line": 169, "span_ids": ["ScaleIntensityd", "ScaleIntensityd.__call__", "ScaleIntensityd.__init__"], "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 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 172, "end_line": 211, "span_ids": ["RandScaleIntensityd.__call__", "RandScaleIntensityd.__init__", "RandScaleIntensityd", "RandScaleIntensityd.randomize"], "tokens": 391}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 214, "end_line": 245, "span_ids": ["NormalizeIntensityd.__call__", "NormalizeIntensityd.__init__", "NormalizeIntensityd"], "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 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 248, "end_line": 268, "span_ids": ["ThresholdIntensityd.__init__", "ThresholdIntensityd", "ThresholdIntensityd.__call__"], "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 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 271, "end_line": 295, "span_ids": ["ScaleIntensityRanged.__call__", "ScaleIntensityRanged.__init__", "ScaleIntensityRanged"], "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 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 298, "end_line": 319, "span_ids": ["AdjustContrastd", "AdjustContrastd.__call__", "AdjustContrastd.__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 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 keys: keys of the corresponding items to be transformed.\n See also: monai.transforms.MapTransform\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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 322, "end_line": 366, "span_ids": ["RandAdjustContrastd", "RandAdjustContrastd.randomize", "RandAdjustContrastd.__call__", "RandAdjustContrastd.__init__"], "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": "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: Optional[float] = 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\n d = dict(data)\n self.randomize()\n assert self.gamma_value is not None\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": 369, "end_line": 401, "span_ids": ["ScaleIntensityRangePercentilesd", "ScaleIntensityRangePercentilesd.__init__", "ScaleIntensityRangePercentilesd.__call__"], "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 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 404, "end_line": 426, "span_ids": ["MaskIntensityd", "MaskIntensityd.__call__", "MaskIntensityd.__init__"], "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 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) -> None:\n super().__init__(keys)\n self.converter = MaskIntensity(mask_data)\n\n def __call__(self, data: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 602, "end_line": 618, "span_ids": ["impl"], "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": "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\nGaussianSmoothD = GaussianSmoothDict = GaussianSmoothd\nRandGaussianSmoothD = RandGaussianSmoothDict = RandGaussianSmoothd\nGaussianSharpenD = GaussianSharpenDict = GaussianSharpend\nRandGaussianSharpenD = RandGaussianSharpenDict = RandGaussianSharpend", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_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": 61, "end_line": 108, "span_ids": ["LoadNifti.__call__"], "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": "class LoadNifti(Transform):\n\n def __call__(self, filename: Union[Sequence[Union[Path, str]], Path, str]):\n \"\"\"\n Args:\n filename: 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 = 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": 129, "end_line": 163, "span_ids": ["LoadPNG.__call__"], "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 LoadPNG(Transform):\n\n def __call__(self, filename: Union[Sequence[Union[Path, str]], Path, str]):\n \"\"\"\n Args:\n filename: 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": 195, "end_line": 224, "span_ids": ["LoadNumpy.__call__"], "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 LoadNumpy(Transform):\n\n def __call__(self, filename: Union[Sequence[Union[Path, str]], Path, str]):\n \"\"\"\n Args:\n filename: path file or file-like object or a list of files.\n\n Raises:\n ValueError: When ``filename`` is a sequence and contains a \"npz\" file extension.\n\n \"\"\"\n if isinstance(filename, (tuple, list)):\n for name in filename:\n if name.endswith(\".npz\"):\n raise ValueError(\"Cannot load a sequence of npz files.\")\n filename = ensure_tuple(filename)\n data_array: List = 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": 226, "end_line": 238, "span_ids": ["LoadNumpy.__call__"], "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 LoadNumpy(Transform):\n\n def __call__(self, filename: Union[Sequence[Union[Path, str]], Path, str]):\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_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": 67, "end_line": 83, "span_ids": ["LoadDatad.__call__"], "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": "class LoadDatad(MapTransform):\n\n def __call__(self, data):\n \"\"\"\n Raises:\n KeyError: When not ``self.overwriting`` and key already exists in ``data``.\n\n \"\"\"\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 and overwriting=False.\")\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": 86, "end_line": 117, "span_ids": ["LoadNiftid", "LoadNiftid.__init__"], "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 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 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": 120, "end_line": 144, "span_ids": ["LoadPNGd.__init__", "LoadPNGd"], "tokens": 241}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 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": 147, "end_line": 180, "span_ids": ["LoadNumpyd.__init__", "LoadNumpyd", "impl"], "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 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 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_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": 47, "end_line": 67, "span_ids": ["SplitChannel.__call__"], "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 SplitChannel(Transform):\n\n def __call__(\n self, img: torch.Tensor, to_onehot: Optional[bool] = None, num_classes: Optional[int] = None\n ) -> List[torch.Tensor]:\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": 70, "end_line": 92, "span_ids": ["Activations.__init__", "Activations"], "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 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 Raises:\n TypeError: When ``other`` is not an ``Optional[Callable]``.\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 if other is not None and not callable(other):\n raise TypeError(f\"other must be None or callable but is {type(other).__name__}.\")\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": 94, "end_line": 130, "span_ids": ["Activations.__call__"], "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": "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 ) -> torch.Tensor:\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: When ``sigmoid=True`` and ``softmax=True``. Incompatible values.\n TypeError: When ``other`` is not an ``Optional[Callable]``.\n ValueError: When ``self.other=None`` and ``other=None``. Incompatible values.\n\n \"\"\"\n if sigmoid and softmax:\n raise ValueError(\"Incompatible values: sigmoid=True and softmax=True.\")\n if other is not None and not callable(other):\n raise TypeError(f\"other must be None or callable but is {type(other).__name__}.\")\n\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\n act_func = self.other if other is None else other\n if act_func is not None:\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": 170, "end_line": 204, "span_ids": ["AsDiscrete.__call__"], "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 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 ) -> torch.Tensor:\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": 273, "end_line": 315, "span_ids": ["KeepLargestConnectedComponent.__call__"], "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": "class KeepLargestConnectedComponent(Transform):\n\n def __call__(self, img: torch.Tensor) -> 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": 318, "end_line": 334, "span_ids": ["LabelToContour", "LabelToContour.__init__"], "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 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 Raises:\n NotImplementedError: When ``kernel_type`` is not \"Laplace\".\n\n \"\"\"\n\n def __init__(self, kernel_type: str = \"Laplace\") -> None:\n if kernel_type != \"Laplace\":\n raise NotImplementedError('Currently only kernel_type=\"Laplace\" is supported.')\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": 336, "end_line": 366, "span_ids": ["LabelToContour.__call__"], "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 LabelToContour(Transform):\n\n def __call__(self, img: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Args:\n img: torch tensor data to extract the contour, with shape: [batch_size, channels, height, width[, depth]]\n\n Raises:\n ValueError: When ``image`` ndim is not one of [4, 5].\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.ndimension() == 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.ndimension() == 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 ValueError(f\"Unsupported img dimension: {img.ndimension()}, available options are [4, 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": 369, "end_line": 393, "span_ids": ["MeanEnsemble", "MeanEnsemble.__init__"], "tokens": 425}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 Typcally, the input data is model output of segmentation task or classificaiton task.\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) -> 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/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": 380}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: Mapping[Hashable, torch.Tensor]) -> Dict[Hashable, torch.Tensor]:\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": 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": "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: Mapping[Hashable, torch.Tensor]) -> Dict[Hashable, torch.Tensor]:\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": 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 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: Mapping[Hashable, torch.Tensor]) -> Dict[Hashable, torch.Tensor]:\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": 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 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: Mapping[Hashable, torch.Tensor]) -> Dict[Hashable, torch.Tensor]:\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/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_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": 61, "end_line": 106, "span_ids": ["Spacing.__init__", "Spacing"], "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": "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 align_corners: bool = False,\n dtype: Optional[np.dtype] = np.float64,\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 align_corners: Geometrically, we consider the pixels of the input as squares rather than points.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision.\n If None, use the data type of input data. To be compatible with other modules,\n the output data type is always ``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.align_corners = align_corners\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_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": 189, "end_line": 224, "span_ids": ["Orientation.__init__", "Orientation"], "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 Orientation(Transform):\n \"\"\"\n Change the input image's orientation into the specified based on `axcodes`.\n \"\"\"\n\n def __init__(\n self,\n axcodes: Optional[str] = None,\n as_closest_canonical: bool = False,\n labels: Optional[Sequence[Tuple[str, str]]] = 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: When ``axcodes=None`` and ``as_closest_canonical=True``. Incompatible values.\n\n See Also: `nibabel.orientations.ornt2axcodes`.\n\n \"\"\"\n if axcodes is None and not as_closest_canonical:\n raise ValueError(\"Incompatible values: axcodes=None and 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": 226, "end_line": 270, "span_ids": ["Orientation.__call__"], "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": "class Orientation(Transform):\n\n def __call__(\n self, data_array: np.ndarray, affine: Optional[np.ndarray] = None\n ) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:\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 Raises:\n ValueError: When ``data_array`` has no spatial dimensions.\n ValueError: When ``axcodes`` spatiality differs from ``data_array``.\n\n Returns:\n data_array (reoriented in `self.axcodes`), original axcodes, current axcodes.\n\n \"\"\"\n sr = data_array.ndim - 1\n if sr <= 0:\n raise ValueError(\"data_array must 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\"axcodes must match data_array spatially, got axcodes={len(self.axcodes)}D data_array={sr}D\"\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": 273, "end_line": 294, "span_ids": ["Flip.__init__", "Flip", "Flip.__call__"], "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 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) -> 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": 325, "end_line": 360, "span_ids": ["Resize.__call__"], "tokens": 444}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 ) -> np.ndarray:\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: When ``self.spatial_size`` length is less than ``img`` spatial dimensions.\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) must be greater or equal to img spatial dimensions, \"\n f\"got spatial_size={output_ndim} img={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.__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": 401, "end_line": 463, "span_ids": ["Rotate.__call__"], "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": "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: Optional[bool] = None,\n dtype: Optional[np.dtype] = None,\n ) -> np.ndarray:\n \"\"\"\n Args:\n img: channel first array, must have shape: [chns, H, W] or [chns, 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: Defaults to ``self.align_corners``.\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 dtype: data type for resampling computation. Defaults to ``self.dtype``.\n If None, use the data type of input data. To be compatible with other modules,\n the output data type is always ``np.float32``.\n\n Raises:\n ValueError: When ``img`` spatially is not one of [2D, 3D].\n\n \"\"\"\n _dtype = dtype or self.dtype or img.dtype\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(f\"Unsupported img dimension: {input_ndim}, available options are [2, 3].\")\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\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.as_tensor(np.ascontiguousarray(img).astype(_dtype)).unsqueeze(0),\n torch.as_tensor(np.ascontiguousarray(transform).astype(_dtype)),\n spatial_size=output_shape,\n )\n output = output.squeeze(0).detach().cpu().numpy().astype(np.float32)\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": 499, "end_line": 534, "span_ids": ["Zoom.__call__"], "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": "class Zoom(Transform):\n\n def __call__(\n self, img: np.ndarray, mode: Optional[Union[InterpolateMode, str]] = None, align_corners: Optional[bool] = None,\n ) -> np.ndarray:\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": 537, "end_line": 560, "span_ids": ["Rotate90.__call__", "Rotate90.__init__", "Rotate90"], "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 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) -> 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": 563, "end_line": 598, "span_ids": ["RandRotate90.randomize", "RandRotate90", "RandRotate90.__init__", "RandRotate90.__call__"], "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 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) -> 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_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": 706, "end_line": 733, "span_ids": ["RandFlip", "RandFlip.__init__", "RandFlip.__call__", "RandFlip.randomize"], "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 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) -> 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) -> 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": 786, "end_line": 807, "span_ids": ["RandZoom.__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 RandZoom(Randomizable, Transform):\n\n def __call__(\n self, img: np.ndarray, mode: Optional[Union[InterpolateMode, str]] = None, align_corners: Optional[bool] = None,\n ) -> np.ndarray:\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": 853, "end_line": 889, "span_ids": ["AffineGrid.__call__"], "tokens": 380}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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__(\n self, spatial_size: Optional[Sequence[int]] = None, grid: Optional[Union[np.ndarray, torch.Tensor]] = None\n ) -> Union[np.ndarray, torch.Tensor]:\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: When ``grid=None`` and ``spatial_size=None``. Incompatible values.\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(\"Incompatible values: grid=None and spatial_size=None.\")\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": 956, "end_line": 976, "span_ids": ["RandAffineGrid.__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 RandAffineGrid(Randomizable, Transform):\n\n def __call__(\n self, spatial_size: Optional[Sequence[int]] = None, grid: Optional[Union[np.ndarray, torch.Tensor]] = None\n ) -> Union[np.ndarray, torch.Tensor]:\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 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": 979, "end_line": 1013, "span_ids": ["RandDeformGrid", "RandDeformGrid.__init__", "RandDeformGrid.randomize"], "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 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]) -> None:\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": 1015, "end_line": 1026, "span_ids": ["RandDeformGrid.__call__"], "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 RandDeformGrid(Randomizable, Transform):\n\n def __call__(self, spatial_size: Sequence[int]) -> Union[np.ndarray, torch.Tensor]:\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": 1056, "end_line": 1098, "span_ids": ["Resample.__call__"], "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 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 ) -> Union[np.ndarray, torch.Tensor]:\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.ndimension() - 2, -1, -1))\n grid = grid[index_ordering]\n grid = grid.permute(list(range(grid.ndimension()))[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": 1157, "end_line": 1183, "span_ids": ["Affine.__call__"], "tokens": 379}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 ) -> Union[np.ndarray, torch.Tensor]:\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": 1261, "end_line": 1303, "span_ids": ["RandAffine.randomize", "RandAffine.__call__", "RandAffine.set_random_state"], "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 RandAffine(Randomizable, Transform):\n\n def set_random_state(\n self, seed: Optional[int] = None, state: Optional[np.random.RandomState] = None\n ) -> \"RandAffine\":\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 ) -> Union[np.ndarray, torch.Tensor]:\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": 1383, "end_line": 1394, "span_ids": ["Rand2DElastic.randomize", "Rand2DElastic.set_random_state"], "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 Rand2DElastic(Randomizable, Transform):\n\n def set_random_state(\n self, seed: Optional[int] = None, state: Optional[np.random.RandomState] = None\n ) -> \"Rand2DElastic\":\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": 1396, "end_line": 1430, "span_ids": ["Rand2DElastic.__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 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 ) -> Union[np.ndarray, torch.Tensor]:\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": 1511, "end_line": 1524, "span_ids": ["Rand3DElastic.randomize", "Rand3DElastic.set_random_state"], "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 Rand3DElastic(Randomizable, Transform):\n\n def set_random_state(\n self, seed: Optional[int] = None, state: Optional[np.random.RandomState] = None\n ) -> \"Rand3DElastic\":\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": 1526, "end_line": 1557, "span_ids": ["Rand3DElastic.__call__"], "tokens": 445}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 ) -> Union[np.ndarray, torch.Tensor]:\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_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": 129, "end_line": 147, "span_ids": ["Spacingd.__call__"], "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 Spacingd(MapTransform):\n\n def __call__(\n self, data: Mapping[Union[Hashable, str], Dict[str, np.ndarray]]\n ) -> Dict[Union[Hashable, str], Union[np.ndarray, Dict[str, np.ndarray]]]:\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 align_corners=self.align_corners[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_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": 209, "end_line": 228, "span_ids": ["Rotate90d.__call__", "Rotate90d.__init__", "Rotate90d"], "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 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 231, "end_line": 274, "span_ids": ["RandRotate90d", "RandRotate90d.__call__", "RandRotate90d.__init__", "RandRotate90d.randomize"], "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 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: Mapping[Hashable, np.ndarray]) -> Mapping[Hashable, np.ndarray]:\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": 277, "end_line": 314, "span_ids": ["Resized.__call__", "Resized.__init__", "Resized"], "tokens": 483}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: 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: Union[Sequence[Optional[bool]], Optional[bool]] = 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 392, "end_line": 416, "span_ids": ["RandAffined.__call__", "RandAffined.set_random_state", "RandAffined.randomize"], "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 RandAffined(Randomizable, MapTransform):\n\n def set_random_state(\n self, seed: Optional[int] = None, state: Optional[np.random.RandomState] = None\n ) -> \"RandAffined\":\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__(\n self, data: Mapping[Hashable, Union[np.ndarray, torch.Tensor]]\n ) -> Dict[Hashable, Union[np.ndarray, torch.Tensor]]:\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": 498, "end_line": 533, "span_ids": ["Rand2DElasticd.randomize", "Rand2DElasticd.__call__", "Rand2DElasticd.set_random_state"], "tokens": 375}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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(\n self, seed: Optional[int] = None, state: Optional[np.random.RandomState] = None\n ) -> \"Rand2DElasticd\":\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__(\n self, data: Mapping[Hashable, Union[np.ndarray, torch.Tensor]]\n ) -> Dict[Hashable, Union[np.ndarray, torch.Tensor]]:\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=ensure_tuple_rep(self.rand_2d_elastic.deform_grid.spacing, 2),\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": 618, "end_line": 648, "span_ids": ["Rand3DElasticd.__call__", "Rand3DElasticd.set_random_state", "Rand3DElasticd.randomize"], "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 Rand3DElasticd(Randomizable, MapTransform):\n\n def set_random_state(\n self, seed: Optional[int] = None, state: Optional[np.random.RandomState] = None\n ) -> \"Rand3DElasticd\":\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__(\n self, data: Mapping[Hashable, Union[np.ndarray, torch.Tensor]]\n ) -> Dict[Hashable, Union[np.ndarray, torch.Tensor]]:\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": 651, "end_line": 671, "span_ids": ["Flipd.__init__", "Flipd", "Flipd.__call__"], "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 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 674, "end_line": 707, "span_ids": ["RandFlipd", "RandFlipd.__init__", "RandFlipd.__call__", "RandFlipd.randomize"], "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 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 710, "end_line": 765, "span_ids": ["Rotated.__init__", "Rotated.__call__", "Rotated"], "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 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#grid-sample\n It also can be a sequence of bool, each element corresponds to a key in ``keys``.\n dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision.\n If None, use the data type of input data. To be compatible with other modules,\n the output data type is always ``np.float32``.\n It also can be a sequence of dtype or None, 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 dtype: Union[Sequence[Optional[np.dtype]], Optional[np.dtype]] = np.float64,\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 self.dtype = ensure_tuple_rep(dtype, len(self.keys))\n\n def __call__(self, data: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\n d = dict(data)\n for idx, key in enumerate(self.keys):\n d[key] = self.rotator(\n d[key],\n mode=self.mode[idx],\n padding_mode=self.padding_mode[idx],\n align_corners=self.align_corners[idx],\n 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/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": 768, "end_line": 800, "span_ids": ["RandRotated"], "tokens": 497}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision.\n If None, use the data type of input data. To be compatible with other modules,\n the output data type is always ``np.float32``.\n It also can be a sequence of dtype or None, 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": 802, "end_line": 842, "span_ids": ["RandRotated.randomize", "RandRotated.__init__"], "tokens": 505}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 dtype: Union[Sequence[Optional[np.dtype]], Optional[np.dtype]] = np.float64,\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 self.dtype = ensure_tuple_rep(dtype, 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": 844, "end_line": 860, "span_ids": ["RandRotated.__call__"], "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 RandRotated(Randomizable, MapTransform):\n\n def __call__(self, data: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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],\n mode=self.mode[idx],\n padding_mode=self.padding_mode[idx],\n align_corners=self.align_corners[idx],\n 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/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": 863, "end_line": 900, "span_ids": ["Zoomd.__call__", "Zoomd.__init__", "Zoomd"], "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": "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: 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: Union[Sequence[Optional[bool]], Optional[bool]] = 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 903, "end_line": 968, "span_ids": ["RandZoomd.__init__", "RandZoomd.randomize", "RandZoomd.__call__", "RandZoomd"], "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 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: 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: Union[Sequence[Optional[bool]], Optional[bool]] = 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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_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": 46, "end_line": 70, "span_ids": ["AsChannelFirst.__init__", "AsChannelFirst", "AsChannelFirst.__call__"], "tokens": 241}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: np.ndarray) -> np.ndarray:\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": 73, "end_line": 96, "span_ids": ["AsChannelLast.__init__", "AsChannelLast.__call__", "AsChannelLast"], "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 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: np.ndarray) -> np.ndarray:\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": 99, "end_line": 117, "span_ids": ["AddChannel.__call__", "AddChannel"], "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 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: NdarrayTensor) -> NdarrayTensor:\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": 120, "end_line": 138, "span_ids": ["RepeatChannel.__call__", "RepeatChannel.__init__", "RepeatChannel"], "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 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: np.ndarray) -> np.ndarray:\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_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": 175, "end_line": 215, "span_ids": ["ToTensor.__call__", "Transpose.__init__", "ToNumpy.__call__", "Transpose", "ToTensor", "ToNumpy", "Transpose.__call__"], "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 ToTensor(Transform):\n \"\"\"\n Converts the input image to a tensor without applying any other transformations.\n \"\"\"\n\n def __call__(self, img: Union[np.ndarray, torch.Tensor]) -> torch.Tensor:\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: Union[np.ndarray, torch.Tensor]) -> np.ndarray:\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: Optional[Sequence[int]]) -> None:\n self.indices = None if indices is None else tuple(indices)\n\n def __call__(self, img: np.ndarray) -> np.ndarray:\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": 218, "end_line": 242, "span_ids": ["SqueezeDim.__call__", "SqueezeDim.__init__", "SqueezeDim"], "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 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 TypeError: When ``dim`` is not an ``Optional[int]``.\n\n \"\"\"\n if dim is not None and not isinstance(dim, int):\n raise TypeError(f\"dim must be None or a int but is {type(dim).__name__}.\")\n self.dim = dim\n\n def __call__(self, img: NdarrayTensor) -> NdarrayTensor:\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": 245, "end_line": 289, "span_ids": ["DataStats", "DataStats.__init__"], "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 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 TypeError: When ``additional_info`` is not an ``Optional[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 TypeError(f\"additional_info must be None or callable but is {type(additional_info).__name__}.\")\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": 291, "end_line": 323, "span_ids": ["DataStats.__call__"], "tokens": 325}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: NdarrayTensor,\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: Optional[Callable] = None,\n ) -> NdarrayTensor:\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": 326, "end_line": 355, "span_ids": ["SimulateDelay.__call__", "SimulateDelay.__init__", "SimulateDelay"], "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 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: NdarrayTensor, delay_time: Optional[float] = None) -> NdarrayTensor:\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_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": 407, "end_line": 430, "span_ids": ["LabelToMask.__init__", "LabelToMask"], "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": "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__(\n self, select_labels: Union[Sequence[int], int], merge_channels: bool = False,\n ) -> None: # pytype: disable=annotation-type-mismatch # pytype bug with bool\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": 432, "end_line": 459, "span_ids": ["LabelToMask.__call__"], "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": "class LabelToMask(Transform):\n\n def __call__(\n self,\n img: np.ndarray,\n select_labels: Optional[Union[Sequence[int], int]] = None,\n merge_channels: Optional[bool] = None,\n ) -> np.ndarray:\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 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_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": 45, "end_line": 64, "span_ids": ["Identityd.__init__", "Identityd", "Identityd.__call__"], "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 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: Mapping[Hashable, Union[np.ndarray, torch.Tensor]]) -> Dict[Hashable, np.ndarray]:\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": 67, "end_line": 86, "span_ids": ["AsChannelFirstd.__init__", "AsChannelFirstd.__call__", "AsChannelFirstd"], "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 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 89, "end_line": 108, "span_ids": ["AsChannelLastd.__call__", "AsChannelLastd.__init__", "AsChannelLastd"], "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 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 111, "end_line": 131, "span_ids": ["AddChanneld.__call__", "AddChanneld.__init__", "AddChanneld"], "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 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__(\n self, data: Mapping[Hashable, Union[np.ndarray, torch.Tensor]]\n ) -> Dict[Hashable, Union[np.ndarray, torch.Tensor]]:\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": 134, "end_line": 153, "span_ids": ["RepeatChanneld.__init__", "RepeatChanneld", "RepeatChanneld.__call__"], "tokens": 162}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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": 156, "end_line": 186, "span_ids": ["CastToTyped", "CastToTyped.__init__", "CastToTyped.__call__"], "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 CastToTyped(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.CastToType`.\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n dtype: Union[Sequence[Union[np.dtype, torch.dtype]], np.dtype, torch.dtype] = np.float32,\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: convert image to this data type, default is `np.float32`.\n it also can be a sequence of np.dtype or torch.dtype,\n 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__(\n self, data: Mapping[Hashable, Union[np.ndarray, torch.Tensor]]\n ) -> Dict[Hashable, Union[np.ndarray, torch.Tensor]]:\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": 189, "end_line": 207, "span_ids": ["ToTensord", "ToTensord.__call__", "ToTensord.__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 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: Mapping[Hashable, Union[np.ndarray, torch.Tensor]]) -> Dict[Hashable, torch.Tensor]:\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": 210, "end_line": 228, "span_ids": ["ToNumpyd.__init__", "ToNumpyd", "ToNumpyd.__call__"], "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 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: Mapping[Hashable, Union[np.ndarray, torch.Tensor]]) -> Dict[Hashable, np.ndarray]:\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": 249, "end_line": 270, "span_ids": ["SqueezeDimd.__init__", "SqueezeDimd", "SqueezeDimd.__call__"], "tokens": 182}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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__(\n self, data: Mapping[Hashable, Union[np.ndarray, torch.Tensor]]\n ) -> Dict[Hashable, Union[np.ndarray, torch.Tensor]]:\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": 273, "end_line": 330, "span_ids": ["DataStatsd.__call__", "DataStatsd", "DataStatsd.__init__"], "tokens": 607}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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__(\n self, data: Mapping[Hashable, Union[np.ndarray, torch.Tensor]]\n ) -> Dict[Hashable, Union[np.ndarray, torch.Tensor]]:\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": 333, "end_line": 357, "span_ids": ["SimulateDelayd.__init__", "SimulateDelayd.__call__", "SimulateDelayd"], "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 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) -> None:\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__(\n self, data: Mapping[Hashable, Union[np.ndarray, torch.Tensor]]\n ) -> Dict[Hashable, Union[np.ndarray, torch.Tensor]]:\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": 360, "end_line": 406, "span_ids": ["CopyItemsd.__call__", "CopyItemsd", "CopyItemsd.__init__"], "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 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) -> None:\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: When ``times`` is nonpositive.\n ValueError: When ``len(names)`` is not ``len(keys) * times``. Incompatible values.\n\n \"\"\"\n super().__init__(keys)\n if times < 1:\n raise ValueError(f\"times must be positive, got {times}.\")\n self.times = times\n names = ensure_tuple(names)\n if len(names) != (len(self.keys) * times):\n raise ValueError(\n \"len(names) must match len(keys) * times, \"\n f\"got len(names)={len(names)} len(keys) * times={len(self.keys) * times}.\"\n )\n self.names = names\n\n def __call__(self, data):\n \"\"\"\n Raises:\n KeyError: When a key in ``self.names`` already exists in ``data``.\n\n \"\"\"\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 data.\")\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": 409, "end_line": 432, "span_ids": ["ConcatItemsd", "ConcatItemsd.__init__"], "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 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: When insufficient keys are given (``len(self.keys) < 2``).\n\n \"\"\"\n super().__init__(keys)\n if len(self.keys) < 2:\n raise ValueError(\"Concatenation requires at least 2 keys.\")\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": 434, "end_line": 456, "span_ids": ["ConcatItemsd.__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 ConcatItemsd(MapTransform):\n\n def __call__(self, data):\n \"\"\"\n Raises:\n TypeError: When items in ``data`` differ in type.\n TypeError: When the item type is not in ``Union[numpy.ndarray, torch.Tensor]``.\n\n \"\"\"\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(\"All items in data must have the same 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: {data_type}, available options are (numpy.ndarray, torch.Tensor).\")\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": 493, "end_line": 519, "span_ids": ["LabelToMaskd", "LabelToMaskd.__init__", "LabelToMaskd.__call__"], "tokens": 275}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: # pytype: disable=annotation-type-mismatch # pytype bug with bool\n super().__init__(keys)\n self.converter = LabelToMask(select_labels, merge_channels)\n\n def __call__(self, data: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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_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": 68, "end_line": 84, "span_ids": ["rescale_array"], "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": "def rescale_array(\n arr: np.ndarray, minv: float = 0.0, maxv: float = 1.0, dtype: Optional[np.dtype] = np.float32\n) -> np.ndarray:\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": 87, "end_line": 105, "span_ids": ["rescale_instance_array", "rescale_array_int_max"], "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": "def rescale_instance_array(\n arr: np.ndarray, minv: float = 0.0, maxv: float = 1.0, dtype: np.dtype = np.float32\n) -> np.ndarray:\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) -> np.ndarray:\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": 108, "end_line": 160, "span_ids": ["copypaste_arrays"], "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 copypaste_arrays(\n src: np.ndarray,\n dest: np.ndarray,\n srccenter: Sequence[int],\n destcenter: Sequence[int],\n dims: Sequence[Optional[int]],\n) -> Tuple[Tuple[slice, ...], Tuple[slice, ...]]:\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": 163, "end_line": 179, "span_ids": ["resize_center"], "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 resize_center(img: np.ndarray, *resize_dims: Optional[int], fill_value: float = 0.0) -> np.ndarray:\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_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": 294, "end_line": 314, "span_ids": ["create_grid"], "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": "def create_grid(\n spatial_size: Sequence[int],\n spacing: Optional[Sequence[float]] = None,\n homogeneous: bool = True,\n dtype: np.dtype = float,\n) -> np.ndarray:\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": 317, "end_line": 330, "span_ids": ["create_control_grid"], "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": "def create_control_grid(\n spatial_shape: Sequence[int], spacing: Sequence[float], homogeneous: bool = True, dtype: np.dtype = float\n) -> np.ndarray:\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_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": 379, "end_line": 404, "span_ids": ["create_shear"], "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": "def create_shear(spatial_dims: int, coefs: Union[Sequence[float], float]) -> np.ndarray:\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: When ``spatial_dims`` is not one of [2, 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(\"Currently only spatial_dims in [2, 3] are supported.\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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": 407, "end_line": 431, "span_ids": ["create_scale", "create_translate"], "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": "def create_scale(spatial_dims: int, scaling_factor: Union[Sequence[float], float]) -> np.ndarray:\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]) -> np.ndarray:\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": 434, "end_line": 463, "span_ids": ["generate_spatial_bounding_box"], "tokens": 334}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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) -> Tuple[List[int], List[int]]:\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": 466, "end_line": 483, "span_ids": ["get_largest_connected_component_mask"], "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 get_largest_connected_component_mask(img: torch.Tensor, connectivity: Optional[int] = None) -> torch.Tensor:\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 exact_version, export, min_version, optional_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/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": 44, "end_line": 101, "span_ids": ["resolve_name"], "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": "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: When the module is not found.\n ValueError: When the module does not have the specified member.\n ValueError: When multiple modules with the declaration name are found.\n ValueError: When no module with the specified member is 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 = f\"Multiple modules ({modnames!r}) with declaration name {name!r} found, resolution is ambiguous.\"\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": 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": "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) -> None:\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": 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 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) -> None:\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_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": 104, "end_line": 145, "span_ids": ["fall_back_tuple"], "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": "def fall_back_tuple(user_provided: Any, default: Sequence, func: Callable = lambda x: x and x > 0) -> Tuple[Any, ...]:\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": 148, "end_line": 180, "span_ids": ["is_scalar", "is_scalar_tensor", "progress_bar", "get_seed"], "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 is_scalar_tensor(val: Any) -> bool:\n if torch.is_tensor(val) and val.ndim == 0:\n return True\n return False\n\n\ndef is_scalar(val: Any) -> 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: Optional[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() -> Optional[int]:\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/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": 163, "span_ids": ["optional_import"], "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": "def optional_import(\n module: str,\n version: str = \"\",\n version_checker: Callable[..., bool] = 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 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": 164, "end_line": 196, "span_ids": ["optional_import"], "tokens": 309}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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[..., bool] = 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 \"\"\"\n Raises:\n AttributeError: When you call this method.\n \"\"\"\n raise self._exception\n\n def __call__(self, *_args, **_kwargs):\n \"\"\"\n Raises:\n AttributeError: When you call this method.\n \"\"\"\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_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": 57, "end_line": 101, "span_ids": ["make_animated_gif_summary"], "tokens": 419}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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: Optional[Dict] = None,\n scale_factor: float = 1.0,\n) -> Summary:\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": 160, "end_line": 209, "span_ids": ["plot_2d_or_3d_image"], "tokens": 528}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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].detach().cpu().numpy() if torch.is_tensor(data) else data[index]\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 numpy as np\nimport torch\nfrom coplenet import CopleNet\n\nimport monai\nfrom monai.data import NiftiSaver\nfrom monai.inferers import sliding_window_inference\nfrom monai.transforms import AddChanneld, Compose, LoadNiftid, Orientationd, ToTensord\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": 54, "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 coplenet import CopleNet\nfrom parameterized import parameterized\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": 46, "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\n\nimport numpy as np\n\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": 52, "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\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_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": 36, "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 torch import nn\nfrom torchgpipe.skip import Namespace, pop, skippable, stash\n\nfrom monai.networks.blocks import Convolution, UpSample\nfrom monai.networks.layers.factories import Act, Conv, Norm\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/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": 94, "span_ids": ["run_testsuit", "impl", "docstring"], "tokens": 563}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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_ahnet\",\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_integration_workflows_gan\",\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": 51, "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\n\nimport torch\nfrom parameterized import parameterized\n\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": 44, "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\n\nimport torch\nfrom parameterized import parameterized\n\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_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": 36, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 44, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 44, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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 import normalize_transform, to_norm_affine\nfrom monai.networks.layers import AffineTransform\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_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": 54, "span_ids": ["impl:5", "TestCompose", "TestCompose.__call__", "docstring"], "tokens": 445}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 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_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": 36, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 23, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 36, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 23, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 51, "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\n\nimport torch\nfrom parameterized import parameterized\n\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": 59, "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\n\nimport torch\nfrom parameterized import parameterized\n\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": 57, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 61, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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_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": 30, "end_line": 54, "span_ids": ["TestCacheDatasetParallel", "impl:7", "TestCacheDatasetParallel.test_shape"], "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 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 with tempfile.TemporaryDirectory() as tempdir:\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\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": 34, "span_ids": ["TestCastToType.test_type", "TestCastToType", "impl:5", "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": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import CastToType\n\nTEST_CASE_1 = [{\"dtype\": np.float64}, np.array([[0, 1], [1, 2]], dtype=np.float32), np.float64]\n\nTEST_CASE_2 = [{\"dtype\": torch.float64}, torch.tensor([[0, 1], [1, 2]], dtype=torch.float32), torch.float64]\n\n\nclass TestCastToType(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2])\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": 46, "span_ids": ["TestCastToTyped", "TestCastToTyped.test_type", "impl:5", "docstring"], "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": "import unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\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\nTEST_CASE_2 = [\n {\"keys\": [\"img\"], \"dtype\": torch.float64},\n {\n \"img\": torch.tensor([[0, 1], [1, 2]], dtype=torch.float32),\n \"seg\": torch.tensor([[0, 1], [1, 2]], dtype=torch.int8),\n },\n {\"img\": torch.float64, \"seg\": torch.int8},\n]\n\n\nclass TestCastToTyped(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2])\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": 27, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 35, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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_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 AddChannel, Compose, Randomizable\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_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": 152, "end_line": 163, "span_ids": ["TestComputeMeanDice.test_value", "TestComputeMeanDice", "TestComputeMeanDice.test_nans"], "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 TestComputeMeanDice(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_9, TEST_CASE_10])\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": 164, "end_line": 185, "span_ids": ["impl:21", "TestComputeMeanDice.test_value_class", "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_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": 31, "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\n\nimport numpy as np\nimport torch\n\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_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": 27, "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\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\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": 53, "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\n\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": 44, "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\n\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_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": 110, "end_line": 141, "span_ids": ["impl:15", "TestDataStats.test_file", "TestDataStats.test_value", "TestDataStats"], "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 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 with tempfile.TemporaryDirectory() as tempdir:\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\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_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": 123, "end_line": 155, "span_ids": ["TestDataStatsd.test_file", "TestDataStatsd", "TestDataStatsd.test_value", "impl:17"], "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": "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 with tempfile.TemporaryDirectory() as tempdir:\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\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": 41, "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\n\nfrom monai.data import CacheDataset, DataLoader\nfrom monai.transforms import Compose, DataStatsd, SimulateDelayd\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_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": 38, "end_line": 134, "span_ids": ["TestDENSENET.test_264_3d_shape", "TestDENSENET", "TestDENSENET.test_169_2d_shape", "TestDENSENET.test_121_3d_shape", "TestDENSENET.test_121_4d_shape", "TestDENSENET.test_121_2d_shape", "TestDENSENET.test_264_2d_shape", "TestDENSENET.test_264_4d_shape", "TestDENSENET.test_201_3d_shape", "TestDENSENET.test_169_3d_shape", "TestDENSENET.test_201_4d_shape", "TestDENSENET.test_169_4d_shape", "TestDENSENET.test_201_2d_shape"], "tokens": 836}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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_4d_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_4d_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_4d_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_4d_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)\n\n @parameterized.expand([TEST_CASE_2])\n def test_121_3d_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_2])\n def test_169_3d_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_2])\n def test_201_3d_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_2])\n def test_264_3d_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)\n\n @parameterized.expand([TEST_CASE_3])\n def test_121_2d_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_3])\n def test_169_2d_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_3])\n def test_201_2d_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_3])\n def test_264_2d_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": 52, "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\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": 46, "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 parameterized import parameterized\n\nfrom monai.transforms import DivisiblePad\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": 48, "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 parameterized import parameterized\n\nfrom monai.transforms import DivisiblePadd\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": 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": "import os\nimport unittest\nfrom urllib.error import ContentTooShortError, HTTPError\n\nfrom monai.apps import download_and_extract, download_url, extractall\nfrom tests.utils import skip_if_quick\n\n\nclass TestDownloadAndExtract(unittest.TestCase):\n @skip_if_quick\n def test_actions(self):\n testing_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), \"testing_data\")\n url = \"https://www.dropbox.com/s/5wwskxctvcxiuea/MedNIST.tar.gz?dl=1\"\n filepath = os.path.join(testing_dir, \"MedNIST.tar.gz\")\n output_dir = testing_dir\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, RuntimeError) as e:\n print(str(e))\n if isinstance(e, RuntimeError):\n # FIXME: skip MD5 check as current downloading method may fail\n self.assertTrue(str(e).startswith(\"MD5 check\"))\n return # skipping this test due the network connection errors\n\n wrong_md5 = \"0\"\n try:\n download_url(url, filepath, wrong_md5)\n except (ContentTooShortError, HTTPError, RuntimeError) as e:\n print(str(e))\n if isinstance(e, RuntimeError):\n # FIXME: skip MD5 check as current downloading method may fail\n self.assertTrue(str(e).startswith(\"MD5 check\"))\n return # skipping this test due the network connection errors\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\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": 52, "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 parameterized import parameterized\n\nfrom monai.networks.blocks import MaxAvgPool\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_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": 46, "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\n\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": 69, "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\n\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_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": 65, "end_line": 88, "span_ids": ["TestHandlerCheckpointLoader.test_save_single_device_load_multi_devices", "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 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 with tempfile.TemporaryDirectory() as tempdir:\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\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": 38, "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\n\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_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": 49, "end_line": 79, "span_ids": ["impl:5", "TestHandlerSegmentationSaver.test_save_resized_content"], "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 TestHandlerSegmentationSaver(unittest.TestCase):\n\n @parameterized.expand([TEST_CASE_0, TEST_CASE_1])\n def test_save_resized_content(self, output_ext):\n with tempfile.TemporaryDirectory() as tempdir:\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=tempdir, 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(tempdir, filepath)))\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_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": 113, "end_line": 163, "span_ids": ["TestHandlerStats.test_loss_file", "impl", "TestHandlerStats.test_exception"], "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 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 with tempfile.TemporaryDirectory() as tempdir:\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\n def test_exception(self):\n logging.basicConfig(level=logging.INFO)\n\n # set up engine\n def _train_func(engine, batch):\n raise RuntimeError(\"test exception.\")\n\n engine = Engine(_train_func)\n\n # set up testing handler\n stats_handler = StatsHandler()\n stats_handler.attach(engine)\n\n with self.assertRaises(RuntimeError):\n engine.run(range(3), max_epochs=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_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": 23, "span_ids": ["docstring"], "tokens": 107}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 tempfile\nimport unittest\n\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": 26, "end_line": 49, "span_ids": ["TestHandlerTBImage.test_tb_image_shape", "impl:3", "TestHandlerTBImage"], "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 TestHandlerTBImage(unittest.TestCase):\n @parameterized.expand(TEST_CASES)\n def test_tb_image_shape(self, shape):\n with tempfile.TemporaryDirectory() as tempdir:\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(len(glob.glob(tempdir)) > 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_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": 45, "end_line": 73, "span_ids": ["TestHandlerTBStats.test_metrics_writer", "impl"], "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": "class TestHandlerTBStats(unittest.TestCase):\n\n def test_metrics_writer(self):\n with tempfile.TemporaryDirectory() as tempdir:\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(len(glob.glob(tempdir)) > 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_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": 50, "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\n\nimport torch\nfrom ignite.engine import Engine\n\nfrom monai.data import Dataset\nfrom monai.engines import Evaluator\nfrom monai.handlers import ValidationHandler\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_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": 42, "span_ids": ["MedNISTDataset", "MedNISTDataset.__len__", "MedNISTDataset.__init__", "docstring", "MedNISTDataset.__getitem__"], "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 unittest\nfrom urllib.error import ContentTooShortError, HTTPError\n\nimport numpy as np\nimport torch\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.apps import download_and_extract\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?dl=1\"\nMD5_VALUE = \"0bc7306e7427e00ad1c5526a6677552d\"\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": 151, "end_line": 197, "span_ids": ["IntegrationClassification2D", "IntegrationClassification2D.setUp"], "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": "class IntegrationClassification2D(unittest.TestCase):\n def setUp(self):\n set_determinism(seed=0)\n self.data_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), \"testing_data\")\n data_dir = os.path.join(self.data_dir, \"MedNIST\")\n dataset_file = os.path.join(self.data_dir, \"MedNIST.tar.gz\")\n\n if not os.path.exists(data_dir):\n try:\n download_and_extract(TEST_DATA_URL, dataset_file, self.data_dir, MD5_VALUE)\n except (ContentTooShortError, HTTPError, RuntimeError) as e:\n print(str(e))\n if isinstance(e, RuntimeError):\n # FIXME: skip MD5 check as current downloading method may fail\n self.assertTrue(str(e).startswith(\"MD5 check\"))\n return # skipping this test due the network connection errors\n\n assert os.path.exists(data_dir)\n\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": 199, "end_line": 240, "span_ids": ["IntegrationClassification2D.test_training", "IntegrationClassification2D.tearDown", "impl:5"], "tokens": 406}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 os.remove(os.path.join(self.data_dir, \"best_metric_model.pth\"))\n\n @skip_if_quick\n def test_training(self):\n if not os.path.exists(os.path.join(self.data_dir, \"MedNIST\")):\n # skip test if no MedNIST dataset\n return\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 AddChannel, Compose, 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": 40, "span_ids": ["docstring"], "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": "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.tensorboard import SummaryWriter\n\nimport monai\nfrom monai.data import NiftiSaver, create_test_image_3d\nfrom monai.inferers import sliding_window_inference\nfrom monai.metrics import DiceMetric\nfrom monai.networks.nets import UNet\nfrom monai.transforms import (\n AsChannelFirstd,\n Compose,\n LoadNiftid,\n RandCropByPosNegLabeld,\n RandRotate90d,\n ScaleIntensityd,\n Spacingd,\n ToTensord,\n)\nfrom monai.utils import set_determinism\nfrom monai.visualize import plot_2d_or_3d_image\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_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": 169, "end_line": 221, "span_ids": ["run_inference_test"], "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 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 # resampling with align_corners=True or dtype=float64 will generate\n # slight different results between PyTorch 1.5 an 1.6\n Spacingd(keys=[\"img\", \"seg\"], pixdim=[1.2, 0.8, 0.7], mode=[\"bilinear\", \"nearest\"], dtype=np.float32),\n ScaleIntensityd(keys=\"img\"),\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 = monai.data.DataLoader(val_ds, batch_size=1, num_workers=4)\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 # resampling with align_corners=True or dtype=float64 will generate\n # slight different results between PyTorch 1.5 an 1.6\n saver = NiftiSaver(output_dir=os.path.join(root_dir, \"output\"), dtype=np.float32)\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": 242, "end_line": 334, "span_ids": ["IntegrationSegmentation3D.test_training", "impl"], "tokens": 921}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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.5469526141881943,\n 0.48241865634918213,\n 0.4494174599647522,\n 0.44529161751270296,\n 0.4375701665878296,\n 0.4191529631614685,\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.9310397356748581, 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.9311131909489632, 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.1424753292588007,\n 0.1526987837377587,\n 0.1522260782081298,\n 0.14019321331952597,\n 0.1889864339514267,\n 0.1701282966371258,\n 0.14722480298056123,\n 0.16880386820665885,\n 0.15761801809458714,\n 0.17966934735315532,\n 0.16294827907125564,\n 0.16845101446685762,\n 0.1449689105633501,\n 0.11433514172116171,\n 0.16221140044365004,\n 0.20167776688188802,\n 0.17651101148068069,\n 0.09850290784203589,\n 0.19442294509584152,\n 0.20366986799489217,\n 0.19687920603828438,\n 0.20891339578342968,\n 0.16267399855187073,\n 0.13240519812867665,\n 0.14902747106846712,\n 0.14290015447893328,\n 0.23212359931942977,\n 0.16157145267490547,\n 0.14873448049959515,\n 0.10324549379352314,\n 0.11922617331906066,\n 0.13010115069670078,\n 0.1142811082302379,\n 0.15300297514849476,\n 0.1636881807980574,\n 0.1943394302416328,\n 0.22336282196225676,\n 0.1813985200502387,\n 0.19082037882616065,\n 0.07541222674515398,\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": 29, "span_ids": ["docstring"], "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": "import os\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.handlers import SegmentationSaver\nfrom monai.inferers import sliding_window_inference\nfrom monai.networks import predict_segmentation\nfrom monai.networks.nets import UNet\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": 32, "end_line": 59, "span_ids": ["run_test"], "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": "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, device=device)\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_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_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": 56, "end_line": 119, "span_ids": ["run_training_test"], "tokens": 764}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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\"), amp=False):\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": 121, "end_line": 165, "span_ids": ["run_training_test"], "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": "def run_training_test(root_dir, device=torch.device(\"cuda:0\"), amp=False):\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 amp=True if amp else False,\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 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 amp=True if amp else False,\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": 168, "end_line": 229, "span_ids": ["run_inference_test"], "tokens": 565}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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\"), amp=False):\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 amp=True if amp else False,\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": 252, "end_line": 373, "span_ids": ["IntegrationWorkflows.test_training", "impl"], "tokens": 1318}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 test_rounds = 3 if monai.config.get_torch_version_tuple() >= (1, 6) else 2\n for i in range(test_rounds):\n torch.manual_seed(0)\n\n repeated.append([])\n best_metric = run_training_test(self.data_dir, device=self.device, amp=(i == 2))\n print(\"best metric\", best_metric)\n if i == 2:\n np.testing.assert_allclose(best_metric, 0.9241043657064438, rtol=1e-3)\n else:\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, amp=(i == 2))\n print(\"infer metric\", infer_metric)\n # check inference properties\n if i == 2:\n np.testing.assert_allclose(infer_metric, 0.9236116781830788, rtol=1e-3)\n else:\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 if i == 2:\n sums = [\n 0.14142131805419922,\n 0.1509075164794922,\n 0.13735723495483398,\n 0.1331934928894043,\n 0.18468952178955078,\n 0.16349554061889648,\n 0.14034032821655273,\n 0.16618776321411133,\n 0.15580987930297852,\n 0.1762104034423828,\n 0.16085290908813477,\n 0.1645350456237793,\n 0.14300870895385742,\n 0.1095418930053711,\n 0.16037845611572266,\n 0.1964101791381836,\n 0.1740407943725586,\n 0.05246734619140625,\n 0.19054365158081055,\n 0.19893646240234375,\n 0.1951923370361328,\n 0.20318841934204102,\n 0.159881591796875,\n 0.1309795379638672,\n 0.1499776840209961,\n 0.1361088752746582,\n 0.2268390655517578,\n 0.1607356071472168,\n 0.1469106674194336,\n 0.1029515266418457,\n 0.11846733093261719,\n 0.1298527717590332,\n 0.11112213134765625,\n 0.15118646621704102,\n 0.1595325469970703,\n 0.18976068496704102,\n 0.21662378311157227,\n 0.17733526229858398,\n 0.1854104995727539,\n 0.035239219665527344,\n ]\n else:\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": 102, "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\n\nimport numpy as np\nimport torch\n\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": 144, "end_line": 179, "span_ids": ["impl:3", "TestContour", "TestContour.test_contour"], "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": "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(ValueError, LabelToContour(**input_param), error_input)\n error_input = torch.rand(1, 2, 3, 4, 5, 6)\n self.assertRaises(ValueError, 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": 102, "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\n\nimport numpy as np\nimport torch\n\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": 144, "end_line": 179, "span_ids": ["impl:3", "TestContourd", "TestContourd.test_contour"], "tokens": 379}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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(ValueError, LabelToContourd(**input_param), error_input)\n error_input = {\"img\": torch.rand(1, 2, 3, 4, 5, 6)}\n self.assertRaises(ValueError, 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": 59, "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\n\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": 59, "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\n\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": 47, "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\n\nimport numpy as np\nimport torch\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_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": 84, "end_line": 102, "span_ids": ["TestLoadDecathalonDatalist.test_seg_no_labels", "impl"], "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 TestLoadDecathalonDatalist(unittest.TestCase):\n\n def test_seg_no_labels(self):\n with tempfile.TemporaryDirectory() as tempdir:\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\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_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": 41, "end_line": 62, "span_ids": ["TestLoadNifti", "impl:11", "TestLoadNifti.test_shape"], "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 TestLoadNifti(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5])\n def test_shape(self, input_param, filenames, expected_shape):\n test_image = np.random.randint(0, 2, size=[128, 128, 128])\n with tempfile.TemporaryDirectory() as tempdir:\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.assert_allclose(header[\"original_affine\"], np.eye(4))\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_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": 68, "end_line": 81, "span_ids": ["TestLoadNumpy.test_npy_pickle", "impl"], "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 TestLoadNumpy(unittest.TestCase):\n\n def test_npy_pickle(self):\n test_data = {\"test\": np.random.randint(0, 256, size=[3, 4, 4])}\n with tempfile.TemporaryDirectory() as tempdir:\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\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_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": 68, "end_line": 81, "span_ids": ["TestLoadNumpyd.test_npy_pickle", "impl"], "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 TestLoadNumpyd(unittest.TestCase):\n\n def test_npy_pickle(self):\n test_data = {\"test\": np.random.randint(0, 256, size=[3, 4, 4])}\n with tempfile.TemporaryDirectory() as tempdir:\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\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_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": 29, "end_line": 48, "span_ids": ["TestLoadPNG.test_shape", "TestLoadPNG", "impl:7"], "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": "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 with tempfile.TemporaryDirectory() as tempdir:\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\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": 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": "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 = [[ValueError, list()], [ValueError, tuple()], [TypeError, [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, exception, keys):\n with self.assertRaisesRegex(exception, \"\"):\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": 47, "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\n\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": 47, "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\n\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": 54, "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\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\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": 54, "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\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\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_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": 35, "span_ids": ["RandTest", "RandTest.__call__", "RandTest.randomize", "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 os\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_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\n\nimport nibabel as nib\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": 45, "span_ids": ["docstring"], "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": "import os\nimport tempfile\nimport unittest\n\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_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": 156, "end_line": 178, "span_ids": ["TestNiftiLoadRead.test_write_5d", "impl:7"], "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": "class TestNiftiLoadRead(unittest.TestCase):\n\n def test_write_5d(self):\n with tempfile.TemporaryDirectory() as out_dir:\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\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_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": 49, "end_line": 68, "span_ids": ["TestNiftiSaver.test_saved_3d_resize_content", "impl"], "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 TestNiftiSaver(unittest.TestCase):\n\n def test_saved_3d_resize_content(self):\n with tempfile.TemporaryDirectory() as tempdir:\n\n saver = NiftiSaver(output_dir=tempdir, 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(tempdir, filepath)))\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": 28, "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\n\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": 41, "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\n\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_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": 44, "end_line": 99, "span_ids": ["TestDataset.test_shape", "TestDataset", "impl:7"], "tokens": 719}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 with tempfile.TemporaryDirectory() as tempdir:\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\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": 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 glob\nimport tempfile\nimport unittest\n\nimport torch\nfrom parameterized import parameterized\nfrom torch.utils.tensorboard import SummaryWriter\n\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": 46, "span_ids": ["impl:11", "TestPlot2dOr3dImage", "TestPlot2dOr3dImage.test_tb_image_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 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 with tempfile.TemporaryDirectory() as tempdir:\n writer = SummaryWriter(log_dir=tempdir)\n plot_2d_or_3d_image(torch.zeros(shape), 0, writer)\n writer.flush()\n writer.close()\n self.assertTrue(len(glob.glob(tempdir)) > 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_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": 79, "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": 629}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 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 with tempfile.TemporaryDirectory() as out_dir:\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\n def test_write_gray_1height(self):\n with tempfile.TemporaryDirectory() as out_dir:\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\n def test_write_gray_1channel(self):\n with tempfile.TemporaryDirectory() as out_dir:\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\n def test_write_rgb(self):\n with tempfile.TemporaryDirectory() as out_dir:\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\n def test_write_2channels(self):\n with tempfile.TemporaryDirectory() as out_dir:\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\n def test_write_output_shape(self):\n with tempfile.TemporaryDirectory() as out_dir:\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\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_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": 44, "end_line": 61, "span_ids": ["TestPNGSaver.test_saved_content_spatial_size", "impl"], "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 TestPNGSaver(unittest.TestCase):\n\n def test_saved_content_spatial_size(self):\n with tempfile.TemporaryDirectory() as tempdir:\n\n saver = PNGSaver(output_dir=tempdir, 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(tempdir, filepath)))\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": 41, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 41, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 79, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 83, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 36, "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 parameterized import parameterized\n\nfrom monai.transforms import RandGaussianNoise\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\n\nimport numpy as np\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\n\nfrom monai.transforms import RandRotate\nfrom tests.utils import NumpyImageTestCase2D, NumpyImageTestCase3D\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\n\nimport numpy as np\nimport scipy.ndimage\nfrom parameterized import parameterized\n\nfrom monai.transforms import RandRotated\nfrom monai.utils import GridSampleMode, GridSamplePadMode\nfrom tests.utils import NumpyImageTestCase2D, NumpyImageTestCase3D\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": 32, "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\n\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": 33, "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\n\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": 32, "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\n\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": 33, "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\n\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": 36, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 42, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 43, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 40, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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\n\nfrom monai.transforms import RandZoom\nfrom monai.utils import GridSampleMode, InterpolateMode\nfrom tests.utils import NumpyImageTestCase2D\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\n\nfrom monai.transforms import RandZoomd\nfrom tests.utils import NumpyImageTestCase2D\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": 31, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 35, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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\n\nfrom monai.transforms import Resize\nfrom tests.utils import NumpyImageTestCase2D\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\n\nfrom monai.transforms import Resized\nfrom tests.utils import NumpyImageTestCase2D\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\n\nfrom monai.transforms import Rotate\nfrom tests.utils import NumpyImageTestCase2D, NumpyImageTestCase3D\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\n\nfrom monai.transforms import Rotated\nfrom tests.utils import NumpyImageTestCase2D, NumpyImageTestCase3D\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": 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": "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.astype(np.float32), 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": 39, "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\n\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": 41, "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\n\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": 52, "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\n\nimport numpy as np\nimport torch\n\nfrom monai.utils import get_seed, set_determinism\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": 30, "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\n\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": 31, "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\n\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": 65, "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 parameterized import parameterized\n\nfrom monai.networks.blocks import SimpleASPP\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_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": 45, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 53, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 50, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 54, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 34, "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\n\nimport torch\nfrom parameterized import parameterized\n\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": 49, "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\n\nimport torch\nfrom parameterized import parameterized\n\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_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": 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": "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, exception, input_param, test_data):\n with self.assertRaises(exception):\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": 60, "span_ids": ["impl:11", "docstring"], "tokens": 582}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 ValueError,\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 TypeError,\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": 63, "end_line": 78, "span_ids": ["impl:15", "TestSqueezeDim.test_invalid_inputs", "TestSqueezeDim.test_shape", "TestSqueezeDim"], "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 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, exception, input_param, test_data):\n with self.assertRaises(exception):\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": 36, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 32, "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\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": 42, "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\n\nimport numpy as np\nimport torch\n\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": 42, "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\n\nimport numpy as np\nimport torch\n\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_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": 98, "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 Act, Norm\nfrom monai.networks.nets import UNet\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": 74, "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 parameterized import parameterized\n\nfrom monai.networks.blocks import UpSample\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": 59, "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\n\nimport torch\nfrom parameterized import parameterized\n\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\n\nfrom monai.transforms import Zoom\nfrom tests.utils import NumpyImageTestCase2D\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": 23, "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\nfrom parameterized import parameterized\nfrom scipy.ndimage import zoom as zoom_scipy\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": 31, "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\n\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"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/classification_3d/densenet_evaluation_array.py_logging_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_logging_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": 59, "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 logging\nimport os\nimport sys\n\nimport numpy as np\nimport torch\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.data import CSVSaver, NiftiDataset\nfrom monai.transforms import AddChannel, Compose, Resize, ScaleIntensity, 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_dict.py_logging_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_logging_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": 67, "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 logging\nimport os\nimport sys\n\nimport numpy as np\nimport torch\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.data import CSVSaver\nfrom monai.transforms import AddChanneld, Compose, LoadNiftid, Resized, ScaleIntensityd, 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 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_training_array.py_logging_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_logging_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": 52, "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 logging\nimport os\nimport sys\n\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\nfrom monai.transforms import AddChannel, Compose, RandRotate90, Resize, ScaleIntensity, 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_dict.py_logging_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_logging_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": 52, "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 logging\nimport os\nimport sys\n\nimport numpy as np\nimport torch\nfrom torch.utils.data import DataLoader\nfrom torch.utils.tensorboard import SummaryWriter\n\nimport monai\nfrom monai.metrics import compute_roc_auc\nfrom monai.transforms import AddChanneld, Compose, LoadNiftid, RandRotate90d, Resized, ScaleIntensityd, 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\", \"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_evaluation_array.py_logging_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_logging_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": 73, "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 logging\nimport os\nimport sys\n\nimport numpy as np\nimport torch\nfrom ignite.engine import _prepare_batch, create_supervised_evaluator\nfrom ignite.metrics import Accuracy\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.data import NiftiDataset\nfrom monai.handlers import CheckpointLoader, ClassificationSaver, StatsHandler\nfrom monai.transforms import AddChannel, Compose, Resize, ScaleIntensity, 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 # 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_dict.py_logging_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_logging_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": 74, "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": "import logging\nimport os\nimport sys\n\nimport numpy as np\nimport torch\nfrom ignite.engine import _prepare_batch, create_supervised_evaluator\nfrom ignite.metrics import Accuracy\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.handlers import CheckpointLoader, ClassificationSaver, StatsHandler\nfrom monai.transforms import AddChanneld, Compose, LoadNiftid, Resized, ScaleIntensityd, 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_training_array.py_logging_from_monai_transforms_imp": {"__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_logging_from_monai_transforms_imp", "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": 26, "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 logging\nimport os\nimport sys\n\nimport numpy as np\nimport torch\nfrom ignite.engine import Events, create_supervised_evaluator, create_supervised_trainer\nfrom ignite.handlers import EarlyStopping, ModelCheckpoint\nfrom ignite.metrics import Accuracy\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.data import NiftiDataset\nfrom monai.handlers import StatsHandler, TensorBoardStatsHandler, stopping_fn_from_metric\nfrom monai.transforms import AddChannel, Compose, RandRotate90, Resize, ScaleIntensity, ToTensor", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "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_logging_from_monai_transforms_imp": {"__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_logging_from_monai_transforms_imp", "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": 25, "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 logging\nimport os\nimport sys\n\nimport numpy as np\nimport torch\nfrom ignite.engine import Events, _prepare_batch, create_supervised_evaluator, create_supervised_trainer\nfrom ignite.handlers import EarlyStopping, ModelCheckpoint\nfrom ignite.metrics import Accuracy\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.handlers import ROCAUC, StatsHandler, TensorBoardStatsHandler, stopping_fn_from_metric\nfrom monai.transforms import AddChanneld, Compose, LoadNiftid, RandRotate90d, Resized, ScaleIntensityd, ToTensord", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "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_argparse_from_monai_transforms_imp": {"__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_argparse_from_monai_transforms_imp", "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": 51, "end_line": 66, "span_ids": ["imports"], "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 argparse\nimport os\nfrom glob import glob\n\nimport nibabel as nib\nimport numpy as np\nimport torch\nimport torch.distributed as dist\nfrom torch.nn.parallel import DistributedDataParallel\nfrom torch.utils.data.distributed import DistributedSampler\n\nimport monai\nfrom monai.data import DataLoader, Dataset, create_test_image_3d\nfrom monai.inferers import sliding_window_inference\nfrom monai.metrics import DiceMetric\nfrom monai.transforms import AsChannelFirstd, Compose, LoadNiftid, ScaleIntensityd, ToTensord", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "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.model_eval_": {"__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.model_eval_", "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": 69, "end_line": 125, "span_ids": ["evaluate"], "tokens": 657}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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(args):\n if args.local_rank == 0 and not os.path.exists(args.dir):\n # create 16 random image, mask paris for evaluation\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 # initialize the distributed evaluation process, every GPU runs in a process\n dist.init_process_group(backend=\"nccl\", init_method=\"env://\")\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\"),\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, shuffle=False)\n # sliding window inference need to input 1 image in every iteration\n val_loader = DataLoader(val_ds, batch_size=1, shuffle=False, num_workers=2, pin_memory=True, sampler=val_sampler)\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:{args.local_rank}\")\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=[args.local_rank])\n # config mapping to expected GPU device\n map_location = {\"cuda:0\": f\"cuda:{args.local_rank}\"}\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 # ... 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_evaluation_ddp.py_evaluate.with_torch_no_grad__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.with_torch_no_grad__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": 126, "end_line": 145, "span_ids": ["evaluate"], "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 evaluate(args):\n # ... other code\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 dist.get_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_horovod.py_argparse_from_monai_transforms_imp": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_horovod.py_argparse_from_monai_transforms_imp", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_evaluation_horovod.py", "file_name": "unet_evaluation_horovod.py", "file_type": "text/x-python", "category": "implementation", "start_line": 44, "end_line": 59, "span_ids": ["docstring:11", "imports:7"], "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 argparse\nimport os\nfrom glob import glob\n\nimport horovod.torch as hvd\nimport nibabel as nib\nimport numpy as np\nimport torch\nimport torch.multiprocessing as mp\nfrom torch.utils.data.distributed import DistributedSampler\n\nimport monai\nfrom monai.data import DataLoader, Dataset, create_test_image_3d\nfrom monai.inferers import sliding_window_inference\nfrom monai.metrics import DiceMetric\nfrom monai.transforms import AsChannelFirstd, Compose, LoadNiftid, ScaleIntensityd, ToTensord", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "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_horovod.py_evaluate_evaluate.model_eval_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_horovod.py_evaluate_evaluate.model_eval_", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_evaluation_horovod.py", "file_name": "unet_evaluation_horovod.py", "file_type": "text/x-python", "category": "implementation", "start_line": 62, "end_line": 132, "span_ids": ["evaluate"], "tokens": 743}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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(args):\n # initialize Horovod library\n hvd.init()\n # Horovod limits CPU threads to be used per worker\n torch.set_num_threads(1)\n\n if hvd.local_rank() == 0 and not os.path.exists(args.dir):\n # create 16 random image, mask paris for evaluation\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 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\"),\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, shuffle=False, num_replicas=hvd.size(), rank=hvd.rank())\n # when supported, use \"forkserver\" to spawn dataloader workers instead of \"fork\" to prevent\n # issues with Infiniband implementations that are not fork-safe\n multiprocessing_context = None\n if hasattr(mp, \"_supports_context\") and mp._supports_context and \"forkserver\" in mp.get_all_start_methods():\n multiprocessing_context = \"forkserver\"\n # sliding window inference need to input 1 image in every iteration\n val_loader = DataLoader(\n val_ds,\n batch_size=1,\n shuffle=False,\n num_workers=2,\n pin_memory=True,\n sampler=val_sampler,\n multiprocessing_context=multiprocessing_context,\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:{hvd.local_rank()}\")\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 if hvd.rank() == 0:\n # load model parameters for evaluation\n model.load_state_dict(torch.load(\"final_model.pth\"))\n # Horovod broadcasts parameters\n hvd.broadcast_parameters(model.state_dict(), root_rank=0)\n\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/distributed_training/unet_evaluation_horovod.py_evaluate.with_torch_no_grad__evaluate.with_torch_no_grad_.if_hvd_rank_0_.print_evaluation_metric_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_horovod.py_evaluate.with_torch_no_grad__evaluate.with_torch_no_grad_.if_hvd_rank_0_.print_evaluation_metric_", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_evaluation_horovod.py", "file_name": "unet_evaluation_horovod.py", "file_type": "text/x-python", "category": "implementation", "start_line": 133, "end_line": 151, "span_ids": ["evaluate"], "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": "def evaluate(args):\n # ... other code\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 print(f\"metric in rank {hvd.rank()}: sum={metric[0].item()}, count={metric[1].item()}\")\n avg_metric = hvd.allreduce(metric, name=\"mean_dice\")\n if hvd.rank() == 0:\n print(f\"average metric: sum={avg_metric[0].item()}, count={avg_metric[1].item()}\")\n print(\"evaluation metric:\", (avg_metric[0] / avg_metric[1]).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/examples/distributed_training/unet_evaluation_horovod.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_horovod.py_main_", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_evaluation_horovod.py", "file_name": "unet_evaluation_horovod.py", "file_type": "text/x-python", "category": "implementation", "start_line": 154, "end_line": 166, "span_ids": ["impl", "main"], "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": "def main():\n parser = argparse.ArgumentParser()\n parser.add_argument(\"-d\", \"--dir\", default=\"./testdata\", type=str, help=\"directory to create random data\")\n args = parser.parse_args()\n\n evaluate(args=args)\n\n\n# Example script to execute this program only on the master node:\n# horovodrun -np 16 -H server1:4,server2:4,server3:4,server4:4 python unet_evaluation_horovod.py -d \"./testdata\"\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_workflows.py_argparse_from_monai_transforms_imp": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_workflows.py_argparse_from_monai_transforms_imp", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_evaluation_workflows.py", "file_name": "unet_evaluation_workflows.py", "file_type": "text/x-python", "category": "implementation", "start_line": 53, "end_line": 81, "span_ids": ["imports"], "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": "import argparse\nimport logging\nimport os\nimport sys\nfrom glob import glob\n\nimport nibabel as nib\nimport numpy as np\nimport torch\nimport torch.distributed as dist\nfrom ignite.metrics import Accuracy\nfrom torch.nn.parallel import DistributedDataParallel\nfrom torch.utils.data.distributed import DistributedSampler\n\nimport monai\nfrom monai.data import DataLoader, Dataset, create_test_image_3d\nfrom monai.engines import SupervisedEvaluator\nfrom monai.handlers import CheckpointLoader, MeanDice, SegmentationSaver, StatsHandler\nfrom monai.inferers import SlidingWindowInferer\nfrom monai.transforms import (\n Activationsd,\n AsChannelFirstd,\n AsDiscreted,\n Compose,\n KeepLargestConnectedComponentd,\n LoadNiftid,\n ScaleIntensityd,\n ToTensord,\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/examples/distributed_training/unet_evaluation_workflows.py_evaluate_evaluate.if_dist_get_rank_0_.val_handlers_extend_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_evaluation_workflows.py_evaluate_evaluate.if_dist_get_rank_0_.val_handlers_extend_", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_evaluation_workflows.py", "file_name": "unet_evaluation_workflows.py", "file_type": "text/x-python", "category": "implementation", "start_line": 84, "end_line": 161, "span_ids": ["evaluate"], "tokens": 769}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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(args):\n if args.local_rank == 0 and not os.path.exists(args.dir):\n # create 16 random image, mask paris for evaluation\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 # initialize the distributed evaluation process, every GPU runs in a process\n dist.init_process_group(backend=\"nccl\", init_method=\"env://\")\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 = [{\"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\"),\n ToTensord(keys=[\"image\", \"label\"]),\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, shuffle=False)\n # sliding window inference need to input 1 image in every iteration\n val_loader = DataLoader(val_ds, batch_size=1, shuffle=False, num_workers=2, pin_memory=True, sampler=val_sampler)\n\n # create UNet, DiceLoss and Adam optimizer\n device = torch.device(f\"cuda:{args.local_rank}\")\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 # wrap the model with DistributedDataParallel module\n net = DistributedDataParallel(net, device_ids=[args.local_rank])\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 CheckpointLoader(\n load_path=\"./runs/checkpoint_epoch=4.pth\",\n load_dict={\"net\": net},\n # config mapping to expected GPU device\n map_location={\"cuda:0\": f\"cuda:{args.local_rank}\"},\n ),\n ]\n if dist.get_rank() == 0:\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n val_handlers.extend(\n [\n StatsHandler(output_transform=lambda x: None),\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 # ... 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_evaluation_workflows.py_evaluate.evaluator_evaluate.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_workflows.py_evaluate.evaluator_evaluate.dist_destroy_process_grou", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_evaluation_workflows.py", "file_name": "unet_evaluation_workflows.py", "file_type": "text/x-python", "category": "implementation", "start_line": 163, "end_line": 180, "span_ids": ["evaluate"], "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 evaluate(args):\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(\n include_background=True, output_transform=lambda x: (x[\"pred\"], x[\"label\"]), device=device,\n )\n },\n additional_metrics={\"val_acc\": Accuracy(output_transform=lambda x: (x[\"pred\"], x[\"label\"]), device=device)},\n val_handlers=val_handlers,\n # if no FP16 support in GPU or PyTorch version < 1.6, will not enable AMP evaluation\n amp=True if monai.config.get_torch_version_tuple() >= (1, 6) else False,\n )\n evaluator.run()\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_workflows.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_workflows.py_main_", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_evaluation_workflows.py", "file_name": "unet_evaluation_workflows.py", "file_type": "text/x-python", "category": "implementation", "start_line": 183, "end_line": 202, "span_ids": ["impl", "main"], "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": "def main():\n parser = argparse.ArgumentParser()\n parser.add_argument(\"-d\", \"--dir\", default=\"./testdata\", type=str, help=\"directory to create random data\")\n # must parse the command-line argument: ``--local_rank=LOCAL_PROCESS_RANK``, which will be provided by DDP\n parser.add_argument(\"--local_rank\", type=int)\n args = parser.parse_args()\n\n evaluate(args=args)\n\n\n# usage example(refer to https://github.com/pytorch/pytorch/blob/master/torch/distributed/launch.py):\n\n# python -m torch.distributed.launch --nproc_per_node=NUM_GPUS_PER_NODE\n# --nnodes=NUM_NODES --node_rank=INDEX_CURRENT_NODE\n# --master_addr=\"192.168.1.1\" --master_port=1234\n# unet_evaluation_workflows.py -d DIR_OF_TESTDATA\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_training_ddp.py_argparse_from_monai_transforms_imp": {"__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_argparse_from_monai_transforms_imp", "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": 50, "end_line": 72, "span_ids": ["imports"], "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": "import argparse\nimport os\nimport sys\nfrom glob import glob\n\nimport nibabel as nib\nimport numpy as np\nimport torch\nimport torch.distributed as dist\nfrom torch.nn.parallel import DistributedDataParallel\nfrom torch.utils.data.distributed import DistributedSampler\n\nimport monai\nfrom monai.data import DataLoader, Dataset, create_test_image_3d\nfrom monai.transforms import (\n AsChannelFirstd,\n Compose,\n LoadNiftid,\n RandCropByPosNegLabeld,\n RandRotate90d,\n ScaleIntensityd,\n ToTensord,\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/examples/distributed_training/unet_training_horovod.py_argparse_from_monai_transforms_imp": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_horovod.py_argparse_from_monai_transforms_imp", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_training_horovod.py", "file_name": "unet_training_horovod.py", "file_type": "text/x-python", "category": "implementation", "start_line": 48, "end_line": 70, "span_ids": ["imports"], "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": "import argparse\nimport os\nimport sys\nfrom glob import glob\n\nimport horovod.torch as hvd\nimport nibabel as nib\nimport numpy as np\nimport torch\nimport torch.multiprocessing as mp\nfrom torch.utils.data.distributed import DistributedSampler\n\nimport monai\nfrom monai.data import DataLoader, Dataset, create_test_image_3d\nfrom monai.transforms import (\n AsChannelFirstd,\n Compose,\n LoadNiftid,\n RandCropByPosNegLabeld,\n RandRotate90d,\n ScaleIntensityd,\n ToTensord,\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/examples/distributed_training/unet_training_horovod.py_train_train.model.monai_networks_nets_UNet_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_horovod.py_train_train.model.monai_networks_nets_UNet_", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_training_horovod.py", "file_name": "unet_training_horovod.py", "file_type": "text/x-python", "category": "implementation", "start_line": 73, "end_line": 142, "span_ids": ["train"], "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": "def train(args):\n # initialize Horovod library\n hvd.init()\n # Horovod limits CPU threads to be used per worker\n torch.set_num_threads(1)\n # disable logging for processes execpt 0 on every node\n if hvd.local_rank() != 0:\n f = open(os.devnull, \"w\")\n sys.stdout = sys.stderr = f\n elif not os.path.exists(args.dir):\n # create 40 random image, mask paris on master node for training\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 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\"),\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=hvd.size(), rank=hvd.rank())\n # when supported, use \"forkserver\" to spawn dataloader workers instead of \"fork\" to prevent\n # issues with Infiniband implementations that are not fork-safe\n multiprocessing_context = None\n if hasattr(mp, \"_supports_context\") and mp._supports_context and \"forkserver\" in mp.get_all_start_methods():\n multiprocessing_context = \"forkserver\"\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=2,\n pin_memory=True,\n sampler=train_sampler,\n multiprocessing_context=multiprocessing_context,\n )\n\n # create UNet, DiceLoss and Adam optimizer\n device = torch.device(f\"cuda:{hvd.local_rank()}\")\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 # ... 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_horovod.py_train.loss_function_train.if_hvd_rank_0_.torch_save_model_state_di": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_horovod.py_train.loss_function_train.if_hvd_rank_0_.torch_save_model_state_di", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_training_horovod.py", "file_name": "unet_training_horovod.py", "file_type": "text/x-python", "category": "implementation", "start_line": 143, "end_line": 179, "span_ids": ["train"], "tokens": 393}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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(args):\n # ... other code\n loss_function = monai.losses.DiceLoss(sigmoid=True).to(device)\n optimizer = torch.optim.Adam(model.parameters(), 1e-3)\n # Horovod broadcasts parameters & optimizer state\n hvd.broadcast_parameters(model.state_dict(), root_rank=0)\n hvd.broadcast_optimizer_state(optimizer, root_rank=0)\n # Horovod wraps optimizer with DistributedOptimizer\n optimizer = hvd.DistributedOptimizer(optimizer, named_parameters=model.named_parameters())\n\n # start a typical PyTorch training\n epoch_loss_values = list()\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 hvd.rank() == 0:\n # all processes should see same parameters as they all start from same\n # random parameters and gradients are synchronized in backward passes,\n # therefore, saving it in one process is sufficient\n torch.save(model.state_dict(), \"final_model.pth\")", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "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_horovod.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_horovod.py_main_", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_training_horovod.py", "file_name": "unet_training_horovod.py", "file_type": "text/x-python", "category": "implementation", "start_line": 182, "end_line": 194, "span_ids": ["impl", "main"], "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": "def main():\n parser = argparse.ArgumentParser()\n parser.add_argument(\"-d\", \"--dir\", default=\"./testdata\", type=str, help=\"directory to create random data\")\n args = parser.parse_args()\n\n train(args=args)\n\n\n# Example script to execute this program only on the master node:\n# horovodrun -np 16 -H server1:4,server2:4,server3:4,server4:4 python unet_training_horovod.py -d \"./testdata\"\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_workflows.py_argparse_from_monai_transforms_imp": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_workflows.py_argparse_from_monai_transforms_imp", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_training_workflows.py", "file_name": "unet_training_workflows.py", "file_type": "text/x-python", "category": "implementation", "start_line": 53, "end_line": 83, "span_ids": ["imports"], "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 argparse\nimport logging\nimport os\nimport sys\nfrom glob import glob\n\nimport nibabel as nib\nimport numpy as np\nimport torch\nimport torch.distributed as dist\nfrom ignite.metrics import Accuracy\nfrom torch.nn.parallel import DistributedDataParallel\nfrom torch.utils.data.distributed import DistributedSampler\n\nimport monai\nfrom monai.data import DataLoader, Dataset, create_test_image_3d\nfrom monai.engines import SupervisedTrainer\nfrom monai.handlers import CheckpointSaver, LrScheduleHandler, StatsHandler\nfrom monai.inferers import SimpleInferer\nfrom monai.transforms import (\n Activationsd,\n AsChannelFirstd,\n AsDiscreted,\n Compose,\n KeepLargestConnectedComponentd,\n LoadNiftid,\n RandCropByPosNegLabeld,\n RandRotate90d,\n ScaleIntensityd,\n ToTensord,\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/examples/distributed_training/unet_training_workflows.py_train_train.train_post_transforms.Compose_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/distributed_training/unet_training_workflows.py_train_train.train_post_transforms.Compose_", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_training_workflows.py", "file_name": "unet_training_workflows.py", "file_type": "text/x-python", "category": "implementation", "start_line": 86, "end_line": 152, "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(args):\n if args.local_rank == 0 and not os.path.exists(args.dir):\n # create 40 random image, mask paris for training\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 # initialize the distributed training process, every GPU runs in a process\n dist.init_process_group(backend=\"nccl\", init_method=\"env://\")\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 = [{\"image\": img, \"label\": seg} for img, seg in zip(images, segs)]\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\"),\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\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)\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, batch_size=2, shuffle=False, num_workers=2, pin_memory=True, sampler=train_sampler,\n )\n\n # create UNet, DiceLoss and Adam optimizer\n device = torch.device(f\"cuda:{args.local_rank}\")\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).to(device)\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 # wrap the model with DistributedDataParallel module\n net = DistributedDataParallel(net, device_ids=[args.local_rank])\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 # ... 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_workflows.py_train.train_handlers_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_workflows.py_train.train_handlers_train.dist_destroy_process_grou", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_training_workflows.py", "file_name": "unet_training_workflows.py", "file_type": "text/x-python", "category": "implementation", "start_line": 153, "end_line": 180, "span_ids": ["train"], "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": "def train(args):\n # ... other code\n train_handlers = [\n LrScheduleHandler(lr_scheduler=lr_scheduler, print_lr=True),\n ]\n if dist.get_rank() == 0:\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n train_handlers.extend(\n [\n StatsHandler(tag_name=\"train_loss\", output_transform=lambda x: x[\"loss\"]),\n CheckpointSaver(save_dir=\"./runs/\", save_dict={\"net\": net, \"opt\": opt}, save_interval=2),\n ]\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 # if no FP16 support in GPU or PyTorch version < 1.6, will not enable AMP evaluation\n amp=True if monai.config.get_torch_version_tuple() >= (1, 6) else False,\n post_transform=train_post_transforms,\n key_train_metric={\"train_acc\": Accuracy(output_transform=lambda x: (x[\"pred\"], x[\"label\"]), device=device)},\n train_handlers=train_handlers,\n )\n trainer.run()\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_workflows.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_workflows.py_main_", "embedding": null, "metadata": {"file_path": "examples/distributed_training/unet_training_workflows.py", "file_name": "unet_training_workflows.py", "file_type": "text/x-python", "category": "implementation", "start_line": 183, "end_line": 202, "span_ids": ["impl", "main"], "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": "def main():\n parser = argparse.ArgumentParser()\n parser.add_argument(\"-d\", \"--dir\", default=\"./testdata\", type=str, help=\"directory to create random data\")\n # must parse the command-line argument: ``--local_rank=LOCAL_PROCESS_RANK``, which will be provided by DDP\n parser.add_argument(\"--local_rank\", type=int)\n args = parser.parse_args()\n\n train(args=args)\n\n\n# usage example(refer to https://github.com/pytorch/pytorch/blob/master/torch/distributed/launch.py):\n\n# python -m torch.distributed.launch --nproc_per_node=NUM_GPUS_PER_NODE\n# --nnodes=NUM_NODES --node_rank=INDEX_CURRENT_NODE\n# --master_addr=\"192.168.1.1\" --master_port=1234\n# unet_training_workflows.py -d DIR_OF_TESTDATA\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_array.py_logging_from_monai_transforms_imp": {"__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_logging_from_monai_transforms_imp", "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": 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": "import logging\nimport os\nimport sys\nimport tempfile\nfrom glob import glob\n\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom torch.utils.data import DataLoader\n\nfrom monai import config\nfrom monai.data import NiftiDataset, NiftiSaver, create_test_image_3d\nfrom monai.inferers import sliding_window_inference\nfrom monai.metrics import DiceMetric\nfrom monai.networks.nets import UNet\nfrom monai.transforms import AddChannel, Compose, ScaleIntensity, ToTensor", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "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_logging_from_monai_transforms_imp": {"__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_logging_from_monai_transforms_imp", "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": 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 logging\nimport os\nimport sys\nimport tempfile\nfrom glob import glob\n\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.data import NiftiSaver, create_test_image_3d, list_data_collate\nfrom monai.engines import get_devices_spec\nfrom monai.inferers import sliding_window_inference\nfrom monai.metrics import DiceMetric\nfrom monai.networks.nets import UNet\nfrom monai.transforms import AsChannelFirstd, Compose, LoadNiftid, ScaleIntensityd, ToTensord", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "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_logging_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_logging_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": 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": "import logging\nimport os\nimport sys\nimport tempfile\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 NiftiDataset, create_test_image_3d\nfrom monai.inferers import sliding_window_inference\nfrom monai.metrics import DiceMetric\nfrom monai.transforms import AddChannel, Compose, RandRotate90, RandSpatialCrop, ScaleIntensity, ToTensor\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_logging_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_logging_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": 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 logging\nimport os\nimport sys\nimport tempfile\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, list_data_collate\nfrom monai.inferers import sliding_window_inference\nfrom monai.metrics import DiceMetric\nfrom monai.transforms import (\n AsChannelFirstd,\n Compose,\n LoadNiftid,\n RandCropByPosNegLabeld,\n RandRotate90d,\n ScaleIntensityd,\n ToTensord,\n)\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._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_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": 40, "end_line": 105, "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(tempdir):\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 pairs\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\"),\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\"),\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\n # create UNet, DiceLoss and Adam optimizer\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.device_": {"__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.device_", "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": 822}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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(tempdir):\n # ... other code\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\n print(f\"train completed, best_metric: {best_metric:.4f} at epoch: {best_metric_epoch}\")\n writer.close()\n\n\nif __name__ == \"__main__\":\n with tempfile.TemporaryDirectory() as tempdir:\n main(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/examples/segmentation_3d_ignite/unet_evaluation_array.py_logging_from_monai_transforms_imp": {"__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_logging_from_monai_transforms_imp", "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": 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 logging\nimport os\nimport sys\nimport tempfile\nfrom glob import glob\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 import config\nfrom monai.data import NiftiDataset, create_test_image_3d\nfrom monai.handlers import CheckpointLoader, MeanDice, SegmentationSaver, StatsHandler\nfrom monai.inferers import sliding_window_inference\nfrom monai.networks import predict_segmentation\nfrom monai.networks.nets import UNet\nfrom monai.transforms import AddChannel, Compose, ScaleIntensity, ToTensor", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "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_logging_from_monai_transforms_imp": {"__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_logging_from_monai_transforms_imp", "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": 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": "import logging\nimport os\nimport sys\nimport tempfile\nfrom glob import glob\n\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 create_test_image_3d, list_data_collate\nfrom monai.handlers import CheckpointLoader, MeanDice, SegmentationSaver, StatsHandler\nfrom monai.inferers import sliding_window_inference\nfrom monai.networks import predict_segmentation\nfrom monai.networks.nets import UNet\nfrom monai.transforms import AsChannelFirstd, Compose, LoadNiftid, ScaleIntensityd, ToTensord", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "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_logging_from_monai_transforms_imp": {"__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_logging_from_monai_transforms_imp", "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": 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 logging\nimport os\nimport sys\nimport tempfile\nfrom glob import glob\n\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom ignite.engine import Events, create_supervised_evaluator, create_supervised_trainer\nfrom ignite.handlers import EarlyStopping, ModelCheckpoint\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.data import NiftiDataset, create_test_image_3d\nfrom monai.handlers import (\n MeanDice,\n StatsHandler,\n TensorBoardImageHandler,\n TensorBoardStatsHandler,\n stopping_fn_from_metric,\n)\nfrom monai.networks import predict_segmentation\nfrom monai.transforms import AddChannel, Compose, RandSpatialCrop, Resize, ScaleIntensity, ToTensor", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "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_logging_from_monai_transforms_imp": {"__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_logging_from_monai_transforms_imp", "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": 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 logging\nimport os\nimport sys\nimport tempfile\nfrom glob import glob\n\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom ignite.engine import Events, _prepare_batch, create_supervised_evaluator, create_supervised_trainer\nfrom ignite.handlers import EarlyStopping, ModelCheckpoint\nfrom torch.utils.data import DataLoader\n\nimport monai\nfrom monai.data import create_test_image_3d, list_data_collate\nfrom monai.handlers import (\n MeanDice,\n StatsHandler,\n TensorBoardImageHandler,\n TensorBoardStatsHandler,\n stopping_fn_from_metric,\n)\nfrom monai.networks import predict_segmentation\nfrom monai.transforms import (\n AsChannelFirstd,\n Compose,\n LoadNiftid,\n RandCropByPosNegLabeld,\n RandRotate90d,\n ScaleIntensityd,\n ToTensord,\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/examples/segmentation_3d_ignite/unet_training_dict.py_main_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_ignite/unet_training_dict.py_main_main._create_UNet_DiceLoss_a", "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": 114, "span_ids": ["main"], "tokens": 779}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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(tempdir):\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 pairs\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\"),\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\"),\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\n # create UNet, DiceLoss and Adam optimizer\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.net_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.net_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": 184, "span_ids": ["main"], "tokens": 806}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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(tempdir):\n # ... other code\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/synthesis/gan_evaluation.py_logging_save_generator_fakes.for_i_image_in_enumerate.png_writer_write_png_img_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/synthesis/gan_evaluation.py_logging_save_generator_fakes.for_i_image_in_enumerate.png_writer_write_png_img_", "embedding": null, "metadata": {"file_path": "examples/synthesis/gan_evaluation.py", "file_name": "gan_evaluation.py", "file_type": "text/x-python", "category": "implementation", "start_line": 17, "end_line": 35, "span_ids": ["save_generator_fakes", "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 logging\nimport os\nimport sys\n\nimport torch\n\nimport monai\nfrom monai.data import png_writer\nfrom monai.engines.utils import default_make_latent as make_latent\nfrom monai.networks.nets import Generator\nfrom monai.utils.misc import set_determinism\n\n\ndef save_generator_fakes(run_folder, g_output_tensor):\n for i, image in enumerate(g_output_tensor):\n filename = \"gen-fake-%d.png\" % (i)\n save_path = os.path.join(run_folder, filename)\n img_array = image[0].cpu().data.numpy()\n png_writer.write_png(img_array, save_path, scale=255)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "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/synthesis/gan_evaluation.py_main_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/synthesis/gan_evaluation.py_main_", "embedding": null, "metadata": {"file_path": "examples/synthesis/gan_evaluation.py", "file_name": "gan_evaluation.py", "file_type": "text/x-python", "category": "implementation", "start_line": 38, "end_line": 67, "span_ids": ["impl", "main"], "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": "def main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n set_determinism(12345)\n device = torch.device(\"cuda:0\")\n\n # load generator\n network_filepath = \"./network_final.pth\"\n data = torch.load(network_filepath)\n latent_size = 64\n gen_net = Generator(\n latent_shape=latent_size, start_shape=(latent_size, 8, 8), channels=[32, 16, 8, 1], strides=[2, 2, 2, 1]\n )\n gen_net.conv.add_module(\"activation\", torch.nn.Sigmoid())\n gen_net.load_state_dict(data[\"g_net\"])\n gen_net = gen_net.to(device)\n\n # create fakes\n output_dir = \"./generated_images\"\n if not os.path.isdir(output_dir):\n os.mkdir(output_dir)\n num_fakes = 10\n print(\"Generating %d fakes and saving in %s\" % (num_fakes, output_dir))\n fake_latents = make_latent(num_fakes, latent_size).to(device)\n save_generator_fakes(output_dir, gen_net(fake_latents))\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/synthesis/gan_training.py_logging_from_monai_utils_misc_imp": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/synthesis/gan_training.py_logging_from_monai_utils_misc_imp", "embedding": null, "metadata": {"file_path": "examples/synthesis/gan_training.py", "file_name": "gan_training.py", "file_type": "text/x-python", "category": "implementation", "start_line": 23, "end_line": 48, "span_ids": ["docstring"], "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": "import logging\nimport os\nimport sys\n\nimport torch\n\nimport monai\nfrom monai.apps.utils import download_and_extract\nfrom monai.data import CacheDataset, DataLoader, png_writer\nfrom monai.engines import GanTrainer\nfrom monai.engines.utils import GanKeys as Keys\nfrom monai.engines.utils import default_make_latent as make_latent\nfrom monai.handlers import CheckpointSaver, StatsHandler\nfrom monai.networks import normal_init\nfrom monai.networks.nets import Discriminator, Generator\nfrom monai.transforms import (\n AddChannelD,\n Compose,\n LoadPNGD,\n RandFlipD,\n RandRotateD,\n RandZoomD,\n ScaleIntensityD,\n ToTensorD,\n)\nfrom monai.utils.misc import set_determinism", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "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/synthesis/gan_training.py_main_main.fake_label.0": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/synthesis/gan_training.py_main_main.fake_label.0", "embedding": null, "metadata": {"file_path": "examples/synthesis/gan_training.py", "file_name": "gan_training.py", "file_type": "text/x-python", "category": "implementation", "start_line": 51, "end_line": 118, "span_ids": ["main"], "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": "def main():\n monai.config.print_config()\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n set_determinism(12345)\n device = torch.device(\"cuda:0\")\n\n # load real data\n mednist_url = \"https://www.dropbox.com/s/5wwskxctvcxiuea/MedNIST.tar.gz?dl=1\"\n md5_value = \"0bc7306e7427e00ad1c5526a6677552d\"\n extract_dir = \"data\"\n tar_save_path = os.path.join(extract_dir, \"MedNIST.tar.gz\")\n download_and_extract(mednist_url, tar_save_path, extract_dir, md5_value)\n hand_dir = os.path.join(extract_dir, \"MedNIST\", \"Hand\")\n real_data = [{\"hand\": os.path.join(hand_dir, filename)} for filename in os.listdir(hand_dir)]\n\n # define real data transforms\n train_transforms = Compose(\n [\n LoadPNGD(keys=[\"hand\"]),\n AddChannelD(keys=[\"hand\"]),\n ScaleIntensityD(keys=[\"hand\"]),\n RandRotateD(keys=[\"hand\"], range_x=15, prob=0.5, keep_size=True),\n RandFlipD(keys=[\"hand\"], spatial_axis=0, prob=0.5),\n RandZoomD(keys=[\"hand\"], min_zoom=0.9, max_zoom=1.1, prob=0.5),\n ToTensorD(keys=[\"hand\"]),\n ]\n )\n\n # create dataset and dataloader\n real_dataset = CacheDataset(real_data, train_transforms)\n batch_size = 300\n real_dataloader = DataLoader(real_dataset, batch_size=batch_size, shuffle=True, num_workers=10)\n\n # define function to process batchdata for input into discriminator\n def prepare_batch(batchdata):\n \"\"\"\n Process Dataloader batchdata dict object and return image tensors for D Inferer\n \"\"\"\n return batchdata[\"hand\"]\n\n # define networks\n disc_net = Discriminator(\n in_shape=(1, 64, 64), channels=(8, 16, 32, 64, 1), strides=(2, 2, 2, 2, 1), num_res_units=1, kernel_size=5\n ).to(device)\n\n latent_size = 64\n gen_net = Generator(\n latent_shape=latent_size, start_shape=(latent_size, 8, 8), channels=[32, 16, 8, 1], strides=[2, 2, 2, 1]\n )\n\n # initialize both networks\n disc_net.apply(normal_init)\n gen_net.apply(normal_init)\n\n # input images are scaled to [0,1] so enforce the same of generated outputs\n gen_net.conv.add_module(\"activation\", torch.nn.Sigmoid())\n gen_net = gen_net.to(device)\n\n # create optimizers and loss functions\n learning_rate = 2e-4\n betas = (0.5, 0.999)\n disc_opt = torch.optim.Adam(disc_net.parameters(), learning_rate, betas=betas)\n gen_opt = torch.optim.Adam(gen_net.parameters(), learning_rate, betas=betas)\n\n disc_loss_criterion = torch.nn.BCELoss()\n gen_loss_criterion = torch.nn.BCELoss()\n real_label = 1\n fake_label = 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/examples/synthesis/gan_training.py_main.discriminator_loss_main.discriminator_loss.return._genloss_realloss_2": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/synthesis/gan_training.py_main.discriminator_loss_main.discriminator_loss.return._genloss_realloss_2", "embedding": null, "metadata": {"file_path": "examples/synthesis/gan_training.py", "file_name": "gan_training.py", "file_type": "text/x-python", "category": "implementation", "start_line": 120, "end_line": 132, "span_ids": ["main"], "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": "def main():\n # ... other code\n\n def discriminator_loss(gen_images, real_images):\n \"\"\"\n The discriminator loss is calculated by comparing D\n prediction for real and generated images.\n\n \"\"\"\n real = real_images.new_full((real_images.shape[0], 1), real_label)\n gen = gen_images.new_full((gen_images.shape[0], 1), fake_label)\n\n realloss = disc_loss_criterion(disc_net(real_images), real)\n genloss = disc_loss_criterion(disc_net(gen_images.detach()), gen)\n\n return (genloss + realloss) / 2\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/synthesis/gan_training.py_main.generator_loss_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/synthesis/gan_training.py_main.generator_loss_", "embedding": null, "metadata": {"file_path": "examples/synthesis/gan_training.py", "file_name": "gan_training.py", "file_type": "text/x-python", "category": "implementation", "start_line": 134, "end_line": 204, "span_ids": ["impl", "main"], "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": "def main():\n # ... other code\n\n def generator_loss(gen_images):\n \"\"\"\n The generator loss is calculated by determining how realistic\n the discriminator classifies the generated images.\n\n \"\"\"\n output = disc_net(gen_images)\n cats = output.new_full(output.shape, real_label)\n return gen_loss_criterion(output, cats)\n\n # initialize current run dir\n run_dir = \"model_out\"\n print(\"Saving model output to: %s \" % run_dir)\n\n # create workflow handlers\n handlers = [\n StatsHandler(\n name=\"batch_training_loss\",\n output_transform=lambda x: {Keys.GLOSS: x[Keys.GLOSS], Keys.DLOSS: x[Keys.DLOSS]},\n ),\n CheckpointSaver(\n save_dir=run_dir,\n save_dict={\"g_net\": gen_net, \"d_net\": disc_net},\n save_interval=10,\n save_final=True,\n epoch_level=True,\n ),\n ]\n\n # define key metric\n key_train_metric = None\n\n # create adversarial trainer\n disc_train_steps = 5\n num_epochs = 50\n\n trainer = GanTrainer(\n device,\n num_epochs,\n real_dataloader,\n gen_net,\n gen_opt,\n generator_loss,\n disc_net,\n disc_opt,\n discriminator_loss,\n d_prepare_batch=prepare_batch,\n d_train_steps=disc_train_steps,\n latent_shape=latent_size,\n key_train_metric=key_train_metric,\n train_handlers=handlers,\n )\n\n # run GAN training\n trainer.run()\n\n # Training completed, save a few random generated images.\n print(\"Saving trained generator sample output.\")\n test_img_count = 10\n test_latents = make_latent(test_img_count, latent_size).to(device)\n fakes = gen_net(test_latents)\n for i, image in enumerate(fakes):\n filename = \"gen-fake-final-%d.png\" % (i)\n save_path = os.path.join(run_dir, filename)\n img_array = image[0].cpu().data.numpy()\n png_writer.write_png(img_array, save_path, scale=255)\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_logging_from_monai_transforms_imp": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_evaluation_dict.py_logging_from_monai_transforms_imp", "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": 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 logging\nimport os\nimport sys\nimport tempfile\nfrom glob import glob\n\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom ignite.metrics import Accuracy\n\nimport monai\nfrom monai.data import create_test_image_3d\nfrom monai.engines import SupervisedEvaluator\nfrom monai.handlers import CheckpointLoader, MeanDice, SegmentationSaver, StatsHandler\nfrom monai.inferers import SlidingWindowInferer\nfrom monai.transforms import (\n Activationsd,\n AsChannelFirstd,\n AsDiscreted,\n Compose,\n KeepLargestConnectedComponentd,\n LoadNiftid,\n ScaleIntensityd,\n ToTensord,\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/examples/workflows/unet_training_dict.py_logging_from_monai_transforms_imp": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/examples/workflows/unet_training_dict.py_logging_from_monai_transforms_imp", "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": 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 logging\nimport os\nimport sys\nimport tempfile\nfrom glob import glob\n\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom ignite.metrics import Accuracy\n\nimport monai\nfrom monai.data import create_test_image_3d\nfrom monai.engines import SupervisedEvaluator, SupervisedTrainer\nfrom monai.handlers import (\n CheckpointSaver,\n LrScheduleHandler,\n MeanDice,\n StatsHandler,\n TensorBoardImageHandler,\n TensorBoardStatsHandler,\n ValidationHandler,\n)\nfrom monai.inferers import SimpleInferer, SlidingWindowInferer\nfrom monai.transforms import (\n Activationsd,\n AsChannelFirstd,\n AsDiscreted,\n Compose,\n KeepLargestConnectedComponentd,\n LoadNiftid,\n RandCropByPosNegLabeld,\n RandRotate90d,\n ScaleIntensityd,\n ToTensord,\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/__init__.py_from_datasets_import__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/__init__.py_from_datasets_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 .datasets 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/apps/datasets.py_os_MedNISTDataset.dataset_folder_name._MedNIST_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/apps/datasets.py_os_MedNISTDataset.dataset_folder_name._MedNIST_", "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": 54, "span_ids": ["MedNISTDataset", "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": "import os\nimport sys\nfrom typing import Any, Callable, Dict, List, Optional, Sequence, Union\n\nfrom monai.apps.utils import download_and_extract\nfrom monai.data import CacheDataset, load_decathalon_datalist\nfrom monai.transforms import LoadNiftid, LoadPNGd, Randomizable\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: When ``root_dir`` is not a directory.\n RuntimeError: When ``dataset_dir`` doesn't exist and downloading is not selected (``download=False``).\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\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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.__init___MedNISTDataset.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_MedNISTDataset.__init___MedNISTDataset.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": 56, "end_line": 88, "span_ids": ["MedNISTDataset.__init__", "MedNISTDataset.randomize"], "tokens": 325}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 __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 directory 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\"Cannot 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_MedNISTDataset._generate_data_list_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._generate_data_list_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": 90, "end_line": 131, "span_ids": ["MedNISTDataset._generate_data_list"], "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": "class MedNISTDataset(Randomizable, CacheDataset):\n\n def _generate_data_list(self, dataset_dir: str) -> List[Dict]:\n \"\"\"\n Raises:\n ValueError: When ``section`` is not one of [\"training\", \"validation\", \"test\"].\n\n \"\"\"\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(\n f'Unsupported section: {self.section}, available options are [\"training\", \"validation\", \"test\"].'\n )\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/utils.py_hashlib_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_hashlib_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": 48, "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": "import hashlib\nimport os\nimport tarfile\nimport zipfile\nfrom typing import Optional\nfrom urllib.error import ContentTooShortError, HTTPError, URLError\nfrom urllib.request import urlretrieve\n\nfrom monai.utils import optional_import, progress_bar\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_extractall_extractall.if_filepath_endswith_zip.else_.raise_ValueError_Unsuppo": {"__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_ValueError_Unsuppo", "embedding": null, "metadata": {"file_path": "monai/apps/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 103, "end_line": 135, "span_ids": ["extractall"], "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": "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: When the MD5 validation of the ``filepath`` compressed file fails.\n ValueError: When the ``filepath`` file extension is not one of [zip\", \"tar.gz\", \"tar\"].\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 failed: filepath={filepath}, expected MD5={md5_value}.\")\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 ValueError('Unsupported file extension, available options are: [\"zip\", \"tar.gz\", \"tar\"].')", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_Collec_": {"__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_Collec_", "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": 52, "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 Collection, Hashable, Iterable, Union\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/csv_saver.py_csv_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_csv_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": 43, "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": "import csv\nimport os\nfrom collections import OrderedDict\nfrom typing import Dict, Optional, Union\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/dataset.py_hashlib_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_hashlib_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": 58, "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": "import hashlib\nimport json\nimport sys\nimport threading\nfrom multiprocessing.pool import ThreadPool\nfrom pathlib import Path\nfrom typing import Any, Callable, Optional, Sequence, Tuple, Union\n\nimport numpy as np\nimport torch\nfrom torch.utils.data import Dataset as _TorchDataset\n\nfrom monai.transforms import Compose, Randomizable, Transform, apply_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_ZipDataset_ZipDataset.__getitem__.return.tuple_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.tuple_data_", "embedding": null, "metadata": {"file_path": "monai/data/dataset.py", "file_name": "dataset.py", "file_type": "text/x-python", "category": "implementation", "start_line": 323, "end_line": 365, "span_ids": ["ZipDataset", "ZipDataset.__init__", "ZipDataset.__getitem__", "ZipDataset.__len__"], "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": "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 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 # use tuple instead of list as the default collate_fn callback of MONAI DataLoader flattens nested lists\n return tuple(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/decathalon_datalist.py_json__compute_path_2.if_isinstance_element_st.else_.raise_TypeError_f_element": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/data/decathalon_datalist.py_json__compute_path_2.if_isinstance_element_st.else_.raise_TypeError_f_element", "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": 46, "span_ids": ["_compute_path", "_compute_path_1", "_compute_path_2", "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 json\nimport os\nfrom typing import Dict, List, Optional, overload\n\n\n@overload\ndef _compute_path(base_dir: str, element: str) -> str:\n ...\n\n\n@overload\ndef _compute_path(base_dir: str, element: List[str]) -> List[str]:\n ...\n\n\ndef _compute_path(base_dir, element):\n \"\"\"\n Args:\n base_dir: the base directory of the dataset.\n element: file path(s) to append to directory.\n\n Raises:\n TypeError: When ``element`` contains a non ``str``.\n TypeError: When ``element`` type is not in ``Union[list, str]``.\n\n \"\"\"\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 TypeError(f\"Every file path in element must be a str but got {type(element).__name__}.\")\n return [os.path.normpath(os.path.join(base_dir, e)) for e in element]\n else:\n raise TypeError(f\"element must be one of (str, list) but is {type(element).__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/data/decathalon_datalist.py__append_paths__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__append_paths__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": 49, "end_line": 68, "span_ids": ["_append_paths"], "tokens": 187}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 _append_paths(base_dir: str, is_segmentation: bool, items: List[Dict]) -> List[Dict]:\n \"\"\"\n Args:\n base_dir: the base directory of the dataset.\n is_segmentation: whether the datalist is for segmentation task.\n items: list of data items, each of which is a dict keyed by element names.\n\n Raises:\n TypeError: When ``items`` contains a non ``dict``.\n\n \"\"\"\n for item in items:\n if not isinstance(item, dict):\n raise TypeError(f\"Every item in items must be a dict but got {type(item).__name__}.\")\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/grid_dataset.py_math_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_math_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": 57, "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": "import math\nfrom typing import Dict, Sequence, Union\n\nimport torch\nfrom torch.utils.data import Dataset, IterableDataset\n\nfrom monai.data.utils import iter_patch\nfrom monai.utils import NumpyPadMode, ensure_tuple\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/nifti_reader.py_from_typing_import_Any_C_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_Any_C_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": 79, "span_ids": ["NiftiDataset", "NiftiDataset.randomize", "NiftiDataset.__init__", "NiftiDataset.__len__", "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 Any, Callable, Optional, Sequence\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[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: 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: When ``seg_files`` length differs from ``image_files``.\n\n \"\"\"\n\n if seg_files is not None and len(image_files) != len(seg_files):\n raise ValueError(\n \"Must have same the number of segmentation as image files: \"\n f\"images={len(image_files)}, segmentations={len(seg_files)}.\"\n )\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_saver.py_from_typing_import_Dict__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_Dict__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": 69, "span_ids": ["NiftiSaver", "NiftiSaver.__init__", "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": "from typing import Dict, Optional, Union\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 align_corners: bool = False,\n dtype: Optional[np.dtype] = np.float64,\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 align_corners: Geometrically, we consider the pixels of the input as squares rather than points.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision.\n If None, use the data type of input data. To be compatible with other modules,\n the output data type is always ``np.float32``.\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.align_corners = align_corners\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/png_saver.py_from_typing_import_Dict__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_Dict__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 Dict, Optional, Union\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/utils.py_math_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_math_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": 50, "span_ids": ["get_random_patch", "docstring"], "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": "import math\nimport os\nimport warnings\nfrom itertools import product, starmap\nfrom typing import Dict, Generator, List, Optional, Sequence, Tuple, Union\n\nimport numpy as np\nimport torch\nfrom torch.utils.data._utils.collate import default_collate\n\nfrom monai.networks.layers.simplelayers import GaussianFilter\nfrom monai.utils import BlendMode, NumpyPadMode, ensure_tuple_size, first, optional_import\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/engines/__init__.py_from_evaluator_import__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/__init__.py_from_evaluator_import__", "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 .evaluator import *\nfrom .multi_gpu_supervised_trainer import *\nfrom .trainer 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_TYPE_C_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_TYPE_C_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": 162}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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, Callable, Dict, Optional, Sequence\n\nimport torch\nfrom torch.utils.data import DataLoader\n\nfrom monai.engines.utils import CommonKeys as Keys\nfrom monai.engines.utils import default_prepare_batch\nfrom monai.engines.workflow import Workflow\nfrom monai.inferers import Inferer, SimpleInferer\nfrom monai.transforms import Transform\nfrom monai.utils import ensure_tuple, 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/multi_gpu_supervised_trainer.py_from_typing_import_TYPE_C__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_TYPE_C__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": 40, "span_ids": ["_default_eval_transform", "_default_transform", "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": "from typing import TYPE_CHECKING, Callable, Dict, Optional, Sequence, Tuple\n\nimport torch\nimport torch.nn\nfrom torch.nn.parallel import DataParallel, DistributedDataParallel\nfrom torch.optim.optimizer import Optimizer\n\nfrom monai.engines.utils import get_devices_spec\nfrom monai.utils import exact_version, optional_import\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.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\")\n\n\ndef _default_transform(_x: torch.Tensor, _y: torch.Tensor, _y_pred: torch.Tensor, loss: torch.Tensor) -> float:\n return loss.item()\n\n\ndef _default_eval_transform(\n x: torch.Tensor, y: torch.Tensor, y_pred: torch.Tensor\n) -> Tuple[torch.Tensor, torch.Tensor]:\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/trainer.py_from_typing_import_TYPE_C_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_TYPE_C_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": 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": "from typing import TYPE_CHECKING, Callable, Dict, Optional, Sequence, Union\n\nimport torch\nfrom torch.optim.optimizer import Optimizer\nfrom torch.utils.data import DataLoader\n\nfrom monai.engines.utils import CommonKeys as Keys\nfrom monai.engines.utils import GanKeys, default_make_latent, default_prepare_batch\nfrom monai.engines.workflow import Workflow\nfrom monai.inferers import Inferer, SimpleInferer\nfrom monai.transforms import Transform\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_SupervisedTrainer._iteration_SupervisedTrainer._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/trainer.py_SupervisedTrainer._iteration_SupervisedTrainer._iteration.return._Keys_IMAGE_inputs_Keys", "embedding": null, "metadata": {"file_path": "monai/engines/trainer.py", "file_name": "trainer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 117, "end_line": 154, "span_ids": ["SupervisedTrainer._iteration"], "tokens": 359}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: 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: When ``batchdata`` is None.\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 if self.amp and self.scaler is not None:\n with torch.cuda.amp.autocast():\n predictions = self.inferer(inputs, self.network)\n loss = self.loss_function(predictions, targets).mean()\n self.scaler.scale(loss).backward()\n self.scaler.step(self.optimizer)\n self.scaler.update()\n else:\n predictions = self.inferer(inputs, self.network)\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/trainer.py_GanTrainer_GanTrainer._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_GanTrainer_GanTrainer._", "embedding": null, "metadata": {"file_path": "monai/engines/trainer.py", "file_name": "trainer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 157, "end_line": 198, "span_ids": ["GanTrainer"], "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 GanTrainer(Trainer):\n \"\"\"\n Generative adversarial network training based on Goodfellow et al. 2014 https://arxiv.org/abs/1406.266,\n inherits from ``Trainer`` and ``Workflow``.\n\n Training Loop: for each batch of data size `m`\n 1. Generate `m` fakes from random latent codes.\n 2. Update discriminator with these fakes and current batch reals, repeated d_train_steps times.\n 3. If g_update_latents, generate `m` fakes from new random latent codes.\n 4. Update generator with these fakes using discriminator feedback.\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.\n train_data_loader: Core ignite engines uses `DataLoader` for training loop batchdata.\n g_network: generator (G) network architecture.\n g_optimizer: G optimizer function.\n g_loss_function: G loss function for optimizer.\n d_network: discriminator (D) network architecture.\n d_optimizer: D optimizer function.\n d_loss_function: D loss function for optimizer.\n g_inferer: inference method to execute G model forward. Defaults to ``SimpleInferer()``.\n d_inferer: inference method to execute D model forward. Defaults to ``SimpleInferer()``.\n d_train_steps: number of times to update D with real data minibatch. Defaults to ``1``.\n latent_shape: size of G input latent code. Defaults to ``64``.\n d_prepare_batch: callback function to prepare batchdata for D inferer.\n Defaults to return ``GanKeys.REALS`` in batchdata dict.\n g_prepare_batch: callback function to create batch of latent input for G inferer.\n Defaults to return random latents.\n g_update_latents: Calculate G loss with new latent codes. Defaults to ``True``.\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_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 \"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_GanTrainer.__init___GanTrainer.__init__.self.g_update_latents.g_update_latents": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_GanTrainer.__init___GanTrainer.__init__.self.g_update_latents.g_update_latents", "embedding": null, "metadata": {"file_path": "monai/engines/trainer.py", "file_name": "trainer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 200, "end_line": 247, "span_ids": ["GanTrainer.__init__"], "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": "class GanTrainer(Trainer):\n\n def __init__(\n self,\n device: torch.device,\n max_epochs: int,\n train_data_loader: DataLoader,\n g_network: torch.nn.Module,\n g_optimizer: Optimizer,\n g_loss_function: Callable,\n d_network: torch.nn.Module,\n d_optimizer: Optimizer,\n d_loss_function: Callable,\n g_inferer: Inferer = SimpleInferer(),\n d_inferer: Inferer = SimpleInferer(),\n d_train_steps: int = 1,\n latent_shape: int = 64,\n d_prepare_batch: Callable = default_prepare_batch,\n g_prepare_batch: Callable = default_make_latent,\n g_update_latents: bool = True,\n iteration_update: Optional[Callable] = None,\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 data_loader=train_data_loader,\n prepare_batch=d_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 self.g_network = g_network\n self.g_optimizer = g_optimizer\n self.g_loss_function = g_loss_function\n self.g_inferer = g_inferer\n self.d_network = d_network\n self.d_optimizer = d_optimizer\n self.d_loss_function = d_loss_function\n self.d_inferer = d_inferer\n self.d_train_steps = d_train_steps\n self.latent_shape = latent_shape\n self.g_prepare_batch = g_prepare_batch\n self.g_update_latents = g_update_latents", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_GanTrainer._iteration_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/trainer.py_GanTrainer._iteration_", "embedding": null, "metadata": {"file_path": "monai/engines/trainer.py", "file_name": "trainer.py", "file_type": "text/x-python", "category": "implementation", "start_line": 249, "end_line": 296, "span_ids": ["GanTrainer._iteration"], "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 GanTrainer(Trainer):\n\n def _iteration(\n self, engine: Engine, batchdata: Union[Dict, Sequence]\n ) -> Dict[str, Union[torch.Tensor, int, float, bool]]:\n \"\"\"\n Callback function for Adversarial Training processing logic of 1 iteration in Ignite Engine.\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\n d_input = self.prepare_batch(batchdata).to(engine.state.device)\n batch_size = self.data_loader.batch_size\n g_input = self.g_prepare_batch(batch_size, self.latent_shape, batchdata).to(engine.state.device)\n g_output = self.g_inferer(g_input, self.g_network)\n\n # Train Discriminator\n d_total_loss = torch.zeros(1,)\n for _ in range(self.d_train_steps):\n self.d_optimizer.zero_grad()\n dloss = self.d_loss_function(g_output, d_input)\n dloss.backward()\n self.d_optimizer.step()\n d_total_loss += dloss.item()\n\n # Train Generator\n if self.g_update_latents:\n g_input = self.g_prepare_batch(batch_size, self.latent_shape, batchdata).to(engine.state.device)\n g_output = self.g_inferer(g_input, self.g_network)\n self.g_optimizer.zero_grad()\n g_loss = self.g_loss_function(g_output)\n g_loss.backward()\n self.g_optimizer.step()\n\n return {\n GanKeys.REALS: d_input,\n GanKeys.FAKES: g_output,\n GanKeys.LATENTS: g_input,\n GanKeys.GLOSS: g_loss.item(),\n GanKeys.DLOSS: d_total_loss.item(),\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/utils.py_from_typing_import_Dict__GanKeys.DLOSS._d_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_Dict__GanKeys.DLOSS._d_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": 43, "span_ids": ["CommonKeys", "GanKeys", "docstring"], "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": "from typing import Dict, List, Optional, Sequence, Tuple, Union\n\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\"\n\n\nclass GanKeys:\n \"\"\"\n A set of common keys for generative adversarial networks.\n \"\"\"\n\n REALS = \"reals\"\n FAKES = \"fakes\"\n LATENTS = \"latents\"\n GLOSS = \"g_loss\"\n DLOSS = \"d_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_get_devices_spec.return.devices": {"__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_get_devices_spec.return.devices", "embedding": null, "metadata": {"file_path": "monai/engines/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 46, "end_line": 74, "span_ids": ["get_devices_spec"], "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": "def get_devices_spec(devices: Optional[Sequence[torch.device]] = None) -> List[torch.device]:\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 Raises:\n RuntimeError: When all GPUs are selected (``devices=None``) but no GPUs are available.\n\n Returns:\n list of torch.device: list of devices.\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 RuntimeError(\"No GPU devices available.\")\n\n elif len(devices) == 0:\n devices = [torch.device(\"cpu\")]\n\n else:\n devices = list(devices)\n\n return devices", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_default_prepare_batch_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/engines/utils.py_default_prepare_batch_", "embedding": null, "metadata": {"file_path": "monai/engines/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 77, "end_line": 91, "span_ids": ["default_make_latent", "default_prepare_batch"], "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 default_prepare_batch(\n batchdata: Dict[str, torch.Tensor]\n) -> Union[Tuple[torch.Tensor, Optional[torch.Tensor]], torch.Tensor]:\n assert isinstance(batchdata, dict), \"default prepare_batch expects dictionary input data.\"\n if CommonKeys.LABEL in batchdata:\n return (batchdata[CommonKeys.IMAGE], batchdata[CommonKeys.LABEL])\n elif GanKeys.REALS in batchdata:\n return batchdata[GanKeys.REALS]\n else:\n return (batchdata[CommonKeys.IMAGE], None)\n\n\ndef default_make_latent(num_latents: int, latent_size: int, real_data: Optional[torch.Tensor] = None) -> torch.Tensor:\n return torch.randn(num_latents, latent_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/engines/workflow.py_from_typing_import_TYPE_C_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_TYPE_C_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": 30, "span_ids": ["docstring"], "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": "from typing import TYPE_CHECKING, Callable, Dict, Optional, Sequence\n\nimport torch\nfrom torch.utils.data import DataLoader\nfrom torch.utils.data.distributed import DistributedSampler\n\nfrom monai.engines.utils import default_prepare_batch\nfrom monai.transforms import apply_transform\nfrom monai.utils import ensure_tuple, exact_version, optional_import\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/handlers/checkpoint_loader.py_logging_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_logging_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": 24, "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 logging\nfrom typing import TYPE_CHECKING, Dict, Optional\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_CheckpointLoader.attach.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_loader.py_CheckpointLoader_CheckpointLoader.attach.engine_add_event_handler_", "embedding": null, "metadata": {"file_path": "monai/handlers/checkpoint_loader.py", "file_name": "checkpoint_loader.py", "file_type": "text/x-python", "category": "implementation", "start_line": 27, "end_line": 71, "span_ids": ["CheckpointLoader.attach", "CheckpointLoader", "CheckpointLoader.__init__"], "tokens": 450}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 map_location: when loading the module for distributed training/evaluation,\n need to provide an appropriate map_location argument to prevent a process\n to step into others\u2019 devices. If map_location is missing, torch.load will\n first load the module to CPU and then copy each parameter to where it was\n saved, which would result in all processes on the same machine using the\n same set of devices.\n\n \"\"\"\n\n def __init__(\n self, load_path: str, load_dict: Dict, name: Optional[str] = None, map_location: Optional[Dict] = None,\n ) -> 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 self._name = name\n self.map_location = map_location\n\n def attach(self, engine: Engine) -> None:\n \"\"\"\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n \"\"\"\n if self._name is None:\n self.logger = engine.logger\n engine.add_event_handler(Events.STARTED, self)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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.__call___": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/checkpoint_loader.py_CheckpointLoader.__call___", "embedding": null, "metadata": {"file_path": "monai/handlers/checkpoint_loader.py", "file_name": "checkpoint_loader.py", "file_type": "text/x-python", "category": "implementation", "start_line": 73, "end_line": 86, "span_ids": ["CheckpointLoader.__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 CheckpointLoader:\n\n def __call__(self, engine: Engine) -> None:\n \"\"\"\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n \"\"\"\n checkpoint = torch.load(self.load_path, map_location=self.map_location)\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_logging_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_logging_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": 22, "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 logging\nfrom typing import TYPE_CHECKING, Dict, Optional\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.exception_raised_CheckpointSaver.exception_raised.raise_e": {"__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.exception_raised.raise_e", "embedding": null, "metadata": {"file_path": "monai/handlers/checkpoint_saver.py", "file_name": "checkpoint_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 172, "end_line": 186, "span_ids": ["CheckpointSaver.exception_raised"], "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 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. This callback may be skipped\n because the logic with Ignite can only trigger the first attached handler for `EXCEPTION_RAISED` event.\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 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 raise e", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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.metrics_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.metrics_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": 188, "end_line": 212, "span_ids": ["CheckpointSaver.metrics_completed", "CheckpointSaver.interval_completed"], "tokens": 244}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 metrics_completed(self, engine: Engine) -> None:\n \"\"\"Callback to compare metrics and save models in train or validation when epoch completed.\n\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n \"\"\"\n assert callable(self._key_metric_checkpoint), \"Error: _key_metric_checkpoint function not specified.\"\n self._key_metric_checkpoint(engine, self.save_dict)\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 Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\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_logging_ClassificationSaver.__init__.self._name.name": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/classification_saver.py_logging_ClassificationSaver.__init__.self._name.name", "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": 59, "span_ids": ["ClassificationSaver", "ClassificationSaver.__init__", "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 logging\nfrom typing import TYPE_CHECKING, Callable, Optional\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 = 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/classification_saver.py_ClassificationSaver.attach_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/classification_saver.py_ClassificationSaver.attach_", "embedding": null, "metadata": {"file_path": "monai/handlers/classification_saver.py", "file_name": "classification_saver.py", "file_type": "text/x-python", "category": "implementation", "start_line": 61, "end_line": 83, "span_ids": ["ClassificationSaver.__call__", "ClassificationSaver.attach"], "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 ClassificationSaver:\n\n def attach(self, engine: Engine) -> None:\n \"\"\"\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n \"\"\"\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 Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\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_logging_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_logging_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": 23, "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 logging\nfrom typing import TYPE_CHECKING, Any, Callable, Optional, Union\n\nfrom torch.optim.lr_scheduler import ReduceLROnPlateau, _LRScheduler\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/metric_logger.py_from_collections_import_d_MetricLogger.attach.engine_add_event_handler_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/metric_logger.py_from_collections_import_d_MetricLogger.attach.engine_add_event_handler_", "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": 36, "span_ids": ["MetricLogger.attach", "MetricLogger.__init__", "MetricLogger", "docstring"], "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": "from collections import defaultdict\nfrom typing import TYPE_CHECKING, Callable, DefaultDict, List\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) -> None:\n \"\"\"\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n \"\"\"\n engine.add_event_handler(Events.ITERATION_COMPLETED, self)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_MetricLogger.__call___": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/metric_logger.py_MetricLogger.__call___", "embedding": null, "metadata": {"file_path": "monai/handlers/metric_logger.py", "file_name": "metric_logger.py", "file_type": "text/x-python", "category": "implementation", "start_line": 38, "end_line": 56, "span_ids": ["MetricLogger.__call__", "impl:5"], "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 MetricLogger:\n\n def __call__(self, engine: Engine) -> None:\n \"\"\"\n Args:\n engine: Ignite Engine, it can be a trainer, validator or evaluator.\n \"\"\"\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_ROCAUC.update_ROCAUC.update.self__targets_append_y_cl": {"__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_ROCAUC.update.self__targets_append_y_cl", "embedding": null, "metadata": {"file_path": "monai/handlers/roc_auc.py", "file_name": "roc_auc.py", "file_type": "text/x-python", "category": "implementation", "start_line": 75, "end_line": 96, "span_ids": ["ROCAUC.update"], "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 ROCAUC(Metric):\n\n @reinit__is_reduced\n def update(self, output: Sequence[torch.Tensor]) -> None:\n \"\"\"\n Args:\n output: sequence with contents [y_pred, y].\n\n Raises:\n ValueError: When ``output`` length is not 2. ROCAUC metric can only support y_pred and y.\n ValueError: When ``y_pred`` dimension is not one of [1, 2].\n ValueError: When ``y`` dimension is not one of [1, 2].\n\n \"\"\"\n if len(output) != 2:\n raise ValueError(f\"output must have length 2, got {len(output)}.\")\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())", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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.compute_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/roc_auc.py_ROCAUC.compute_", "embedding": null, "metadata": {"file_path": "monai/handlers/roc_auc.py", "file_name": "roc_auc.py", "file_type": "text/x-python", "category": "implementation", "start_line": 98, "end_line": 120, "span_ids": ["ROCAUC.compute"], "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": "class ROCAUC(Metric):\n\n def compute(self):\n _prediction_tensor = torch.cat(self._predictions, dim=0)\n _target_tensor = torch.cat(self._targets, dim=0)\n\n if dist.is_available() and dist.is_initialized() and not self._is_reduced:\n # create placeholder to collect the data from all processes:\n output = [torch.zeros_like(_prediction_tensor) for _ in range(dist.get_world_size())]\n dist.all_gather(output, _prediction_tensor)\n _prediction_tensor = torch.cat(output, dim=0)\n output = [torch.zeros_like(_target_tensor) for _ in range(dist.get_world_size())]\n dist.all_gather(output, _target_tensor)\n _target_tensor = torch.cat(output, dim=0)\n self._is_reduced = True\n\n return compute_roc_auc(\n y_pred=_prediction_tensor,\n y=_target_tensor,\n to_onehot_y=self.to_onehot_y,\n softmax=self.softmax,\n other_act=self.other_act,\n average=self.average,\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/segmentation_saver.py_logging_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_logging_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": 24, "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": "import logging\nfrom typing import TYPE_CHECKING, Callable, Optional, Union\n\nimport numpy as np\n\nfrom monai.data import NiftiSaver, PNGSaver\nfrom monai.utils import GridSampleMode, GridSamplePadMode, InterpolateMode, 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/stats_handler.py_logging_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_logging_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": 27, "span_ids": ["docstring"], "tokens": 115}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 logging\nimport warnings\nfrom typing import TYPE_CHECKING, Any, Callable, Optional\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.epoch_completed_StatsHandler.iteration_completed.if_self_iteration_print_l.else_.self__default_iteration_p": {"__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.iteration_completed.if_self_iteration_print_l.else_.self__default_iteration_p", "embedding": null, "metadata": {"file_path": "monai/handlers/stats_handler.py", "file_name": "stats_handler.py", "file_type": "text/x-python", "category": "implementation", "start_line": 105, "end_line": 131, "span_ids": ["StatsHandler.epoch_completed", "StatsHandler.iteration_completed"], "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 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)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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.exception_raised_StatsHandler.exception_raised.raise_e": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/handlers/stats_handler.py_StatsHandler.exception_raised_StatsHandler.exception_raised.raise_e", "embedding": null, "metadata": {"file_path": "monai/handlers/stats_handler.py", "file_name": "stats_handler.py", "file_type": "text/x-python", "category": "implementation", "start_line": 133, "end_line": 145, "span_ids": ["StatsHandler.exception_raised"], "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": "class StatsHandler(object):\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. This callback may be skipped because the logic\n with Ignite can only trigger the first attached handler for `EXCEPTION_RAISED` event.\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 raise e", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_warnings_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_warnings_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": 29, "span_ids": ["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 warnings\nfrom typing import TYPE_CHECKING, Any, Callable, Optional\n\nimport numpy as np\nimport torch\n\nfrom monai.utils import exact_version, is_scalar, optional_import\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/utils.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/utils.py_from_typing_import_TYPE_C_", "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": 42, "span_ids": ["stopping_fn_from_metric", "stopping_fn_from_loss", "docstring"], "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": "from typing import TYPE_CHECKING, Any, Callable\n\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[[Engine], Any]:\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[[Engine], Any]:\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/inferers/__init__.py_from_inferer_import__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/inferers/__init__.py_from_inferer_import__", "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": 14}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 .inferer import *\nfrom .utils import sliding_window_inference", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_abc_import_ABC_abst_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_abc_import_ABC_abst_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": 60, "span_ids": ["SimpleInferer", "Inferer.__call__", "SimpleInferer.__call__", "Inferer", "SimpleInferer.__init__", "docstring"], "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": "from abc import ABC, abstractmethod\nfrom typing import Sequence, Union\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: torch.nn.Module):\n \"\"\"\n Run inference on `inputs` with the `network` model.\n\n Args:\n inputs: input of the model inference.\n network: model for inference.\n\n Raises:\n NotImplementedError: When the subclass does not override this method.\n\n \"\"\"\n raise NotImplementedError(f\"Subclass {self.__class__.__name__} must implement this method.\")\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: torch.nn.Module):\n \"\"\"Unified callable function API of Inferers.\n\n Args:\n inputs: model input data for inference.\n 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/utils.py_from_typing_import_Callab_sliding_window_inference._TODO_Enable_batch_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._TODO_Enable_batch_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": 81, "span_ids": ["sliding_window_inference", "docstring"], "tokens": 826}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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\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[[torch.Tensor], torch.Tensor],\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 device: Optional[torch.device] = None,\n) -> torch.Tensor:\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 device: device running the concatenation of the windows.\n By default the device and accordingly the memory of the input device is used. If for example\n set to device=torch.device('cpu') the gpu memory consumption is less and independent of the\n input and roi_size parameter. Output is on the device set or if not set the inputs device.\n\n Raises:\n NotImplementedError: When ``inputs`` does not 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 \"\"\"\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 # ... 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_batch_size_1__sliding_window_inference.count_map.torch_zeros_output_shape_": {"__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_batch_size_1__sliding_window_inference.count_map.torch_zeros_output_shape_", "embedding": null, "metadata": {"file_path": "monai/inferers/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 82, "end_line": 130, "span_ids": ["sliding_window_inference"], "tokens": 639}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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[[torch.Tensor], torch.Tensor],\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 device: Optional[torch.device] = None,\n) -> torch.Tensor:\n # ... other code\n if batch_size > 1:\n raise NotImplementedError(\"Currently only inputs with batch size = 1 are supported.\")\n\n if device is None:\n device = inputs.device\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 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.to(device))\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=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=device)\n count_map = torch.zeros(output_shape, dtype=torch.float32, device=device)\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_window_id_slice_inde_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.for_window_id_slice_inde_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": 132, "end_line": 161, "span_ids": ["sliding_window_inference"], "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 sliding_window_inference(\n inputs: torch.Tensor,\n roi_size: Union[Sequence[int], int],\n sw_batch_size: int,\n predictor: Callable[[torch.Tensor], torch.Tensor],\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 device: Optional[torch.device] = None,\n) -> torch.Tensor:\n # ... other code\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 = output_image / count_map\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/losses/dice.py_warnings_DiceLoss._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_warnings_DiceLoss._", "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": 38, "span_ids": ["DiceLoss", "docstring"], "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": "import warnings\nfrom typing import Callable, Optional, Union\n\nimport numpy as np\nimport torch\nimport torch.nn.functional as F\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 \"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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.__init___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_DiceLoss.__init___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": 40, "end_line": 86, "span_ids": ["DiceLoss.__init__"], "tokens": 563}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 __init__(\n self,\n include_background: bool = True,\n to_onehot_y: bool = False,\n sigmoid: bool = False,\n softmax: bool = False,\n other_act: Optional[Callable] = None,\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 other_act: if don't want to use `sigmoid` or `softmax`, use other callable function to execute\n other activation layers, Defaults to ``None``. for example:\n `other_act = torch.tanh`.\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 TypeError: When ``other_act`` is not an ``Optional[Callable]``.\n ValueError: When more than 1 of [``sigmoid=True``, ``softmax=True``, ``other_act is not None``].\n Incompatible values.\n\n \"\"\"\n super().__init__(reduction=LossReduction(reduction).value)\n if other_act is not None and not callable(other_act):\n raise TypeError(f\"other_act must be None or callable but is {type(other_act).__name__}.\")\n if int(sigmoid) + int(softmax) + int(other_act is not None) > 1:\n raise ValueError(\"Incompatible values: more than 1 of [sigmoid=True, softmax=True, other_act is not None].\")\n self.include_background = include_background\n self.to_onehot_y = to_onehot_y\n self.sigmoid = sigmoid\n self.softmax = softmax\n self.other_act = other_act\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_MaskedDiceLoss_MaskedDiceLoss._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_MaskedDiceLoss_MaskedDiceLoss._", "embedding": null, "metadata": {"file_path": "monai/losses/dice.py", "file_name": "dice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 160, "end_line": 168, "span_ids": ["MaskedDiceLoss"], "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": "class MaskedDiceLoss(DiceLoss):\n \"\"\"\n Add an additional `masking` process before `DiceLoss`, accept a binary mask ([0, 1]) indicating a region,\n `input` and `target` will be masked by the region: region with mask `1` will keep the original value,\n region with `0` mask will be converted to `0`. Then feed `input` and `target` to normal `DiceLoss` computation.\n This has the effect of ensuring only the masked region contributes to the loss computation and\n hence gradient calculation.\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/losses/dice.py_MaskedDiceLoss.forward_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.forward_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": 170, "end_line": 198, "span_ids": ["MaskedDiceLoss.forward"], "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 MaskedDiceLoss(DiceLoss):\n\n def forward(\n self, input: torch.Tensor, target: torch.Tensor, smooth: float = 1e-5, mask: Optional[torch.Tensor] = None\n ) -> torch.Tensor:\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 else:\n warnings.warn(\"no mask value specified for the MaskedDiceLoss.\")\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.forward_GeneralizedDiceLoss.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_GeneralizedDiceLoss.forward_GeneralizedDiceLoss.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": 265, "end_line": 332, "span_ids": ["GeneralizedDiceLoss.forward"], "tokens": 597}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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) -> torch.Tensor:\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: When ``self.reduction`` is not one of [\"mean\", \"sum\", \"none\"].\n\n \"\"\"\n if self.sigmoid:\n input = torch.sigmoid(input)\n n_pred_ch = input.shape[1]\n if self.softmax:\n if n_pred_ch == 1:\n warnings.warn(\"single channel prediction, `softmax=True` ignored.\")\n else:\n input = torch.softmax(input, 1)\n\n if self.other_act is not None:\n input = self.other_act(input)\n\n if self.to_onehot_y:\n if n_pred_ch == 1:\n warnings.warn(\"single channel prediction, `to_onehot_y=True` ignored.\")\n else:\n target = one_hot(target, num_classes=n_pred_ch)\n\n if not self.include_background:\n if n_pred_ch == 1:\n warnings.warn(\"single channel prediction, `include_background=False` ignored.\")\n else:\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, 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: torch.Tensor = 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'Unsupported reduction: {self.reduction}, available options are [\"mean\", \"sum\", \"none\"].')\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_GeneralizedWassersteinDiceLoss_GeneralizedWassersteinDiceLoss.__init__.self.num_classes.self_m_size_0_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedWassersteinDiceLoss_GeneralizedWassersteinDiceLoss.__init__.self.num_classes.self_m_size_0_", "embedding": null, "metadata": {"file_path": "monai/losses/dice.py", "file_name": "dice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 335, "end_line": 395, "span_ids": ["GeneralizedWassersteinDiceLoss.__init__", "GeneralizedWassersteinDiceLoss"], "tokens": 625}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class GeneralizedWassersteinDiceLoss(_Loss):\n \"\"\"\n Generalized Wasserstein Dice Loss [1] in PyTorch.\n Compared to [1] we used a weighting method similar to the one\n used in the generalized Dice Loss [2].\n\n References:\n ===========\n [1] \"Generalised Wasserstein Dice Score for Imbalanced Multi-class\n Segmentation using Holistic Convolutional Networks\",\n Fidon L. et al. MICCAI BrainLes 2017.\n [2] \"Generalised dice overlap as a deep learning loss function\n for highly unbalanced segmentations\",\n Sudre C., et al. MICCAI DLMIA 2017.\n\n wasserstein_distance_map:\n Compute the voxel-wise Wasserstein distance (eq. 6 in [1]) between the\n flattened prediction and the flattened labels (ground_truth) with respect\n to the distance matrix on the label space M.\n References:\n [1] \"Generalised Wasserstein Dice Score for Imbalanced Multi-class\n Segmentation using Holistic Convolutional Networks\",\n Fidon L. et al. MICCAI BrainLes 2017\n\n compute_weights_generalized_true_positives:\n Compute the weights \\alpha_l of eq. 9 in [1] but using the weighting\n method proposed in the generalized Dice Loss [2].\n References:\n [1] \"Generalised Wasserstein Dice Score for Imbalanced Multi-class\n Segmentation using Holistic Convolutional Networks\",\n Fidon L. et al. MICCAI BrainLes 2017\n [2] \"Generalised dice overlap as a deep learning loss function\n for highly unbalanced segmentations.\" Sudre C., et al.\n MICCAI DLMIA 2017.\n \"\"\"\n\n def __init__(\n self, dist_matrix: Union[np.ndarray, torch.Tensor], reduction: Union[LossReduction, str] = LossReduction.MEAN\n ) -> None:\n \"\"\"\n Args:\n dist_matrix: 2d tensor or 2d numpy array; matrix of distances\n between the classes. It must have dimension C x C where C is the\n number of classes.\n reduction: str; reduction mode.\n\n Raises:\n ValueError: When ``dist_matrix`` is not a square matrix.\n\n \"\"\"\n super(GeneralizedWassersteinDiceLoss, self).__init__(reduction=LossReduction(reduction).value)\n\n if dist_matrix.shape[0] != dist_matrix.shape[1]:\n raise ValueError(f\"dist_matrix must be C x C, got {dist_matrix.shape[0]} x {dist_matrix.shape[1]}.\")\n\n self.m = dist_matrix\n if isinstance(self.m, np.ndarray):\n self.m = torch.from_numpy(self.m)\n if torch.max(self.m) != 1:\n self.m = self.m / torch.max(self.m)\n self.num_classes = self.m.size(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/losses/dice.py_GeneralizedWassersteinDiceLoss.forward_GeneralizedWassersteinDiceLoss.forward.return.wass_dice_loss_mean_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedWassersteinDiceLoss.forward_GeneralizedWassersteinDiceLoss.forward.return.wass_dice_loss_mean_", "embedding": null, "metadata": {"file_path": "monai/losses/dice.py", "file_name": "dice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 397, "end_line": 423, "span_ids": ["GeneralizedWassersteinDiceLoss.forward"], "tokens": 296}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class GeneralizedWassersteinDiceLoss(_Loss):\n\n def forward(self, input: torch.Tensor, target: torch.Tensor, smooth: float = 1e-5) -> torch.Tensor:\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 \"\"\"\n # Aggregate spatial dimensions\n flat_input = input.view(input.size(0), input.size(1), -1)\n flat_target = target.view(target.size(0), -1).long()\n\n # Apply the softmax to the input scores map\n probs = F.softmax(flat_input, dim=1)\n\n # Compute the Wasserstein distance map\n wass_dist_map = self.wasserstein_distance_map(probs, flat_target)\n\n # Compute the generalised number of true positives\n alpha = self.compute_weights_generalized_true_positives(flat_target)\n true_pos = self.compute_generalized_true_positive(alpha, flat_target, wass_dist_map)\n denom = self.compute_denominator(alpha, flat_target, wass_dist_map)\n\n # Compute and return the final loss\n wass_dice: torch.Tensor = (2.0 * true_pos + smooth) / (denom + smooth)\n wass_dice_loss: torch.Tensor = 1.0 - wass_dice\n return wass_dice_loss.mean()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_GeneralizedWassersteinDiceLoss.wasserstein_distance_map_GeneralizedWassersteinDiceLoss.wasserstein_distance_map.return.wasserstein_map": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedWassersteinDiceLoss.wasserstein_distance_map_GeneralizedWassersteinDiceLoss.wasserstein_distance_map.return.wasserstein_map", "embedding": null, "metadata": {"file_path": "monai/losses/dice.py", "file_name": "dice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 425, "end_line": 453, "span_ids": ["GeneralizedWassersteinDiceLoss.wasserstein_distance_map"], "tokens": 324}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class GeneralizedWassersteinDiceLoss(_Loss):\n\n def wasserstein_distance_map(self, flat_proba: torch.Tensor, flat_target: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Args:\n flat_proba: the probabilities of input(predicted) tensor.\n flat_target: the target tensor.\n \"\"\"\n # Turn the distance matrix to a map of identical matrix\n m = torch.clone(self.m).to(flat_proba.device)\n m_extended = torch.unsqueeze(m, dim=0)\n m_extended = torch.unsqueeze(m_extended, dim=3)\n m_extended = m_extended.expand((flat_proba.size(0), m_extended.size(1), m_extended.size(2), flat_proba.size(2)))\n\n # Expand the feature dimensions of the target\n flat_target_extended = torch.unsqueeze(flat_target, dim=1)\n flat_target_extended = flat_target_extended.expand(\n (flat_target.size(0), m_extended.size(1), flat_target.size(1))\n )\n flat_target_extended = torch.unsqueeze(flat_target_extended, dim=1)\n\n # Extract the vector of class distances for the ground-truth label at each voxel\n m_extended = torch.gather(m_extended, dim=1, index=flat_target_extended)\n m_extended = torch.squeeze(m_extended, dim=1)\n\n # Compute the wasserstein distance map\n wasserstein_map = m_extended * flat_proba\n\n # Sum over the classes\n wasserstein_map = torch.sum(wasserstein_map, dim=1)\n return wasserstein_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/losses/dice.py_GeneralizedWassersteinDiceLoss.compute_generalized_true_positive_GeneralizedWassersteinDiceLoss.compute_generalized_true_positive.return.generalized_true_pos": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedWassersteinDiceLoss.compute_generalized_true_positive_GeneralizedWassersteinDiceLoss.compute_generalized_true_positive.return.generalized_true_pos", "embedding": null, "metadata": {"file_path": "monai/losses/dice.py", "file_name": "dice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 455, "end_line": 472, "span_ids": ["GeneralizedWassersteinDiceLoss.compute_generalized_true_positive"], "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 GeneralizedWassersteinDiceLoss(_Loss):\n\n def compute_generalized_true_positive(\n self, alpha: torch.Tensor, flat_target: torch.Tensor, wasserstein_distance_map: torch.Tensor\n ) -> torch.Tensor:\n \"\"\"\n Args:\n alpha: generalised number of true positives of target class.\n flat_target: the target tensor.\n wasserstein_distance_map: the map obtained from the above function.\n \"\"\"\n # Extend alpha to a map and select value at each voxel according to flat_target\n alpha_extended = torch.unsqueeze(alpha, dim=2)\n alpha_extended = alpha_extended.expand((flat_target.size(0), self.num_classes, flat_target.size(1)))\n flat_target_extended = torch.unsqueeze(flat_target, dim=1)\n alpha_extended = torch.gather(alpha_extended, index=flat_target_extended, dim=1)\n\n # Compute the generalized true positive as in eq. 9\n generalized_true_pos = torch.sum(alpha_extended * (1.0 - wasserstein_distance_map), dim=[1, 2],)\n return generalized_true_pos", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_GeneralizedWassersteinDiceLoss.compute_denominator_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/losses/dice.py_GeneralizedWassersteinDiceLoss.compute_denominator_", "embedding": null, "metadata": {"file_path": "monai/losses/dice.py", "file_name": "dice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 474, "end_line": 507, "span_ids": ["GeneralizedWassersteinDiceLoss.compute_weights_generalized_true_positives", "GeneralizedWassersteinDiceLoss.compute_denominator", "impl"], "tokens": 359}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class GeneralizedWassersteinDiceLoss(_Loss):\n\n def compute_denominator(\n self, alpha: torch.Tensor, flat_target: torch.Tensor, wasserstein_distance_map: torch.Tensor\n ) -> torch.Tensor:\n \"\"\"\n Args:\n alpha: generalised number of true positives of target class.\n flat_target: the target tensor.\n wasserstein_distance_map: the map obtained from the above function.\n \"\"\"\n # Extend alpha to a map and select value at each voxel according to flat_target\n alpha_extended = torch.unsqueeze(alpha, dim=2)\n alpha_extended = alpha_extended.expand((flat_target.size(0), self.num_classes, flat_target.size(1)))\n flat_target_extended = torch.unsqueeze(flat_target, dim=1)\n alpha_extended = torch.gather(alpha_extended, index=flat_target_extended, dim=1)\n\n # Compute the generalized true positive as in eq. 9\n generalized_true_pos = torch.sum(alpha_extended * (2.0 - wasserstein_distance_map), dim=[1, 2],)\n return generalized_true_pos\n\n def compute_weights_generalized_true_positives(self, flat_target: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Args:\n flat_target: the target tensor.\n \"\"\"\n one_hot = F.one_hot(flat_target, num_classes=self.num_classes).permute(0, 2, 1).float()\n volumes = torch.sum(one_hot, dim=2)\n alpha: torch.Tensor = 1.0 / (volumes + 1.0)\n return alpha\n\n\ndice = Dice = DiceLoss\ngeneralized_dice = GeneralizedDiceLoss\ngeneralized_wasserstein_dice = GeneralizedWassersteinDiceLoss", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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.if_self_weight_is_not_Non.logpt.logpt_at": {"__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.if_self_weight_is_not_Non.logpt.logpt_at", "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": 121, "span_ids": ["FocalLoss.forward"], "tokens": 820}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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) -> 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: When ``target`` ndim differs from ``input``.\n ValueError: When ``target`` channel is not 1 and ``target`` shape differs from ``input``.\n ValueError: When ``self.reduction`` is not one of [\"mean\", \"sum\", \"none\"].\n\n \"\"\"\n i = input\n t = target\n\n if i.ndimension() != t.ndimension():\n raise ValueError(f\"input and target ndim must match, got input={i.ndimension()} target={t.ndimension()}.\")\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\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 # ... 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._Compute_the_loss_mini_b_": {"__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._Compute_the_loss_mini_b_", "embedding": null, "metadata": {"file_path": "monai/losses/focal_loss.py", "file_name": "focal_loss.py", "file_type": "text/x-python", "category": "implementation", "start_line": 123, "end_line": 137, "span_ids": ["FocalLoss.forward"], "tokens": 187}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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) -> torch.Tensor:\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'Unsupported reduction: {self.reduction}, available options are [\"mean\", \"sum\", \"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/losses/tversky.py_warnings_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_warnings_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": 82, "span_ids": ["TverskyLoss.__init__", "TverskyLoss", "docstring"], "tokens": 678}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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\nfrom typing import Callable, Optional, Union\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 other_act: Optional[Callable] = None,\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 other_act: if don't want to use `sigmoid` or `softmax`, use other callable function to execute\n other activation layers, Defaults to ``None``. for example:\n `other_act = torch.tanh`.\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 TypeError: When ``other_act`` is not an ``Optional[Callable]``.\n ValueError: When more than 1 of [``sigmoid=True``, ``softmax=True``, ``other_act is not None``].\n Incompatible values.\n\n \"\"\"\n\n super().__init__(reduction=LossReduction(reduction).value)\n if other_act is not None and not callable(other_act):\n raise TypeError(f\"other_act must be None or callable but is {type(other_act).__name__}.\")\n if int(sigmoid) + int(softmax) + int(other_act is not None) > 1:\n raise ValueError(\"Incompatible values: more than 1 of [sigmoid=True, softmax=True, other_act is not None].\")\n self.include_background = include_background\n self.to_onehot_y = to_onehot_y\n self.sigmoid = sigmoid\n self.softmax = softmax\n self.other_act = other_act\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/metrics/__init__.py_DiceMetric_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/__init__.py_DiceMetric_", "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 DiceMetric, compute_meandice\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_warnings_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_warnings_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": 73, "span_ids": ["DiceMetric.__init__", "DiceMetric", "docstring"], "tokens": 706}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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\nfrom typing import Callable, Optional, Union\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 other_act: callable function to replace `sigmoid` as activation layer if needed, Defaults to ``None``.\n for example: `other_act = torch.tanh`.\n logit_thresh: the threshold value used to convert (for example, 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\"``,\n ``\"mean_channel\"``, ``\"sum_channel\"``}\n Define the mode to reduce computation result of 1 batch data. Defaults to ``\"mean\"``.\n\n Raises:\n ValueError: When ``sigmoid=True`` and ``other_act is not None``. Incompatible values.\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 other_act: Optional[Callable] = None,\n logit_thresh: float = 0.5,\n reduction: Union[MetricReduction, str] = MetricReduction.MEAN,\n ) -> None:\n super().__init__()\n if sigmoid and other_act is not None:\n raise ValueError(\"Incompatible values: ``sigmoid=True`` and ``other_act is not None``.\")\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.other_act = other_act\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_compute_meandice_compute_meandice.if_other_act_is_not_None_.y_pred.other_act_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_compute_meandice.if_other_act_is_not_None_.y_pred.other_act_y_pred_", "embedding": null, "metadata": {"file_path": "monai/metrics/meandice.py", "file_name": "meandice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 147, "end_line": 201, "span_ids": ["compute_meandice"], "tokens": 684}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 other_act: Optional[Callable] = None,\n logit_thresh: float = 0.5,\n) -> torch.Tensor:\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 other_act: callable function to replace `sigmoid` as activation layer if needed, Defaults to ``None``.\n for example: `other_act = torch.tanh`.\n logit_thresh: the threshold value used to convert (for example, after sigmoid if `sigmoid=True`)\n `y_pred` into a binary matrix. Defaults to 0.5.\n\n Raises:\n ValueError: When ``sigmoid=True`` and ``other_act is not None``. Incompatible values.\n TypeError: When ``other_act`` is not an ``Optional[Callable]``.\n ValueError: When ``sigmoid=True`` and ``mutually_exclusive=True``. Incompatible values.\n\n Returns:\n Dice scores per batch and per class, (shape [batch_size, n_classes]).\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 if sigmoid and other_act is not None:\n raise ValueError(\"Incompatible values: sigmoid=True and other_act is not None.\")\n if sigmoid:\n y_pred = y_pred.float().sigmoid()\n\n if other_act is not None:\n if not callable(other_act):\n raise TypeError(f\"other_act must be None or callable but is {type(other_act).__name__}.\")\n y_pred = other_act(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.if_n_classes_1__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/metrics/meandice.py_compute_meandice.if_n_classes_1__", "embedding": null, "metadata": {"file_path": "monai/metrics/meandice.py", "file_name": "meandice.py", "file_type": "text/x-python", "category": "implementation", "start_line": 203, "end_line": 246, "span_ids": ["compute_meandice"], "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": "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 other_act: Optional[Callable] = None,\n logit_thresh: float = 0.5,\n) -> torch.Tensor:\n # ... other code\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(\"Incompatible values: sigmoid=True and 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\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_warnings__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_warnings__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": 52, "span_ids": ["_calculate", "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 warnings\nfrom typing import Callable, List, Optional, Union, cast\n\nimport numpy as np\nimport torch\n\nfrom monai.networks import one_hot\nfrom monai.utils import Average\n\n\ndef _calculate(y: torch.Tensor, y_pred: torch.Tensor) -> float:\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/networks/blocks/aspp.py_from_typing_import_Sequen_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/aspp.py_from_typing_import_Sequen_", "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": 101, "span_ids": ["SimpleASPP", "SimpleASPP.forward", "SimpleASPP.__init__", "docstring"], "tokens": 793}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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\n\nimport 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: Sequence[int] = (1, 3, 3, 3),\n dilations: Sequence[int] = (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: When ``kernel_sizes`` length differs from ``dilations``.\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(\n \"kernel_sizes and dilations length must match, \"\n f\"got kernel_sizes={len(kernel_sizes)} dilations={len(dilations)}.\"\n )\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_from_typing_import_Option_Convolution._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/convolutions.py_from_typing_import_Option_Convolution._", "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": 60, "span_ids": ["Convolution", "docstring"], "tokens": 457}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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\n\nimport numpy as np\nimport torch\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 dropout_dim: determine the dimensions of dropout. Defaults to 1.\n When dropout_dim = 1, randomly zeroes some of the elements for each channel.\n When dropout_dim = 2, Randomly zero out entire channels (a channel is a 2D feature map).\n When dropout_dim = 3, Randomly zero out entire channels (a channel is a 3D feature map).\n The value of dropout_dim should be no no larger than the value of dimensions.\n dilation: dilation rate. Defaults to 1.\n groups: controls the connections between inputs and outputs. 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 \"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_Convolution.__init___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_Convolution.__init___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": 62, "end_line": 144, "span_ids": ["Convolution.__init__"], "tokens": 621}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Convolution(nn.Sequential):\n\n def __init__(\n self,\n dimensions: int,\n in_channels: int,\n out_channels: int,\n strides: int = 1,\n kernel_size: Union[Sequence[int], int] = 3,\n act: Optional[Union[Tuple, str]] = Act.PRELU,\n norm: Union[Tuple, str] = Norm.INSTANCE,\n dropout: Optional[Union[Tuple, str, float]] = None,\n dropout_dim: int = 1,\n dilation: Union[Sequence[int], int] = 1,\n groups: int = 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 if dropout_dim > dimensions:\n raise ValueError(\n f\"dropout_dim should be no larger than dimensions, got dropout_dim={dropout_dim} and dimensions={dimensions}.\"\n )\n drop_type = Dropout[drop_name, dropout_dim]\n\n if is_transposed:\n conv = conv_type(\n in_channels,\n out_channels,\n kernel_size=kernel_size,\n stride=strides,\n padding=padding,\n output_padding=strides - 1,\n groups=groups,\n bias=bias,\n dilation=dilation,\n )\n else:\n conv = conv_type(\n in_channels,\n out_channels,\n kernel_size=kernel_size,\n stride=strides,\n padding=padding,\n dilation=dilation,\n groups=groups,\n bias=bias,\n )\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_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_ResidualUnit._", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/convolutions.py", "file_name": "convolutions.py", "file_type": "text/x-python", "category": "implementation", "start_line": 147, "end_line": 175, "span_ids": ["ResidualUnit"], "tokens": 296}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 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 subunits: number of convolutions. Defaults to 2.\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 dropout_dim: determine the dimensions of dropout. Defaults to 1.\n When dropout_dim = 1, randomly zeroes some of the elements for each channel.\n When dropout_dim = 2, Randomly zero out entire channels (a channel is a 2D feature map).\n When dropout_dim = 3, Randomly zero out entire channels (a channel is a 3D feature map).\n The value of dropout_dim should be no no larger than the value of dimensions.\n dilation: dilation rate. Defaults to 1.\n bias: whether to have a bias term. Defaults to True.\n last_conv_only: for the last subunit, whether to use the convolutional layer only.\n Defaults to False.\n\n See also:\n\n :py:class:`monai.networks.blocks.Convolution`\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/networks/blocks/convolutions.py_ResidualUnit.__init___": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/convolutions.py_ResidualUnit.__init___", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/convolutions.py", "file_name": "convolutions.py", "file_type": "text/x-python", "category": "implementation", "start_line": 177, "end_line": 244, "span_ids": ["ResidualUnit.forward", "ResidualUnit.__init__"], "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": "class ResidualUnit(nn.Module):\n\n def __init__(\n self,\n dimensions: int,\n in_channels: int,\n out_channels: int,\n strides: int = 1,\n kernel_size: Union[Sequence[int], int] = 3,\n subunits: int = 2,\n act: Optional[Union[Tuple, str]] = Act.PRELU,\n norm: Union[Tuple, str] = Norm.INSTANCE,\n dropout: Optional[Union[Tuple, str, float]] = None,\n dropout_dim: int = 1,\n dilation: Union[Sequence[int], int] = 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 strides=sstrides,\n kernel_size=kernel_size,\n act=act,\n norm=norm,\n dropout=dropout,\n dropout_dim=dropout_dim,\n dilation=dilation,\n bias=bias,\n conv_only=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: torch.Tensor) -> torch.Tensor:\n res: torch.Tensor = self.residual(x) # create the additive residual from x\n cx: torch.Tensor = 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/fcn.py_from_typing_import_Type_GCN.forward.return.x": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/fcn.py_from_typing_import_Type_GCN.forward.return.x", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/fcn.py", "file_name": "fcn.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 59, "span_ids": ["GCN", "GCN.forward", "GCN.__init__", "docstring"], "tokens": 500}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nfrom monai.networks.blocks.convolutions import Convolution\nfrom monai.networks.blocks.upsample import UpSample\nfrom monai.networks.layers.factories import Act, Conv, Norm\nfrom monai.utils import optional_import\n\nmodels, _ = optional_import(\"torchvision\", \"0.5.0\", name=\"models\")\n\n\nclass GCN(nn.Module):\n \"\"\"\n The Global Convolutional Network module using large 1D\n Kx1 and 1xK kernels to represent 2D kernels.\n The code is adapted from lsqshr's original version:\n https://github.com/lsqshr/AH-Net/blob/master/net2d.py\n \"\"\"\n\n def __init__(self, inplanes: int, planes: int, ks: int = 7):\n \"\"\"\n Args:\n inplanes: number of input channels.\n planes: number of output channels.\n ks: kernel size for one dimension. Defaults to 7.\n \"\"\"\n super(GCN, self).__init__()\n\n conv2d_type: Type[nn.Conv2d] = Conv[Conv.CONV, 2]\n self.conv_l1 = conv2d_type(in_channels=inplanes, out_channels=planes, kernel_size=(ks, 1), padding=(ks // 2, 0))\n self.conv_l2 = conv2d_type(in_channels=planes, out_channels=planes, kernel_size=(1, ks), padding=(0, ks // 2))\n self.conv_r1 = conv2d_type(in_channels=inplanes, out_channels=planes, kernel_size=(1, ks), padding=(0, ks // 2))\n self.conv_r2 = conv2d_type(in_channels=planes, out_channels=planes, kernel_size=(ks, 1), padding=(ks // 2, 0))\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Args:\n x: in shape (batch, inplanes, spatial_1, spatial_2).\n \"\"\"\n x_l = self.conv_l1(x)\n x_l = self.conv_l2(x_l)\n x_r = self.conv_r1(x)\n x_r = self.conv_r2(x_r)\n x = x_l + x_r\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/fcn.py_Refine_Refine.forward.return.out": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/fcn.py_Refine_Refine.forward.return.out", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/fcn.py", "file_name": "fcn.py", "file_type": "text/x-python", "category": "implementation", "start_line": 62, "end_line": 99, "span_ids": ["Refine", "Refine.__init__", "Refine.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 Refine(nn.Module):\n \"\"\"\n Simple residual block to refine the details of the activation maps.\n The code is adapted from lsqshr's original version:\n https://github.com/lsqshr/AH-Net/blob/master/net2d.py\n \"\"\"\n\n def __init__(self, planes: int):\n \"\"\"\n Args:\n planes: number of input channels.\n \"\"\"\n super(Refine, self).__init__()\n\n relu_type: Type[nn.ReLU] = Act[Act.RELU]\n conv2d_type: Type[nn.Conv2d] = Conv[Conv.CONV, 2]\n norm2d_type: Type[nn.BatchNorm2d] = Norm[Norm.BATCH, 2]\n\n self.bn = norm2d_type(num_features=planes)\n self.relu = relu_type(inplace=True)\n self.conv1 = conv2d_type(in_channels=planes, out_channels=planes, kernel_size=3, padding=1)\n self.conv2 = conv2d_type(in_channels=planes, out_channels=planes, kernel_size=3, padding=1)\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Args:\n x: in shape (batch, planes, spatial_1, spatial_2).\n \"\"\"\n residual = x\n x = self.bn(x)\n x = self.relu(x)\n x = self.conv1(x)\n x = self.bn(x)\n x = self.relu(x)\n x = self.conv2(x)\n\n out = residual + x\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/blocks/fcn.py_FCN_FCN.__init__.if_self_upsample_mode_.self.up_conv.UpSample_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/fcn.py_FCN_FCN.__init__.if_self_upsample_mode_.self.up_conv.UpSample_", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/fcn.py", "file_name": "fcn.py", "file_type": "text/x-python", "category": "implementation", "start_line": 102, "end_line": 162, "span_ids": ["FCN.__init__", "FCN"], "tokens": 607}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class FCN(nn.Module):\n \"\"\"\n 2D FCN network with 3 input channels. The small decoder is built\n with the GCN and Refine modules.\n The code is adapted from lsqshr's original version:\n https://github.com/lsqshr/AH-Net/blob/master/net2d.py\n\n Args:\n out_channels: number of output channels. Defaults to 1.\n upsample_mode: The mode of upsampling manipulations, there are two choices:\n 1) ``transpose``, uses transposed convolution layers.\n 2) ``bilinear``, uses bilinear interpolate.\n Using the second mode cannot guarantee the model's reproducibility. Defaults to ``bilinear``.\n \"\"\"\n\n def __init__(self, out_channels: int = 1, upsample_mode: str = \"bilinear\"):\n super(FCN, self).__init__()\n\n conv2d_type: Type[nn.Conv2d] = Conv[Conv.CONV, 2]\n\n self.upsample_mode = upsample_mode\n self.conv2d_type = conv2d_type\n self.out_channels = out_channels\n resnet = models.resnet50(pretrained=True)\n\n self.conv1 = resnet.conv1\n self.bn0 = resnet.bn1\n self.relu = resnet.relu\n self.maxpool = resnet.maxpool\n\n self.layer1 = resnet.layer1\n self.layer2 = resnet.layer2\n self.layer3 = resnet.layer3\n self.layer4 = resnet.layer4\n\n self.gcn1 = GCN(2048, self.out_channels)\n self.gcn2 = GCN(1024, self.out_channels)\n self.gcn3 = GCN(512, self.out_channels)\n self.gcn4 = GCN(64, self.out_channels)\n self.gcn5 = GCN(64, self.out_channels)\n\n self.refine1 = Refine(self.out_channels)\n self.refine2 = Refine(self.out_channels)\n self.refine3 = Refine(self.out_channels)\n self.refine4 = Refine(self.out_channels)\n self.refine5 = Refine(self.out_channels)\n self.refine6 = Refine(self.out_channels)\n self.refine7 = Refine(self.out_channels)\n self.refine8 = Refine(self.out_channels)\n self.refine9 = Refine(self.out_channels)\n self.refine10 = Refine(self.out_channels)\n self.transformer = self.conv2d_type(in_channels=256, out_channels=64, kernel_size=1)\n\n if self.upsample_mode == \"transpose\":\n self.up_conv = UpSample(\n spatial_dims=2,\n in_channels=self.out_channels,\n out_channels=self.out_channels,\n scale_factor=2,\n with_conv=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/monai/networks/blocks/fcn.py_FCN.forward_FCN.forward.return.out": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/fcn.py_FCN.forward_FCN.forward.return.out", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/fcn.py", "file_name": "fcn.py", "file_type": "text/x-python", "category": "implementation", "start_line": 164, "end_line": 206, "span_ids": ["FCN.forward"], "tokens": 512}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class FCN(nn.Module):\n\n def forward(self, x: torch.Tensor):\n \"\"\"\n Args:\n x: in shape (batch, 3, spatial_1, spatial_2).\n \"\"\"\n org_input = x\n x = self.conv1(x)\n x = self.bn0(x)\n x = self.relu(x)\n conv_x = x\n x = self.maxpool(x)\n pool_x = x\n\n fm1 = self.layer1(x)\n fm2 = self.layer2(fm1)\n fm3 = self.layer3(fm2)\n fm4 = self.layer4(fm3)\n\n gcfm1 = self.refine1(self.gcn1(fm4))\n gcfm2 = self.refine2(self.gcn2(fm3))\n gcfm3 = self.refine3(self.gcn3(fm2))\n gcfm4 = self.refine4(self.gcn4(pool_x))\n gcfm5 = self.refine5(self.gcn5(conv_x))\n\n if self.upsample_mode == \"transpose\":\n fs1 = self.refine6(self.up_conv(gcfm1) + gcfm2)\n fs2 = self.refine7(self.up_conv(fs1) + gcfm3)\n fs3 = self.refine8(self.up_conv(fs2) + gcfm4)\n fs4 = self.refine9(self.up_conv(fs3) + gcfm5)\n out = self.refine10(self.up_conv(fs4))\n else:\n fs1 = self.refine6(\n F.interpolate(gcfm1, fm3.size()[2:], mode=self.upsample_mode, align_corners=True) + gcfm2\n )\n fs2 = self.refine7(F.interpolate(fs1, fm2.size()[2:], mode=self.upsample_mode, align_corners=True) + gcfm3)\n fs3 = self.refine8(\n F.interpolate(fs2, pool_x.size()[2:], mode=self.upsample_mode, align_corners=True) + gcfm4\n )\n fs4 = self.refine9(\n F.interpolate(fs3, conv_x.size()[2:], mode=self.upsample_mode, align_corners=True) + gcfm5\n )\n out = self.refine10(F.interpolate(fs4, org_input.size()[2:], mode=self.upsample_mode, align_corners=True))\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/blocks/fcn.py_MCFCN_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/fcn.py_MCFCN_", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/fcn.py", "file_name": "fcn.py", "file_type": "text/x-python", "category": "implementation", "start_line": 209, "end_line": 246, "span_ids": ["MCFCN.forward", "MCFCN.__init__", "MCFCN"], "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 MCFCN(FCN):\n \"\"\"\n The multi-channel version of the 2D FCN module.\n Adds a projection layer to take arbitrary number of inputs.\n The code is adapted from lsqshr's original version:\n https://github.com/lsqshr/AH-Net/blob/master/net2d.py\n\n Args:\n in_channels: number of input channels. Defaults to 3.\n out_channels: number of output channels. Defaults to 1.\n upsample_mode: The mode of upsampling manipulations, there are two choices:\n 1) ``transpose``, uses transposed convolution layers.\n 2) ``bilinear``, uses bilinear interpolate.\n Using the second mode cannot guarantee the model's reproducibility. Defaults to ``bilinear``.\n \"\"\"\n\n def __init__(self, in_channels: int = 3, out_channels: int = 1, upsample_mode: str = \"bilinear\"):\n super(MCFCN, self).__init__(out_channels=out_channels, upsample_mode=upsample_mode)\n\n self.init_proj = Convolution(\n dimensions=2,\n in_channels=in_channels,\n out_channels=3,\n kernel_size=1,\n act=(\"relu\", {\"inplace\": True}),\n norm=Norm.BATCH,\n bias=False,\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 x = self.init_proj(x)\n out = super(MCFCN, self).forward(x)\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/blocks/segresnet_block.py_nn_get_norm_layer.if_norm_name_not_in_bat.else_.return.norm": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/segresnet_block.py_nn_get_norm_layer.if_norm_name_not_in_bat.else_.return.norm", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/segresnet_block.py", "file_name": "segresnet_block.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 31, "span_ids": ["get_norm_layer", "docstring"], "tokens": 182}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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\nfrom monai.networks.blocks.upsample import UpSample\nfrom monai.networks.layers.factories import Act, Norm\n\n\ndef get_norm_layer(spatial_dims: int, in_channels: int, norm_name: str, num_groups: int = 8):\n if norm_name not in [\"batch\", \"instance\", \"group\"]:\n raise ValueError(f\"Unsupported normalization mode: {norm_name}\")\n else:\n if norm_name == \"group\":\n norm = Norm[norm_name](num_groups=num_groups, num_channels=in_channels)\n else:\n norm = Norm[norm_name, spatial_dims](in_channels)\n if norm.bias is not None:\n nn.init.zeros_(norm.bias)\n if norm.weight is not None:\n nn.init.ones_(norm.weight)\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/blocks/segresnet_block.py_get_conv_layer_get_upsample_layer.return.up_module": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/segresnet_block.py_get_conv_layer_get_upsample_layer.return.up_module", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/segresnet_block.py", "file_name": "segresnet_block.py", "file_type": "text/x-python", "category": "implementation", "start_line": 34, "end_line": 50, "span_ids": ["get_upsample_layer", "get_conv_layer"], "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": "def get_conv_layer(\n spatial_dims: int, in_channels: int, out_channels: int, kernel_size: int = 3, stride: int = 1, bias: bool = False\n):\n\n return Convolution(\n spatial_dims, in_channels, out_channels, strides=stride, kernel_size=kernel_size, bias=bias, conv_only=True,\n )\n\n\ndef get_upsample_layer(spatial_dims: int, in_channels: int, upsample_mode: str = \"trilinear\", scale_factor: int = 2):\n up_module: nn.Module\n if upsample_mode == \"transpose\":\n up_module = UpSample(spatial_dims, in_channels, scale_factor=scale_factor, with_conv=True,)\n else:\n upsample_mode = \"bilinear\" if spatial_dims == 2 else \"trilinear\"\n up_module = nn.Upsample(scale_factor=scale_factor, mode=upsample_mode, align_corners=False)\n return up_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/monai/networks/blocks/segresnet_block.py_ResBlock_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/segresnet_block.py_ResBlock_", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/segresnet_block.py", "file_name": "segresnet_block.py", "file_type": "text/x-python", "category": "implementation", "start_line": 53, "end_line": 109, "span_ids": ["ResBlock.__init__", "ResBlock.forward", "ResBlock"], "tokens": 479}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class ResBlock(nn.Module):\n \"\"\"\n ResBlock employs skip connection and two convolution blocks and is used\n in SegResnet:\n \"3D MRI brain tumor segmentation using autoencoder regularization, https://arxiv.org/abs/1810.11654\"\n \"\"\"\n\n def __init__(\n self,\n spatial_dims: int,\n in_channels: int,\n kernel_size: int = 3,\n stride: int = 1,\n bias: bool = False,\n norm_name: str = \"group\",\n num_groups: int = 8,\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 kernel_size: convolution kernel size, the value should be an odd number. Defaults to 3.\n stride: convolution stride. Defaults to 1.\n bias: whether to have a bias term in convolution layer. Defaults to ``True``.\n norm_name: feature normalization type, this module only supports group norm,\n batch norm and instance norm. Defaults to ``group``.\n num_groups: number of groups to separate the channels into, in this module,\n in_channels should be divisible by num_groups. Defaults to 8.\n \"\"\"\n\n super().__init__()\n\n assert kernel_size % 2 == 1, \"kernel_size should be an odd number.\"\n assert in_channels % num_groups == 0, \"in_channels should be divisible by num_groups.\"\n\n self.norm1 = get_norm_layer(spatial_dims, in_channels, norm_name, num_groups=num_groups)\n self.norm2 = get_norm_layer(spatial_dims, in_channels, norm_name, num_groups=num_groups)\n self.relu = Act[Act.RELU](inplace=True)\n self.conv1 = get_conv_layer(spatial_dims, in_channels, in_channels)\n self.conv2 = get_conv_layer(spatial_dims, in_channels, in_channels)\n\n def forward(self, x):\n\n identity = x\n\n x = self.norm1(x)\n x = self.relu(x)\n x = self.conv1(x)\n\n x = self.norm2(x)\n x = self.relu(x)\n x = self.conv2(x)\n\n x += identity\n\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/squeeze_and_excitation.py_math_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_math_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": 78, "span_ids": ["ChannelSELayer.__init__", "ChannelSELayer", "ChannelSELayer.forward", "docstring"], "tokens": 611}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 math\nfrom typing import Dict, Optional, Tuple, Union\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: Union[Tuple[str, Dict], str] = (\"relu\", {\"inplace\": True}),\n acti_type_2: Union[Tuple[str, Dict], str] = \"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 Raises:\n ValueError: When ``r`` is nonpositive or larger than ``in_channels``.\n\n See also:\n\n :py:class:`monai.networks.layers.Act`\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(f\"r must be positive and smaller than in_channels, got r={r} in_channels={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) -> 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: torch.Tensor = self.avg_pool(x).view(b, c)\n y = self.fc(y).view([b, c] + [1] * (x.ndimension() - 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_SEBlock_SEBlock.__init__.if_acti_type_final_is_not.self.act.Act_act_final_act_fina": {"__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_SEBlock.__init__.if_acti_type_final_is_not.self.act.Act_act_final_act_fina", "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": 124, "end_line": 206, "span_ids": ["SEBlock", "SEBlock.__init__"], "tokens": 1065}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 project: Optional[Convolution] = None,\n r: int = 2,\n acti_type_1: Union[Tuple[str, Dict], str] = (\"relu\", {\"inplace\": True}),\n acti_type_2: Union[Tuple[str, Dict], str] = \"sigmoid\",\n acti_type_final: Optional[Union[Tuple[str, Dict], str]] = (\"relu\", {\"inplace\": True}),\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\": (\"relu\", {\"inplace\": True})}``\n conv_param_2: additional parameters to the 2nd convolution.\n Defaults to ``{\"kernel_size\": 3, \"norm\": Norm.BATCH, \"act\": (\"relu\", {\"inplace\": True})}``\n conv_param_3: additional parameters to the 3rd convolution.\n Defaults to ``{\"kernel_size\": 1, \"norm\": Norm.BATCH, \"act\": None}``\n project: in the case of residual chns and output chns doesn't match, a project\n (Conv) layer/block is used to adjust the number of chns. In SENET, it is\n consisted with a Conv layer as well as a Norm layer.\n Defaults to None (chns are matchable) or a Conv layer with kernel size 1.\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 acti_type_final: activation type of the end of the block. Defaults to \"relu\".\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\": (\"relu\", {\"inplace\": True})}\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\": (\"relu\", {\"inplace\": True})}\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 self.project = project\n if self.project is None and in_channels != n_chns_3:\n self.project = Conv[Conv.CONV, spatial_dims](in_channels, n_chns_3, kernel_size=1)\n\n self.act = None\n if acti_type_final is not None:\n act_final, act_final_args = split_args(acti_type_final)\n self.act = Act[act_final](**act_final_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/squeeze_and_excitation.py_SEBlock.forward_SEBlock.forward.return.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_SEBlock.forward_SEBlock.forward.return.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": 208, "end_line": 221, "span_ids": ["SEBlock.forward"], "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 SEBlock(nn.Module):\n\n def forward(self, x: torch.Tensor) -> 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 if self.act is not None:\n x = self.act(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/blocks/squeeze_and_excitation.py_SEBottleneck_SEBottleneck.__init__.super_SEBottleneck_self_": {"__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_SEBottleneck_SEBottleneck.__init__.super_SEBottleneck_self_", "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": 224, "end_line": 270, "span_ids": ["SEBottleneck.__init__", "SEBottleneck"], "tokens": 342}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SEBottleneck(SEBlock):\n \"\"\"\n Bottleneck for SENet154.\n \"\"\"\n\n expansion = 4\n\n def __init__(\n self,\n spatial_dims: int,\n inplanes: int,\n planes: int,\n groups: int,\n reduction: int,\n stride: int = 1,\n downsample: Optional[Convolution] = None,\n ) -> None:\n\n conv_param_1 = {\n \"strides\": 1,\n \"kernel_size\": 1,\n \"act\": (\"relu\", {\"inplace\": True}),\n \"norm\": Norm.BATCH,\n \"bias\": False,\n }\n conv_param_2 = {\n \"strides\": stride,\n \"kernel_size\": 3,\n \"act\": (\"relu\", {\"inplace\": True}),\n \"norm\": Norm.BATCH,\n \"groups\": groups,\n \"bias\": False,\n }\n conv_param_3 = {\"strides\": 1, \"kernel_size\": 1, \"act\": None, \"norm\": Norm.BATCH, \"bias\": False}\n\n super(SEBottleneck, self).__init__(\n spatial_dims=spatial_dims,\n in_channels=inplanes,\n n_chns_1=planes * 2,\n n_chns_2=planes * 4,\n n_chns_3=planes * 4,\n conv_param_1=conv_param_1,\n conv_param_2=conv_param_2,\n conv_param_3=conv_param_3,\n project=downsample,\n r=reduction,\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/blocks/squeeze_and_excitation.py_SEResNetBottleneck_SEResNetBottleneck.__init__.super_SEResNetBottleneck_": {"__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_SEResNetBottleneck_SEResNetBottleneck.__init__.super_SEResNetBottleneck_", "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": 273, "end_line": 321, "span_ids": ["SEResNetBottleneck", "SEResNetBottleneck.__init__"], "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": "class SEResNetBottleneck(SEBlock):\n \"\"\"\n ResNet bottleneck with a Squeeze-and-Excitation module. It follows Caffe\n implementation and uses `strides=stride` in `conv1` and not in `conv2`\n (the latter is used in the torchvision implementation of ResNet).\n \"\"\"\n\n expansion = 4\n\n def __init__(\n self,\n spatial_dims: int,\n inplanes: int,\n planes: int,\n groups: int,\n reduction: int,\n stride: int = 1,\n downsample: Optional[Convolution] = None,\n ) -> None:\n\n conv_param_1 = {\n \"strides\": stride,\n \"kernel_size\": 1,\n \"act\": (\"relu\", {\"inplace\": True}),\n \"norm\": Norm.BATCH,\n \"bias\": False,\n }\n conv_param_2 = {\n \"strides\": 1,\n \"kernel_size\": 3,\n \"act\": (\"relu\", {\"inplace\": True}),\n \"norm\": Norm.BATCH,\n \"groups\": groups,\n \"bias\": False,\n }\n conv_param_3 = {\"strides\": 1, \"kernel_size\": 1, \"act\": None, \"norm\": Norm.BATCH, \"bias\": False}\n\n super(SEResNetBottleneck, self).__init__(\n spatial_dims=spatial_dims,\n in_channels=inplanes,\n n_chns_1=planes,\n n_chns_2=planes,\n n_chns_3=planes * 4,\n conv_param_1=conv_param_1,\n conv_param_2=conv_param_2,\n conv_param_3=conv_param_3,\n project=downsample,\n r=reduction,\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/blocks/squeeze_and_excitation.py_SEResNeXtBottleneck_": {"__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_SEResNeXtBottleneck_", "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": 324, "end_line": 373, "span_ids": ["SEResNeXtBottleneck.__init__", "SEResNeXtBottleneck"], "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": "class SEResNeXtBottleneck(SEBlock):\n \"\"\"\n ResNeXt bottleneck type C with a Squeeze-and-Excitation module.\n \"\"\"\n\n expansion = 4\n\n def __init__(\n self,\n spatial_dims: int,\n inplanes: int,\n planes: int,\n groups: int,\n reduction: int,\n stride: int = 1,\n downsample: Optional[Convolution] = None,\n base_width: int = 4,\n ) -> None:\n\n conv_param_1 = {\n \"strides\": 1,\n \"kernel_size\": 1,\n \"act\": (\"relu\", {\"inplace\": True}),\n \"norm\": Norm.BATCH,\n \"bias\": False,\n }\n conv_param_2 = {\n \"strides\": stride,\n \"kernel_size\": 3,\n \"act\": (\"relu\", {\"inplace\": True}),\n \"norm\": Norm.BATCH,\n \"groups\": groups,\n \"bias\": False,\n }\n conv_param_3 = {\"strides\": 1, \"kernel_size\": 1, \"act\": None, \"norm\": Norm.BATCH, \"bias\": False}\n width = math.floor(planes * (base_width / 64)) * groups\n\n super(SEResNeXtBottleneck, self).__init__(\n spatial_dims=spatial_dims,\n in_channels=inplanes,\n n_chns_1=width,\n n_chns_2=width,\n n_chns_3=planes * 4,\n conv_param_1=conv_param_1,\n conv_param_2=conv_param_2,\n conv_param_3=conv_param_3,\n project=downsample,\n r=reduction,\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/blocks/upsample.py_from_typing_import_Option_UpSample.forward.return.torch_as_tensor_self_upsa": {"__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_UpSample.forward.return.torch_as_tensor_self_upsa", "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": 651}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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.networks.utils import icnr_init, pixelshuffle\nfrom monai.utils import UpsampleMode, ensure_tuple_rep\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 torch.as_tensor(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/blocks/upsample.py_SubpixelUpsample_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/blocks/upsample.py_SubpixelUpsample_", "embedding": null, "metadata": {"file_path": "monai/networks/blocks/upsample.py", "file_name": "upsample.py", "file_type": "text/x-python", "category": "implementation", "start_line": 77, "end_line": 131, "span_ids": ["SubpixelUpsample.forward", "SubpixelUpsample.__init__", "SubpixelUpsample"], "tokens": 534}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class SubpixelUpsample(nn.Module):\n \"\"\"\n Upsample via using a subpixel CNN. This module supports 1D, 2D and 3D input images.\n The module is consisted with two parts. First of all, a convolutional layer is employed\n to increase the number of channels into: ``in_channels * (scale_factor ** spatial_dims)``.\n Secondly, a pixel shuffle manipulation is utilized to aggregates the feature maps from\n low resolution space and build the super resolution space.\n The first part of the module is not fixed, a sequential layers can be used to replace the\n default single layer.\n The idea comes from:\n https://arxiv.org/abs/1609.05158\n The pixel shuffle mechanism refers to:\n https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/PixelShuffle.cpp\n and:\n https://github.com/pytorch/pytorch/pull/6340/files\n \"\"\"\n\n def __init__(\n self, spatial_dims: int, in_channels: int, scale_factor: int = 2, conv_block: Optional[nn.Module] = None,\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 scale_factor: multiplier for spatial size. Defaults to 2.\n conv_block: a conv block to extract feature maps before upsampling. Defaults to None.\n When ``conv_block is None``, one reserved conv layer will be utilized.\n \"\"\"\n super().__init__()\n\n if scale_factor <= 0:\n raise ValueError(\"the `scale_factor` multiplier should be an integer and no less than 1.\")\n\n self.spatial_dims = spatial_dims\n self.scale_factor = scale_factor\n\n if conv_block is None:\n conv_out_channels = in_channels * (scale_factor ** spatial_dims)\n self.conv_block = Conv[Conv.CONV, spatial_dims](\n in_channels=in_channels, out_channels=conv_out_channels, kernel_size=3, stride=1, padding=1,\n )\n\n icnr_init(self.conv_block, self.scale_factor)\n else:\n self.conv_block = conv_block\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 x = self.conv_block(x)\n x = pixelshuffle(x, self.spatial_dims, self.scale_factor)\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/layers/convutils.py_from_typing_import_Sequen_same_padding.return.padding_if_len_padding_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/convutils.py_from_typing_import_Sequen_same_padding.return.padding_if_len_padding_", "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": 42, "span_ids": ["same_padding", "docstring"], "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": "from typing import Sequence, Tuple, Union\n\nimport numpy as np\n\n__all__ = [\"same_padding\", \"calculate_out_shape\", \"gaussian_1d\"]\n\n\ndef same_padding(\n kernel_size: Union[Sequence[int], int], dilation: Union[Sequence[int], int] = 1\n) -> Union[Tuple[int, ...], int]:\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: When ``np.any((kernel_size - 1) * dilation % 2 == 1)``.\n\n \"\"\"\n\n kernel_size_np = np.atleast_1d(kernel_size)\n dilation_np = np.atleast_1d(dilation)\n\n if np.any((kernel_size_np - 1) * dilation % 2 == 1):\n raise NotImplementedError(\n f\"Same padding not available for kernel_size={kernel_size_np} and dilation={dilation_np}.\"\n )\n\n padding_np = (kernel_size_np - 1) / 2 * dilation_np\n padding = tuple(int(p) for p in padding_np)\n\n return 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.out_shape_if_len_out_shap": {"__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.out_shape_if_len_out_shap", "embedding": null, "metadata": {"file_path": "monai/networks/layers/convutils.py", "file_name": "convutils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 45, "end_line": 64, "span_ids": ["calculate_out_shape"], "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": "def calculate_out_shape(\n in_shape: Union[Sequence[int], int],\n kernel_size: Union[Sequence[int], int],\n stride: Union[Sequence[int], int],\n padding: Union[Sequence[int], int],\n) -> Union[Tuple[int, ...], int]:\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 = np.atleast_1d(in_shape)\n kernel_size_np = np.atleast_1d(kernel_size)\n stride_np = np.atleast_1d(stride)\n padding_np = np.atleast_1d(padding)\n\n out_shape_np = ((in_shape_np - kernel_size_np + padding_np + padding_np) // stride_np) + 1\n out_shape = tuple(int(s) for s in out_shape_np)\n\n return 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/factories.py__Define_factories_for_th_adaptive_maxpooling_factory.return.types_dim_1_": {"__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_adaptive_maxpooling_factory.return.types_dim_1_", "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": 256, "span_ids": ["impl:3", "conv_factory", "adaptive_maxpooling_factory", "split_args", "maxpooling_factory", "convtrans_factory", "dropout_factory", "impl:13", "batch_factory", "instance_factory"], "tokens": 703}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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) -> Type[Union[nn.Dropout, nn.Dropout2d, nn.Dropout3d]]:\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) -> Type[Union[nn.InstanceNorm1d, nn.InstanceNorm2d, nn.InstanceNorm3d]]:\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) -> Type[Union[nn.BatchNorm1d, nn.BatchNorm2d, nn.BatchNorm3d]]:\n types = (nn.BatchNorm1d, nn.BatchNorm2d, nn.BatchNorm3d)\n return types[dim - 1]\n\n\nNorm.add_factory_callable(\"group\", lambda: nn.modules.GroupNorm)\nAct.add_factory_callable(\"elu\", lambda: nn.modules.ELU)\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) -> Type[Union[nn.Conv1d, nn.Conv2d, nn.Conv3d]]:\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) -> Type[Union[nn.ConvTranspose1d, nn.ConvTranspose2d, nn.ConvTranspose3d]]:\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) -> Type[Union[nn.MaxPool1d, nn.MaxPool2d, nn.MaxPool3d]]:\n types = (nn.MaxPool1d, nn.MaxPool2d, nn.MaxPool3d)\n return types[dim - 1]\n\n\n@Pool.factory_function(\"adaptivemax\")\ndef adaptive_maxpooling_factory(\n dim: int,\n) -> Type[Union[nn.AdaptiveMaxPool1d, nn.AdaptiveMaxPool2d, nn.AdaptiveMaxPool3d]]:\n types = (nn.AdaptiveMaxPool1d, nn.AdaptiveMaxPool2d, nn.AdaptiveMaxPool3d)\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/factories.py_avgpooling_factory_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/factories.py_avgpooling_factory_", "embedding": null, "metadata": {"file_path": "monai/networks/layers/factories.py", "file_name": "factories.py", "file_type": "text/x-python", "category": "implementation", "start_line": 259, "end_line": 271, "span_ids": ["avgpooling_factory", "adaptive_avgpooling_factory"], "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": "@Pool.factory_function(\"avg\")\ndef avgpooling_factory(dim: int) -> Type[Union[nn.AvgPool1d, nn.AvgPool2d, nn.AvgPool3d]]:\n types = (nn.AvgPool1d, nn.AvgPool2d, nn.AvgPool3d)\n return types[dim - 1]\n\n\n@Pool.factory_function(\"adaptiveavg\")\ndef adaptive_avgpooling_factory(\n dim: int,\n) -> Type[Union[nn.AdaptiveAvgPool1d, nn.AdaptiveAvgPool2d, nn.AdaptiveAvgPool3d]]:\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_math_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_math_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": 49, "span_ids": ["Flatten", "SkipConnection.forward", "Flatten.forward", "docstring", "SkipConnection.__init__", "SkipConnection"], "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 math\nfrom typing import Sequence, Union, cast\n\nimport torch\nimport torch.nn.functional as F\nfrom torch import nn\nfrom torch.autograd import Function\n\nfrom monai.networks.layers.convutils import gaussian_1d, same_padding\nfrom monai.utils import ensure_tuple_rep, optional_import\n\n_C, _ = optional_import(\"monai._C\")\n_C_CUDA, _ = optional_import(\"monai._C_CUDA\")\n\n__all__ = [\"SkipConnection\", \"Flatten\", \"GaussianFilter\", \"LLTM\"]\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: torch.Tensor) -> torch.Tensor:\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: torch.Tensor) -> torch.Tensor:\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_GaussianFilter.forward_GaussianFilter.forward.return._conv_x_sp_dim_1_": {"__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_GaussianFilter.forward.return._conv_x_sp_dim_1_", "embedding": null, "metadata": {"file_path": "monai/networks/layers/simplelayers.py", "file_name": "simplelayers.py", "file_type": "text/x-python", "category": "implementation", "start_line": 94, "end_line": 120, "span_ids": ["GaussianFilter.forward"], "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 GaussianFilter(nn.Module):\n\n def forward(self, x: torch.Tensor) -> torch.Tensor:\n \"\"\"\n Args:\n x: in shape [Batch, chns, H, W, D].\n\n Raises:\n TypeError: When ``x`` is not a ``torch.Tensor``.\n\n \"\"\"\n if not torch.is_tensor(x):\n raise TypeError(f\"x must be a torch.Tensor but is {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_: torch.Tensor, d: int) -> torch.Tensor:\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/simplelayers.py_LLTMFunction_LLTMFunction.backward.return.d_input_d_weights_d_bia": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_LLTMFunction_LLTMFunction.backward.return.d_input_d_weights_d_bia", "embedding": null, "metadata": {"file_path": "monai/networks/layers/simplelayers.py", "file_name": "simplelayers.py", "file_type": "text/x-python", "category": "implementation", "start_line": 123, "end_line": 143, "span_ids": ["LLTMFunction.forward", "LLTMFunction", "LLTMFunction.backward"], "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": "class LLTMFunction(Function):\n @staticmethod\n def forward(ctx, input, weights, bias, old_h, old_cell):\n ext = _C_CUDA if weights.is_cuda else _C\n outputs = ext.lltm_forward(input, weights, bias, old_h, old_cell)\n new_h, new_cell = outputs[:2]\n variables = outputs[1:] + [weights]\n ctx.save_for_backward(*variables)\n\n return new_h, new_cell\n\n @staticmethod\n def backward(ctx, grad_h, grad_cell):\n if grad_h.is_cuda:\n outputs = _C_CUDA.lltm_backward(grad_h.contiguous(), grad_cell.contiguous(), *ctx.saved_tensors)\n d_old_h, d_input, d_weights, d_bias, d_old_cell, d_gates = outputs\n else:\n outputs = _C.lltm_backward(grad_h.contiguous(), grad_cell.contiguous(), *ctx.saved_tensors)\n d_old_h, d_input, d_weights, d_bias, d_old_cell = outputs\n\n return d_input, d_weights, d_bias, d_old_h, d_old_cell", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_LLTM_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/layers/simplelayers.py_LLTM_", "embedding": null, "metadata": {"file_path": "monai/networks/layers/simplelayers.py", "file_name": "simplelayers.py", "file_type": "text/x-python", "category": "implementation", "start_line": 146, "end_line": 176, "span_ids": ["LLTM.forward", "LLTM", "LLTM.__init__", "LLTM.reset_parameters"], "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 LLTM(nn.Module):\n \"\"\"\n This recurrent unit is similar to an LSTM, but differs in that it lacks a forget\n gate and uses an Exponential Linear Unit (ELU) as its internal activation function.\n Because this unit never forgets, call it LLTM, or Long-Long-Term-Memory unit.\n It has both C++ and CUDA implementation, automatically switch according to the\n target device where put this module to.\n\n Args:\n input_features: size of input feature data\n state_size: size of the state of recurrent unit\n\n Referring to: https://pytorch.org/tutorials/advanced/cpp_extension.html\n \"\"\"\n\n def __init__(self, input_features: int, state_size: int):\n super(LLTM, self).__init__()\n self.input_features = input_features\n self.state_size = state_size\n self.weights = nn.Parameter(torch.empty(3 * state_size, input_features + state_size))\n self.bias = nn.Parameter(torch.empty(1, 3 * state_size))\n self.reset_parameters()\n\n def reset_parameters(self):\n stdv = 1.0 / math.sqrt(self.state_size)\n for weight in self.parameters():\n weight.data.uniform_(-stdv, +stdv)\n\n def forward(self, input, state):\n return LLTMFunction.apply(input, self.weights, self.bias, *state)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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.dst_size.src_size": {"__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.dst_size.src_size", "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": 128, "span_ids": ["AffineTransform.forward"], "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 AffineTransform(nn.Module):\n\n def forward(\n self, src: torch.Tensor, theta: torch.Tensor, spatial_size: Optional[Union[Sequence[int], int]] = None\n ) -> torch.Tensor:\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: When ``theta`` is not a ``torch.Tensor``.\n ValueError: When ``theta`` is not one of [Nxdxd, dxd].\n ValueError: When ``theta`` is not one of [Nx3x3, Nx4x4].\n TypeError: When ``src`` is not a ``torch.Tensor``.\n ValueError: When ``src`` spatially is not one of [2D, 3D].\n ValueError: When affine and image batch dimension differ.\n\n \"\"\"\n # validate `theta`\n if not torch.is_tensor(theta):\n raise TypeError(f\"theta must be torch.Tensor but is {type(theta).__name__}.\")\n if theta.dim() not in (2, 3):\n raise ValueError(f\"theta must be Nxdxd or dxd, got {theta.shape}.\")\n if theta.dim() == 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\"theta must be Nx3x3 or Nx4x4, got {theta.shape}.\")\n\n # validate `src`\n if not torch.is_tensor(src):\n raise TypeError(f\"src must be torch.Tensor but is {type(src).__name__}.\")\n sr = src.dim() - 2 # input spatial rank\n if sr not in (2, 3):\n raise ValueError(f\"Unsupported src dimension: {sr}, available options are [2, 3].\")\n\n # set output shape\n src_size = tuple(src.shape)\n dst_size = src_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._default_to_the_src_shap_": {"__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._default_to_the_src_shap_", "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": 160, "span_ids": ["AffineTransform.forward"], "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": "class AffineTransform(nn.Module):\n\n def forward(\n self, src: torch.Tensor, theta: torch.Tensor, spatial_size: Optional[Union[Sequence[int], int]] = None\n ) -> torch.Tensor: # default to the src shape\n if self.spatial_size is not None:\n dst_size = src_size[:2] + self.spatial_size\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 f\"affine and image batch dimension must match, got affine={theta.shape[0]} image={src_size[0]}.\"\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_AHNet_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/__init__.py_AHNet_", "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": 22, "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 .ahnet import AHNet\nfrom .classifier import *\nfrom .densenet import DenseNet, densenet121, densenet169, densenet201, densenet264\nfrom .generator import Generator\nfrom .highresnet import HighResBlock, HighResNet\nfrom .regressor import Regressor\nfrom .segresnet import SegResNet, SegResNetVAE\nfrom .senet import SENet, se_resnet50, se_resnet101, se_resnet152, se_resnext50_32x4d, se_resnext101_32x4d, senet154\nfrom .unet import *\nfrom .vnet import VNet", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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/ahnet.py_math_Bottleneck3x3x1.__init__.self.pool.pool_type_kernel_size_1_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_math_Bottleneck3x3x1.__init__.self.pool.pool_type_kernel_size_1_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/ahnet.py", "file_name": "ahnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 58, "span_ids": ["Bottleneck3x3x1.__init__", "Bottleneck3x3x1", "docstring"], "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": "import math\nfrom typing import Optional, Sequence, Type, Union\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nfrom monai.networks.layers.factories import Act, Conv, Norm, Pool\n\n\nclass Bottleneck3x3x1(nn.Module):\n\n expansion = 4\n\n def __init__(\n self,\n spatial_dims: int,\n inplanes: int,\n planes: int,\n stride: Union[Sequence[int], int] = 1,\n downsample: Optional[nn.Sequential] = None,\n ) -> None:\n\n super(Bottleneck3x3x1, self).__init__()\n\n conv_type = Conv[Conv.CONV, spatial_dims]\n norm_type: Type[Union[nn.BatchNorm2d, nn.BatchNorm3d]] = Norm[Norm.BATCH, spatial_dims]\n pool_type: Type[Union[nn.MaxPool2d, nn.MaxPool3d]] = Pool[Pool.MAX, spatial_dims]\n relu_type: Type[nn.ReLU] = Act[Act.RELU]\n\n self.conv1 = conv_type(inplanes, planes, kernel_size=1, bias=False)\n self.bn1 = norm_type(planes)\n self.conv2 = conv_type(\n planes,\n planes,\n kernel_size=(3, 3, 1)[-spatial_dims:],\n stride=stride,\n padding=(1, 1, 0)[-spatial_dims:],\n bias=False,\n )\n self.bn2 = norm_type(planes)\n self.conv3 = conv_type(planes, planes * 4, kernel_size=1, bias=False)\n self.bn3 = norm_type(planes * 4)\n self.relu = relu_type(inplace=True)\n self.downsample = downsample\n self.stride = stride\n self.pool = pool_type(kernel_size=(1, 1, 2)[-spatial_dims:], stride=(1, 1, 2)[-spatial_dims:])", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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/ahnet.py_Bottleneck3x3x1.forward_Bottleneck3x3x1.forward.return.out": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_Bottleneck3x3x1.forward_Bottleneck3x3x1.forward.return.out", "embedding": null, "metadata": {"file_path": "monai/networks/nets/ahnet.py", "file_name": "ahnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 60, "end_line": 82, "span_ids": ["Bottleneck3x3x1.forward"], "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 Bottleneck3x3x1(nn.Module):\n\n def forward(self, x):\n residual = x\n\n out = self.conv1(x)\n out = self.bn1(out)\n out = self.relu(out)\n\n out = self.conv2(out)\n out = self.bn2(out)\n out = self.relu(out)\n\n out = self.conv3(out)\n out = self.bn3(out)\n\n if self.downsample is not None:\n residual = self.downsample(x)\n if out.size() != residual.size():\n out = self.pool(out)\n\n out += residual\n out = self.relu(out)\n\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/nets/ahnet.py_Projection_Projection.__init__.self_add_module_conv_c": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_Projection_Projection.__init__.self_add_module_conv_c", "embedding": null, "metadata": {"file_path": "monai/networks/nets/ahnet.py", "file_name": "ahnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 85, "end_line": 95, "span_ids": ["Projection.__init__", "Projection"], "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": "class Projection(nn.Sequential):\n def __init__(self, spatial_dims: int, num_input_features: int, num_output_features: int):\n super(Projection, self).__init__()\n\n conv_type = Conv[Conv.CONV, spatial_dims]\n norm_type: Type[Union[nn.BatchNorm2d, nn.BatchNorm3d]] = Norm[Norm.BATCH, spatial_dims]\n relu_type: Type[nn.ReLU] = Act[Act.RELU]\n\n self.add_module(\"norm\", norm_type(num_input_features))\n self.add_module(\"relu\", relu_type(inplace=True))\n self.add_module(\"conv\", conv_type(num_input_features, num_output_features, kernel_size=1, stride=1, bias=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/ahnet.py_DenseBlock_DenseBlock.__init__.for_i_in_range_num_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/ahnet.py_DenseBlock_DenseBlock.__init__.for_i_in_range_num_layers.self_add_module_denselay", "embedding": null, "metadata": {"file_path": "monai/networks/nets/ahnet.py", "file_name": "ahnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 98, "end_line": 113, "span_ids": ["DenseBlock.__init__", "DenseBlock"], "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": "class DenseBlock(nn.Sequential):\n def __init__(\n self,\n spatial_dims: int,\n num_layers: int,\n num_input_features: int,\n bn_size: int,\n growth_rate: int,\n dropout_prob: float,\n ):\n super(DenseBlock, self).__init__()\n for i in range(num_layers):\n layer = Pseudo3DLayer(\n spatial_dims, num_input_features + i * growth_rate, growth_rate, bn_size, dropout_prob\n )\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/ahnet.py_UpTransition_UpTransition.__init__.if_upsample_mode_tran.else_.self_add_module_up_nn_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_UpTransition_UpTransition.__init__.if_upsample_mode_tran.else_.self_add_module_up_nn_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/ahnet.py", "file_name": "ahnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 116, "end_line": 135, "span_ids": ["UpTransition.__init__", "UpTransition"], "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 UpTransition(nn.Sequential):\n def __init__(\n self, spatial_dims: int, num_input_features: int, num_output_features: int, upsample_mode: str = \"trilinear\"\n ):\n super(UpTransition, self).__init__()\n\n conv_type = Conv[Conv.CONV, spatial_dims]\n norm_type: Type[Union[nn.BatchNorm2d, nn.BatchNorm3d]] = Norm[Norm.BATCH, spatial_dims]\n relu_type: Type[nn.ReLU] = Act[Act.RELU]\n\n self.add_module(\"norm\", norm_type(num_input_features))\n self.add_module(\"relu\", relu_type(inplace=True))\n self.add_module(\"conv\", conv_type(num_input_features, num_output_features, kernel_size=1, stride=1, bias=False))\n if upsample_mode == \"transpose\":\n conv_trans_type = Conv[Conv.CONVTRANS, spatial_dims]\n self.add_module(\n \"up\", conv_trans_type(num_output_features, num_output_features, kernel_size=2, stride=2, bias=False)\n )\n else:\n self.add_module(\"up\", nn.Upsample(scale_factor=2, mode=upsample_mode, align_corners=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/ahnet.py_Final_Final.__init__.if_upsample_mode_tran.else_.self_add_module_up_nn_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_Final_Final.__init__.if_upsample_mode_tran.else_.self_add_module_up_nn_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/ahnet.py", "file_name": "ahnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 138, "end_line": 168, "span_ids": ["Final.__init__", "Final"], "tokens": 309}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Final(nn.Sequential):\n def __init__(\n self, spatial_dims: int, num_input_features: int, num_output_features: int, upsample_mode: str = \"trilinear\"\n ):\n super(Final, self).__init__()\n\n conv_type = Conv[Conv.CONV, spatial_dims]\n norm_type: Type[Union[nn.BatchNorm2d, nn.BatchNorm3d]] = Norm[Norm.BATCH, spatial_dims]\n relu_type: Type[nn.ReLU] = Act[Act.RELU]\n\n self.add_module(\"norm\", norm_type(num_input_features))\n self.add_module(\"relu\", relu_type(inplace=True))\n self.add_module(\n \"conv\",\n conv_type(\n num_input_features,\n num_output_features,\n kernel_size=(3, 3, 1)[-spatial_dims:],\n stride=1,\n padding=(1, 1, 0)[-spatial_dims:],\n bias=False,\n ),\n )\n if upsample_mode == \"transpose\":\n conv_trans_type = Conv[Conv.CONVTRANS, spatial_dims]\n self.add_module(\n \"up\", conv_trans_type(num_output_features, num_output_features, kernel_size=2, stride=2, bias=False)\n )\n else:\n upsample_mode = \"bilinear\" if spatial_dims == 2 else \"trilinear\"\n self.add_module(\"up\", nn.Upsample(scale_factor=2, mode=upsample_mode, align_corners=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/ahnet.py_Pseudo3DLayer_Pseudo3DLayer.__init__.self.dropout_prob.dropout_prob": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_Pseudo3DLayer_Pseudo3DLayer.__init__.self.dropout_prob.dropout_prob", "embedding": null, "metadata": {"file_path": "monai/networks/nets/ahnet.py", "file_name": "ahnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 171, "end_line": 209, "span_ids": ["Pseudo3DLayer.__init__", "Pseudo3DLayer"], "tokens": 419}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Pseudo3DLayer(nn.Module):\n def __init__(self, spatial_dims: int, num_input_features: int, growth_rate: int, bn_size: int, dropout_prob: float):\n super(Pseudo3DLayer, self).__init__()\n # 1x1x1\n\n conv_type = Conv[Conv.CONV, spatial_dims]\n norm_type: Type[Union[nn.BatchNorm2d, nn.BatchNorm3d]] = Norm[Norm.BATCH, spatial_dims]\n relu_type: Type[nn.ReLU] = Act[Act.RELU]\n\n self.bn1 = norm_type(num_input_features)\n self.relu1 = relu_type(inplace=True)\n self.conv1 = conv_type(num_input_features, bn_size * growth_rate, kernel_size=1, stride=1, bias=False)\n # 3x3x1\n self.bn2 = norm_type(bn_size * growth_rate)\n self.relu2 = relu_type(inplace=True)\n self.conv2 = conv_type(\n bn_size * growth_rate,\n growth_rate,\n kernel_size=(3, 3, 1)[-spatial_dims:],\n stride=1,\n padding=(1, 1, 0)[-spatial_dims:],\n bias=False,\n )\n # 1x1x3\n self.bn3 = norm_type(growth_rate)\n self.relu3 = relu_type(inplace=True)\n self.conv3 = conv_type(\n growth_rate,\n growth_rate,\n kernel_size=(1, 1, 3)[-spatial_dims:],\n stride=1,\n padding=(0, 0, 1)[-spatial_dims:],\n bias=False,\n )\n # 1x1x1\n self.bn4 = norm_type(growth_rate)\n self.relu4 = relu_type(inplace=True)\n self.conv4 = conv_type(growth_rate, growth_rate, kernel_size=1, stride=1, bias=False)\n self.dropout_prob = dropout_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/networks/nets/ahnet.py_Pseudo3DLayer.forward_Pseudo3DLayer.forward.return.torch_cat_inx_new_featu": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_Pseudo3DLayer.forward_Pseudo3DLayer.forward.return.torch_cat_inx_new_featu", "embedding": null, "metadata": {"file_path": "monai/networks/nets/ahnet.py", "file_name": "ahnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 211, "end_line": 234, "span_ids": ["Pseudo3DLayer.forward"], "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 Pseudo3DLayer(nn.Module):\n\n def forward(self, x):\n inx = x\n x = self.bn1(x)\n x = self.relu1(x)\n x = self.conv1(x)\n\n x = self.bn2(x)\n x = self.relu2(x)\n x3x3x1 = self.conv2(x)\n\n x = self.bn3(x3x3x1)\n x = self.relu3(x)\n x1x1x3 = self.conv3(x)\n\n x = x3x3x1 + x1x1x3\n x = self.bn4(x)\n x = self.relu4(x)\n new_features = self.conv4(x)\n\n self.dropout_prob = 0 # Dropout will make trouble!\n # since we use the train mode for inference\n if self.dropout_prob > 0:\n new_features = F.dropout(new_features, p=self.dropout_prob, training=self.training)\n return torch.cat([inx, 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/ahnet.py_PSP_PSP.__init__.if_self_upsample_mode_.self.up8.conv_trans_type_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_PSP_PSP.__init__.if_self_upsample_mode_.self.up8.conv_trans_type_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/ahnet.py", "file_name": "ahnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 237, "end_line": 293, "span_ids": ["PSP.__init__", "PSP"], "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 PSP(nn.Module):\n def __init__(self, spatial_dims: int, in_ch: int, upsample_mode: str = \"trilinear\"):\n super(PSP, self).__init__()\n\n conv_type = Conv[Conv.CONV, spatial_dims]\n pool_type: Type[Union[nn.MaxPool2d, nn.MaxPool3d]] = Pool[Pool.MAX, spatial_dims]\n\n self.pool64 = pool_type(kernel_size=(64, 64, 1)[-spatial_dims:], stride=(64, 64, 1)[-spatial_dims:])\n self.pool32 = pool_type(kernel_size=(32, 32, 1)[-spatial_dims:], stride=(32, 32, 1)[-spatial_dims:])\n self.pool16 = pool_type(kernel_size=(16, 16, 1)[-spatial_dims:], stride=(16, 16, 1)[-spatial_dims:])\n self.pool8 = pool_type(kernel_size=(8, 8, 1)[-spatial_dims:], stride=(8, 8, 1)[-spatial_dims:])\n\n self.proj64 = conv_type(\n in_ch, 1, kernel_size=(1, 1, 1)[-spatial_dims:], stride=1, padding=(1, 1, 0)[-spatial_dims:]\n )\n self.proj32 = conv_type(\n in_ch, 1, kernel_size=(1, 1, 1)[-spatial_dims:], stride=1, padding=(1, 1, 0)[-spatial_dims:]\n )\n self.proj16 = conv_type(\n in_ch, 1, kernel_size=(1, 1, 1)[-spatial_dims:], stride=1, padding=(1, 1, 0)[-spatial_dims:]\n )\n self.proj8 = conv_type(\n in_ch, 1, kernel_size=(1, 1, 1)[-spatial_dims:], stride=1, padding=(1, 1, 0)[-spatial_dims:]\n )\n\n self.upsample_mode = upsample_mode\n self.spatial_dims = spatial_dims\n if self.upsample_mode == \"transpose\":\n conv_trans_type = Conv[Conv.CONVTRANS, spatial_dims]\n self.up64 = conv_trans_type(\n 1,\n 1,\n kernel_size=(64, 64, 1)[-spatial_dims:],\n stride=(64, 64, 1)[-spatial_dims:],\n padding=(64, 64, 0)[-spatial_dims:],\n )\n self.up32 = conv_trans_type(\n 1,\n 1,\n kernel_size=(32, 32, 1)[-spatial_dims:],\n stride=(32, 32, 1)[-spatial_dims:],\n padding=(32, 32, 0)[-spatial_dims:],\n )\n self.up16 = conv_trans_type(\n 1,\n 1,\n kernel_size=(16, 16, 1)[-spatial_dims:],\n stride=(16, 16, 1)[-spatial_dims:],\n padding=(16, 16, 0)[-spatial_dims:],\n )\n self.up8 = conv_trans_type(\n 1,\n 1,\n kernel_size=(8, 8, 1)[-spatial_dims:],\n stride=(8, 8, 1)[-spatial_dims:],\n padding=(8, 8, 0)[-spatial_dims:],\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/ahnet.py_PSP.forward_PSP.forward.return.x": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_PSP.forward_PSP.forward.return.x", "embedding": null, "metadata": {"file_path": "monai/networks/nets/ahnet.py", "file_name": "ahnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 295, "end_line": 316, "span_ids": ["PSP.forward"], "tokens": 261}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class PSP(nn.Module):\n\n def forward(self, x):\n if self.upsample_mode == \"transpose\":\n x64 = self.up64(self.proj64(self.pool64(x)))\n x32 = self.up32(self.proj32(self.pool32(x)))\n x16 = self.up16(self.proj16(self.pool16(x)))\n x8 = self.up8(self.proj8(self.pool8(x)))\n else:\n interpolate_size = tuple(x.size()[2:])\n x64 = F.interpolate(\n self.proj64(self.pool64(x)), size=interpolate_size, mode=self.upsample_mode, align_corners=True,\n )\n x32 = F.interpolate(\n self.proj32(self.pool32(x)), size=interpolate_size, mode=self.upsample_mode, align_corners=True,\n )\n x16 = F.interpolate(\n self.proj16(self.pool16(x)), size=interpolate_size, mode=self.upsample_mode, align_corners=True,\n )\n x8 = F.interpolate(\n self.proj8(self.pool8(x)), size=interpolate_size, mode=self.upsample_mode, align_corners=True,\n )\n x = torch.cat((x64, x32, x16, x8), dim=1)\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/ahnet.py_AHNet_AHNet._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_AHNet_AHNet._", "embedding": null, "metadata": {"file_path": "monai/networks/nets/ahnet.py", "file_name": "ahnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 319, "end_line": 341, "span_ids": ["AHNet"], "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": "class AHNet(nn.Module):\n \"\"\"\n Anisotropic Hybrid Network (AH-Net).\n The code is adapted from lsqshr's original version:\n https://github.com/lsqshr/AH-Net/blob/master/net3d.py\n The model supports 2D or 3D inputs, as for the original 3D version, in order to use pretrained weights\n from 2D FCN/MCFCN, please call the copy_from function.\n To meet to requirements of the structure, the input size of the first ``dim-1`` dimensions should be divided\n by 32 and no less than 128. If you need to use lower sizes, please reduce the largest blocks in PSP\n module and change the ``num_input_features`` in Final module.\n In addition, to utilize the \"transpose\" upsample mode, please ensure that the input size of the first ``dim-1`` dimensions\n should be divided by 128.\n\n Args:\n layers: number of residual blocks for 4 layers of the network (layer1...layer4). Defaults to ``(3, 4, 6, 3)``.\n spatial_dims: spatial dimension of the input data. Defaults to 3.\n out_channels: number of output channels for the network. Defaults to 1.\n upsample_mode: The mode of upsampling manipulations, there are three choices:\n 1) ``transpose``, uses transposed convolution layers.\n 2) ``bilinear``, uses bilinear interpolate.\n 3) ``trilinear``, uses trilinear interpolate.\n Using the last two modes cannot guarantee the model's reproducibility. Defaults to ``trilinear``.\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/ahnet.py_AHNet.__init___AHNet.__init__.for_m_in_self_modules_.if_isinstance_m_conv_ty.elif_isinstance_m_norm_t.m_bias_data_zero__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_AHNet.__init___AHNet.__init__.for_m_in_self_modules_.if_isinstance_m_conv_ty.elif_isinstance_m_norm_t.m_bias_data_zero__", "embedding": null, "metadata": {"file_path": "monai/networks/nets/ahnet.py", "file_name": "ahnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 343, "end_line": 433, "span_ids": ["AHNet.__init__"], "tokens": 1189}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AHNet(nn.Module):\n\n def __init__(\n self,\n layers: tuple = (3, 4, 6, 3),\n spatial_dims: int = 3,\n out_channels: int = 1,\n upsample_mode: str = \"trilinear\",\n ):\n self.inplanes = 64\n super(AHNet, self).__init__()\n\n conv_type = Conv[Conv.CONV, spatial_dims]\n conv_trans_type = Conv[Conv.CONVTRANS, spatial_dims]\n norm_type = Norm[Norm.BATCH, spatial_dims]\n pool_type: Type[Union[nn.MaxPool2d, nn.MaxPool3d]] = Pool[Pool.MAX, spatial_dims]\n relu_type: Type[nn.ReLU] = Act[Act.RELU]\n conv2d_type: Type[nn.Conv2d] = Conv[Conv.CONV, 2]\n norm2d_type: Type[nn.BatchNorm2d] = Norm[Norm.BATCH, 2]\n\n self.conv2d_type = conv2d_type\n self.norm2d_type = norm2d_type\n self.conv_type = conv_type\n self.norm_type = norm_type\n self.relu_type = relu_type\n self.pool_type = pool_type\n self.spatial_dims = spatial_dims\n\n assert spatial_dims == 2 or spatial_dims == 3, \"spatial_dims can only be 2 or 3.\"\n\n self.conv1 = conv_type(\n 1,\n 64,\n kernel_size=(7, 7, 3)[-spatial_dims:],\n stride=(2, 2, 1)[-spatial_dims:],\n padding=(3, 3, 1)[-spatial_dims:],\n bias=False,\n )\n self.pool1 = pool_type(kernel_size=(1, 1, 2)[-spatial_dims:], stride=(1, 1, 2)[-spatial_dims:])\n self.bn0 = norm_type(64)\n self.relu = relu_type(inplace=True)\n if upsample_mode == \"transpose\":\n self.maxpool = pool_type(kernel_size=(2, 2, 2)[-spatial_dims:], stride=2)\n else:\n self.maxpool = pool_type(kernel_size=(3, 3, 3)[-spatial_dims:], stride=2, padding=1)\n\n self.layer1 = self._make_layer(Bottleneck3x3x1, 64, layers[0], stride=1)\n self.layer2 = self._make_layer(Bottleneck3x3x1, 128, layers[1], stride=2)\n self.layer3 = self._make_layer(Bottleneck3x3x1, 256, layers[2], stride=2)\n self.layer4 = self._make_layer(Bottleneck3x3x1, 512, layers[3], stride=2)\n\n # Make the 3D dense decoder layers\n densegrowth = 20\n densebn = 4\n ndenselayer = 3\n\n num_init_features = 64\n noutres1 = 256\n noutres2 = 512\n noutres3 = 1024\n noutres4 = 2048\n\n self.up0 = UpTransition(spatial_dims, noutres4, noutres3, upsample_mode)\n self.dense0 = DenseBlock(spatial_dims, ndenselayer, noutres3, densebn, densegrowth, 0.0)\n noutdense = noutres3 + ndenselayer * densegrowth\n\n self.up1 = UpTransition(spatial_dims, noutdense, noutres2, upsample_mode)\n self.dense1 = DenseBlock(spatial_dims, ndenselayer, noutres2, densebn, densegrowth, 0.0)\n noutdense1 = noutres2 + ndenselayer * densegrowth\n\n self.up2 = UpTransition(spatial_dims, noutdense1, noutres1, upsample_mode)\n self.dense2 = DenseBlock(spatial_dims, ndenselayer, noutres1, densebn, densegrowth, 0.0)\n noutdense2 = noutres1 + ndenselayer * densegrowth\n\n self.trans1 = Projection(spatial_dims, noutdense2, num_init_features)\n self.dense3 = DenseBlock(spatial_dims, ndenselayer, num_init_features, densebn, densegrowth, 0.0)\n noutdense3 = num_init_features + densegrowth * ndenselayer\n\n self.up3 = UpTransition(spatial_dims, noutdense3, num_init_features, upsample_mode)\n self.dense4 = DenseBlock(spatial_dims, ndenselayer, num_init_features, densebn, densegrowth, 0.0)\n noutdense4 = num_init_features + densegrowth * ndenselayer\n\n self.psp = PSP(spatial_dims, noutdense4, upsample_mode)\n self.final = Final(spatial_dims, 4 + noutdense4, out_channels, upsample_mode)\n\n # Initialise parameters\n for m in self.modules():\n if isinstance(m, (conv_type, conv_trans_type)):\n n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels\n m.weight.data.normal_(0, math.sqrt(2.0 / n))\n elif isinstance(m, norm_type):\n m.weight.data.fill_(1)\n m.bias.data.zero_()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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/ahnet.py_AHNet._make_layer_AHNet._make_layer.return.nn_Sequential_layers_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_AHNet._make_layer_AHNet._make_layer.return.nn_Sequential_layers_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/ahnet.py", "file_name": "ahnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 435, "end_line": 459, "span_ids": ["AHNet._make_layer"], "tokens": 244}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class AHNet(nn.Module):\n\n def _make_layer(self, block: Type[Bottleneck3x3x1], planes: int, blocks: int, stride: int = 1,) -> nn.Sequential:\n downsample = None\n if stride != 1 or self.inplanes != planes * block.expansion:\n downsample = nn.Sequential(\n self.conv_type(\n self.inplanes,\n planes * block.expansion,\n kernel_size=1,\n stride=(stride, stride, 1)[: self.spatial_dims],\n bias=False,\n ),\n self.pool_type(\n kernel_size=(1, 1, stride)[: self.spatial_dims], stride=(1, 1, stride)[: self.spatial_dims]\n ),\n self.norm_type(planes * block.expansion),\n )\n\n layers = []\n layers.append(\n block(self.spatial_dims, self.inplanes, planes, (stride, stride, 1)[: self.spatial_dims], downsample)\n )\n self.inplanes = planes * block.expansion\n for _ in range(1, blocks):\n layers.append(block(self.spatial_dims, self.inplanes, planes))\n return nn.Sequential(*layers)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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/ahnet.py_AHNet.forward_AHNet.forward.return.self_final_x_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_AHNet.forward_AHNet.forward.return.self_final_x_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/ahnet.py", "file_name": "ahnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 461, "end_line": 492, "span_ids": ["AHNet.forward"], "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 AHNet(nn.Module):\n\n def forward(self, x):\n x = self.conv1(x)\n x = self.pool1(x)\n x = self.bn0(x)\n x = self.relu(x)\n conv_x = x\n x = self.maxpool(x)\n pool_x = x\n\n fm1 = self.layer1(x)\n fm2 = self.layer2(fm1)\n fm3 = self.layer3(fm2)\n fm4 = self.layer4(fm3)\n\n sum0 = self.up0(fm4) + fm3\n d0 = self.dense0(sum0)\n\n sum1 = self.up1(d0) + fm2\n d1 = self.dense1(sum1)\n\n sum2 = self.up2(d1) + fm1\n d2 = self.dense2(sum2)\n\n sum3 = self.trans1(d2) + pool_x\n d3 = self.dense3(sum3)\n\n sum4 = self.up3(d3) + conv_x\n d4 = self.dense4(sum4)\n\n psp = self.psp(d4)\n x = torch.cat((psp, d4), dim=1)\n return self.final(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/ahnet.py_AHNet.copy_from_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/ahnet.py_AHNet.copy_from_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/ahnet.py", "file_name": "ahnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 494, "end_line": 532, "span_ids": ["copy_conv_param", "copy_bn_param", "AHNet.copy_from"], "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 AHNet(nn.Module):\n\n def copy_from(self, net):\n # This method only supports for 3D AHNet, the input channel should be 1.\n p2d, p3d = next(net.conv1.parameters()), next(self.conv1.parameters())\n\n # From 64x3x7x7 -> 64x3x7x7x1 -> 64x1x7x7x3\n p3d.data = p2d.data.unsqueeze(dim=4).permute(0, 4, 2, 3, 1).clone()\n\n # Copy the initial module BN0\n copy_bn_param(net.bn0, self.bn0)\n\n # Copy layer1 to layer4\n for i in range(1, 5):\n layer_num = \"layer\" + str(i)\n\n layer_2d = []\n layer_3d = []\n for m1 in vars(net)[\"_modules\"][layer_num].modules():\n if isinstance(m1, (self.norm2d_type, self.conv2d_type)):\n layer_2d.append(m1)\n for m2 in vars(self)[\"_modules\"][layer_num].modules():\n if isinstance(m2, (self.norm_type, self.conv_type)):\n layer_3d.append(m2)\n\n for m1, m2 in zip(layer_2d, layer_3d):\n if isinstance(m1, self.conv2d_type):\n copy_conv_param(m1, m2)\n if isinstance(m1, self.norm2d_type):\n copy_bn_param(m1, m2)\n\n\ndef copy_conv_param(module2d, module3d):\n for p2d, p3d in zip(module2d.parameters(), module3d.parameters()):\n p3d.data[:] = p2d.data.unsqueeze(dim=4).clone()[:]\n\n\ndef copy_bn_param(module2d, module3d):\n for p2d, p3d in zip(module2d.parameters(), module3d.parameters()):\n p3d.data[:] = p2d.data[:] # Two parameter gamma and 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/networks/nets/highresnet.py_from_typing_import_Dict__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_Dict__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": 37, "span_ids": ["docstring"], "tokens": 325}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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, Sequence, Union\n\nimport torch\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 Activation, ChannelMatching, Normalisation\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.torch_as_tensor_self_laye": {"__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.torch_as_tensor_self_laye", "embedding": null, "metadata": {"file_path": "monai/networks/nets/highresnet.py", "file_name": "highresnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 40, "end_line": 86, "span_ids": ["ConvNormActi.__init__", "ConvNormActi.forward", "ConvNormActi"], "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 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 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 kernel_size: size of the convolving kernel.\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 \"\"\"\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: torch.Tensor) -> torch.Tensor:\n return torch.as_tensor(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/unet.py_from_typing_import_Sequen_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_from_typing_import_Sequen_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": 100, "span_ids": ["UNet", "UNet.__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 Sequence, Union\n\nimport torch\nimport torch.nn as nn\n\nfrom monai.networks.blocks.convolutions import Convolution, ResidualUnit\nfrom monai.networks.layers.factories import Act, Norm\nfrom monai.networks.layers.simplelayers import SkipConnection\nfrom monai.utils import alias, export\n\n\n@export(\"monai.networks.nets\")\n@alias(\"Unet\")\nclass UNet(nn.Module):\n def __init__(\n self,\n dimensions: int,\n in_channels: int,\n out_channels: int,\n channels: Sequence[int],\n strides: Sequence[int],\n kernel_size: Union[Sequence[int], int] = 3,\n up_kernel_size: Union[Sequence[int], int] = 3,\n num_res_units: int = 0,\n act=Act.PRELU,\n norm=Norm.INSTANCE,\n dropout=0,\n ) -> None:\n \"\"\"\n Args:\n dimensions: number of spatial dimensions.\n in_channels: number of input channels.\n out_channels: number of output channels.\n channels: sequence of channels. Top block first.\n strides: convolution stride.\n kernel_size: convolution kernel size. Defaults to 3.\n up_kernel_size: upsampling convolution kernel size. Defaults to 3.\n num_res_units: number of residual units. Defaults to 0.\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 \"\"\"\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(\n inc: int, outc: int, channels: Sequence[int], strides: Sequence[int], is_top: bool\n ) -> nn.Sequential:\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 Args:\n inc: number of input channels.\n outc: number of output channels.\n channels: sequence of channels. Top block first.\n strides: convolution stride.\n is_top: True if this is the top block.\n \"\"\"\n c = channels[0]\n s = strides[0]\n\n subblock: Union[nn.Sequential, ResidualUnit, Convolution]\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/vnet.py_from_typing_import_Dict__get_acti_layer.return.act_type_act_args_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/vnet.py_from_typing_import_Dict__get_acti_layer.return.act_type_act_args_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/vnet.py", "file_name": "vnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 26, "span_ids": ["get_acti_layer", "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": "from typing import Dict, Optional, Tuple, Type, Union\n\nimport torch\nimport torch.nn as nn\n\nfrom monai.networks.blocks.convolutions import Convolution\nfrom monai.networks.layers.factories import Act, Conv, Dropout, Norm, split_args\n\n\ndef get_acti_layer(act: Union[Tuple[str, Dict], str], nchan: int = 0):\n if act == \"prelu\":\n act = (\"prelu\", {\"num_parameters\": nchan})\n act_name, act_args = split_args(act)\n act_type = Act[act_name]\n return 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/nets/vnet.py_LUConv__make_nconv.return.nn_Sequential_layers_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/vnet.py_LUConv__make_nconv.return.nn_Sequential_layers_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/vnet.py", "file_name": "vnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 29, "end_line": 48, "span_ids": ["LUConv.__init__", "LUConv.forward", "LUConv", "_make_nconv"], "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 LUConv(nn.Module):\n def __init__(self, spatial_dims: int, nchan: int, act: Union[Tuple[str, Dict], str]):\n super(LUConv, self).__init__()\n\n self.act_function = get_acti_layer(act, nchan)\n self.conv_block = Convolution(\n dimensions=spatial_dims, in_channels=nchan, out_channels=nchan, kernel_size=5, act=None, norm=Norm.BATCH,\n )\n\n def forward(self, x):\n out = self.conv_block(x)\n out = self.act_function(out)\n return out\n\n\ndef _make_nconv(spatial_dims: int, nchan: int, depth: int, act: Union[Tuple[str, Dict], str]):\n layers = []\n for _ in range(depth):\n layers.append(LUConv(spatial_dims, nchan, act))\n return nn.Sequential(*layers)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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/vnet.py_InputTransition_InputTransition.forward.return.out": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/vnet.py_InputTransition_InputTransition.forward.return.out", "embedding": null, "metadata": {"file_path": "monai/networks/nets/vnet.py", "file_name": "vnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 51, "end_line": 70, "span_ids": ["InputTransition.forward", "InputTransition.__init__", "InputTransition"], "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": "class InputTransition(nn.Module):\n def __init__(self, spatial_dims: int, in_channels: int, out_channels: int, act: Union[Tuple[str, Dict], str]):\n super(InputTransition, self).__init__()\n\n if 16 % in_channels != 0:\n raise ValueError(f\"16 should be divided by in_channels, got in_channels={in_channels}.\")\n\n self.spatial_dims = spatial_dims\n self.in_channels = in_channels\n self.act_function = get_acti_layer(act, 16)\n self.conv_block = Convolution(\n dimensions=spatial_dims, in_channels=in_channels, out_channels=16, kernel_size=5, act=None, norm=Norm.BATCH,\n )\n\n def forward(self, x):\n out = self.conv_block(x)\n repeat_num = 16 // self.in_channels\n x16 = x.repeat([1, repeat_num, 1, 1, 1][: self.spatial_dims + 2])\n out = self.act_function(torch.add(out, x16))\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/nets/vnet.py_DownTransition_DownTransition.forward.return.out": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/vnet.py_DownTransition_DownTransition.forward.return.out", "embedding": null, "metadata": {"file_path": "monai/networks/nets/vnet.py", "file_name": "vnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 73, "end_line": 105, "span_ids": ["DownTransition.__init__", "DownTransition", "DownTransition.forward"], "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": "class DownTransition(nn.Module):\n def __init__(\n self,\n spatial_dims: int,\n in_channels: int,\n nconvs: int,\n act: Union[Tuple[str, Dict], str],\n dropout_prob: Optional[float] = None,\n dropout_dim: int = 3,\n ):\n super(DownTransition, self).__init__()\n\n conv_type: Type[Union[nn.Conv2d, nn.Conv3d]] = Conv[Conv.CONV, spatial_dims]\n norm_type: Type[Union[nn.BatchNorm2d, nn.BatchNorm3d]] = Norm[Norm.BATCH, spatial_dims]\n dropout_type: Type[Union[nn.Dropout, nn.Dropout2d, nn.Dropout3d]] = Dropout[Dropout.DROPOUT, dropout_dim]\n\n out_channels = 2 * in_channels\n self.down_conv = conv_type(in_channels, out_channels, kernel_size=2, stride=2)\n self.bn1 = norm_type(out_channels)\n self.act_function1 = get_acti_layer(act, out_channels)\n self.act_function2 = get_acti_layer(act, out_channels)\n self.ops = _make_nconv(spatial_dims, out_channels, nconvs, act)\n self.dropout = dropout_type(dropout_prob) if dropout_prob is not None else None\n\n def forward(self, x):\n down = self.act_function1(self.bn1(self.down_conv(x)))\n if self.dropout is not None:\n out = self.dropout(down)\n else:\n out = down\n out = self.ops(out)\n out = self.act_function2(torch.add(out, down))\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/nets/vnet.py_UpTransition_UpTransition.forward.return.out": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/vnet.py_UpTransition_UpTransition.forward.return.out", "embedding": null, "metadata": {"file_path": "monai/networks/nets/vnet.py", "file_name": "vnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 108, "end_line": 143, "span_ids": ["UpTransition.__init__", "UpTransition", "UpTransition.forward"], "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 UpTransition(nn.Module):\n def __init__(\n self,\n spatial_dims: int,\n in_channels: int,\n out_channels: int,\n nconvs: int,\n act: Union[Tuple[str, Dict], str],\n dropout_prob: Optional[float] = None,\n dropout_dim: int = 3,\n ):\n super(UpTransition, self).__init__()\n\n conv_trans_type: Type[Union[nn.ConvTranspose2d, nn.ConvTranspose3d]] = Conv[Conv.CONVTRANS, spatial_dims]\n norm_type: Type[Union[nn.BatchNorm2d, nn.BatchNorm3d]] = Norm[Norm.BATCH, spatial_dims]\n dropout_type: Type[Union[nn.Dropout, nn.Dropout2d, nn.Dropout3d]] = Dropout[Dropout.DROPOUT, dropout_dim]\n\n self.up_conv = conv_trans_type(in_channels, out_channels // 2, kernel_size=2, stride=2)\n self.bn1 = norm_type(out_channels // 2)\n self.dropout = dropout_type(dropout_prob) if dropout_prob is not None else None\n self.dropout2 = dropout_type(0.5)\n self.act_function1 = get_acti_layer(act, out_channels // 2)\n self.act_function2 = get_acti_layer(act, out_channels)\n self.ops = _make_nconv(spatial_dims, out_channels, nconvs, act)\n\n def forward(self, x, skipx):\n if self.dropout is not None:\n out = self.dropout(x)\n else:\n out = x\n skipxdo = self.dropout2(skipx)\n out = self.act_function1(self.bn1(self.up_conv(out)))\n xcat = torch.cat((out, skipxdo), 1)\n out = self.ops(xcat)\n out = self.act_function2(torch.add(out, xcat))\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/nets/vnet.py_OutputTransition_OutputTransition.forward.return.out": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/vnet.py_OutputTransition_OutputTransition.forward.return.out", "embedding": null, "metadata": {"file_path": "monai/networks/nets/vnet.py", "file_name": "vnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 146, "end_line": 168, "span_ids": ["OutputTransition.__init__", "OutputTransition.forward", "OutputTransition"], "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 OutputTransition(nn.Module):\n def __init__(self, spatial_dims: int, in_channels: int, out_channels: int, act: Union[Tuple[str, Dict], str]):\n super(OutputTransition, self).__init__()\n\n conv_type: Type[Union[nn.Conv2d, nn.Conv3d]] = Conv[Conv.CONV, spatial_dims]\n\n self.act_function1 = get_acti_layer(act, out_channels)\n self.conv_block = Convolution(\n dimensions=spatial_dims,\n in_channels=in_channels,\n out_channels=out_channels,\n kernel_size=5,\n act=None,\n norm=Norm.BATCH,\n )\n self.conv2 = conv_type(out_channels, out_channels, kernel_size=1)\n\n def forward(self, x):\n # convolve 32 down to 2 channels\n out = self.conv_block(x)\n out = self.act_function1(out)\n out = self.conv2(out)\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/nets/vnet.py_VNet_VNet.__init__.self.out_tr.OutputTransition_spatial_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/vnet.py_VNet_VNet.__init__.self.out_tr.OutputTransition_spatial_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/vnet.py", "file_name": "vnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 171, "end_line": 215, "span_ids": ["VNet", "VNet.__init__"], "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": "class VNet(nn.Module):\n \"\"\"\n V-Net: Fully Convolutional Neural Networks for Volumetric Medical Image Segmentation\n The official Caffe implementation is available in:\n https://github.com/faustomilletari/VNet\n This code is adapted from:\n https://github.com/mattmacy/vnet.pytorch/blob/master/vnet.py\n The model supports 2D or 3D inputs.\n\n Args:\n spatial_dims: spatial dimension of the input data. Defaults to 3.\n in_channels: number of input channels for the network. Defaults to 1.\n The value should meet the condition that ``16 % in_channels == 0``.\n out_channels: number of output channels for the network. Defaults to 1.\n act: activation type in the network. Defaults to ``(\"elu\", {\"inplace\": True})``.\n dropout_prob: dropout ratio. Defaults to 0.5. Defaults to 3.\n dropout_dim: determine the dimensions of dropout. Defaults to 3.\n When dropout_dim = 1, randomly zeroes some of the elements for each channel.\n When dropout_dim = 2, Randomly zero out entire channels (a channel is a 2D feature map).\n When dropout_dim = 3, Randomly zero out entire channels (a channel is a 3D feature map).\n \"\"\"\n\n def __init__(\n self,\n spatial_dims: int = 3,\n in_channels: int = 1,\n out_channels: int = 1,\n act: Union[Tuple[str, Dict], str] = (\"elu\", {\"inplace\": True}),\n dropout_prob: float = 0.5,\n dropout_dim: int = 3,\n ):\n super().__init__()\n\n assert spatial_dims == 2 or spatial_dims == 3, \"spatial_dims can only be 2 or 3.\"\n\n self.in_tr = InputTransition(spatial_dims, in_channels, 16, act)\n self.down_tr32 = DownTransition(spatial_dims, 16, 1, act)\n self.down_tr64 = DownTransition(spatial_dims, 32, 2, act)\n self.down_tr128 = DownTransition(spatial_dims, 64, 3, act, dropout_prob=dropout_prob)\n self.down_tr256 = DownTransition(spatial_dims, 128, 2, act, dropout_prob=dropout_prob)\n self.up_tr256 = UpTransition(spatial_dims, 256, 256, 2, act, dropout_prob=dropout_prob)\n self.up_tr128 = UpTransition(spatial_dims, 256, 128, 2, act, dropout_prob=dropout_prob)\n self.up_tr64 = UpTransition(spatial_dims, 128, 64, 1, act)\n self.up_tr32 = UpTransition(spatial_dims, 64, 32, 1, act)\n self.out_tr = OutputTransition(spatial_dims, 32, out_channels, 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/vnet.py_VNet.forward_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/nets/vnet.py_VNet.forward_", "embedding": null, "metadata": {"file_path": "monai/networks/nets/vnet.py", "file_name": "vnet.py", "file_type": "text/x-python", "category": "implementation", "start_line": 217, "end_line": 229, "span_ids": ["VNet.forward"], "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 VNet(nn.Module):\n\n def forward(self, x):\n out16 = self.in_tr(x)\n out32 = self.down_tr32(out16)\n out64 = self.down_tr64(out32)\n out128 = self.down_tr128(out64)\n out256 = self.down_tr256(out128)\n x = self.up_tr256(out256, out128)\n x = self.up_tr128(x, out64)\n x = self.up_tr64(x, out32)\n x = self.up_tr32(x, out16)\n x = self.out_tr(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/utils.py_normal_init_normal_init.if_getattr_m_weight_N.elif_cname_find_BatchNor.nn_init_constant__m_bias_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_normal_init_normal_init.if_getattr_m_weight_N.elif_cname_find_BatchNor.nn_init_constant__m_bias_", "embedding": null, "metadata": {"file_path": "monai/networks/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 152, "end_line": 170, "span_ids": ["normal_init"], "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": "def normal_init(\n m, std: float = 0.02, normal_func: Callable[[torch.Tensor, float, float], Any] = torch.nn.init.normal_\n) -> None:\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/networks/utils.py_icnr_init_icnr_init.conv_weight_data_copy__ke": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_icnr_init_icnr_init.conv_weight_data_copy__ke", "embedding": null, "metadata": {"file_path": "monai/networks/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 173, "end_line": 190, "span_ids": ["icnr_init"], "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 icnr_init(conv, upsample_factor, init=nn.init.kaiming_normal_):\n \"\"\"\n ICNR initialization for 2D/3D kernels adapted from Aitken et al.,2017 , \"Checkerboard artifact free\n sub-pixel convolution\".\n \"\"\"\n out_channels, in_channels, *dims = conv.weight.shape\n scale_factor = upsample_factor ** len(dims)\n\n oc2 = int(out_channels / scale_factor)\n\n kernel = torch.zeros([oc2, in_channels] + dims)\n kernel = init(kernel)\n kernel = kernel.transpose(0, 1)\n kernel = kernel.reshape(oc2, in_channels, -1)\n kernel = kernel.repeat(1, 1, scale_factor)\n kernel = kernel.reshape([in_channels, out_channels] + dims)\n kernel = kernel.transpose(0, 1)\n conv.weight.data.copy_(kernel)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_pixelshuffle_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/networks/utils.py_pixelshuffle_", "embedding": null, "metadata": {"file_path": "monai/networks/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 193, "end_line": 227, "span_ids": ["pixelshuffle"], "tokens": 356}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 pixelshuffle(x: torch.Tensor, spatial_dims: int, scale_factor: int) -> torch.Tensor:\n \"\"\"\n Apply pixel shuffle to the tensor `x` with spatial dimensions `spatial_dims` and scaling factor `scale_factor`.\n See Aitken et al.,2017 , \"Checkerboard artifact free sub-pixel convolution\".\n\n Args:\n x: Input tensor\n spatial_dims: number of spatial dimensions, typically 2 or 3 for 2D or 3D\n scale_factor: factor to rescale the spatial dimensions by, must be >=1\n\n Returns:\n Reshuffled version of `x`.\n\n Raises:\n ValueError: When input channels of `x` are not divisible by (scale_factor ** spatial_dims)\n \"\"\"\n\n dim, factor = spatial_dims, scale_factor\n input_size = list(x.size())\n batch_size, channels = input_size[:2]\n\n if channels % (factor ** dim) != 0:\n raise ValueError(\"PixelShuffle expects input channel to be divisible by (scale_factor ** spatial_dims).\")\n\n org_channels = channels // (factor ** dim)\n output_size = [batch_size, org_channels] + [dim * factor for dim in input_size[2:]]\n\n indices = list(range(2, 2 + 2 * dim))\n indices_factor, indices_dim = indices[:dim], indices[dim:]\n indices = [j for i in zip(indices_dim, indices_factor) for j in i]\n\n x = x.reshape(batch_size, org_channels, *([factor] * dim + input_size[2:]))\n x = x.permute([0, 1] + indices).reshape(output_size)\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/transforms/__init__.py_from_adaptors_import__": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/__init__.py_from_adaptors_import__", "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 .adaptors import *\nfrom .compose import *\nfrom .croppad.array import *\nfrom .croppad.dictionary import *\nfrom .intensity.array import *\nfrom .intensity.dictionary import *\nfrom .io.array import *\nfrom .io.dictionary import *\nfrom .post.array import *\nfrom .post.dictionary import *\nfrom .spatial.array import *\nfrom .spatial.dictionary import *\nfrom .utility.array import *\nfrom .utility.dictionary 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_typing_import_Callab_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_typing_import_Callab_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": 145, "span_ids": ["adaptor", "imports"], "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": "from typing import Callable\n\nfrom 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 TypeError(f\"'{variable_name}' must be None or one of {types} but is {type(variable)}\")\n\n def must_be_types(variable_name, variable, types):\n if not isinstance(variable, types):\n raise TypeError(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/compose.py_warnings_Transform._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/compose.py_warnings_Transform._", "embedding": null, "metadata": {"file_path": "monai/transforms/compose.py", "file_name": "compose.py", "file_type": "text/x-python", "category": "implementation", "start_line": 15, "end_line": 43, "span_ids": ["Transform", "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 warnings\nfrom abc import ABC, abstractmethod\nfrom typing import Any, Callable, Hashable, Optional, Sequence, Tuple, Union\n\nimport numpy as np\n\nfrom monai.config import KeysCollection\nfrom monai.transforms.utils import apply_transform\nfrom monai.utils import ensure_tuple, get_seed\n\n\nclass Transform(ABC):\n \"\"\"\n An abstract class of a ``Transform``.\n A transform is callable that processes ``data``.\n\n It could be stateful and may modify ``data`` in place,\n the implementation should be aware of:\n\n #. thread safety when mutating its own states.\n When used from a multi-process context, transform's instance variables are read-only.\n #. ``data`` content unused by this transform may still be used in the\n subsequent transforms in a composed transform.\n #. storing too much information in ``data`` may not scale.\n\n See Also\n\n :py:class:`monai.transforms.Compose`\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/compose.py_MapTransform_MapTransform.__init__.for_key_in_self_keys_.if_not_isinstance_key_Ha.raise_TypeError_f_keys_mu": {"__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_TypeError_f_keys_mu", "embedding": null, "metadata": {"file_path": "monai/transforms/compose.py", "file_name": "compose.py", "file_type": "text/x-python", "category": "implementation", "start_line": 236, "end_line": 267, "span_ids": ["MapTransform", "MapTransform.__init__"], "tokens": 276}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 Raises:\n ValueError: When ``keys`` is an empty iterable.\n TypeError: When ``keys`` type is not in ``Union[Hashable, Iterable[Hashable]]``.\n\n \"\"\"\n\n def __init__(self, keys: KeysCollection) -> None:\n self.keys: Tuple[Hashable, ...] = ensure_tuple(keys)\n if not self.keys:\n raise ValueError(\"keys must be non empty.\")\n for key in self.keys:\n if not isinstance(key, Hashable):\n raise TypeError(f\"keys must be one of (Hashable, Iterable[Hashable]) but is {type(keys).__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/transforms/croppad/array.py_from_typing_import_Any_C_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_Any_C_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 Any, Callable, List, Optional, Sequence, Tuple, Union\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 Method, NumpyPadMode, ensure_tuple, fall_back_tuple\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_RandCropByPosNegLabel_RandCropByPosNegLabel.__init__.self.centers.None": {"__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.__init__.self.centers.None", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 406, "end_line": 461, "span_ids": ["RandCropByPosNegLabel.__init__", "RandCropByPosNegLabel"], "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": "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 with `neg` together to calculate the ratio ``pos / (pos + neg)`` for the probability\n to pick a foreground voxel as a center rather than a background voxel.\n neg: used with `pos` together to calculate the ratio ``pos / (pos + neg)`` for the probability\n to pick a 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 Raises:\n ValueError: When ``pos`` or ``neg`` are negative.\n ValueError: When ``pos=0`` and ``neg=0``. Incompatible values.\n\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 = ensure_tuple(spatial_size)\n self.label = label\n if pos < 0 or neg < 0:\n raise ValueError(f\"pos and neg must be nonnegative, got pos={pos} neg={neg}.\")\n if pos + neg == 0:\n raise ValueError(\"Incompatible values: pos=0 and neg=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: Optional[List[List[np.ndarray]]] = 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_RandCropByPosNegLabel.randomize_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/croppad/array.py_RandCropByPosNegLabel.randomize_", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 463, "end_line": 489, "span_ids": ["RandCropByPosNegLabel.__call__", "RandCropByPosNegLabel.randomize"], "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": "class RandCropByPosNegLabel(Randomizable, Transform):\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 )\n\n def __call__(\n self, img: np.ndarray, label: Optional[np.ndarray] = None, image: Optional[np.ndarray] = None,\n ) -> List[np.ndarray]:\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_Any_C_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_Any_C_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": 29, "span_ids": ["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": "from typing import Any, Callable, Dict, Hashable, List, Mapping, Optional, Sequence, Tuple, Union\n\nimport numpy as np\n\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 BorderPad, CenterSpatialCrop, DivisiblePad, SpatialCrop, SpatialPad\nfrom monai.transforms.utils import generate_pos_neg_label_crop_centers, generate_spatial_bounding_box\nfrom monai.utils import Method, NumpyPadMode, ensure_tuple, ensure_tuple_rep, fall_back_tuple\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_RandSpatialCropd.randomize_RandSpatialCropd.randomize.if_self_random_center_.self._slices._slice_None_get_rand": {"__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.randomize.if_self_random_center_.self._slices._slice_None_get_rand", "embedding": null, "metadata": {"file_path": "monai/transforms/croppad/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 240, "end_line": 246, "span_ids": ["RandSpatialCropd.randomize"], "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 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)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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.__call___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.__call___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": 248, "end_line": 258, "span_ids": ["RandSpatialCropd.__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 RandSpatialCropd(Randomizable, MapTransform):\n\n def __call__(self, data: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\n d = dict(data)\n self.randomize(d[self.keys[0]].shape[1:]) # image shape from the first data key\n assert self._size is not None\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/intensity/array.py_from_collections_abc_impo_RandGaussianNoise.__call__.return.img_self__noise_astype_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_from_collections_abc_impo_RandGaussianNoise.__call__.return.img_self__noise_astype_", "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": 56, "span_ids": ["RandGaussianNoise.randomize", "RandGaussianNoise.__init__", "RandGaussianNoise", "docstring", "RandGaussianNoise.__call__"], "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": "from collections.abc import Iterable\nfrom typing import Any, Optional, Sequence, Tuple, Union\nfrom warnings import warn\n\nimport numpy as np\nimport torch\n\nfrom monai.networks.layers import GaussianFilter\nfrom monai.transforms.compose import Randomizable, Transform\nfrom monai.transforms.utils import rescale_array\nfrom monai.utils import ensure_tuple_size\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: np.ndarray) -> np.ndarray:\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n self.randomize(img.shape)\n assert self._noise is not None\n return img + self._noise.astype(img.dtype) if self._do_transform else 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_ShiftIntensity_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_ShiftIntensity_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": 59, "end_line": 110, "span_ids": ["RandShiftIntensity.randomize", "RandShiftIntensity.__init__", "ShiftIntensity.__call__", "RandShiftIntensity", "ShiftIntensity.__init__", "ShiftIntensity", "RandShiftIntensity.__call__"], "tokens": 387}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class 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: np.ndarray) -> np.ndarray:\n \"\"\"\n Apply the transform to `img`.\n \"\"\"\n return (img + self.offset).astype(img.dtype)\n\n\nclass 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) -> None:\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: np.ndarray) -> np.ndarray:\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.__init__.self.factor.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.__init__.self.factor.factor", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 113, "end_line": 130, "span_ids": ["ScaleIntensity", "ScaleIntensity.__init__"], "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": "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", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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.__call___ScaleIntensity.__call__.if_self_minv_is_not_None_.else_.raise_ValueError_Incompa": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_ScaleIntensity.__call___ScaleIntensity.__call__.if_self_minv_is_not_None_.else_.raise_ValueError_Incompa", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 132, "end_line": 145, "span_ids": ["ScaleIntensity.__call__"], "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 ScaleIntensity(Transform):\n\n def __call__(self, img: np.ndarray) -> np.ndarray:\n \"\"\"\n Apply the transform to `img`.\n\n Raises:\n ValueError: When ``self.minv=None`` or ``self.maxv=None`` and ``self.factor=None``. Incompatible values.\n\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 elif self.factor is not None:\n return (img * (1 + self.factor)).astype(img.dtype)\n else:\n raise ValueError(\"Incompatible values: minv=None or maxv=None and factor=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/intensity/array.py_MaskIntensity_MaskIntensity.__init__.self.mask_data.mask_data": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_MaskIntensity_MaskIntensity.__init__.self.mask_data.mask_data", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 454, "end_line": 470, "span_ids": ["MaskIntensity.__init__", "MaskIntensity"], "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": "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) -> None:\n self.mask_data = 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/array.py_MaskIntensity.__call___MaskIntensity.__call__.return.img_mask_data_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_MaskIntensity.__call___MaskIntensity.__call__.return.img_mask_data_", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 472, "end_line": 491, "span_ids": ["MaskIntensity.__call__"], "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 MaskIntensity(Transform):\n\n def __call__(self, img: np.ndarray, mask_data: Optional[np.ndarray] = None) -> np.ndarray:\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 Raises:\n ValueError: When ``mask_data`` and ``img`` channels differ and ``mask_data`` is not single channel.\n\n \"\"\"\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 ValueError(\n \"When mask_data is not single channel, mask_data channels must match img, \"\n f\"got img={img.shape[0]} mask_data={mask_data_.shape[0]}.\"\n )\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/array.py_GaussianSmooth_GaussianSmooth.__call__.return.gaussian_filter_input_dat": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_GaussianSmooth_GaussianSmooth.__call__.return.gaussian_filter_input_dat", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 494, "end_line": 512, "span_ids": ["GaussianSmooth.__call__", "GaussianSmooth", "GaussianSmooth.__init__"], "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 GaussianSmooth(Transform):\n \"\"\"\n Apply Gaussian smooth to the input data based on specified `sigma` parameter.\n A default value `sigma=1.0` is provided for reference.\n\n Args:\n sigma: if a list of values, must match the count of spatial dimensions of input data,\n and apply every value in the list to 1 spatial dimension. if only 1 value provided,\n use it for all spatial dimensions.\n\n \"\"\"\n\n def __init__(self, sigma: Union[Sequence[float], float] = 1.0) -> None:\n self.sigma = sigma\n\n def __call__(self, img: np.ndarray) -> np.ndarray:\n gaussian_filter = GaussianFilter(img.ndim - 1, self.sigma)\n input_data = torch.as_tensor(np.ascontiguousarray(img), dtype=torch.float).unsqueeze(0)\n return gaussian_filter(input_data).squeeze(0).detach().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/intensity/array.py_RandGaussianSmooth_RandGaussianSmooth.__call__.return.GaussianSmooth_sigma_sigm": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_RandGaussianSmooth_RandGaussianSmooth.__call__.return.GaussianSmooth_sigma_sigm", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 515, "end_line": 551, "span_ids": ["RandGaussianSmooth.__call__", "RandGaussianSmooth.randomize", "RandGaussianSmooth", "RandGaussianSmooth.__init__"], "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 RandGaussianSmooth(Randomizable, Transform):\n \"\"\"\n Apply Gaussian smooth to the input data based on randomly selected `sigma` parameters.\n\n Args:\n sigma_x: randomly select sigma value for the first spatial dimension.\n sigma_y: randomly select sigma value for the second spatial dimension if have.\n sigma_z: randomly select sigma value for the third spatial dimension if have.\n prob: probability of Gaussian smooth.\n\n \"\"\"\n\n def __init__(\n self,\n sigma_x: Tuple[float, float] = (0.25, 1.5),\n sigma_y: Tuple[float, float] = (0.25, 1.5),\n sigma_z: Tuple[float, float] = (0.25, 1.5),\n prob: float = 0.1,\n ) -> None:\n self.sigma_x = sigma_x\n self.sigma_y = sigma_y\n self.sigma_z = sigma_z\n self.prob = prob\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 self.x = self.R.uniform(low=self.sigma_x[0], high=self.sigma_x[1])\n self.y = self.R.uniform(low=self.sigma_y[0], high=self.sigma_y[1])\n self.z = self.R.uniform(low=self.sigma_z[0], high=self.sigma_z[1])\n\n def __call__(self, img: np.ndarray) -> np.ndarray:\n self.randomize()\n if not self._do_transform:\n return img\n sigma = ensure_tuple_size(tup=(self.x, self.y, self.z), dim=img.ndim - 1)\n return GaussianSmooth(sigma=sigma)(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_GaussianSharpen_GaussianSharpen.__init__.self.alpha.alpha": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_GaussianSharpen_GaussianSharpen.__init__.self.alpha.alpha", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 554, "end_line": 587, "span_ids": ["GaussianSharpen", "GaussianSharpen.__init__"], "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 GaussianSharpen(Transform):\n \"\"\"\n Sharpen images using the Gaussian Blur filter.\n Referring to: http://scipy-lectures.org/advanced/image_processing/auto_examples/plot_sharpen.html.\n The algorithm is shown as below\n\n .. code-block:: python\n\n blurred_f = gaussian_filter(img, sigma1)\n filter_blurred_f = gaussian_filter(blurred_f, sigma2)\n img = blurred_f + alpha * (blurred_f - filter_blurred_f)\n\n A set of default values `sigma1=3.0`, `sigma2=1.0` and `alpha=30.0` is provide for reference.\n\n Args:\n sigma1: sigma parameter for the first gaussian kernel. if a list of values, must match the count\n of spatial dimensions of input data, and apply every value in the list to 1 spatial dimension.\n if only 1 value provided, use it for all spatial dimensions.\n sigma2: sigma parameter for the second gaussian kernel. if a list of values, must match the count\n of spatial dimensions of input data, and apply every value in the list to 1 spatial dimension.\n if only 1 value provided, use it for all spatial dimensions.\n alpha: weight parameter to compute the final result.\n\n \"\"\"\n\n def __init__(\n self,\n sigma1: Union[Sequence[float], float] = 3.0,\n sigma2: Union[Sequence[float], float] = 1.0,\n alpha: float = 30.0,\n ) -> None:\n self.sigma1 = sigma1\n self.sigma2 = sigma2\n self.alpha = alpha", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_GaussianSharpen.__call___GaussianSharpen.__call__.return._blurred_f_self_alpha_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_GaussianSharpen.__call___GaussianSharpen.__call__.return._blurred_f_self_alpha_", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 589, "end_line": 595, "span_ids": ["GaussianSharpen.__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 GaussianSharpen(Transform):\n\n def __call__(self, img: np.ndarray) -> np.ndarray:\n gaussian_filter1 = GaussianFilter(img.ndim - 1, self.sigma1)\n gaussian_filter2 = GaussianFilter(img.ndim - 1, self.sigma2)\n input_data = torch.as_tensor(np.ascontiguousarray(img), dtype=torch.float).unsqueeze(0)\n blurred_f = gaussian_filter1(input_data)\n filter_blurred_f = gaussian_filter2(blurred_f)\n return (blurred_f + self.alpha * (blurred_f - filter_blurred_f)).squeeze(0).detach().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/intensity/array.py_RandGaussianSharpen_RandGaussianSharpen.__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/intensity/array.py_RandGaussianSharpen_RandGaussianSharpen.__init__.self._do_transform.False", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 598, "end_line": 637, "span_ids": ["RandGaussianSharpen", "RandGaussianSharpen.__init__"], "tokens": 546}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class RandGaussianSharpen(Randomizable, Transform):\n \"\"\"\n Sharpen images using the Gaussian Blur filter based on randomly selected `sigma1`, `sigma2` and `alpha`.\n The algorithm is :py:class:`monai.transforms.GaussianSharpen`.\n\n Args:\n sigma1_x: randomly select sigma value for the first spatial dimension of first gaussian kernel.\n sigma1_y: randomly select sigma value for the second spatial dimension(if have) of first gaussian kernel.\n sigma1_z: randomly select sigma value for the third spatial dimension(if have) of first gaussian kernel.\n sigma2_x: randomly select sigma value for the first spatial dimension of second gaussian kernel.\n if only 1 value `X` provided, it must be smaller than `sigma1_x` and randomly select from [X, sigma1_x].\n sigma2_y: randomly select sigma value for the second spatial dimension(if have) of second gaussian kernel.\n if only 1 value `Y` provided, it must be smaller than `sigma1_y` and randomly select from [Y, sigma1_y].\n sigma2_z: randomly select sigma value for the third spatial dimension(if have) of second gaussian kernel.\n if only 1 value `Z` provided, it must be smaller than `sigma1_z` and randomly select from [Z, sigma1_z].\n alpha: randomly select weight parameter to compute the final result.\n prob: probability of Gaussian sharpen.\n\n \"\"\"\n\n def __init__(\n self,\n sigma1_x: Tuple[float, float] = (0.5, 1.0),\n sigma1_y: Tuple[float, float] = (0.5, 1.0),\n sigma1_z: Tuple[float, float] = (0.5, 1.0),\n sigma2_x: Union[Tuple[float, float], float] = 0.5,\n sigma2_y: Union[Tuple[float, float], float] = 0.5,\n sigma2_z: Union[Tuple[float, float], float] = 0.5,\n alpha: Tuple[float, float] = (10.0, 30.0),\n prob: float = 0.1,\n ) -> None:\n self.sigma1_x = sigma1_x\n self.sigma1_y = sigma1_y\n self.sigma1_z = sigma1_z\n self.sigma2_x = sigma2_x\n self.sigma2_y = sigma2_y\n self.sigma2_z = sigma2_z\n self.alpha = alpha\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/intensity/array.py_RandGaussianSharpen.randomize_RandGaussianSharpen.randomize.self.a.self_R_uniform_low_self_a": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_RandGaussianSharpen.randomize_RandGaussianSharpen.randomize.self.a.self_R_uniform_low_self_a", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 639, "end_line": 650, "span_ids": ["RandGaussianSharpen.randomize"], "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": "class RandGaussianSharpen(Randomizable, Transform):\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self._do_transform = self.R.random_sample() < self.prob\n self.x1 = self.R.uniform(low=self.sigma1_x[0], high=self.sigma1_x[1])\n self.y1 = self.R.uniform(low=self.sigma1_y[0], high=self.sigma1_y[1])\n self.z1 = self.R.uniform(low=self.sigma1_z[0], high=self.sigma1_z[1])\n sigma2_x = (self.sigma2_x, self.x1) if not isinstance(self.sigma2_x, Iterable) else self.sigma2_x\n sigma2_y = (self.sigma2_y, self.y1) if not isinstance(self.sigma2_y, Iterable) else self.sigma2_y\n sigma2_z = (self.sigma2_z, self.z1) if not isinstance(self.sigma2_z, Iterable) else self.sigma2_z\n self.x2 = self.R.uniform(low=sigma2_x[0], high=sigma2_x[1])\n self.y2 = self.R.uniform(low=sigma2_y[0], high=sigma2_y[1])\n self.z2 = self.R.uniform(low=sigma2_z[0], high=sigma2_z[1])\n self.a = self.R.uniform(low=self.alpha[0], high=self.alpha[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/intensity/array.py_RandGaussianSharpen.__call___": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/array.py_RandGaussianSharpen.__call___", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 652, "end_line": 659, "span_ids": ["RandGaussianSharpen.__call__"], "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 RandGaussianSharpen(Randomizable, Transform):\n\n def __call__(self, img: np.ndarray) -> np.ndarray:\n self.randomize()\n if not self._do_transform:\n return img\n sigma1 = ensure_tuple_size(tup=(self.x1, self.y1, self.z1), dim=img.ndim - 1)\n sigma2 = ensure_tuple_size(tup=(self.x2, self.y2, self.z2), dim=img.ndim - 1)\n return GaussianSharpen(sigma1=sigma1, sigma2=sigma2, alpha=self.a)(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/dictionary.py_from_collections_abc_impo_from_monai_utils_import_e": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_from_collections_abc_impo_from_monai_utils_import_e", "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": 37, "span_ids": ["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": "from collections.abc import Iterable\nfrom typing import Any, Dict, Hashable, Mapping, Optional, Sequence, Tuple, Union\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 AdjustContrast,\n GaussianSharpen,\n GaussianSmooth,\n MaskIntensity,\n NormalizeIntensity,\n ScaleIntensity,\n ScaleIntensityRange,\n ScaleIntensityRangePercentiles,\n ShiftIntensity,\n ThresholdIntensity,\n)\nfrom monai.utils import ensure_tuple_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/intensity/dictionary.py_RandGaussianNoised_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_RandGaussianNoised_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": 40, "end_line": 77, "span_ids": ["RandGaussianNoised.__call__", "RandGaussianNoised.randomize", "RandGaussianNoised", "RandGaussianNoised.__init__"], "tokens": 379}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class 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 = ensure_tuple_size(mean, len(self.keys))\n self.std = std\n self._do_transform = False\n self._noise: Optional[np.ndarray] = 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: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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 assert self._noise is not None\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_GaussianSmoothd_GaussianSmoothd.__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_GaussianSmoothd_GaussianSmoothd.__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": 429, "end_line": 450, "span_ids": ["GaussianSmoothd", "GaussianSmoothd.__call__", "GaussianSmoothd.__init__"], "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 GaussianSmoothd(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.GaussianSmooth`.\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n sigma: if a list of values, must match the count of spatial dimensions of input data,\n and apply every value in the list to 1 spatial dimension. if only 1 value provided,\n use it for all spatial dimensions.\n\n \"\"\"\n\n def __init__(self, keys: KeysCollection, sigma: Union[Sequence[float], float]) -> None:\n super().__init__(keys)\n self.converter = GaussianSmooth(sigma)\n\n def __call__(self, data: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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_RandGaussianSmoothd_RandGaussianSmoothd.__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_RandGaussianSmoothd_RandGaussianSmoothd.__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": 453, "end_line": 496, "span_ids": ["RandGaussianSmoothd.__init__", "RandGaussianSmoothd", "RandGaussianSmoothd.randomize", "RandGaussianSmoothd.__call__"], "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": "class RandGaussianSmoothd(Randomizable, MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.GaussianSmooth`.\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n sigma_x: randomly select sigma value for the first spatial dimension.\n sigma_y: randomly select sigma value for the second spatial dimension if have.\n sigma_z: randomly select sigma value for the third spatial dimension if have.\n prob: probability of Gaussian smooth.\n\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n sigma_x: Tuple[float, float] = (0.25, 1.5),\n sigma_y: Tuple[float, float] = (0.25, 1.5),\n sigma_z: Tuple[float, float] = (0.25, 1.5),\n prob: float = 0.1,\n ) -> None:\n super().__init__(keys)\n self.sigma_x = sigma_x\n self.sigma_y = sigma_y\n self.sigma_z = sigma_z\n self.prob = prob\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 self.x = self.R.uniform(low=self.sigma_x[0], high=self.sigma_x[1])\n self.y = self.R.uniform(low=self.sigma_y[0], high=self.sigma_y[1])\n self.z = self.R.uniform(low=self.sigma_z[0], high=self.sigma_z[1])\n\n def __call__(self, data: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\n d = dict(data)\n self.randomize()\n if not self._do_transform:\n return d\n for key in self.keys:\n sigma = ensure_tuple_size(tup=(self.x, self.y, self.z), dim=d[key].ndim - 1)\n d[key] = GaussianSmooth(sigma=sigma)(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_GaussianSharpend_GaussianSharpend.__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_GaussianSharpend_GaussianSharpend.__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": 499, "end_line": 530, "span_ids": ["GaussianSharpend.__init__", "GaussianSharpend.__call__", "GaussianSharpend"], "tokens": 324}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class GaussianSharpend(MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.GaussianSharpen`.\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n sigma1: sigma parameter for the first gaussian kernel. if a list of values, must match the count\n of spatial dimensions of input data, and apply every value in the list to 1 spatial dimension.\n if only 1 value provided, use it for all spatial dimensions.\n sigma2: sigma parameter for the second gaussian kernel. if a list of values, must match the count\n of spatial dimensions of input data, and apply every value in the list to 1 spatial dimension.\n if only 1 value provided, use it for all spatial dimensions.\n alpha: weight parameter to compute the final result.\n\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n sigma1: Union[Sequence[float], float] = 3.0,\n sigma2: Union[Sequence[float], float] = 1.0,\n alpha: float = 30.0,\n ) -> None:\n super().__init__(keys)\n self.converter = GaussianSharpen(sigma1, sigma2, alpha)\n\n def __call__(self, data: Mapping[Hashable, np.ndarray]) -> Dict[Hashable, np.ndarray]:\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_RandGaussianSharpend_RandGaussianSharpend.__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/intensity/dictionary.py_RandGaussianSharpend_RandGaussianSharpend.__init__.self._do_transform.False", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 533, "end_line": 575, "span_ids": ["RandGaussianSharpend.__init__", "RandGaussianSharpend"], "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": "class RandGaussianSharpend(Randomizable, MapTransform):\n \"\"\"\n Dictionary-based wrapper of :py:class:`monai.transforms.GaussianSharpen`.\n\n Args:\n keys: keys of the corresponding items to be transformed.\n See also: :py:class:`monai.transforms.compose.MapTransform`\n sigma1_x: randomly select sigma value for the first spatial dimension of first gaussian kernel.\n sigma1_y: randomly select sigma value for the second spatial dimension(if have) of first gaussian kernel.\n sigma1_z: randomly select sigma value for the third spatial dimension(if have) of first gaussian kernel.\n sigma2_x: randomly select sigma value for the first spatial dimension of second gaussian kernel.\n if only 1 value `X` provided, it must be smaller than `sigma1_x` and randomly select from [X, sigma1_x].\n sigma2_y: randomly select sigma value for the second spatial dimension(if have) of second gaussian kernel.\n if only 1 value `Y` provided, it must be smaller than `sigma1_y` and randomly select from [Y, sigma1_y].\n sigma2_z: randomly select sigma value for the third spatial dimension(if have) of second gaussian kernel.\n if only 1 value `Z` provided, it must be smaller than `sigma1_z` and randomly select from [Z, sigma1_z].\n alpha: randomly select weight parameter to compute the final result.\n prob: probability of Gaussian sharpen.\n\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n sigma1_x: Tuple[float, float] = (0.5, 1.0),\n sigma1_y: Tuple[float, float] = (0.5, 1.0),\n sigma1_z: Tuple[float, float] = (0.5, 1.0),\n sigma2_x: Union[Tuple[float, float], float] = 0.5,\n sigma2_y: Union[Tuple[float, float], float] = 0.5,\n sigma2_z: Union[Tuple[float, float], float] = 0.5,\n alpha: Tuple[float, float] = (10.0, 30.0),\n prob: float = 0.1,\n ):\n super().__init__(keys)\n self.sigma1_x = sigma1_x\n self.sigma1_y = sigma1_y\n self.sigma1_z = sigma1_z\n self.sigma2_x = sigma2_x\n self.sigma2_y = sigma2_y\n self.sigma2_z = sigma2_z\n self.alpha = alpha\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/intensity/dictionary.py_RandGaussianSharpend.randomize_RandGaussianSharpend.randomize.self.a.self_R_uniform_low_self_a": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/intensity/dictionary.py_RandGaussianSharpend.randomize_RandGaussianSharpend.randomize.self.a.self_R_uniform_low_self_a", "embedding": null, "metadata": {"file_path": "monai/transforms/intensity/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 577, "end_line": 588, "span_ids": ["RandGaussianSharpend.randomize"], "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 RandGaussianSharpend(Randomizable, MapTransform):\n\n def randomize(self, data: Optional[Any] = None) -> None:\n self._do_transform = self.R.random_sample() < self.prob\n self.x1 = self.R.uniform(low=self.sigma1_x[0], high=self.sigma1_x[1])\n self.y1 = self.R.uniform(low=self.sigma1_y[0], high=self.sigma1_y[1])\n self.z1 = self.R.uniform(low=self.sigma1_z[0], high=self.sigma1_z[1])\n sigma2_x = (self.sigma2_x, self.x1) if not isinstance(self.sigma2_x, Iterable) else self.sigma2_x\n sigma2_y = (self.sigma2_y, self.y1) if not isinstance(self.sigma2_y, Iterable) else self.sigma2_y\n sigma2_z = (self.sigma2_z, self.z1) if not isinstance(self.sigma2_z, Iterable) else self.sigma2_z\n self.x2 = self.R.uniform(low=sigma2_x[0], high=sigma2_x[1])\n self.y2 = self.R.uniform(low=sigma2_y[0], high=sigma2_y[1])\n self.z2 = self.R.uniform(low=sigma2_z[0], high=sigma2_z[1])\n self.a = self.R.uniform(low=self.alpha[0], high=self.alpha[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/intensity/dictionary.py_RandGaussianSharpend.__call___RandGaussianSharpend.__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_RandGaussianSharpend.__call___RandGaussianSharpend.__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": 590, "end_line": 599, "span_ids": ["RandGaussianSharpend.__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 RandGaussianSharpend(Randomizable, MapTransform):\n\n def __call__(self, data):\n d = dict(data)\n self.randomize()\n if not self._do_transform:\n return d\n for key in self.keys:\n sigma1 = ensure_tuple_size(tup=(self.x1, self.y1, self.z1), dim=d[key].ndim - 1)\n sigma2 = ensure_tuple_size(tup=(self.x2, self.y2, self.z2), dim=d[key].ndim - 1)\n d[key] = GaussianSharpen(sigma1=sigma1, sigma2=sigma2, alpha=self.a)(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/io/array.py_from_pathlib_import_Path_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_pathlib_import_Path_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": 59, "span_ids": ["LoadNifti.__init__", "LoadNifti", "docstring"], "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": "from pathlib import Path\nfrom typing import Dict, List, Optional, Sequence, Union\n\nimport numpy as np\nfrom torch.utils.data._utils.collate import np_str_obj_array_pattern\n\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 ensure_tuple, optional_import\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/dictionary.py_from_typing_import_Callab_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_Callab_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": 65, "span_ids": ["LoadDatad", "LoadDatad.__init__", "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": "from typing import Callable, Optional\n\nimport numpy as np\n\nfrom monai.config import KeysCollection\nfrom monai.transforms.compose import MapTransform\nfrom monai.transforms.io.array import LoadNifti, LoadNumpy, LoadPNG\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 TypeError: When ``loader`` is not ``callable``.\n TypeError: When ``meta_key_postfix`` is not a ``str``.\n\n \"\"\"\n super().__init__(keys)\n if not callable(loader):\n raise TypeError(f\"loader must be callable but is {type(loader).__name__}.\")\n self.loader = loader\n if not isinstance(meta_key_postfix, str):\n raise TypeError(f\"meta_key_postfix must be a str but is {type(meta_key_postfix).__name__}.\")\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/post/array.py_warnings_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_warnings_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": 45, "span_ids": ["SplitChannel", "SplitChannel.__init__", "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 warnings\nfrom typing import Callable, List, Optional, Sequence, Union\n\nimport numpy as np\nimport torch\nimport torch.nn.functional as F\n\nfrom monai.networks import one_hot\nfrom monai.transforms.compose import Transform\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_MeanEnsemble.__call___MeanEnsemble.__call__.return.torch_mean_img__dim_0_": {"__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___MeanEnsemble.__call__.return.torch_mean_img__dim_0_", "embedding": null, "metadata": {"file_path": "monai/transforms/post/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 395, "end_line": 406, "span_ids": ["MeanEnsemble.__call__"], "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": "class MeanEnsemble(Transform):\n\n def __call__(self, img: Union[Sequence[torch.Tensor], torch.Tensor]) -> torch.Tensor:\n img_ = 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_.ndimension() - self.weights.ndimension()):\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/array.py_VoteEnsemble_VoteEnsemble.__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_VoteEnsemble_VoteEnsemble.__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": 409, "end_line": 430, "span_ids": ["VoteEnsemble.__init__", "VoteEnsemble"], "tokens": 239}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class VoteEnsemble(Transform):\n \"\"\"\n Execute vote 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 Typcally, the input data is model output of segmentation task or classificaiton task.\n\n Note:\n This vote transform expects the input data is discrete values. It can be multiple channels\n data in One-Hot format or single channel data. It will vote to select the most common data\n between items.\n The output data has the same shape as every item of the input data.\n\n Args:\n num_classes: if the input is single channel data instead of One-Hot, we can't get class number\n from channel, need to explicitly specify the number of classes to vote.\n\n \"\"\"\n\n def __init__(self, num_classes: Optional[int] = None) -> None:\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_VoteEnsemble.__call___": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/array.py_VoteEnsemble.__call___", "embedding": null, "metadata": {"file_path": "monai/transforms/post/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 432, "end_line": 452, "span_ids": ["VoteEnsemble.__call__"], "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 VoteEnsemble(Transform):\n\n def __call__(self, img: Union[Sequence[torch.Tensor], torch.Tensor]) -> torch.Tensor:\n img_ = torch.stack(img) if isinstance(img, (tuple, list)) else torch.as_tensor(img)\n if self.num_classes is not None:\n has_ch_dim = True\n if img_.ndimension() > 2 and img_.shape[2] > 1:\n warnings.warn(\"no need to specify num_classes for One-Hot format data.\")\n else:\n if img_.ndimension() == 2:\n # if no channel dim, need to remove channel dim after voting\n has_ch_dim = False\n img_ = one_hot(img_, self.num_classes, dim=2)\n\n img_ = torch.mean(img_.float(), dim=0)\n\n if self.num_classes is not None:\n # if not One-Hot, use \"argmax\" to vote the most common class\n return torch.argmax(img_, dim=1, keepdim=has_ch_dim)\n else:\n # for One-Hot data, round the float number to 0 or 1\n return torch.round(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/dictionary.py_from_typing_import_Callab_SplitChanneld.__init__.self.splitter.SplitChannel_": {"__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_Callab_SplitChanneld.__init__.self.splitter.SplitChannel_", "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": 69, "span_ids": ["SplitChanneld.__init__", "SplitChanneld", "docstring"], "tokens": 450}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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, Hashable, List, Mapping, Optional, Sequence, Union\n\nimport numpy as np\nimport torch\n\nfrom monai.config import KeysCollection\nfrom monai.transforms.compose import MapTransform\nfrom monai.transforms.post.array import (\n Activations,\n AsDiscrete,\n KeepLargestConnectedComponent,\n LabelToContour,\n MeanEnsemble,\n SplitChannel,\n VoteEnsemble,\n)\nfrom monai.utils import ensure_tuple_rep\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 \"\"\"\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()", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_SplitChanneld.__call___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_SplitChanneld.__call___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": 71, "end_line": 78, "span_ids": ["SplitChanneld.__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 SplitChanneld(MapTransform):\n\n def __call__(self, data: Mapping[Hashable, torch.Tensor]) -> Dict[Hashable, torch.Tensor]:\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_Ensembled_Ensembled.__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_Ensembled_Ensembled.__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": 232, "end_line": 274, "span_ids": ["Ensembled", "Ensembled.__call__", "Ensembled.__init__"], "tokens": 392}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "end_line", "tokens"], "excluded_llm_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date"], "relationships": {}, "text": "class Ensembled(MapTransform):\n \"\"\"\n Base class of dictionary-based ensemble transforms.\n\n \"\"\"\n\n def __init__(\n self,\n keys: KeysCollection,\n ensemble: Callable[[Union[Sequence[torch.Tensor], torch.Tensor]], torch.Tensor],\n output_key: Optional[str] = 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 ensemble: callable method to execute ensemble on specified data.\n if only 1 key provided in `keys`, `output_key` can be None and use `keys` as default.\n\n Raises:\n TypeError: When ``ensemble`` is not ``callable``.\n ValueError: When ``len(keys) > 1`` and ``output_key=None``. Incompatible values.\n\n \"\"\"\n super().__init__(keys)\n if not callable(ensemble):\n raise TypeError(f\"ensemble must be callable but is {type(ensemble).__name__}.\")\n self.ensemble = ensemble\n if len(self.keys) > 1 and output_key is None:\n raise ValueError(\"Incompatible values: len(self.keys) > 1 and output_key=None.\")\n self.output_key = output_key if output_key is not None else self.keys[0]\n\n def __call__(self, data: Mapping[Hashable, torch.Tensor]) -> Dict[Hashable, torch.Tensor]:\n d = dict(data)\n items: Union[List[torch.Tensor], torch.Tensor]\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", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_MeanEnsembled.__init__.super___init___keys_en": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_MeanEnsembled_MeanEnsembled.__init__.super___init___keys_en", "embedding": null, "metadata": {"file_path": "monai/transforms/post/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 277, "end_line": 307, "span_ids": ["MeanEnsembled", "MeanEnsembled.__init__"], "tokens": 435}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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(Ensembled):\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 ensemble = MeanEnsemble(weights=weights)\n super().__init__(keys, ensemble, output_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/post/dictionary.py_VoteEnsembled_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/post/dictionary.py_VoteEnsembled_", "embedding": null, "metadata": {"file_path": "monai/transforms/post/dictionary.py", "file_name": "dictionary.py", "file_type": "text/x-python", "category": "implementation", "start_line": 310, "end_line": 339, "span_ids": ["VoteEnsembled.__init__", "VoteEnsembled", "impl"], "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 VoteEnsembled(Ensembled):\n \"\"\"\n Dictionary-based wrapper of :py:class:monai.transforms.VoteEnsemble.\n \"\"\"\n\n def __init__(\n self, keys: KeysCollection, output_key: Optional[str] = None, num_classes: Optional[int] = 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 num_classes: if the input is single channel data instead of One-Hot, we can't get class number\n from channel, need to explicitly specify the number of classes to vote.\n\n \"\"\"\n ensemble = VoteEnsemble(num_classes=num_classes)\n super().__init__(keys, ensemble, output_key)\n\n\nSplitChannelD = SplitChannelDict = SplitChanneld\nActivationsD = ActivationsDict = Activationsd\nAsDiscreteD = AsDiscreteDict = AsDiscreted\nKeepLargestConnectedComponentD = KeepLargestConnectedComponentDict = KeepLargestConnectedComponentd\nLabelToContourD = LabelToContourDict = LabelToContourd\nMeanEnsembleD = MeanEnsembleDict = MeanEnsembled\nVoteEnsembleD = VoteEnsembleDict = VoteEnsembled", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_warnings_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_warnings_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": 58, "span_ids": ["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 warnings\nfrom typing import Any, Callable, List, Optional, Sequence, Tuple, Union\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 GridSampleMode,\n GridSamplePadMode,\n InterpolateMode,\n NumpyPadMode,\n ensure_tuple,\n ensure_tuple_rep,\n ensure_tuple_size,\n fall_back_tuple,\n optional_import,\n)\n\nnib, _ = optional_import(\"nibabel\")\n\n_torch_interp: Callable[..., torch.Tensor]\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.__call___Spacing.__call__._resample": {"__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__._resample", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 108, "end_line": 170, "span_ids": ["Spacing.__call__"], "tokens": 753}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: Optional[np.ndarray] = None,\n mode: Optional[Union[GridSampleMode, str]] = None,\n padding_mode: Optional[Union[GridSamplePadMode, str]] = None,\n align_corners: Optional[bool] = None,\n dtype: Optional[np.dtype] = None,\n ) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:\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 align_corners: Geometrically, we consider the pixels of the input as squares rather than points.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n dtype: data type for resampling computation. Defaults to ``self.dtype``.\n If None, use the data type of input data. To be compatible with other modules,\n the output data type is always ``np.float32``.\n\n Raises:\n ValueError: When ``data_array`` has no spatial dimensions.\n ValueError: When ``pixdim`` is nonpositive.\n\n Returns:\n data_array (resampled into `self.pixdim`), original pixdim, current pixdim.\n\n \"\"\"\n _dtype = dtype or self.dtype or data_array.dtype\n sr = data_array.ndim - 1\n if sr <= 0:\n raise ValueError(\"data_array must 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\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(np.float32)\n new_affine = to_affine_nd(affine, new_affine)\n return output_data, affine, new_affine\n\n # resample\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/spatial/array.py_Spacing.__call__.affine_xform_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__.affine_xform_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": 171, "end_line": 186, "span_ids": ["Spacing.__call__"], "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 Spacing(Transform):\n\n def __call__(\n self,\n data_array: np.ndarray,\n affine: Optional[np.ndarray] = None,\n mode: Optional[Union[GridSampleMode, str]] = None,\n padding_mode: Optional[Union[GridSamplePadMode, str]] = None,\n align_corners: Optional[bool] = None,\n dtype: Optional[np.dtype] = None,\n ) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:\n # ... other code\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=self.align_corners if align_corners is None else align_corners,\n reverse_indexing=True,\n )\n output_data = affine_xform(\n # AffineTransform requires a batch dim\n torch.as_tensor(np.ascontiguousarray(data_array).astype(_dtype)).unsqueeze(0),\n torch.as_tensor(np.ascontiguousarray(transform).astype(_dtype)),\n spatial_size=output_shape,\n )\n output_data = output_data.squeeze(0).detach().cpu().numpy().astype(np.float32)\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_Rotate_Rotate.__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_Rotate_Rotate.__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": 363, "end_line": 399, "span_ids": ["Rotate.__init__", "Rotate"], "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": "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#grid-sample\n dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision.\n If None, use the data type of input data. To be compatible with other modules,\n the output data type is always ``np.float32``.\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 dtype: Optional[np.dtype] = np.float64,\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\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_RandRotate_RandRotate.__init__.self.z.0_0": {"__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.__init__.self.z.0_0", "embedding": null, "metadata": {"file_path": "monai/transforms/spatial/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 601, "end_line": 661, "span_ids": ["RandRotate", "RandRotate.__init__"], "tokens": 750}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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#grid-sample\n dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision.\n If None, use the data type of input data. To be compatible with other modules,\n the output data type is always ``np.float32``.\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 dtype: Optional[np.dtype] = np.float64,\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 self.dtype = dtype\n\n self._do_transform = False\n self.x = 0.0\n self.y = 0.0\n self.z = 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/monai/transforms/spatial/array.py_RandRotate.randomize_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.randomize_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": 663, "end_line": 703, "span_ids": ["RandRotate.randomize", "RandRotate.__call__"], "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 RandRotate(Randomizable, Transform):\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])\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: Optional[bool] = None,\n dtype: Optional[np.dtype] = None,\n ) -> np.ndarray:\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: Defaults to ``self.align_corners``.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n dtype: data type for resampling computation. Defaults to ``self.dtype``.\n If None, use the data type of input data. To be compatible with other modules,\n the output data type is always ``np.float32``.\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 dtype=dtype or self.dtype or img.dtype,\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/dictionary.py_from_typing_import_Any_D_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_Any_D_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": 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": "from typing import Any, Dict, Hashable, Mapping, Optional, Sequence, Tuple, Union\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._": {"__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._", "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": 67, "span_ids": ["Spacingd"], "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 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 \"\"\"", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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.__init___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.__init___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": 69, "end_line": 127, "span_ids": ["Spacingd.__init__"], "tokens": 773}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 __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 align_corners: Union[Sequence[bool], bool] = False,\n dtype: Optional[Union[Sequence[np.dtype], np.dtype]] = np.float64,\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 align_corners: Geometrically, we consider the pixels of the input as squares rather than points.\n See also: https://pytorch.org/docs/stable/nn.functional.html#grid-sample\n It also can be a sequence of bool, each element corresponds to a key in ``keys``.\n dtype: data type for resampling computation. Defaults to ``np.float64`` for best precision.\n If None, use the data type of input data. To be compatible with other modules,\n the output data type is always ``np.float32``.\n It also can be a sequence of np.dtype, 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 TypeError: When ``meta_key_postfix`` is not a ``str``.\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.align_corners = ensure_tuple_rep(align_corners, len(self.keys))\n self.dtype = ensure_tuple_rep(dtype, len(self.keys))\n if not isinstance(meta_key_postfix, str):\n raise TypeError(f\"meta_key_postfix must be a str but is {type(meta_key_postfix).__name__}.\")\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_Orientationd_Orientationd.__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_Orientationd_Orientationd.__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": 150, "end_line": 196, "span_ids": ["Orientationd.__init__", "Orientationd"], "tokens": 552}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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: Optional[Sequence[Tuple[str, str]]] = 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 TypeError: When ``meta_key_postfix`` is not a ``str``.\n\n See Also:\n `nibabel.orientations.ornt2axcodes`.\n\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 TypeError(f\"meta_key_postfix must be a str but is {type(meta_key_postfix).__name__}.\")\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_Orientationd.__call___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.__call___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": 198, "end_line": 206, "span_ids": ["Orientationd.__call__"], "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": "class Orientationd(MapTransform):\n\n def __call__(\n self, data: Mapping[Union[Hashable, str], Dict[str, np.ndarray]]\n ) -> Dict[Union[Hashable, str], Union[np.ndarray, Dict[str, np.ndarray]]]:\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/utility/array.py_logging_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_logging_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": 43, "span_ids": ["Identity.__call__", "Identity", "docstring"], "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": "import logging\nimport time\nfrom typing import Callable, Optional, Sequence, TypeVar, Union\n\nimport numpy as np\nimport torch\n\nfrom monai.transforms.compose import Transform\nfrom monai.utils import ensure_tuple\n\n# Generic type which can represent either a numpy.ndarray or a torch.Tensor\n# Unlike Union can create a dependence between parameter(s) / return(s)\nNdarrayTensor = TypeVar(\"NdarrayTensor\", np.ndarray, torch.Tensor)\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: Union[np.ndarray, torch.Tensor]) -> np.ndarray:\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_CastToType_CastToType.__call__.if_isinstance_img_np_nda.else_.raise_TypeError_f_img_mus": {"__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__.if_isinstance_img_np_nda.else_.raise_TypeError_f_img_mus", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 141, "end_line": 172, "span_ids": ["CastToType.__call__", "CastToType", "CastToType.__init__"], "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 CastToType(Transform):\n \"\"\"\n Cast the Numpy data to specified numpy data type, or cast the PyTorch Tensor to\n specified PyTorch data type.\n \"\"\"\n\n def __init__(self, dtype: Union[np.dtype, torch.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__(\n self, img: Union[np.ndarray, torch.Tensor], dtype: Optional[Union[np.dtype, torch.dtype]] = None\n ) -> Union[np.ndarray, torch.Tensor]:\n \"\"\"\n Apply the transform to `img`, assuming `img` is a numpy array or PyTorch Tensor.\n\n Args:\n dtype: convert image to this data type, default is `self.dtype`.\n\n Raises:\n TypeError: When ``img`` type is not in ``Union[numpy.ndarray, torch.Tensor]``.\n\n \"\"\"\n if isinstance(img, np.ndarray):\n return img.astype(self.dtype if dtype is None else dtype)\n elif torch.is_tensor(img):\n return torch.as_tensor(img, dtype=self.dtype if dtype is None else dtype)\n else:\n raise TypeError(f\"img must be one of (numpy.ndarray, torch.Tensor) but is {type(img).__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/transforms/utility/array.py_Lambda_Lambda.__init__.self.func.func": {"__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.__init__.self.func.func", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 358, "end_line": 383, "span_ids": ["Lambda", "Lambda.__init__"], "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 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 Raises:\n TypeError: When ``func`` is not an ``Optional[Callable]``.\n\n \"\"\"\n\n def __init__(self, func: Optional[Callable] = None) -> None:\n if func is not None and not callable(func):\n raise TypeError(f\"func must be None or callable but is {type(func).__name__}.\")\n self.func = func", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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.__call___Lambda.__call__.if_self_func_is_not_None_.else_.raise_ValueError_Incompa": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/array.py_Lambda.__call___Lambda.__call__.if_self_func_is_not_None_.else_.raise_ValueError_Incompa", "embedding": null, "metadata": {"file_path": "monai/transforms/utility/array.py", "file_name": "array.py", "file_type": "text/x-python", "category": "implementation", "start_line": 385, "end_line": 404, "span_ids": ["Lambda.__call__"], "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 Lambda(Transform):\n\n def __call__(self, img: Union[np.ndarray, torch.Tensor], func: Optional[Callable] = None):\n \"\"\"\n Apply `self.func` to `img`.\n\n Args:\n func: Lambda/function to be applied. Defaults to `self.func`.\n\n Raises:\n TypeError: When ``func`` is not an ``Optional[Callable]``.\n ValueError: When ``func=None`` and ``self.func=None``. Incompatible values.\n\n \"\"\"\n if func is not None:\n if not callable(func):\n raise TypeError(f\"func must be None or callable but is {type(func).__name__}.\")\n return func(img)\n if self.func is not None:\n return self.func(img)\n else:\n raise ValueError(\"Incompatible values: func=None and self.func=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/dictionary.py_copy_from_monai_utils_import_e": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/transforms/utility/dictionary.py_copy_from_monai_utils_import_e", "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": 42, "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 copy\nimport logging\nfrom typing import Callable, Dict, Hashable, Mapping, Optional, Sequence, Union\n\nimport numpy as np\nimport torch\n\nfrom monai.config import KeysCollection\nfrom monai.transforms.compose import MapTransform\nfrom monai.transforms.utility.array import (\n AddChannel,\n AsChannelFirst,\n AsChannelLast,\n CastToType,\n DataStats,\n Identity,\n LabelToMask,\n Lambda,\n RepeatChannel,\n SimulateDelay,\n SqueezeDim,\n ToNumpy,\n ToTensor,\n)\nfrom monai.utils import ensure_tuple, ensure_tuple_rep", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_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_random_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_random_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": 65, "span_ids": ["zero_margins", "docstring", "img_bounds", "is_empty", "rand_choice", "in_bounds"], "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 random\nimport warnings\nfrom typing import Callable, List, Optional, Sequence, Tuple, Union\n\nimport numpy as np\nimport torch\n\nfrom monai.config import IndexSelection\nfrom monai.utils import ensure_tuple, ensure_tuple_size, fall_back_tuple, min_version, optional_import\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: np.ndarray) -> np.ndarray:\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: float, y: float, margin: float, maxx: float, maxy: float) -> 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: Union[np.ndarray, torch.Tensor]) -> 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: np.ndarray, margin: int) -> 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_generate_pos_neg_label_crop_centers_generate_pos_neg_label_crop_centers.if_image_is_not_None_.else_.bg_indices.np_nonzero_label_flat_0": {"__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.if_image_is_not_None_.else_.bg_indices.np_nonzero_label_flat_0", "embedding": null, "metadata": {"file_path": "monai/transforms/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 182, "end_line": 246, "span_ids": ["generate_pos_neg_label_crop_centers"], "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": "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) -> List[List[np.ndarray]]:\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: When the proposed roi is larger than the image.\n ValueError: When the foreground and background indices lengths are 0.\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(\"The proposed roi is larger than the image.\")\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(\n center_ori: List[np.ndarray], valid_start: np.ndarray, valid_end: np.ndarray\n ) -> List[np.ndarray]:\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 # ... 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/utils.py_generate_pos_neg_label_crop_centers.if_not_len_fg_indices_or_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.if_not_len_fg_indices_or_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": 248, "end_line": 266, "span_ids": ["generate_pos_neg_label_crop_centers"], "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": "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) -> List[List[np.ndarray]]:\n # ... other code\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": 269, "end_line": 291, "span_ids": ["apply_transform"], "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 apply_transform(transform: Callable, data, 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 Exception: When ``transform`` raises an exception.\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_rotate_create_rotate.raise_ValueError_f_Unsupp": {"__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_Unsupp", "embedding": null, "metadata": {"file_path": "monai/transforms/utils.py", "file_name": "utils.py", "file_type": "text/x-python", "category": "implementation", "start_line": 333, "end_line": 376, "span_ids": ["create_rotate"], "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": "def create_rotate(spatial_dims: int, radians: Union[Sequence[float], float]) -> np.ndarray:\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: When ``radians`` is empty.\n ValueError: When ``spatial_dims`` is not one of [2, 3].\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 raise ValueError(\"radians must be non empty.\")\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 if affine is None:\n raise ValueError(\"radians must be non empty.\")\n return affine\n\n raise ValueError(f\"Unsupported spatial_dims: {spatial_dims}, available options are [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/monai/utils/aliases.py_importlib_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_importlib_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": 41, "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 importlib\nimport inspect\nimport sys\nimport threading\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/misc.py_collections.abc_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_collections.abc_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": 70, "span_ids": ["zip_with", "ensure_tuple_size", "first", "docstring", "ensure_tuple", "star_zip_with", "issequenceiterable"], "tokens": 375}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 collections.abc\nimport itertools\nimport random\nfrom ast import literal_eval\nfrom distutils.util import strtobool\nfrom typing import Any, Callable, Optional, Sequence, Tuple, Union\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: Any) -> bool:\n \"\"\"\n Determine if the object is an iterable sequence and is not a string.\n \"\"\"\n return isinstance(obj, collections.abc.Iterable) and not isinstance(obj, str)\n\n\ndef ensure_tuple(vals: Any) -> Tuple[Any, ...]:\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: Any, dim: int, pad_val: Any = 0) -> Tuple[Any, ...]:\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": 73, "end_line": 101, "span_ids": ["ensure_tuple_rep"], "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 ensure_tuple_rep(tup: Any, dim: int) -> Tuple[Any, ...]:\n \"\"\"\n Returns a copy of `tup` with `dim` values by either shortened or duplicated input.\n\n Raises:\n ValueError: When ``tup`` is a sequence and ``tup`` length is not ``dim``.\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 \"\"\"\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 {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_set_determinism_set_determinism.if_seed_is_not_None_.else_.torch.backends.cudnn.deterministic.False": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_set_determinism_set_determinism.if_seed_is_not_None_.else_.torch.backends.cudnn.deterministic.False", "embedding": null, "metadata": {"file_path": "monai/utils/misc.py", "file_name": "misc.py", "file_type": "text/x-python", "category": "implementation", "start_line": 183, "end_line": 221, "span_ids": ["set_determinism"], "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": "def set_determinism(\n seed: Optional[int] = np.iinfo(np.int32).max,\n additional_settings: Optional[Union[Sequence[Callable[[int], Any]], Callable[[int], Any]]] = 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)\n if not torch.cuda._is_in_bad_fork():\n torch.cuda.manual_seed_all(seed_)\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\n torch.backends.cudnn.benchmark = False\n else:\n torch.backends.cudnn.deterministic = 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/utils/misc.py_list_to_dict_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/monai/utils/misc.py_list_to_dict_", "embedding": null, "metadata": {"file_path": "monai/utils/misc.py", "file_name": "misc.py", "file_type": "text/x-python", "category": "implementation", "start_line": 224, "end_line": 256, "span_ids": ["list_to_dict"], "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": "def list_to_dict(items):\n \"\"\"\n To convert a list of \"key=value\" pairs into a dictionary.\n For examples: items: `[\"a=1\", \"b=2\", \"c=3\"]`, return: {\"a\": \"1\", \"b\": \"2\", \"c\": \"3\"}.\n If no \"=\" in the pair, use None as the value, for example: [\"a\"], return: {\"a\": None}.\n Note that it will remove the blanks around keys and values.\n\n \"\"\"\n\n def _parse_var(s):\n items = s.split(\"=\", maxsplit=1)\n key = items[0].strip(\" \\n\\r\\t'\")\n value = None\n if len(items) > 1:\n value = items[1].strip(\" \\n\\r\\t'\")\n return key, value\n\n d = dict()\n if items:\n for item in items:\n key, value = _parse_var(item)\n\n try:\n if key in d:\n raise KeyError(f\"encounter duplicated key {key}.\")\n d[key] = literal_eval(value)\n except ValueError:\n try:\n d[key] = bool(strtobool(str(value)))\n except ValueError:\n d[key] = value\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/visualize/img2tensorboard.py_from_typing_import_TYPE_C_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_TYPE_C_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": 28, "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": "from typing import TYPE_CHECKING, Dict, Optional, Sequence, Union\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\")\n\nif TYPE_CHECKING:\n from tensorboard.compat.proto.summary_pb2 import Summary\n from torch.utils.tensorboard import SummaryWriter\nelse:\n Summary, _ = optional_import(\"tensorboard.compat.proto.summary_pb2\", name=\"Summary\")\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_value_image_summ": {"__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_value_image_summ", "embedding": null, "metadata": {"file_path": "monai/visualize/img2tensorboard.py", "file_name": "img2tensorboard.py", "file_type": "text/x-python", "category": "implementation", "start_line": 31, "end_line": 54, "span_ids": ["_image3_animated_gif"], "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": "def _image3_animated_gif(tag: str, image: Union[np.ndarray, torch.Tensor], scale_factor: float = 1.0) -> Summary:\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.Image(height=10, width=10, colorspace=1, encoded_image_string=img_str)\n image_summary = Summary.Value(tag=tag, image=summary_image_str)\n return 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/research/lamp-automated-model-parallelism/train.py_os_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_os_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 os\nimport time\nfrom argparse import ArgumentParser\n\nimport numpy as np\nimport torch\nfrom data_utils import get_filenames, load_data_and_mask\nfrom torchgpipe import GPipe\nfrom torchgpipe.balance import balance_by_size\nfrom unet_pipe import UNetPipe, flatten_sequential\n\nfrom monai.data import Dataset, list_data_collate\nfrom monai.losses import DiceLoss, FocalLoss\nfrom monai.metrics import compute_meandice\nfrom monai.transforms import AddChannelDict, Compose, Rand3DElasticd, RandCropByPosNegLabeld, SpatialPadd\nfrom monai.utils import first\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/setup.py_warnings_get_extensions.return.ext_modules": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/setup.py_warnings_get_extensions.return.ext_modules", "embedding": null, "metadata": {"file_path": "setup.py", "file_name": "setup.py", "file_type": "text/x-python", "category": "implementation", "start_line": 12, "end_line": 38, "span_ids": ["get_extensions", "docstring"], "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": "import warnings\n\nfrom setuptools import find_packages, setup\n\nimport versioneer\n\n\ndef get_extensions():\n\n try:\n import torch\n from torch.utils.cpp_extension import CUDA_HOME, CppExtension, CUDAExtension\n\n print(f\"setup.py with torch {torch.__version__}\")\n except ImportError:\n warnings.warn(\"torch cpp/cuda building skipped.\")\n return []\n\n ext_modules = [CppExtension(\"monai._C\", [\"monai/networks/extensions/lltm/lltm.cpp\"])]\n if torch.cuda.is_available() and (CUDA_HOME is not None):\n ext_modules.append(\n CUDAExtension(\n \"monai._C_CUDA\",\n [\"monai/networks/extensions/lltm/lltm_cuda.cpp\", \"monai/networks/extensions/lltm/lltm_cuda_kernel.cu\"],\n )\n )\n return ext_modules", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "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_get_cmds_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/setup.py_get_cmds_", "embedding": null, "metadata": {"file_path": "setup.py", "file_name": "setup.py", "file_type": "text/x-python", "category": "implementation", "start_line": 41, "end_line": 60, "span_ids": ["get_cmds", "impl"], "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": "def get_cmds():\n cmds = versioneer.get_cmdclass()\n try:\n from torch.utils.cpp_extension import BuildExtension\n\n cmds.update({\"build_ext\": BuildExtension})\n except ImportError:\n warnings.warn(\"torch cpp_extension module not found.\")\n return cmds\n\n\nsetup(\n version=versioneer.get_version(),\n cmdclass=get_cmds(),\n packages=find_packages(exclude=(\"docs\", \"examples\", \"tests\", \"research\")),\n zip_safe=False,\n package_data={\"monai\": [\"py.typed\"]},\n ext_modules=get_extensions(),\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_adaptors.py_itertools_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_itertools_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": 53, "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 itertools\nimport unittest\n\nfrom monai.transforms.adaptors import FunctionSignature, adaptor, apply_alias, to_kwargs\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_affine_transform.py_TestToNormAffine.test_to_norm_affine_ill_TestToNormAffine.test_to_norm_affine_ill.with_self_assertRaises_Va.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.with_self_assertRaises_Va.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(TypeError):\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_ahnet.py_unittest_TestFCN.test_fcn_shape.with_torch_no_grad_.self_assertEqual_result_s": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_ahnet.py_unittest_TestFCN.test_fcn_shape.with_torch_no_grad_.self_assertEqual_result_s", "embedding": null, "metadata": {"file_path": "tests/test_ahnet.py", "file_name": "test_ahnet.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 69, "span_ids": ["TestFCN", "impl:15", "TestFCN.test_fcn_shape", "docstring"], "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": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.networks.blocks import FCN, MCFCN\nfrom monai.networks.nets import AHNet\n\nTEST_CASE_FCN_1 = [{\"out_channels\": 3, \"upsample_mode\": \"transpose\"}, torch.randn(5, 3, 64, 64), (5, 3, 64, 64)]\nTEST_CASE_FCN_2 = [{\"out_channels\": 2, \"upsample_mode\": \"transpose\"}, torch.randn(5, 3, 64, 64), (5, 2, 64, 64)]\nTEST_CASE_FCN_3 = [{\"out_channels\": 1, \"upsample_mode\": \"bilinear\"}, torch.randn(5, 3, 64, 64), (5, 1, 64, 64)]\n\nTEST_CASE_MCFCN_1 = [\n {\"out_channels\": 3, \"in_channels\": 8, \"upsample_mode\": \"transpose\"},\n torch.randn(5, 8, 64, 64),\n (5, 3, 64, 64),\n]\nTEST_CASE_MCFCN_2 = [\n {\"out_channels\": 2, \"in_channels\": 1, \"upsample_mode\": \"transpose\"},\n torch.randn(5, 1, 64, 64),\n (5, 2, 64, 64),\n]\nTEST_CASE_MCFCN_3 = [\n {\"out_channels\": 1, \"in_channels\": 2, \"upsample_mode\": \"bilinear\"},\n torch.randn(5, 2, 64, 64),\n (5, 1, 64, 64),\n]\n\nTEST_CASE_AHNET_2D_1 = [\n {\"spatial_dims\": 2, \"upsample_mode\": \"bilinear\"},\n torch.randn(3, 1, 128, 128),\n (3, 1, 128, 128),\n]\nTEST_CASE_AHNET_2D_2 = [\n {\"spatial_dims\": 2, \"upsample_mode\": \"transpose\", \"out_channels\": 2},\n torch.randn(2, 1, 128, 128),\n (2, 2, 128, 128),\n]\nTEST_CASE_AHNET_3D_1 = [\n {\"spatial_dims\": 3, \"upsample_mode\": \"trilinear\"},\n torch.randn(3, 1, 128, 128, 64),\n (3, 1, 128, 128, 64),\n]\nTEST_CASE_AHNET_3D_2 = [\n {\"spatial_dims\": 3, \"upsample_mode\": \"transpose\", \"out_channels\": 2},\n torch.randn(2, 1, 128, 128, 64),\n (2, 2, 128, 128, 64),\n]\n\n\nclass TestFCN(unittest.TestCase):\n @parameterized.expand([TEST_CASE_FCN_1, TEST_CASE_FCN_2, TEST_CASE_FCN_3])\n def test_fcn_shape(self, input_param, input_data, expected_shape):\n net = FCN(**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_ahnet.py_TestMCFCN_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_ahnet.py_TestMCFCN_", "embedding": null, "metadata": {"file_path": "tests/test_ahnet.py", "file_name": "test_ahnet.py", "file_type": "text/x-python", "category": "test", "start_line": 72, "end_line": 94, "span_ids": ["impl:21", "TestMCFCN", "TestAHNET.test_ahnet_shape", "TestAHNET", "TestMCFCN.test_mcfcn_shape"], "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 TestMCFCN(unittest.TestCase):\n @parameterized.expand([TEST_CASE_MCFCN_1, TEST_CASE_MCFCN_2, TEST_CASE_MCFCN_3])\n def test_mcfcn_shape(self, input_param, input_data, expected_shape):\n net = MCFCN(**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\nclass TestAHNET(unittest.TestCase):\n @parameterized.expand([TEST_CASE_AHNET_2D_1, TEST_CASE_AHNET_2D_2, TEST_CASE_AHNET_3D_1, TEST_CASE_AHNET_3D_2])\n def test_ahnet_shape(self, input_param, input_data, expected_shape):\n net = AHNet(**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_arraydataset.py_TestArrayDataset_TestArrayDataset.test_shape.with_tempfile_TemporaryDi.None_13": {"__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.with_tempfile_TemporaryDi.None_13", "embedding": null, "metadata": {"file_path": "tests/test_arraydataset.py", "file_name": "test_arraydataset.py", "file_type": "text/x-python", "category": "test", "start_line": 57, "end_line": 90, "span_ids": ["TestArrayDataset", "TestArrayDataset.test_shape"], "tokens": 480}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 with tempfile.TemporaryDirectory() as tempdir:\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)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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.with_tempfile_TemporaryDi.np_testing_assert_allclos": {"__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.with_tempfile_TemporaryDi.np_testing_assert_allclos", "embedding": null, "metadata": {"file_path": "tests/test_arraydataset.py", "file_name": "test_arraydataset.py", "file_type": "text/x-python", "category": "test", "start_line": 92, "end_line": 113, "span_ids": ["TestArrayDataset.test_default_none"], "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 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 with tempfile.TemporaryDirectory() as tempdir:\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)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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_img_TestArrayDataset.test_dataloading_img.with_tempfile_TemporaryDi.None_6": {"__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_img_TestArrayDataset.test_dataloading_img.with_tempfile_TemporaryDi.None_6", "embedding": null, "metadata": {"file_path": "tests/test_arraydataset.py", "file_name": "test_arraydataset.py", "file_type": "text/x-python", "category": "test", "start_line": 115, "end_line": 133, "span_ids": ["TestArrayDataset.test_dataloading_img"], "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 TestArrayDataset(unittest.TestCase):\n\n @parameterized.expand([TEST_CASE_4])\n def test_dataloading_img(self, img_transform, expected_shape):\n test_image = nib.Nifti1Image(np.random.randint(0, 2, size=(128, 128, 128)), np.eye(4))\n with tempfile.TemporaryDirectory() as tempdir:\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)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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_img_label_": {"__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_img_label_", "embedding": null, "metadata": {"file_path": "tests/test_arraydataset.py", "file_name": "test_arraydataset.py", "file_type": "text/x-python", "category": "test", "start_line": 135, "end_line": 163, "span_ids": ["impl:9", "TestArrayDataset.test_dataloading_img_label"], "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 TestArrayDataset(unittest.TestCase):\n\n @parameterized.expand([TEST_CASE_4])\n def test_dataloading_img_label(self, img_transform, expected_shape):\n test_image = nib.Nifti1Image(np.random.randint(0, 2, size=(128, 128, 128)), np.eye(4))\n with tempfile.TemporaryDirectory() as tempdir:\n test_image1 = os.path.join(tempdir, \"test_image1.nii.gz\")\n test_image2 = os.path.join(tempdir, \"test_image2.nii.gz\")\n test_label1 = os.path.join(tempdir, \"test_label1.nii.gz\")\n test_label2 = os.path.join(tempdir, \"test_label2.nii.gz\")\n nib.save(test_image, test_image1)\n nib.save(test_image, test_image2)\n nib.save(test_image, test_label1)\n nib.save(test_image, test_label2)\n test_images = [test_image1, test_image2]\n test_labels = [test_label1, test_label2]\n dataset = ArrayDataset(test_images, img_transform, test_labels, 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 data = next(iter(loader)) # test batching\n np.testing.assert_allclose(data[0].shape, [2] + list(expected_shape))\n\n dataset.set_random_state(1234)\n new_data = next(iter(loader)) # test batching\n np.testing.assert_allclose(data[0], new_data[0], 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_cachedataset.py_os_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_cachedataset.py_os_", "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": 69, "span_ids": ["impl:5", "TestCacheDataset.test_shape", "TestCacheDataset", "docstring"], "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": "import os\nimport tempfile\nimport unittest\n\nimport nibabel as nib\nimport numpy as np\nfrom parameterized import parameterized\n\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 with tempfile.TemporaryDirectory() as tempdir:\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\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_os_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_os_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": 27, "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": "import os\nimport tempfile\nimport unittest\n\nimport nibabel as nib\nimport numpy as np\nfrom parameterized import parameterized\n\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_check_md5.py_os_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_check_md5.py_os_", "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": 43, "span_ids": ["TestCheckMD5", "TestCheckMD5.test_shape", "impl:7", "docstring"], "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": "import os\nimport tempfile\nimport unittest\n\nimport numpy as np\nfrom parameterized import parameterized\nfrom PIL import Image\n\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 with tempfile.TemporaryDirectory() as tempdir:\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\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_TEST_CASE_7_TEST_CASE_10._y_1_1_2_2_y_pr": {"__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_10._y_1_1_2_2_y_pr", "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": 149, "span_ids": ["impl:11", "impl:17"], "tokens": 700}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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]\n\nTEST_CASE_10 = [ # 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.0,\n \"other_act\": torch.tanh,\n },\n [[0.8]],\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_roc_auc.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_compute_roc_auc.py_unittest_TEST_CASE_7._", "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": 65, "span_ids": ["impl:11", "docstring"], "tokens": 653}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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]", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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_TEST_CASE_8_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_compute_roc_auc.py_TEST_CASE_8_", "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": 67, "end_line": 89, "span_ids": ["impl:11", "TestComputeROCAUC", "TestComputeROCAUC.test_value", "impl:17"], "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": "TEST_CASE_8 = [\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 \"other_act\": lambda x: torch.log_softmax(x, dim=1),\n },\n 0.75,\n]\n\n\nclass TestComputeROCAUC(unittest.TestCase):\n @parameterized.expand(\n [TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5, TEST_CASE_6, TEST_CASE_7, TEST_CASE_8]\n )\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_convolutions.py_from_monai_networks_block_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_monai_networks_block_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": 63, "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 monai.networks.blocks import Convolution, ResidualUnit\nfrom tests.utils import TorchImageTestCase2D\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_csv_saver.py_csv_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_csv_saver.py_csv_", "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": 44, "span_ids": ["TestCSVSaver.test_saved_content", "TestCSVSaver", "impl", "docstring"], "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": "import csv\nimport os\nimport tempfile\nimport unittest\n\nimport numpy as np\nimport torch\n\nfrom monai.data import CSVSaver\n\n\nclass TestCSVSaver(unittest.TestCase):\n def test_saved_content(self):\n with tempfile.TemporaryDirectory() as tempdir:\n saver = CSVSaver(output_dir=tempdir, filename=\"predictions.csv\")\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(tempdir, \"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\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_logging_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_logging_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": 107, "span_ids": ["impl:9", "docstring"], "tokens": 738}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 logging\nimport os\nimport tempfile\nimport unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\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_statsd.py_logging_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_logging_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": 102, "span_ids": ["impl:9", "docstring"], "tokens": 684}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 logging\nimport os\nimport tempfile\nimport unittest\n\nimport numpy as np\nimport torch\nfrom parameterized import parameterized\n\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_dataset.py_os_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_dataset.py_os_", "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": 700}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 nibabel as nib\nimport numpy as np\nfrom parameterized import parameterized\n\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 with tempfile.TemporaryDirectory() as tempdir:\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\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_os_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_decathlondataset.py_os_", "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": 80, "span_ids": ["TestDecathlonDataset", "TestDecathlonDataset.test_values", "impl", "docstring"], "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": "import os\nimport shutil\nimport unittest\nfrom urllib.error import ContentTooShortError, HTTPError\n\nfrom monai.apps import DecathlonDataset\nfrom monai.transforms import AddChanneld, Compose, LoadNiftid, ScaleIntensityd, ToTensord\nfrom tests.utils import skip_if_quick\n\n\nclass TestDecathlonDataset(unittest.TestCase):\n @skip_if_quick\n def test_values(self):\n testing_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), \"testing_data\")\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: # will start downloading if testing_dir doesn't have the Decathlon files\n data = DecathlonDataset(\n root_dir=testing_dir,\n task=\"Task04_Hippocampus\",\n transform=transform,\n section=\"validation\",\n download=True,\n )\n except (ContentTooShortError, HTTPError, RuntimeError) as e:\n print(str(e))\n if isinstance(e, RuntimeError):\n # FIXME: skip MD5 check as current downloading method may fail\n self.assertTrue(str(e).startswith(\"MD5 check\"))\n return # skipping this test due the network connection errors\n\n _test_dataset(data)\n data = DecathlonDataset(\n root_dir=testing_dir, task=\"Task04_Hippocampus\", transform=transform, section=\"validation\", download=False\n )\n _test_dataset(data)\n data = DecathlonDataset(root_dir=testing_dir, task=\"Task04_Hippocampus\", section=\"validation\", download=False)\n self.assertTupleEqual(data[0][\"image\"].shape, (33, 47, 34))\n shutil.rmtree(os.path.join(testing_dir, \"Task04_Hippocampus\"))\n try:\n data = DecathlonDataset(\n root_dir=testing_dir,\n task=\"Task04_Hippocampus\",\n transform=transform,\n section=\"validation\",\n download=False,\n )\n except RuntimeError as e:\n print(str(e))\n self.assertTrue(str(e).startswith(\"Cannot find dataset directory\"))\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_sys_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_delete_itemsd.py_sys_", "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": 38, "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 sys\nimport time\nimport unittest\n\nfrom parameterized import parameterized\n\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_3._4_channel_1D_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_3._4_channel_1D_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": 35, "span_ids": ["docstring"], "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": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.networks.nets import densenet121, densenet169, densenet201, densenet264\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]\n\nTEST_CASE_2 = [ # 4-channel 2D, batch 16\n {\"spatial_dims\": 2, \"in_channels\": 2, \"out_channels\": 3},\n torch.randn(16, 2, 32, 64),\n (16, 3),\n]\n\nTEST_CASE_3 = [ # 4-channel 1D, batch 16\n {\"spatial_dims\": 1, \"in_channels\": 2, \"out_channels\": 3},\n torch.randn(16, 2, 32),\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_ensemble_evaluator.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_ensemble_evaluator.py_unittest_", "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": 65, "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 unittest\n\nimport torch\nfrom ignite.engine import Events\n\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_gaussian_sharpen.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_sharpen.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_gaussian_sharpen.py", "file_name": "test_gaussian_sharpen.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 62, "span_ids": ["TestGaussianSharpen", "impl:7", "TestGaussianSharpen.test_value", "impl:5", "docstring"], "tokens": 738}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 GaussianSharpen\n\nTEST_CASE_1 = [\n {},\n np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]]),\n np.array(\n [\n [[4.0335875, 3.362756, 4.0335875], [3.588128, 2.628216, 3.588128], [4.491922, 3.8134987, 4.491922]],\n [[10.427719, 8.744948, 10.427719], [8.97032, 6.5705404, 8.970321], [10.886056, 9.195692, 10.886056]],\n ]\n ),\n]\n\nTEST_CASE_2 = [\n {\"sigma1\": 1.0, \"sigma2\": 0.75, \"alpha\": 20},\n np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]]),\n np.array(\n [\n [[4.146659, 4.392873, 4.146659], [8.031006, 8.804623, 8.031005], [10.127394, 11.669131, 10.127394]],\n [[14.852196, 16.439377, 14.852201], [20.077503, 22.011555, 20.077507], [20.832941, 23.715641, 20.832935]],\n ]\n ),\n]\n\nTEST_CASE_3 = [\n {\"sigma1\": (0.5, 1.0), \"sigma2\": (0.5, 0.75), \"alpha\": 20},\n np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]]),\n np.array(\n [\n [[3.129089, 3.0711129, 3.129089], [6.783306, 6.8526435, 6.7833037], [11.901203, 13.098082, 11.901203]],\n [[14.401806, 15.198004, 14.401809], [16.958261, 17.131605, 16.958261], [23.17392, 25.224974, 23.17392]],\n ]\n ),\n]\n\n\nclass TestGaussianSharpen(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 = GaussianSharpen(**argments)(image)\n np.testing.assert_allclose(result, expected_data, rtol=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_gaussian_sharpend.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_sharpend.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_gaussian_sharpend.py", "file_name": "test_gaussian_sharpend.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 62, "span_ids": ["TestGaussianSharpend.test_value", "TestGaussianSharpend", "impl:7", "impl:5", "docstring"], "tokens": 769}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 GaussianSharpend\n\nTEST_CASE_1 = [\n {\"keys\": \"img\"},\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(\n [\n [[4.0335875, 3.362756, 4.0335875], [3.588128, 2.628216, 3.588128], [4.491922, 3.8134987, 4.491922]],\n [[10.427719, 8.744948, 10.427719], [8.97032, 6.5705404, 8.970321], [10.886056, 9.195692, 10.886056]],\n ]\n ),\n]\n\nTEST_CASE_2 = [\n {\"keys\": \"img\", \"sigma1\": 1.0, \"sigma2\": 0.75, \"alpha\": 20},\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(\n [\n [[4.146659, 4.392873, 4.146659], [8.031006, 8.804623, 8.031005], [10.127394, 11.669131, 10.127394]],\n [[14.852196, 16.439377, 14.852201], [20.077503, 22.011555, 20.077507], [20.832941, 23.715641, 20.832935]],\n ]\n ),\n]\n\nTEST_CASE_3 = [\n {\"keys\": \"img\", \"sigma1\": (0.5, 1.0), \"sigma2\": (0.5, 0.75), \"alpha\": 20},\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(\n [\n [[3.129089, 3.0711129, 3.129089], [6.783306, 6.8526435, 6.7833037], [11.901203, 13.098082, 11.901203]],\n [[14.401806, 15.198004, 14.401809], [16.958261, 17.131605, 16.958261], [23.17392, 25.224974, 23.17392]],\n ]\n ),\n]\n\n\nclass TestGaussianSharpend(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 = GaussianSharpend(**argments)(image)\n np.testing.assert_allclose(result[\"img\"], expected_data, rtol=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_gaussian_smooth.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_smooth.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_gaussian_smooth.py", "file_name": "test_gaussian_smooth.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 62, "span_ids": ["impl:7", "impl:5", "docstring", "TestGaussianSmooth", "TestGaussianSmooth.test_value"], "tokens": 739}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 GaussianSmooth\n\nTEST_CASE_1 = [\n {\"sigma\": 1.5},\n np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]]),\n np.array(\n [\n [[0.5999930, 0.7056839, 0.5999930], [0.8140513, 0.9574494, 0.8140513], [0.7842673, 0.9224188, 0.7842673]],\n [[1.6381884, 1.926761, 1.6381884], [2.0351284, 2.3936234, 2.0351284], [1.8224627, 2.143496, 1.8224627]],\n ]\n ),\n]\n\nTEST_CASE_2 = [\n {\"sigma\": 0.5},\n np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]]),\n np.array(\n [\n [[0.893521, 0.99973595, 0.893521], [1.785628, 1.9978896, 1.7856278], [2.2983139, 2.5715199, 2.2983139]],\n [[3.2873974, 3.6781778, 3.2873974], [4.46407, 4.9947243, 4.46407], [4.69219, 5.2499614, 4.69219]],\n ]\n ),\n]\n\nTEST_CASE_3 = [\n {\"sigma\": [1.5, 0.5]},\n np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]]),\n np.array(\n [\n [[0.91108215, 1.0193846, 0.91108215], [1.236127, 1.3830683, 1.236127], [1.1909003, 1.3324654, 1.1909003]],\n [[2.4875693, 2.7832723, 2.487569], [3.0903177, 3.457671, 3.0903175], [2.7673876, 3.0963533, 2.7673874]],\n ]\n ),\n]\n\n\nclass TestGaussianSmooth(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 = GaussianSmooth(**argments)(image)\n np.testing.assert_allclose(result, expected_data, rtol=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_gaussian_smoothd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_gaussian_smoothd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_gaussian_smoothd.py", "file_name": "test_gaussian_smoothd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 62, "span_ids": ["TestGaussianSmoothd", "impl:7", "impl:5", "TestGaussianSmoothd.test_value", "docstring"], "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": "import unittest\n\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.transforms import GaussianSmoothd\n\nTEST_CASE_1 = [\n {\"keys\": \"img\", \"sigma\": 1.5},\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(\n [\n [[0.5999930, 0.7056839, 0.5999930], [0.8140513, 0.9574494, 0.8140513], [0.7842673, 0.9224188, 0.7842673]],\n [[1.6381884, 1.926761, 1.6381884], [2.0351284, 2.3936234, 2.0351284], [1.8224627, 2.143496, 1.8224627]],\n ]\n ),\n]\n\nTEST_CASE_2 = [\n {\"keys\": \"img\", \"sigma\": 0.5},\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(\n [\n [[0.893521, 0.99973595, 0.893521], [1.785628, 1.9978896, 1.7856278], [2.2983139, 2.5715199, 2.2983139]],\n [[3.2873974, 3.6781778, 3.2873974], [4.46407, 4.9947243, 4.46407], [4.69219, 5.2499614, 4.69219]],\n ]\n ),\n]\n\nTEST_CASE_3 = [\n {\"keys\": \"img\", \"sigma\": [1.5, 0.5]},\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(\n [\n [[0.91108215, 1.0193846, 0.91108215], [1.236127, 1.3830683, 1.236127], [1.1909003, 1.3324654, 1.1909003]],\n [[2.4875693, 2.7832723, 2.487569], [3.0903177, 3.457671, 3.0903175], [2.7673876, 3.0963533, 2.7673874]],\n ]\n ),\n]\n\n\nclass TestGaussianSmoothd(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 = GaussianSmoothd(**argments)(image)\n np.testing.assert_allclose(result[\"img\"], expected_data, rtol=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_generalized_wasserstein_dice_loss.py_unittest_TestGeneralizedWassersteinDiceLoss.test_bin_seg_2d.None_2": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generalized_wasserstein_dice_loss.py_unittest_TestGeneralizedWassersteinDiceLoss.test_bin_seg_2d.None_2", "embedding": null, "metadata": {"file_path": "tests/test_generalized_wasserstein_dice_loss.py", "file_name": "test_generalized_wasserstein_dice_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 44, "span_ids": ["TestGeneralizedWassersteinDiceLoss", "TestGeneralizedWassersteinDiceLoss.test_bin_seg_2d", "docstring"], "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": "import unittest\n\nimport numpy as np\nimport torch\nimport torch.nn.functional as F\n\nfrom monai.losses import GeneralizedWassersteinDiceLoss\n\n\nclass TestGeneralizedWassersteinDiceLoss(unittest.TestCase):\n def test_bin_seg_2d(self):\n target = torch.tensor([[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]])\n\n # add another dimension corresponding to the batch (batch size = 1 here)\n target = target.unsqueeze(0)\n pred_very_good = 1000 * F.one_hot(target, num_classes=2).permute(0, 3, 1, 2).float()\n pred_very_poor = 1000 * F.one_hot(1 - target, num_classes=2).permute(0, 3, 1, 2).float()\n\n # initialize the loss\n loss = GeneralizedWassersteinDiceLoss(dist_matrix=np.array([[0.0, 1.0], [1.0, 0.0]]))\n\n # the loss for pred_very_good should be close to 0\n loss_good = float(loss.forward(pred_very_good, target))\n self.assertAlmostEqual(loss_good, 0.0, places=3)\n\n # same test, but with target with a class dimension\n target_4dim = target.unsqueeze(1)\n loss_good = float(loss.forward(pred_very_good, target_4dim))\n self.assertAlmostEqual(loss_good, 0.0, places=3)\n\n # the loss for pred_very_poor should be close to 1\n loss_poor = float(loss.forward(pred_very_poor, target))\n self.assertAlmostEqual(loss_poor, 1.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_generalized_wasserstein_dice_loss.py_TestGeneralizedWassersteinDiceLoss.test_empty_class_2d_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_generalized_wasserstein_dice_loss.py_TestGeneralizedWassersteinDiceLoss.test_empty_class_2d_", "embedding": null, "metadata": {"file_path": "tests/test_generalized_wasserstein_dice_loss.py", "file_name": "test_generalized_wasserstein_dice_loss.py", "file_type": "text/x-python", "category": "test", "start_line": 46, "end_line": 69, "span_ids": ["TestGeneralizedWassersteinDiceLoss.test_empty_class_2d", "impl"], "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 TestGeneralizedWassersteinDiceLoss(unittest.TestCase):\n\n def test_empty_class_2d(self):\n num_classes = 2\n target = torch.tensor([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])\n\n # add another dimension corresponding to the batch (batch size = 1 here)\n target = target.unsqueeze(0)\n pred_very_good = 1000 * F.one_hot(target, num_classes=num_classes).permute(0, 3, 1, 2).float()\n pred_very_poor = 1000 * F.one_hot(1 - target, num_classes=num_classes).permute(0, 3, 1, 2).float()\n\n # initialize the loss\n loss = GeneralizedWassersteinDiceLoss(dist_matrix=np.array([[0.0, 1.0], [1.0, 0.0]]))\n\n # loss for pred_very_good should be close to 0\n loss_good = float(loss.forward(pred_very_good, target))\n self.assertAlmostEqual(loss_good, 0.0, places=3)\n\n # loss for pred_very_poor should be close to 1\n loss_poor = float(loss.forward(pred_very_poor, target))\n self.assertAlmostEqual(loss_poor, 1.0, places=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_handler_checkpoint_loader.py_logging_TestHandlerCheckpointLoader.test_one_save_one_load.with_tempfile_TemporaryDi.torch_testing_assert_allc": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_checkpoint_loader.py_logging_TestHandlerCheckpointLoader.test_one_save_one_load.with_tempfile_TemporaryDi.torch_testing_assert_allc", "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": 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": "import logging\nimport sys\nimport tempfile\nimport unittest\n\nimport torch\nimport torch.optim as optim\nfrom ignite.engine import Engine\n\nfrom monai.handlers import CheckpointLoader, CheckpointSaver\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 with tempfile.TemporaryDirectory() as tempdir:\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)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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.with_tempfile_TemporaryDi.torch_testing_assert_allc": {"__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.with_tempfile_TemporaryDi.torch_testing_assert_allc", "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": 63, "span_ids": ["TestHandlerCheckpointLoader.test_two_save_one_load"], "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 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 with tempfile.TemporaryDirectory() as tempdir:\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)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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_logging_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_logging_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": 51, "span_ids": ["docstring"], "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": "import logging\nimport os\nimport sys\nimport tempfile\nimport unittest\n\nimport torch\nimport torch.optim as optim\nfrom ignite.engine import Engine\nfrom parameterized import parameterized\n\nfrom monai.handlers import CheckpointSaver\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_TestHandlerCheckpointSaver.test_file.with_tempfile_TemporaryDi.for_filename_in_filenames.self_assertTrue_os_path_e": {"__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_TestHandlerCheckpointSaver.test_file.with_tempfile_TemporaryDi.for_filename_in_filenames.self_assertTrue_os_path_e", "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": 54, "end_line": 99, "span_ids": ["TestHandlerCheckpointSaver", "TestHandlerCheckpointSaver.test_file"], "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 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 with tempfile.TemporaryDirectory() as tempdir:\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)))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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.test_exception_": {"__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.test_exception_", "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": 101, "end_line": 123, "span_ids": ["impl:11", "TestHandlerCheckpointSaver.test_exception"], "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 TestHandlerCheckpointSaver(unittest.TestCase):\n\n def test_exception(self):\n logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n net = torch.nn.PReLU()\n\n # set up engine\n def _train_func(engine, batch):\n raise RuntimeError(\"test exception.\")\n\n engine = Engine(_train_func)\n\n # set up testing handler\n with tempfile.TemporaryDirectory() as tempdir:\n stats_handler = CheckpointSaver(tempdir, {\"net\": net}, save_final=True)\n stats_handler.attach(engine)\n\n with self.assertRaises(RuntimeError):\n engine.run(range(3), max_epochs=2)\n self.assertTrue(os.path.exists(os.path.join(tempdir, \"net_final_iteration=1.pth\")))\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_csv_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_classification_saver.py_csv_", "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": 54, "span_ids": ["TestHandlerClassificationSaver", "TestHandlerClassificationSaver.test_saved_content", "impl", "docstring"], "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": "import csv\nimport os\nimport tempfile\nimport unittest\n\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 with tempfile.TemporaryDirectory() as tempdir:\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=tempdir, 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(tempdir, \"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\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_logging_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_lr_scheduler.py_logging_", "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": 66, "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 logging\nimport sys\nimport unittest\n\nimport numpy as np\nimport torch\nfrom ignite.engine import Engine, Events\n\nfrom monai.handlers import LrScheduleHandler\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_rocauc_dist.py_np_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_rocauc_dist.py_np_", "embedding": null, "metadata": {"file_path": "tests/test_handler_rocauc_dist.py", "file_name": "test_handler_rocauc_dist.py", "file_type": "text/x-python", "category": "test", "start_line": 13, "end_line": 48, "span_ids": ["main", "impl", "docstring"], "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": "import numpy as np\nimport torch\nimport torch.distributed as dist\n\nfrom monai.handlers import ROCAUC\n\n\ndef main():\n dist.init_process_group(backend=\"nccl\", init_method=\"env://\")\n\n auc_metric = ROCAUC(to_onehot_y=True, softmax=True)\n\n if dist.get_rank() == 0:\n y_pred = torch.tensor([[0.1, 0.9], [0.3, 1.4]], device=torch.device(\"cuda:0\"))\n y = torch.tensor([[0], [1]], device=torch.device(\"cuda:0\"))\n auc_metric.update([y_pred, y])\n\n if dist.get_rank() == 1:\n y_pred = torch.tensor([[0.2, 0.1], [0.1, 0.5]], device=torch.device(\"cuda:1\"))\n y = torch.tensor([[0], [1]], device=torch.device(\"cuda:1\"))\n auc_metric.update([y_pred, y])\n\n result = auc_metric.compute()\n np.testing.assert_allclose(0.75, result)\n\n dist.destroy_process_group()\n\n\n# python -m torch.distributed.launch --nproc_per_node=NUM_GPUS_PER_NODE\n# --nnodes=NUM_NODES --node_rank=INDEX_CURRENT_NODE\n# --master_addr=\"192.168.1.1\" --master_port=1234\n# test_handler_rocauc_dist.py\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/tests/test_handler_segmentation_saver.py_os_TestHandlerSegmentationSaver.test_saved_content.with_tempfile_TemporaryDi.for_i_in_range_8_.self_assertTrue_os_path_e": {"__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.with_tempfile_TemporaryDi.for_i_in_range_8_.self_assertTrue_os_path_e", "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": 47, "span_ids": ["TestHandlerSegmentationSaver.test_saved_content", "TestHandlerSegmentationSaver", "docstring"], "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": "import os\nimport tempfile\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 with tempfile.TemporaryDirectory() as tempdir:\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=tempdir, 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(tempdir, filepath)))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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_logging_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_logging_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": 57, "span_ids": ["TestHandlerStats.test_metrics_print", "TestHandlerStats", "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 logging\nimport os\nimport re\nimport tempfile\nimport unittest\nfrom io import StringIO\n\nimport torch\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_tb_stats.py_glob_TestHandlerTBStats.test_metrics_print.with_tempfile_TemporaryDi.self_assertTrue_len_glob_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_handler_tb_stats.py_glob_TestHandlerTBStats.test_metrics_print.with_tempfile_TemporaryDi.self_assertTrue_len_glob_", "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": 43, "span_ids": ["TestHandlerTBStats.test_metrics_print", "TestHandlerTBStats", "docstring"], "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": "import glob\nimport tempfile\nimport unittest\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 with tempfile.TemporaryDirectory() as tempdir:\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 self.assertTrue(len(glob.glob(tempdir)) > 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_img2tensorboard.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_img2tensorboard.py_unittest_", "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": 52, "span_ids": ["TestImg2Tensorboard.test_write_gray", "TestImg2Tensorboard", "impl", "docstring"], "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": "import unittest\n\nimport numpy as np\nimport tensorboard\nimport torch\n\nfrom monai.visualize import make_animated_gif_summary\n\n\nclass TestImg2Tensorboard(unittest.TestCase):\n def test_write_gray(self):\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_segmentation_3d.py_run_training_test_run_training_test.loss_function.monai_losses_DiceLoss_sig": {"__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.loss_function.monai_losses_DiceLoss_sig", "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": 43, "end_line": 100, "span_ids": ["run_training_test"], "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": "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 # resampling with align_corners=True or dtype=float64 will generate\n # slight different results between PyTorch 1.5 an 1.6\n Spacingd(keys=[\"img\", \"seg\"], pixdim=[1.2, 0.8, 0.7], mode=[\"bilinear\", \"nearest\"], dtype=np.float32),\n ScaleIntensityd(keys=\"img\"),\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 # resampling with align_corners=True or dtype=float64 will generate\n # slight different results between PyTorch 1.5 an 1.6\n Spacingd(keys=[\"img\", \"seg\"], pixdim=[1.2, 0.8, 0.7], mode=[\"bilinear\", \"nearest\"], dtype=np.float32),\n ScaleIntensityd(keys=\"img\"),\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 = monai.data.DataLoader(train_ds, batch_size=2, shuffle=True, num_workers=4)\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 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 # ... 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.optimizer_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.optimizer_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": 101, "end_line": 166, "span_ids": ["run_training_test"], "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 run_training_test(root_dir, device=torch.device(\"cuda:0\"), cachedataset=False):\n # ... other code\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 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_sliding_window.py_TestIntegrationSlidingWindow_": {"__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_", "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": 62, "end_line": 90, "span_ids": ["TestIntegrationSlidingWindow.test_training", "impl", "TestIntegrationSlidingWindow.setUp", "TestIntegrationSlidingWindow", "TestIntegrationSlidingWindow.tearDown"], "tokens": 275}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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)\n\n def test_training(self):\n with tempfile.TemporaryDirectory() as tempdir:\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), 33621)\n np.testing.assert_allclose(output_image.shape, (28, 25, 63, 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_workflows.py_logging_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_logging_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": 53, "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 logging\nimport os\nimport shutil\nimport sys\nimport tempfile\nimport unittest\nfrom glob import glob\n\nimport nibabel as nib\nimport numpy as np\nimport torch\nfrom ignite.metrics import Accuracy\n\nimport monai\nfrom monai.data import create_test_image_3d\nfrom monai.engines import SupervisedEvaluator, SupervisedTrainer\nfrom monai.handlers import (\n CheckpointLoader,\n CheckpointSaver,\n LrScheduleHandler,\n MeanDice,\n SegmentationSaver,\n StatsHandler,\n TensorBoardImageHandler,\n TensorBoardStatsHandler,\n ValidationHandler,\n)\nfrom monai.inferers import SimpleInferer, SlidingWindowInferer\nfrom monai.transforms import (\n Activationsd,\n AsChannelFirstd,\n AsDiscreted,\n Compose,\n KeepLargestConnectedComponentd,\n LoadNiftid,\n RandCropByPosNegLabeld,\n RandRotate90d,\n ScaleIntensityd,\n ToTensord,\n)\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_gan.py_logging_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_gan.py_logging_from_tests_utils_import_s", "embedding": null, "metadata": {"file_path": "tests/test_integration_workflows_gan.py", "file_name": "test_integration_workflows_gan.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 33, "span_ids": ["docstring"], "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": "import logging\nimport os\nimport shutil\nimport sys\nimport tempfile\nimport unittest\nfrom glob import glob\n\nimport nibabel as nib\nimport numpy as np\nimport torch\n\nimport monai\nfrom monai.data import create_test_image_2d\nfrom monai.engines import GanTrainer\nfrom monai.engines.utils import GanKeys as Keys\nfrom monai.handlers import CheckpointSaver, StatsHandler, TensorBoardStatsHandler\nfrom monai.networks import normal_init\nfrom monai.networks.nets import Discriminator, Generator\nfrom monai.transforms import AsChannelFirstd, Compose, LoadNiftid, RandFlipd, ScaleIntensityd, ToTensord\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_gan.py_run_training_test_run_training_test.return.trainer_state": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows_gan.py_run_training_test_run_training_test.return.trainer_state", "embedding": null, "metadata": {"file_path": "tests/test_integration_workflows_gan.py", "file_name": "test_integration_workflows_gan.py", "file_type": "text/x-python", "category": "test", "start_line": 36, "end_line": 125, "span_ids": ["run_training_test"], "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 run_training_test(root_dir, device=torch.device(\"cuda:0\")):\n real_images = sorted(glob(os.path.join(root_dir, \"img*.nii.gz\")))\n train_files = [{\"reals\": img} for img in zip(real_images)]\n\n # prepare real data\n train_transforms = Compose(\n [\n LoadNiftid(keys=[\"reals\"]),\n AsChannelFirstd(keys=[\"reals\"]),\n ScaleIntensityd(keys=[\"reals\"]),\n RandFlipd(keys=[\"reals\"], prob=0.5),\n ToTensord(keys=[\"reals\"]),\n ]\n )\n train_ds = monai.data.CacheDataset(data=train_files, transform=train_transforms, cache_rate=0.5)\n train_loader = monai.data.DataLoader(train_ds, batch_size=2, shuffle=True, num_workers=4)\n\n learning_rate = 2e-4\n betas = (0.5, 0.999)\n real_label = 1\n fake_label = 0\n\n # create discriminator\n disc_net = Discriminator(\n in_shape=(1, 64, 64), channels=(8, 16, 32, 64, 1), strides=(2, 2, 2, 2, 1), num_res_units=1, kernel_size=5\n ).to(device)\n disc_net.apply(normal_init)\n disc_opt = torch.optim.Adam(disc_net.parameters(), learning_rate, betas=betas)\n disc_loss_criterion = torch.nn.BCELoss()\n\n def discriminator_loss(gen_images, real_images):\n real = real_images.new_full((real_images.shape[0], 1), real_label)\n gen = gen_images.new_full((gen_images.shape[0], 1), fake_label)\n realloss = disc_loss_criterion(disc_net(real_images), real)\n genloss = disc_loss_criterion(disc_net(gen_images.detach()), gen)\n return torch.div(torch.add(realloss, genloss), 2)\n\n # create generator\n latent_size = 64\n gen_net = Generator(\n latent_shape=latent_size, start_shape=(latent_size, 8, 8), channels=[32, 16, 8, 1], strides=[2, 2, 2, 1]\n )\n gen_net.apply(normal_init)\n gen_net.conv.add_module(\"activation\", torch.nn.Sigmoid())\n gen_net = gen_net.to(device)\n gen_opt = torch.optim.Adam(gen_net.parameters(), learning_rate, betas=betas)\n gen_loss_criterion = torch.nn.BCELoss()\n\n def generator_loss(gen_images):\n output = disc_net(gen_images)\n cats = output.new_full(output.shape, real_label)\n return gen_loss_criterion(output, cats)\n\n key_train_metric = None\n\n train_handlers = [\n StatsHandler(\n name=\"training_loss\", output_transform=lambda x: {Keys.GLOSS: x[Keys.GLOSS], Keys.DLOSS: x[Keys.DLOSS]},\n ),\n TensorBoardStatsHandler(\n log_dir=root_dir,\n tag_name=\"training_loss\",\n output_transform=lambda x: {Keys.GLOSS: x[Keys.GLOSS], Keys.DLOSS: x[Keys.DLOSS]},\n ),\n CheckpointSaver(\n save_dir=root_dir, save_dict={\"g_net\": gen_net, \"d_net\": disc_net}, save_interval=2, epoch_level=True\n ),\n ]\n\n disc_train_steps = 2\n num_epochs = 5\n\n trainer = GanTrainer(\n device,\n num_epochs,\n train_loader,\n gen_net,\n gen_opt,\n generator_loss,\n disc_net,\n disc_opt,\n discriminator_loss,\n d_train_steps=disc_train_steps,\n latent_shape=latent_size,\n key_train_metric=key_train_metric,\n train_handlers=train_handlers,\n )\n trainer.run()\n\n return trainer.state", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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_gan.py_IntegrationWorkflowsGAN_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_integration_workflows_gan.py_IntegrationWorkflowsGAN_", "embedding": null, "metadata": {"file_path": "tests/test_integration_workflows_gan.py", "file_name": "test_integration_workflows_gan.py", "file_type": "text/x-python", "category": "test", "start_line": 128, "end_line": 159, "span_ids": ["impl", "IntegrationWorkflowsGAN", "IntegrationWorkflowsGAN.tearDown", "IntegrationWorkflowsGAN.test_training", "IntegrationWorkflowsGAN.setUp"], "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 IntegrationWorkflowsGAN(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, _ = create_test_image_2d(64, 64, num_objs=3, rad_max=14, 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 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)\n\n @skip_if_quick\n def test_training(self):\n torch.manual_seed(0)\n\n finish_state = run_training_test(self.data_dir, device=self.device)\n\n # assert GAN training finished\n self.assertEqual(finish_state.iteration, 100)\n self.assertEqual(finish_state.epoch, 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_list_to_dict.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_list_to_dict.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_list_to_dict.py", "file_name": "test_list_to_dict.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 53, "span_ids": ["impl:11", "TestListToDict.test_value_shape", "TestListToDict", "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\n\nfrom parameterized import parameterized\n\nfrom monai.utils import list_to_dict\n\nTEST_CASE_1 = [\n [\"a=1\", \"b=2\", \"c=3\", \"d=4\"],\n {\"a\": 1, \"b\": 2, \"c\": 3, \"d\": 4},\n]\n\nTEST_CASE_2 = [\n [\"a=a\", \"b=b\", \"c=c\", \"d=d\"],\n {\"a\": \"a\", \"b\": \"b\", \"c\": \"c\", \"d\": \"d\"},\n]\n\nTEST_CASE_3 = [\n [\"a=0.1\", \"b=0.2\", \"c=0.3\", \"d=0.4\"],\n {\"a\": 0.1, \"b\": 0.2, \"c\": 0.3, \"d\": 0.4},\n]\n\nTEST_CASE_4 = [\n [\"a=True\", \"b=TRUE\", \"c=false\", \"d=FALSE\"],\n {\"a\": True, \"b\": True, \"c\": False, \"d\": False},\n]\n\nTEST_CASE_5 = [\n [\"a='1'\", \"b=2 \", \" c = 3\", \"d='test'\", \"'e'=0\", \"f\", \"g=None\"],\n {\"a\": 1, \"b\": 2, \"c\": 3, \"d\": \"test\", \"e\": 0, \"f\": None, \"g\": None},\n]\n\n\nclass TestListToDict(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5])\n def test_value_shape(self, input, output):\n result = list_to_dict(input)\n self.assertDictEqual(result, output)\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_lltm.py_unittest_TEST_CASE_1._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_lltm.py_unittest_TEST_CASE_1._", "embedding": null, "metadata": {"file_path": "tests/test_lltm.py", "file_name": "test_lltm.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 23, "span_ids": ["docstring"], "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": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.networks.layers import LLTM\n\nTEST_CASE_1 = [\n {\"input_features\": 32, \"state_size\": 2},\n torch.tensor([[-0.1622, 0.1663], [0.5465, 0.0459], [-0.1436, 0.6171], [0.3632, -0.0111]]),\n torch.tensor([[-1.3773, 0.3348], [0.8353, 1.3064], [-0.2179, 4.1739], [1.3045, -0.1444]]),\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_lltm.py_TestLLTM_TestLLTM.test_value.None_3": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_lltm.py_TestLLTM_TestLLTM.test_value.None_3", "embedding": null, "metadata": {"file_path": "tests/test_lltm.py", "file_name": "test_lltm.py", "file_type": "text/x-python", "category": "test", "start_line": 26, "end_line": 37, "span_ids": ["TestLLTM", "TestLLTM.test_value"], "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 TestLLTM(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1])\n def test_value(self, input_param, expected_h, expected_c):\n torch.manual_seed(0)\n x = torch.randn(4, 32)\n h = torch.randn(4, 2)\n c = torch.randn(4, 2)\n new_h, new_c = LLTM(**input_param)(x, (h, c))\n (new_h.sum() + new_c.sum()).backward()\n\n torch.testing.assert_allclose(new_h, expected_h, rtol=0.0001, atol=1e-04)\n torch.testing.assert_allclose(new_c, expected_c, rtol=0.0001, atol=1e-04)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\n", "class_name": "TextNode"}, "__type__": "1"}, "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_lltm.py_TestLLTM.test_value_cuda_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_lltm.py_TestLLTM.test_value_cuda_", "embedding": null, "metadata": {"file_path": "tests/test_lltm.py", "file_name": "test_lltm.py", "file_type": "text/x-python", "category": "test", "start_line": 39, "end_line": 56, "span_ids": ["impl:3", "TestLLTM.test_value_cuda"], "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": "class TestLLTM(unittest.TestCase):\n\n @parameterized.expand([TEST_CASE_1])\n def test_value_cuda(self, input_param, expected_h, expected_c):\n device = torch.device(\"cuda:0\") if torch.cuda.is_available() else torch.device(\"cpu:0\")\n torch.manual_seed(0)\n x = torch.randn(4, 32).to(device)\n h = torch.randn(4, 2).to(device)\n c = torch.randn(4, 2).to(device)\n lltm = LLTM(**input_param).to(device)\n new_h, new_c = lltm(x, (h, c))\n (new_h.sum() + new_c.sum()).backward()\n\n torch.testing.assert_allclose(new_h, expected_h.to(device), rtol=0.0001, atol=1e-04)\n torch.testing.assert_allclose(new_c, expected_c.to(device), rtol=0.0001, atol=1e-04)\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_json_TestLoadDecathalonDatalist.test_seg_values.with_tempfile_TemporaryDi.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_json_TestLoadDecathalonDatalist.test_seg_values.with_tempfile_TemporaryDi.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": 12, "end_line": 39, "span_ids": ["TestLoadDecathalonDatalist", "TestLoadDecathalonDatalist.test_seg_values", "docstring"], "tokens": 292}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 json\nimport os\nimport tempfile\nimport unittest\n\nfrom monai.data import load_decathalon_datalist\n\n\nclass TestLoadDecathalonDatalist(unittest.TestCase):\n def test_seg_values(self):\n with tempfile.TemporaryDirectory() as tempdir:\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\"))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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.with_tempfile_TemporaryDi.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_cls_values_TestLoadDecathalonDatalist.test_cls_values.with_tempfile_TemporaryDi.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": 41, "end_line": 56, "span_ids": ["TestLoadDecathalonDatalist.test_cls_values"], "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 TestLoadDecathalonDatalist(unittest.TestCase):\n\n def test_cls_values(self):\n with tempfile.TemporaryDirectory() as tempdir:\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)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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.with_tempfile_TemporaryDi.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.with_tempfile_TemporaryDi.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": 58, "end_line": 82, "span_ids": ["TestLoadDecathalonDatalist.test_seg_no_basedir"], "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": "class TestLoadDecathalonDatalist(unittest.TestCase):\n\n def test_seg_no_basedir(self):\n with tempfile.TemporaryDirectory() as tempdir:\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_nifti.py_os_TEST_CASE_5._as_closest_canonical_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_nifti.py_os_TEST_CASE_5._as_closest_canonical_", "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": 38, "span_ids": ["docstring"], "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": "import os\nimport tempfile\nimport unittest\n\nimport nibabel as nib\nimport numpy as np\nfrom parameterized import parameterized\n\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]\n\nTEST_CASE_5 = [{\"as_closest_canonical\": True, \"image_only\": False}, [\"test_image.nii.gz\"], (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_niftid.py_os_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_niftid.py_os_", "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": 44, "span_ids": ["TestLoadNiftid", "impl:5", "TestLoadNiftid.test_shape", "docstring"], "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": "import os\nimport tempfile\nimport unittest\n\nimport nibabel as nib\nimport numpy as np\nfrom parameterized import parameterized\n\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 with tempfile.TemporaryDirectory() as tempdir:\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\n for key in KEYS:\n self.assertTupleEqual(result[key].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_numpy.py_os_TestLoadNumpy.test_npy.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_numpy.py_os_TestLoadNumpy.test_npy.np_testing_assert_allclos", "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": 31, "span_ids": ["TestLoadNumpy.test_npy", "TestLoadNumpy", "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": "import os\nimport tempfile\nimport unittest\n\nimport numpy as np\n\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 with tempfile.TemporaryDirectory() as tempdir:\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)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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.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_numpy.py_TestLoadNumpy.test_npz1_TestLoadNumpy.test_npz1.np_testing_assert_allclos", "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": 33, "end_line": 42, "span_ids": ["TestLoadNumpy.test_npz1"], "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 TestLoadNumpy(unittest.TestCase):\n\n def test_npz1(self):\n test_data1 = np.random.randint(0, 256, size=[3, 4, 4])\n with tempfile.TemporaryDirectory() as tempdir:\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)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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.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_numpy.py_TestLoadNumpy.test_npz2_TestLoadNumpy.test_npz2.np_testing_assert_allclos", "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": 44, "end_line": 54, "span_ids": ["TestLoadNumpy.test_npz2"], "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 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 with tempfile.TemporaryDirectory() as tempdir:\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]))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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.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_numpy.py_TestLoadNumpy.test_npz3_TestLoadNumpy.test_npz3.np_testing_assert_allclos", "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": 56, "end_line": 66, "span_ids": ["TestLoadNumpy.test_npz3"], "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 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 with tempfile.TemporaryDirectory() as tempdir:\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]))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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_os_TestLoadNumpyd.test_npy.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_numpyd.py_os_TestLoadNumpyd.test_npy.np_testing_assert_allclos", "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": 31, "span_ids": ["TestLoadNumpyd", "TestLoadNumpyd.test_npy", "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 os\nimport tempfile\nimport unittest\n\nimport numpy as np\n\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 with tempfile.TemporaryDirectory() as tempdir:\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)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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.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_numpyd.py_TestLoadNumpyd.test_npz1_TestLoadNumpyd.test_npz1.np_testing_assert_allclos", "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": 33, "end_line": 42, "span_ids": ["TestLoadNumpyd.test_npz1"], "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 TestLoadNumpyd(unittest.TestCase):\n\n def test_npz1(self):\n test_data1 = np.random.randint(0, 256, size=[3, 4, 4])\n with tempfile.TemporaryDirectory() as tempdir:\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)", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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.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_numpyd.py_TestLoadNumpyd.test_npz2_TestLoadNumpyd.test_npz2.np_testing_assert_allclos", "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": 44, "end_line": 54, "span_ids": ["TestLoadNumpyd.test_npz2"], "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 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 with tempfile.TemporaryDirectory() as tempdir:\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]))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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.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_numpyd.py_TestLoadNumpyd.test_npz3_TestLoadNumpyd.test_npz3.np_testing_assert_allclos", "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": 56, "end_line": 66, "span_ids": ["TestLoadNumpyd.test_npz3"], "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 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 with tempfile.TemporaryDirectory() as tempdir:\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]))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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_os_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_os_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": 26, "span_ids": ["docstring"], "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": "import os\nimport tempfile\nimport unittest\n\nimport numpy as np\nfrom parameterized import parameterized\nfrom PIL import Image\n\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_pngd.py_os_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_load_pngd.py_os_", "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": 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 os\nimport tempfile\nimport unittest\n\nimport numpy as np\nfrom parameterized import parameterized\nfrom PIL import Image\n\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 with tempfile.TemporaryDirectory() as tempdir:\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\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_os_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_mednistdataset.py_os_", "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": 68, "span_ids": ["TestMedNISTDataset", "TestMedNISTDataset.test_values", "impl", "docstring"], "tokens": 501}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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\nfrom urllib.error import ContentTooShortError, HTTPError\n\nfrom monai.apps import MedNISTDataset\nfrom monai.transforms import AddChanneld, Compose, LoadPNGd, ScaleIntensityd, ToTensord\nfrom tests.utils import skip_if_quick\n\n\nclass TestMedNISTDataset(unittest.TestCase):\n @skip_if_quick\n def test_values(self):\n testing_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), \"testing_data\")\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 try: # will start downloading if testing_dir doesn't have the MedNIST files\n data = MedNISTDataset(root_dir=testing_dir, transform=transform, section=\"test\", download=True)\n except (ContentTooShortError, HTTPError, RuntimeError) as e:\n print(str(e))\n if isinstance(e, RuntimeError):\n # FIXME: skip MD5 check as current downloading method may fail\n self.assertTrue(str(e).startswith(\"MD5 check\"))\n return # skipping this test due the network connection errors\n\n _test_dataset(data)\n\n # testing from\n data = MedNISTDataset(root_dir=testing_dir, transform=transform, section=\"test\", download=False)\n _test_dataset(data)\n data = MedNISTDataset(root_dir=testing_dir, section=\"test\", download=False)\n self.assertTupleEqual(data[0][\"image\"].shape, (64, 64))\n shutil.rmtree(os.path.join(testing_dir, \"MedNIST\"))\n try:\n data = MedNISTDataset(root_dir=testing_dir, transform=transform, section=\"test\", download=False)\n except RuntimeError as e:\n print(str(e))\n self.assertTrue(str(e).startswith(\"Cannot find dataset directory\"))\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_TestNiftiDataset_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_nifti_dataset.py_TestNiftiDataset_", "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": 38, "end_line": 126, "span_ids": ["TestNiftiDataset.test_dataset", "TestNiftiDataset", "impl:3"], "tokens": 963}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 with tempfile.TemporaryDirectory() as tempdir:\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,\n transform=lambda x: x + 1,\n seg_files=full_names,\n seg_transform=lambda x: x + 2,\n 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 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\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_TestNiftiLoadRead.test_write_2d_TestNiftiLoadRead.test_write_2d.with_tempfile_TemporaryDi.None_5": {"__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.with_tempfile_TemporaryDi.None_5", "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": 108, "end_line": 122, "span_ids": ["TestNiftiLoadRead.test_write_2d"], "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 TestNiftiLoadRead(unittest.TestCase):\n\n def test_write_2d(self):\n with tempfile.TemporaryDirectory() as out_dir:\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]))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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.with_tempfile_TemporaryDi.None_5": {"__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.with_tempfile_TemporaryDi.None_5", "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": 124, "end_line": 138, "span_ids": ["TestNiftiLoadRead.test_write_3d"], "tokens": 296}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_line", "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 with tempfile.TemporaryDirectory() as out_dir:\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]))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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.with_tempfile_TemporaryDi.None_5": {"__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.with_tempfile_TemporaryDi.None_5", "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": 140, "end_line": 154, "span_ids": ["TestNiftiLoadRead.test_write_4d"], "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 TestNiftiLoadRead(unittest.TestCase):\n\n def test_write_4d(self):\n with tempfile.TemporaryDirectory() as out_dir:\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]))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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.with_tempfile_TemporaryDi.for_i_in_range_8_.self_assertTrue_os_path_e": {"__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.with_tempfile_TemporaryDi.for_i_in_range_8_.self_assertTrue_os_path_e", "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": 32, "span_ids": ["TestNiftiSaver.test_saved_content", "TestNiftiSaver", "docstring"], "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": "import os\nimport tempfile\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 with tempfile.TemporaryDirectory() as tempdir:\n\n saver = NiftiSaver(output_dir=tempdir, 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(tempdir, filepath)))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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.with_tempfile_TemporaryDi.for_i_in_range_8_.self_assertTrue_os_path_e": {"__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.with_tempfile_TemporaryDi.for_i_in_range_8_.self_assertTrue_os_path_e", "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": 34, "end_line": 47, "span_ids": ["TestNiftiSaver.test_saved_resize_content"], "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 TestNiftiSaver(unittest.TestCase):\n\n def test_saved_resize_content(self):\n with tempfile.TemporaryDirectory() as tempdir:\n\n saver = NiftiSaver(output_dir=tempdir, 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(tempdir, filepath)))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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_os_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_os_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": 41, "span_ids": ["docstring"], "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": "import os\nimport tempfile\nimport unittest\n\nimport nibabel as nib\nimport numpy as np\nfrom parameterized import parameterized\n\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_png_saver.py_os_TestPNGSaver.test_saved_content.with_tempfile_TemporaryDi.for_i_in_range_8_.self_assertTrue_os_path_e": {"__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.with_tempfile_TemporaryDi.for_i_in_range_8_.self_assertTrue_os_path_e", "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": 31, "span_ids": ["TestPNGSaver.test_saved_content", "TestPNGSaver", "docstring"], "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": "import os\nimport tempfile\nimport unittest\n\nimport torch\n\nfrom monai.data import PNGSaver\n\n\nclass TestPNGSaver(unittest.TestCase):\n def test_saved_content(self):\n with tempfile.TemporaryDirectory() as tempdir:\n\n saver = PNGSaver(output_dir=tempdir, 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(tempdir, filepath)))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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.with_tempfile_TemporaryDi.for_i_in_range_8_.self_assertTrue_os_path_e": {"__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.with_tempfile_TemporaryDi.for_i_in_range_8_.self_assertTrue_os_path_e", "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": 33, "end_line": 42, "span_ids": ["TestPNGSaver.test_saved_content_three_channel"], "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 TestPNGSaver(unittest.TestCase):\n\n def test_saved_content_three_channel(self):\n with tempfile.TemporaryDirectory() as tempdir:\n\n saver = PNGSaver(output_dir=tempdir, 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(tempdir, filepath)))", "start_char_idx": null, "end_char_idx": null, "text_template": "{metadata_str}\n\n{content}", "metadata_template": "{key}: {value}", "metadata_seperator": "\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_sharpen.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_gaussian_sharpen.py_unittest_TEST_CASE_2._", "embedding": null, "metadata": {"file_path": "tests/test_rand_gaussian_sharpen.py", "file_name": "test_rand_gaussian_sharpen.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 47, "span_ids": ["docstring"], "tokens": 505}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 RandGaussianSharpen\n\nTEST_CASE_1 = [\n {\"prob\": 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(\n [\n [[4.754159, 4.736094, 4.754159], [10.598042, 11.24803, 10.598039], [14.249546, 16.14466, 14.249547]],\n [[19.00694, 20.396658, 19.00694], [26.495098, 28.120085, 26.49509], [28.502321, 31.805233, 28.502329]],\n ]\n ),\n]\n\nTEST_CASE_2 = [\n {\n \"sigma1_x\": (0.5, 0.75),\n \"sigma1_y\": (0.5, 0.75),\n \"sigma1_z\": (0.5, 0.75),\n \"sigma2_x\": 0.4,\n \"sigma2_y\": 0.4,\n \"sigma2_z\": 0.4,\n \"prob\": 1.0,\n },\n np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]]),\n np.array(\n [\n [[3.4868715, 2.693231, 3.4868698], [8.438889, 7.384708, 8.438892], [12.872246, 12.808499, 12.872242]],\n [[15.7562065, 14.319538, 15.7562065], [21.09723, 18.461775, 21.097229], [25.14158, 24.434803, 25.14158]],\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_gaussian_sharpen.py_TEST_CASE_3_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_gaussian_sharpen.py_TEST_CASE_3_", "embedding": null, "metadata": {"file_path": "tests/test_rand_gaussian_sharpen.py", "file_name": "test_rand_gaussian_sharpen.py", "file_type": "text/x-python", "category": "test", "start_line": 49, "end_line": 80, "span_ids": ["TestRandGaussianSharpen", "impl:7", "impl:5", "TestRandGaussianSharpen.test_value"], "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": "TEST_CASE_3 = [\n {\n \"sigma1_x\": (0.5, 0.75),\n \"sigma1_y\": (0.5, 0.75),\n \"sigma1_z\": (0.5, 0.75),\n \"sigma2_x\": (0.5, 0.75),\n \"sigma2_y\": (0.5, 0.75),\n \"sigma2_z\": (0.5, 0.75),\n \"prob\": 1.0,\n },\n np.array([[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, 6, 6]]]),\n np.array(\n [\n [[4.4568377, 3.4987352, 4.4568377], [11.090087, 10.003474, 11.090087], [17.025122, 17.420639, 17.025122]],\n [[20.568314, 19.188267, 20.568314], [27.725227, 25.008686, 27.725227], [33.136593, 33.11017, 33.1366]],\n ]\n ),\n]\n\n\nclass TestRandGaussianSharpen(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_value(self, argments, image, expected_data):\n converter = RandGaussianSharpen(**argments)\n converter.set_random_state(seed=0)\n result = converter(image)\n np.testing.assert_allclose(result, expected_data, rtol=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_gaussian_sharpend.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_gaussian_sharpend.py_unittest_TEST_CASE_2._", "embedding": null, "metadata": {"file_path": "tests/test_rand_gaussian_sharpend.py", "file_name": "test_rand_gaussian_sharpend.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 48, "span_ids": ["docstring"], "tokens": 526}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 RandGaussianSharpend\n\nTEST_CASE_1 = [\n {\"keys\": \"img\", \"prob\": 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(\n [\n [[4.754159, 4.736094, 4.754159], [10.598042, 11.24803, 10.598039], [14.249546, 16.14466, 14.249547]],\n [[19.00694, 20.396658, 19.00694], [26.495098, 28.120085, 26.49509], [28.502321, 31.805233, 28.502329]],\n ]\n ),\n]\n\nTEST_CASE_2 = [\n {\n \"keys\": \"img\",\n \"sigma1_x\": (0.5, 0.75),\n \"sigma1_y\": (0.5, 0.75),\n \"sigma1_z\": (0.5, 0.75),\n \"sigma2_x\": 0.4,\n \"sigma2_y\": 0.4,\n \"sigma2_z\": 0.4,\n \"prob\": 1.0,\n },\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(\n [\n [[3.4868715, 2.693231, 3.4868698], [8.438889, 7.384708, 8.438892], [12.872246, 12.808499, 12.872242]],\n [[15.7562065, 14.319538, 15.7562065], [21.09723, 18.461775, 21.097229], [25.14158, 24.434803, 25.14158]],\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_gaussian_sharpend.py_TEST_CASE_3_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_gaussian_sharpend.py_TEST_CASE_3_", "embedding": null, "metadata": {"file_path": "tests/test_rand_gaussian_sharpend.py", "file_name": "test_rand_gaussian_sharpend.py", "file_type": "text/x-python", "category": "test", "start_line": 50, "end_line": 82, "span_ids": ["TestRandGaussianSharpend", "TestRandGaussianSharpend.test_value", "impl:5", "impl:7"], "tokens": 414}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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_3 = [\n {\n \"keys\": \"img\",\n \"sigma1_x\": (0.5, 0.75),\n \"sigma1_y\": (0.5, 0.75),\n \"sigma1_z\": (0.5, 0.75),\n \"sigma2_x\": (0.5, 0.75),\n \"sigma2_y\": (0.5, 0.75),\n \"sigma2_z\": (0.5, 0.75),\n \"prob\": 1.0,\n },\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(\n [\n [[4.4568377, 3.4987352, 4.4568377], [11.090087, 10.003474, 11.090087], [17.025122, 17.420639, 17.025122]],\n [[20.568314, 19.188267, 20.568314], [27.725227, 25.008686, 27.725227], [33.136593, 33.11017, 33.1366]],\n ]\n ),\n]\n\n\nclass TestRandGaussianSharpend(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])\n def test_value(self, argments, image, expected_data):\n converter = RandGaussianSharpend(**argments)\n converter.set_random_state(seed=0)\n result = converter(image)\n np.testing.assert_allclose(result[\"img\"], expected_data, rtol=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_gaussian_smooth.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_gaussian_smooth.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rand_gaussian_smooth.py", "file_name": "test_rand_gaussian_smooth.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 53, "span_ids": ["TestRandGaussianSmooth.test_value", "TestRandGaussianSmooth", "impl:5", "docstring"], "tokens": 580}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 RandGaussianSmooth\n\nTEST_CASE_1 = [\n {\"sigma_x\": (0.5, 1.5), \"prob\": 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(\n [\n [[0.7291442, 0.9260285, 0.7291442], [1.1054044, 1.4038869, 1.1054044], [1.0672514, 1.3554319, 1.0672514]],\n [[2.076441, 2.6371238, 2.076441], [2.763511, 3.5097172, 2.763511], [2.4145484, 3.0665274, 2.4145484]],\n ]\n ),\n]\n\nTEST_CASE_2 = [\n {\"sigma_x\": (0.5, 1.5), \"sigma_y\": (0.5, 1.0), \"prob\": 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(\n [\n [[0.78625894, 1.0031066, 0.78625894], [1.1919919, 1.5207394, 1.191992], [1.1508504, 1.4682512, 1.1508505]],\n [[2.239091, 2.8566248, 2.239091], [2.97998, 3.8018486, 2.97998], [2.6036828, 3.3217697, 2.6036828]],\n ]\n ),\n]\n\n\nclass TestRandGaussianSmooth(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2])\n def test_value(self, argments, image, expected_data):\n converter = RandGaussianSmooth(**argments)\n converter.set_random_state(seed=0)\n result = converter(image)\n np.testing.assert_allclose(result, expected_data, rtol=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_gaussian_smoothd.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_rand_gaussian_smoothd.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_rand_gaussian_smoothd.py", "file_name": "test_rand_gaussian_smoothd.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 53, "span_ids": ["TestRandGaussianSmoothd.test_value", "impl:5", "TestRandGaussianSmoothd", "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\n\nimport numpy as np\nfrom parameterized import parameterized\n\nfrom monai.transforms import RandGaussianSmoothd\n\nTEST_CASE_1 = [\n {\"keys\": \"img\", \"sigma_x\": (0.5, 1.5), \"prob\": 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(\n [\n [[0.7291442, 0.9260285, 0.7291442], [1.1054044, 1.4038869, 1.1054044], [1.0672514, 1.3554319, 1.0672514]],\n [[2.076441, 2.6371238, 2.076441], [2.763511, 3.5097172, 2.763511], [2.4145484, 3.0665274, 2.4145484]],\n ]\n ),\n]\n\nTEST_CASE_2 = [\n {\"keys\": \"img\", \"sigma_x\": (0.5, 1.5), \"sigma_y\": (0.5, 1.0), \"prob\": 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(\n [\n [[0.78625894, 1.0031066, 0.78625894], [1.1919919, 1.5207394, 1.191992], [1.1508504, 1.4682512, 1.1508505]],\n [[2.239091, 2.8566248, 2.239091], [2.97998, 3.8018486, 2.97998], [2.6036828, 3.3217697, 2.6036828]],\n ]\n ),\n]\n\n\nclass TestRandGaussianSmoothd(unittest.TestCase):\n @parameterized.expand([TEST_CASE_1, TEST_CASE_2])\n def test_value(self, argments, image, expected_data):\n converter = RandGaussianSmoothd(**argments)\n converter.set_random_state(seed=0)\n result = converter(image)\n np.testing.assert_allclose(result[\"img\"], expected_data, rtol=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_segresnet.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_segresnet.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_segresnet.py", "file_name": "test_segresnet.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 102, "span_ids": ["impl:30", "TestResBlock.test_ill_arg", "TestResBlockVAE.test_vae_shape", "TestResBlock", "TestResBlockVAE", "docstring", "TestResBlock.test_shape"], "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": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.networks.nets import SegResNet, SegResNetVAE\n\nTEST_CASE_SEGRESNET = []\nfor spatial_dims in range(2, 4):\n for init_filters in [8, 16]:\n for dropout_prob in [None, 0.2]:\n for norm_name in [\"group\", \"batch\", \"instance\"]:\n for upsample_mode in [\"trilinear\", \"transpose\"]:\n test_case = [\n {\n \"spatial_dims\": spatial_dims,\n \"init_filters\": init_filters,\n \"dropout_prob\": dropout_prob,\n \"norm_name\": norm_name,\n \"upsample_mode\": upsample_mode,\n \"use_conv_final\": False,\n },\n torch.randn(2, 1, *([16] * spatial_dims)),\n (2, init_filters, *([16] * spatial_dims)),\n ]\n TEST_CASE_SEGRESNET.append(test_case)\n\nTEST_CASE_SEGRESNET_2 = []\nfor spatial_dims in range(2, 4):\n for init_filters in [8, 16]:\n for out_channels in range(1, 3):\n for upsample_mode in [\"bilinear\", \"transpose\"]:\n test_case = [\n {\n \"spatial_dims\": spatial_dims,\n \"init_filters\": init_filters,\n \"out_channels\": out_channels,\n \"upsample_mode\": upsample_mode,\n },\n torch.randn(2, 1, *([16] * spatial_dims)),\n (2, out_channels, *([16] * spatial_dims)),\n ]\n TEST_CASE_SEGRESNET_2.append(test_case)\n\nTEST_CASE_SEGRESNET_VAE = []\nfor spatial_dims in range(2, 4):\n for init_filters in [8, 16]:\n for out_channels in range(1, 3):\n for upsample_mode in [\"bilinear\", \"transpose\"]:\n for vae_estimate_std in [True, False]:\n test_case = [\n {\n \"spatial_dims\": spatial_dims,\n \"init_filters\": init_filters,\n \"out_channels\": out_channels,\n \"upsample_mode\": upsample_mode,\n \"input_image_size\": ([16] * spatial_dims),\n \"vae_estimate_std\": vae_estimate_std,\n },\n torch.randn(2, 1, *([16] * spatial_dims)),\n (2, out_channels, *([16] * spatial_dims)),\n ]\n TEST_CASE_SEGRESNET_VAE.append(test_case)\n\n\nclass TestResBlock(unittest.TestCase):\n @parameterized.expand(TEST_CASE_SEGRESNET + TEST_CASE_SEGRESNET_2)\n def test_shape(self, input_param, input_data, expected_shape):\n net = SegResNet(**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(AssertionError):\n SegResNet(spatial_dims=4)\n\n\nclass TestResBlockVAE(unittest.TestCase):\n @parameterized.expand(TEST_CASE_SEGRESNET_VAE)\n def test_vae_shape(self, input_param, input_data, expected_shape):\n net = SegResNetVAE(**input_param)\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_segresnet_block.py_unittest_for_spatial_dims_in_range.for_in_channels_in_range_.for_kernel_size_in_1_3_.TEST_CASE_RESBLOCK_append": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_segresnet_block.py_unittest_for_spatial_dims_in_range.for_in_channels_in_range_.for_kernel_size_in_1_3_.TEST_CASE_RESBLOCK_append", "embedding": null, "metadata": {"file_path": "tests/test_segresnet_block.py", "file_name": "test_segresnet_block.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 35, "span_ids": ["docstring"], "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": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.networks.blocks.segresnet_block import ResBlock\n\nTEST_CASE_RESBLOCK = []\nfor spatial_dims in range(2, 4):\n for in_channels in range(1, 4):\n for kernel_size in [1, 3]:\n for norm_name in [\"group\", \"batch\", \"instance\"]:\n test_case = [\n {\n \"spatial_dims\": spatial_dims,\n \"in_channels\": in_channels,\n \"kernel_size\": kernel_size,\n \"norm_name\": norm_name,\n \"num_groups\": in_channels,\n },\n torch.randn(2, in_channels, *([16] * spatial_dims)),\n (2, in_channels, *([16] * spatial_dims)),\n ]\n TEST_CASE_RESBLOCK.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_segresnet_block.py_TestResBlock_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_segresnet_block.py_TestResBlock_", "embedding": null, "metadata": {"file_path": "tests/test_segresnet_block.py", "file_name": "test_segresnet_block.py", "file_type": "text/x-python", "category": "test", "start_line": 38, "end_line": 58, "span_ids": ["impl:10", "TestResBlock.test_ill_arg", "TestResBlock", "TestResBlock.test_shape"], "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 TestResBlock(unittest.TestCase):\n @parameterized.expand(TEST_CASE_RESBLOCK)\n def test_shape(self, input_param, input_data, expected_shape):\n net = ResBlock(**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(AssertionError):\n ResBlock(spatial_dims=3, in_channels=8, kernel_size=2, num_groups=8)\n with self.assertRaises(ValueError):\n ResBlock(spatial_dims=3, in_channels=8, norm_name=\"norm\", num_groups=8)\n with self.assertRaises(AssertionError):\n ResBlock(spatial_dims=3, in_channels=8, num_groups=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_senet.py_unittest_TEST_CASE_6._se_resnext101_32x4d_in": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_senet.py_unittest_TEST_CASE_6._se_resnext101_32x4d_in", "embedding": null, "metadata": {"file_path": "tests/test_senet.py", "file_name": "test_senet.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 33, "span_ids": ["docstring"], "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": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.networks.nets import (\n se_resnet50,\n se_resnet101,\n se_resnet152,\n se_resnext50_32x4d,\n se_resnext101_32x4d,\n senet154,\n)\n\ninput_param = {\"spatial_dims\": 3, \"in_channels\": 2, \"num_classes\": 10}\n\nTEST_CASE_1 = [senet154(**input_param)]\nTEST_CASE_2 = [se_resnet50(**input_param)]\nTEST_CASE_3 = [se_resnet101(**input_param)]\nTEST_CASE_4 = [se_resnet152(**input_param)]\nTEST_CASE_5 = [se_resnext50_32x4d(**input_param)]\nTEST_CASE_6 = [se_resnext101_32x4d(**input_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/tests/test_senet.py_TestSENET_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_senet.py_TestSENET_", "embedding": null, "metadata": {"file_path": "tests/test_senet.py", "file_name": "test_senet.py", "file_type": "text/x-python", "category": "test", "start_line": 36, "end_line": 45, "span_ids": ["TestSENET", "TestSENET.test_senet154_shape"], "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": "class TestSENET(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_senet154_shape(self, net):\n input_data = torch.randn(5, 2, 64, 64, 64)\n expected_shape = (5, 10)\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_simulatedelay.py_time_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_simulatedelay.py_time_", "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": 35, "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 time\nimport unittest\n\nimport numpy as np\nfrom parameterized import parameterized\n\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_time_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_simulatedelayd.py_time_", "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": 35, "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 time\nimport unittest\n\nimport numpy as np\nfrom parameterized import parameterized\n\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_8._": {"__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_8._", "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": 43, "span_ids": ["docstring:17", "docstring"], "tokens": 518}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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.inferers import sliding_window_inference\n\nTEST_CASE_0 = [(1, 3, 16, 15, 7), (4, -1, 7), 3, 0.25, \"constant\", torch.device(\"cpu:0\")] # 3D small roi\n\nTEST_CASE_1 = [(1, 3, 16, 15, 7), (4, 10, 7), 3, 0.25, \"constant\", torch.device(\"cpu:0\")] # 3D small roi\n\nTEST_CASE_2 = [(1, 3, 16, 15, 7), (20, 22, 23), 10, 0.25, \"constant\", torch.device(\"cpu:0\")] # 3D large roi\n\nTEST_CASE_3 = [(1, 3, 15, 7), (2, 6), 1000, 0.25, \"constant\", torch.device(\"cpu:0\")] # 2D small roi, large batch\n\nTEST_CASE_4 = [(1, 3, 16, 7), (80, 50), 7, 0.25, \"constant\", torch.device(\"cpu:0\")] # 2D large roi\n\nTEST_CASE_5 = [(1, 3, 16, 15, 7), (20, 22, 23), 10, 0.5, \"constant\", torch.device(\"cpu:0\")] # 3D large overlap\n\nTEST_CASE_6 = [(1, 3, 16, 7), (80, 50), 7, 0.5, \"gaussian\", torch.device(\"cpu:0\")] # 2D large overlap, gaussian\n\nTEST_CASE_7 = [(1, 3, 16, 15, 7), (4, 10, 7), 3, 0.25, \"gaussian\", torch.device(\"cpu:0\")] # 3D small roi, gaussian\n\nTEST_CASE_8 = [\n (1, 3, 16, 15, 7),\n (4, 10, 7),\n 3,\n 0.25,\n \"gaussian\",\n torch.device(\"cuda: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_sliding_window_inference.py__test_inference_on_gpu_i_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_sliding_window_inference.py__test_inference_on_gpu_i_", "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": 43, "end_line": 66, "span_ids": ["TestSlidingWindowInference", "TestSlidingWindowInference.test_sliding_window_default", "impl:19", "docstring:17"], "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": " # test inference on gpu if availabe\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, device):\n inputs = torch.ones(*image_shape)\n if device.type == \"cuda\" and not torch.cuda.is_available():\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 np.testing.assert_string_equal(device.type, result.device.type)\n expected_val = np.ones(image_shape, dtype=np.float32) + 1\n np.testing.assert_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_squeezedim.py_unittest_TEST_CASE_6._TypeError_dim_0_5_": {"__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._TypeError_dim_0_5_", "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": 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 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 = [ValueError, {\"dim\": -2}, np.random.rand(1, 1, 16, 8, 1)]\n\nTEST_CASE_6 = [TypeError, {\"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_subpixel_upsample.py_unittest_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_subpixel_upsample.py_unittest_", "embedding": null, "metadata": {"file_path": "tests/test_subpixel_upsample.py", "file_name": "test_subpixel_upsample.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 69, "span_ids": ["impl:17", "impl:20", "TestSUBPIXEL.test_subpixel_shape", "TestSUBPIXEL", "docstring"], "tokens": 573}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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\nfrom parameterized import parameterized\n\nfrom monai.networks.blocks import SubpixelUpsample\nfrom monai.networks.layers.factories import Conv\n\nTEST_CASE_SUBPIXEL = []\nfor inch in range(1, 5):\n for dim in range(1, 4):\n for factor in range(1, 3):\n test_case = [\n {\"spatial_dims\": dim, \"in_channels\": inch, \"scale_factor\": factor},\n torch.randn(2, inch, *([8] * dim)),\n (2, inch, *([8 * factor] * dim)),\n ]\n TEST_CASE_SUBPIXEL.append(test_case)\nTEST_CASE_SUBPIXEL_2D_EXTRA = [\n {\"spatial_dims\": 2, \"in_channels\": 2, \"scale_factor\": 3},\n torch.randn(2, 2, 8, 4), # different size for H and W\n (2, 2, 24, 12),\n]\nTEST_CASE_SUBPIXEL_3D_EXTRA = [\n {\"spatial_dims\": 3, \"in_channels\": 1, \"scale_factor\": 2},\n torch.randn(2, 1, 16, 8, 4), # different size for H, W and D\n (2, 1, 32, 16, 8),\n]\n\nconv_block = nn.Sequential(\n Conv[Conv.CONV, 3](1, 4, kernel_size=1), Conv[Conv.CONV, 3](4, 8, kernel_size=3, stride=1, padding=1,),\n)\n\nTEST_CASE_SUBPIXEL_CONV_BLOCK_EXTRA = [\n {\"spatial_dims\": 3, \"in_channels\": 1, \"scale_factor\": 2, \"conv_block\": conv_block},\n torch.randn(2, 1, 16, 8, 4), # different size for H, W and D\n (2, 1, 32, 16, 8),\n]\n\nTEST_CASE_SUBPIXEL.append(TEST_CASE_SUBPIXEL_2D_EXTRA)\nTEST_CASE_SUBPIXEL.append(TEST_CASE_SUBPIXEL_3D_EXTRA)\nTEST_CASE_SUBPIXEL.append(TEST_CASE_SUBPIXEL_CONV_BLOCK_EXTRA)\n\n\nclass TestSUBPIXEL(unittest.TestCase):\n @parameterized.expand(TEST_CASE_SUBPIXEL)\n def test_subpixel_shape(self, input_param, input_data, expected_shape):\n net = SubpixelUpsample(**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_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": 120, "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 TverskyLoss\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_vnet.py_unittest_TEST_CASE_VNET_3D_3._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_vnet.py_unittest_TEST_CASE_VNET_3D_3._", "embedding": null, "metadata": {"file_path": "tests/test_vnet.py", "file_name": "test_vnet.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 48, "span_ids": ["impl:11", "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 unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.networks.nets import VNet\n\nTEST_CASE_VNET_2D_1 = [\n {\"spatial_dims\": 2, \"in_channels\": 4, \"out_channels\": 1, \"act\": \"elu\", \"dropout_dim\": 1},\n torch.randn(1, 4, 32, 32),\n (1, 1, 32, 32),\n]\nTEST_CASE_VNET_2D_2 = [\n {\"spatial_dims\": 2, \"in_channels\": 2, \"out_channels\": 2, \"act\": \"prelu\", \"dropout_dim\": 2},\n torch.randn(1, 2, 32, 32),\n (1, 2, 32, 32),\n]\nTEST_CASE_VNET_2D_3 = [\n {\"spatial_dims\": 2, \"in_channels\": 1, \"out_channels\": 3, \"dropout_dim\": 3},\n torch.randn(1, 1, 32, 32),\n (1, 3, 32, 32),\n]\nTEST_CASE_VNET_3D_1 = [\n {\"spatial_dims\": 3, \"in_channels\": 4, \"out_channels\": 1, \"act\": \"elu\", \"dropout_dim\": 1},\n torch.randn(1, 4, 32, 32, 32),\n (1, 1, 32, 32, 32),\n]\nTEST_CASE_VNET_3D_2 = [\n {\"spatial_dims\": 3, \"in_channels\": 2, \"out_channels\": 2, \"act\": \"prelu\", \"dropout_dim\": 2},\n torch.randn(1, 2, 32, 32, 32),\n (1, 2, 32, 32, 32),\n]\nTEST_CASE_VNET_3D_3 = [\n {\"spatial_dims\": 3, \"in_channels\": 1, \"out_channels\": 3, \"dropout_dim\": 3},\n torch.randn(1, 1, 32, 32, 32),\n (1, 3, 32, 32, 32),\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_vnet.py_TestVNet_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_vnet.py_TestVNet_", "embedding": null, "metadata": {"file_path": "tests/test_vnet.py", "file_name": "test_vnet.py", "file_type": "text/x-python", "category": "test", "start_line": 51, "end_line": 68, "span_ids": ["TestVNet", "TestVNet.test_vnet_shape"], "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 TestVNet(unittest.TestCase):\n @parameterized.expand(\n [\n TEST_CASE_VNET_2D_1,\n TEST_CASE_VNET_2D_2,\n TEST_CASE_VNET_2D_3,\n TEST_CASE_VNET_3D_1,\n TEST_CASE_VNET_3D_2,\n TEST_CASE_VNET_3D_3,\n ]\n )\n def test_vnet_shape(self, input_param, input_data, expected_shape):\n net = VNet(**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_vote_ensemble.py_unittest_TEST_CASE_5._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_vote_ensemble.py_unittest_TEST_CASE_5._", "embedding": null, "metadata": {"file_path": "tests/test_vote_ensemble.py", "file_name": "test_vote_ensemble.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 52, "span_ids": ["docstring"], "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": "import unittest\n\nimport torch\nfrom parameterized import parameterized\n\nfrom monai.transforms import VoteEnsemble\n\n# shape: [1, 2, 1, 1]\nTEST_CASE_1 = [\n {\"num_classes\": None},\n [torch.tensor([[[[1]], [[0]]]]), torch.tensor([[[[1]], [[0]]]]), torch.tensor([[[[0]], [[1]]]])],\n torch.tensor([[[[1.0]], [[0.0]]]]),\n]\n\n# shape: [1, 2, 1, 1]\nTEST_CASE_2 = [\n {\"num_classes\": None},\n torch.stack([torch.tensor([[[[1]], [[0]]]]), torch.tensor([[[[1]], [[0]]]]), torch.tensor([[[[0]], [[1]]]])]),\n torch.tensor([[[[1.0]], [[0.0]]]]),\n]\n\n# shape: [1, 1, 2, 1]\nTEST_CASE_3 = [\n {\"num_classes\": 3},\n [torch.tensor([[[[0], [2]]]]), torch.tensor([[[[0], [2]]]]), torch.tensor([[[[1], [1]]]])],\n torch.tensor([[[[0], [2]]]]),\n]\n\n# shape: [1, 1, 2, 1]\nTEST_CASE_4 = [\n {\"num_classes\": 5},\n [torch.tensor([[[[0], [2]]]]), torch.tensor([[[[0], [2]]]]), torch.tensor([[[[1], [1]]]])],\n torch.tensor([[[[0], [2]]]]),\n]\n\n# shape: [2]\nTEST_CASE_5 = [\n {\"num_classes\": 3},\n [torch.tensor([0, 2]), torch.tensor([0, 2]), torch.tensor([1, 1])],\n torch.tensor([0, 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_vote_ensemble.py_TestVoteEnsemble_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_vote_ensemble.py_TestVoteEnsemble_", "embedding": null, "metadata": {"file_path": "tests/test_vote_ensemble.py", "file_name": "test_vote_ensemble.py", "file_type": "text/x-python", "category": "test", "start_line": 55, "end_line": 75, "span_ids": ["TestVoteEnsemble.test_cuda_value", "TestVoteEnsemble", "TestVoteEnsemble.test_value", "impl:11"], "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 TestVoteEnsemble(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, input_param, img, expected_value):\n result = VoteEnsemble(**input_param)(img)\n torch.testing.assert_allclose(result, expected_value)\n\n def test_cuda_value(self):\n img = torch.stack(\n [torch.tensor([[[[1]], [[0]]]]), torch.tensor([[[[1]], [[0]]]]), torch.tensor([[[[0]], [[1]]]])]\n )\n expected_value = torch.tensor([[[[1.0]], [[0.0]]]])\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 = VoteEnsemble(num_classes=None)(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_vote_ensembled.py_unittest_TEST_CASE_5._": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_vote_ensembled.py_unittest_TEST_CASE_5._", "embedding": null, "metadata": {"file_path": "tests/test_vote_ensembled.py", "file_name": "test_vote_ensembled.py", "file_type": "text/x-python", "category": "test", "start_line": 12, "end_line": 68, "span_ids": ["docstring:14", "docstring"], "tokens": 585}, "excluded_embed_metadata_keys": ["file_name", "file_type", "file_size", "creation_date", "last_modified_date", "last_accessed_date", "start_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 VoteEnsembled\n\n# shape: [1, 2, 1, 1]\nTEST_CASE_1 = [\n {\"keys\": [\"pred0\", \"pred1\", \"pred2\"], \"output_key\": \"output\", \"num_classes\": None},\n {\n \"pred0\": torch.tensor([[[[1]], [[0]]]]),\n \"pred1\": torch.tensor([[[[1]], [[0]]]]),\n \"pred2\": torch.tensor([[[[0]], [[1]]]]),\n },\n torch.tensor([[[[1.0]], [[0.0]]]]),\n]\n\n# shape: [1, 2, 1, 1]\nTEST_CASE_2 = [\n {\"keys\": \"output\", \"output_key\": \"output\", \"num_classes\": None},\n {\n \"output\": torch.stack(\n [torch.tensor([[[[1]], [[0]]]]), torch.tensor([[[[1]], [[0]]]]), torch.tensor([[[[0]], [[1]]]])]\n )\n },\n torch.tensor([[[[1.0]], [[0.0]]]]),\n]\n\n# shape: [1, 1, 2, 1]\nTEST_CASE_3 = [\n {\"keys\": [\"pred0\", \"pred1\", \"pred2\"], \"output_key\": \"output\", \"num_classes\": 3},\n {\n \"pred0\": torch.tensor([[[[0], [2]]]]),\n \"pred1\": torch.tensor([[[[0], [2]]]]),\n \"pred2\": torch.tensor([[[[1], [1]]]]),\n },\n torch.tensor([[[[0], [2]]]]),\n]\n\n# shape: [1, 1, 2, 1]\nTEST_CASE_4 = [\n {\"keys\": [\"pred0\", \"pred1\", \"pred2\"], \"output_key\": \"output\", \"num_classes\": 5},\n {\n \"pred0\": torch.tensor([[[[0], [2]]]]),\n \"pred1\": torch.tensor([[[[0], [2]]]]),\n \"pred2\": torch.tensor([[[[1], [1]]]]),\n },\n torch.tensor([[[[0], [2]]]]),\n]\n\n# shape: [2]\nTEST_CASE_5 = [\n {\"keys\": [\"pred0\", \"pred1\", \"pred2\"], \"output_key\": \"output\", \"num_classes\": 3},\n {\"pred0\": torch.tensor([0, 2]), \"pred1\": torch.tensor([0, 2]), \"pred2\": torch.tensor([1, 1])},\n torch.tensor([0, 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_vote_ensembled.py_TestVoteEnsembled_": {"__data__": {"id_": "/home/jiayipan/code/24FA/temp/ml-01/moatless-tools/t/repos/swe-train_Project-MONAI__MONAI/tests/test_vote_ensembled.py_TestVoteEnsembled_", "embedding": null, "metadata": {"file_path": "tests/test_vote_ensembled.py", "file_name": "test_vote_ensembled.py", "file_type": "text/x-python", "category": "test", "start_line": 71, "end_line": 91, "span_ids": ["TestVoteEnsembled.test_cuda_value", "TestVoteEnsembled", "impl:11", "TestVoteEnsembled.test_value"], "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 TestVoteEnsembled(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, input_param, img, expected_value):\n result = VoteEnsembled(**input_param)(img)\n torch.testing.assert_allclose(result[\"output\"], expected_value)\n\n def test_cuda_value(self):\n img = torch.stack(\n [torch.tensor([[[[1]], [[0]]]]), torch.tensor([[[[1]], [[0]]]]), torch.tensor([[[[0]], [[1]]]])]\n )\n expected_value = torch.tensor([[[[1.0]], [[0.0]]]])\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 = VoteEnsembled(keys=\"output\", num_classes=None)({\"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"}}}