Full Code of apple/corenet for AI

main f9f83e616a34 cached
738 files
7.5 MB
2.0M tokens
2560 symbols
1 requests
Download .txt
Showing preview only (8,014K chars total). Download the full file or copy to clipboard to get everything.
Repository: apple/corenet
Branch: main
Commit: f9f83e616a34
Files: 738
Total size: 7.5 MB

Directory structure:
gitextract_0z54odcq/

├── .dockerignore
├── .flake8
├── .gitattributes
├── .gitignore
├── ACKNOWLEDGEMENTS
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── Makefile
├── README.md
├── conftest.py
├── corenet/
│   ├── __init__.py
│   ├── __main__.py
│   ├── __version__.py
│   ├── cli/
│   │   ├── __init__.py
│   │   ├── entrypoints.py
│   │   ├── main.py
│   │   ├── main_benchmark.py
│   │   ├── main_conversion.py
│   │   ├── main_eval.py
│   │   ├── main_eval_llmadapters.py
│   │   └── main_train.py
│   ├── constants.py
│   ├── data/
│   │   ├── __init__.py
│   │   ├── collate_fns/
│   │   │   ├── __init__.py
│   │   │   ├── byteformer_collate_functions.py
│   │   │   └── collate_functions.py
│   │   ├── data_loaders.py
│   │   ├── datasets/
│   │   │   ├── __init__.py
│   │   │   ├── audio_classification/
│   │   │   │   ├── __init__.py
│   │   │   │   └── speech_commands_v2.py
│   │   │   ├── classification/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_image_classification_dataset.py
│   │   │   │   ├── base_imagenet_shift_dataset.py
│   │   │   │   ├── coco.py
│   │   │   │   ├── imagenet.py
│   │   │   │   ├── imagenet_a.py
│   │   │   │   ├── imagenet_r.py
│   │   │   │   ├── imagenet_sketch.py
│   │   │   │   ├── imagenet_synsets.py
│   │   │   │   ├── imagenet_v2.py
│   │   │   │   ├── places365.py
│   │   │   │   └── wordnet_tagged_classification.py
│   │   │   ├── dataset_base.py
│   │   │   ├── detection/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_detection.py
│   │   │   │   ├── coco_base.py
│   │   │   │   ├── coco_mask_rcnn.py
│   │   │   │   └── coco_ssd.py
│   │   │   ├── language_modeling/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_lm.py
│   │   │   │   ├── commonsense_170k.py
│   │   │   │   └── general_lm.py
│   │   │   ├── multi_modal_img_text/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_multi_modal_img_text.py
│   │   │   │   ├── flickr.py
│   │   │   │   ├── img_text_tar_dataset.py
│   │   │   │   └── zero_shot_image_classification/
│   │   │   │       ├── __init__.py
│   │   │   │       ├── base_zero_shot_image_classification.py
│   │   │   │       ├── imagenet.py
│   │   │   │       ├── imagenet_a.py
│   │   │   │       ├── imagenet_class_names.py
│   │   │   │       ├── imagenet_r.py
│   │   │   │       ├── imagenet_sketch.py
│   │   │   │       └── templates.py
│   │   │   ├── segmentation/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── ade20k.py
│   │   │   │   ├── base_segmentation.py
│   │   │   │   ├── coco_segmentation.py
│   │   │   │   ├── coco_stuff.py
│   │   │   │   └── pascal_voc.py
│   │   │   └── utils/
│   │   │       ├── __init__.py
│   │   │       ├── common.py
│   │   │       ├── text.py
│   │   │       └── video.py
│   │   ├── io/
│   │   │   ├── __init__.py
│   │   │   └── transfer_clients.py
│   │   ├── loader/
│   │   │   ├── __init__.py
│   │   │   └── dataloader.py
│   │   ├── sampler/
│   │   │   ├── __init__.py
│   │   │   ├── base_sampler.py
│   │   │   ├── batch_sampler.py
│   │   │   ├── chain_sampler.py
│   │   │   ├── multi_scale_sampler.py
│   │   │   ├── utils.py
│   │   │   ├── variable_batch_sampler.py
│   │   │   ├── video_batch_sampler.py
│   │   │   ├── video_clip_batch_sampler.py
│   │   │   └── video_variable_seq_sampler.py
│   │   ├── text_tokenizer/
│   │   │   ├── __init__.py
│   │   │   ├── base_tokenizer.py
│   │   │   ├── clip_tokenizer.py
│   │   │   └── sentencepiece_tokenizer.py
│   │   ├── transforms/
│   │   │   ├── __init__.py
│   │   │   ├── audio.py
│   │   │   ├── audio_aux/
│   │   │   │   ├── __init__.py
│   │   │   │   └── mfccs.py
│   │   │   ├── audio_bytes.py
│   │   │   ├── base_transforms.py
│   │   │   ├── common.py
│   │   │   ├── image_bytes.py
│   │   │   ├── image_pil.py
│   │   │   ├── image_torch.py
│   │   │   ├── utils.py
│   │   │   └── video.py
│   │   └── video_reader/
│   │       ├── __init__.py
│   │       ├── base_av_reader.py
│   │       ├── decord_reader.py
│   │       ├── ffmpeg_reader.py
│   │       ├── ffmpeg_utils.py
│   │       └── pyav_reader.py
│   ├── engine/
│   │   ├── __init__.py
│   │   ├── default_trainer.py
│   │   ├── detection_utils/
│   │   │   ├── __init__.py
│   │   │   └── coco_map.py
│   │   ├── eval_detection.py
│   │   ├── eval_segmentation.py
│   │   ├── evaluation_engine.py
│   │   ├── fsdp_trainer.py
│   │   ├── segmentation_utils/
│   │   │   ├── __init__.py
│   │   │   └── cityscapes_iou.py
│   │   └── utils.py
│   ├── loss_fn/
│   │   ├── __init__.py
│   │   ├── base_criteria.py
│   │   ├── classification/
│   │   │   ├── __init__.py
│   │   │   ├── base_classification_criteria.py
│   │   │   ├── binary_cross_entropy.py
│   │   │   ├── cross_entropy.py
│   │   │   └── focal_loss.py
│   │   ├── composite_loss.py
│   │   ├── detection/
│   │   │   ├── __init__.py
│   │   │   ├── base_detection_criteria.py
│   │   │   ├── mask_rcnn_loss.py
│   │   │   └── ssd_multibox_loss.py
│   │   ├── distillation/
│   │   │   ├── __init__.py
│   │   │   ├── base_distillation.py
│   │   │   ├── hard_distillation.py
│   │   │   └── soft_kl_distillation.py
│   │   ├── language_modeling/
│   │   │   ├── __init__.py
│   │   │   ├── base_lm.py
│   │   │   ├── cross_entropy.py
│   │   │   └── cross_entropy_for_kv_prediction.py
│   │   ├── multi_modal_img_text/
│   │   │   ├── __init__.py
│   │   │   ├── base_multi_modal_img_text_criteria.py
│   │   │   └── contrastive_loss_clip.py
│   │   ├── neural_augmentation.py
│   │   ├── segmentation/
│   │   │   ├── __init__.py
│   │   │   ├── base_segmentation_criteria.py
│   │   │   └── cross_entropy.py
│   │   └── utils/
│   │       ├── __init__.py
│   │       ├── build_helper.py
│   │       └── class_weighting.py
│   ├── metrics/
│   │   ├── __init__.py
│   │   ├── average_precision.py
│   │   ├── coco_map.py
│   │   ├── confusion_mat.py
│   │   ├── image_text_retrieval.py
│   │   ├── intersection_over_union.py
│   │   ├── metric_base.py
│   │   ├── metric_base_test.py
│   │   ├── misc.py
│   │   ├── multiclass_classification_pr.py
│   │   ├── probability_histograms.py
│   │   ├── psnr.py
│   │   ├── retrieval_cmc.py
│   │   ├── stats.py
│   │   ├── topk_accuracy.py
│   │   └── vqa_preset_score.py
│   ├── modeling/
│   │   ├── __init__.py
│   │   ├── anchor_generator/
│   │   │   ├── __init__.py
│   │   │   ├── base_anchor_generator.py
│   │   │   └── ssd_anchor_generator.py
│   │   ├── image_projection_layers/
│   │   │   ├── __init__.py
│   │   │   ├── attention_pool_2d.py
│   │   │   ├── base_image_projection.py
│   │   │   ├── global_pool_2d.py
│   │   │   └── simple_projection_head.py
│   │   ├── layers/
│   │   │   ├── __init__.py
│   │   │   ├── activation/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── gelu.py
│   │   │   │   ├── hard_sigmoid.py
│   │   │   │   ├── hard_swish.py
│   │   │   │   ├── leaky_relu.py
│   │   │   │   ├── prelu.py
│   │   │   │   ├── relu.py
│   │   │   │   ├── relu6.py
│   │   │   │   ├── sigmoid.py
│   │   │   │   ├── swish.py
│   │   │   │   └── tanh.py
│   │   │   ├── adaptive_pool.py
│   │   │   ├── base_layer.py
│   │   │   ├── conv_layer.py
│   │   │   ├── dropout.py
│   │   │   ├── embedding.py
│   │   │   ├── flash_multi_head_attention.py
│   │   │   ├── flatten.py
│   │   │   ├── global_pool.py
│   │   │   ├── identity.py
│   │   │   ├── linear_attention.py
│   │   │   ├── linear_layer.py
│   │   │   ├── multi_head_attention.py
│   │   │   ├── normalization/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── batch_norm.py
│   │   │   │   ├── group_norm.py
│   │   │   │   ├── instance_norm.py
│   │   │   │   ├── layer_norm.py
│   │   │   │   ├── rms_norm.py
│   │   │   │   └── sync_batch_norm.py
│   │   │   ├── normalization_layers.py
│   │   │   ├── pixel_shuffle.py
│   │   │   ├── pooling.py
│   │   │   ├── positional_embedding.py
│   │   │   ├── positional_encoding.py
│   │   │   ├── random_layers.py
│   │   │   ├── rotary_embeddings.py
│   │   │   ├── single_head_attention.py
│   │   │   ├── softmax.py
│   │   │   ├── stochastic_depth.py
│   │   │   ├── token_merging.py
│   │   │   └── upsample.py
│   │   ├── matcher_det/
│   │   │   ├── __init__.py
│   │   │   ├── base_matcher.py
│   │   │   └── ssd_matcher.py
│   │   ├── misc/
│   │   │   ├── __init__.py
│   │   │   ├── averaging_utils.py
│   │   │   ├── box_utils.py
│   │   │   ├── common.py
│   │   │   └── init_utils.py
│   │   ├── models/
│   │   │   ├── __init__.py
│   │   │   ├── audio_classification/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── audio_byteformer.py
│   │   │   │   └── base_audio_classification.py
│   │   │   ├── base_model.py
│   │   │   ├── classification/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_image_encoder.py
│   │   │   │   ├── byteformer.py
│   │   │   │   ├── config/
│   │   │   │   │   ├── __init__.py
│   │   │   │   │   ├── byteformer.py
│   │   │   │   │   ├── efficientnet.py
│   │   │   │   │   ├── fastvit.py
│   │   │   │   │   ├── mobilenetv1.py
│   │   │   │   │   ├── mobilenetv2.py
│   │   │   │   │   ├── mobilenetv3.py
│   │   │   │   │   ├── mobileone.py
│   │   │   │   │   ├── mobilevit.py
│   │   │   │   │   ├── mobilevit_v2.py
│   │   │   │   │   ├── regnet.py
│   │   │   │   │   ├── resnet.py
│   │   │   │   │   ├── swin_transformer.py
│   │   │   │   │   └── vit.py
│   │   │   │   ├── efficientnet.py
│   │   │   │   ├── fastvit.py
│   │   │   │   ├── mobilenetv1.py
│   │   │   │   ├── mobilenetv2.py
│   │   │   │   ├── mobilenetv3.py
│   │   │   │   ├── mobileone.py
│   │   │   │   ├── mobilevit.py
│   │   │   │   ├── mobilevit_v2.py
│   │   │   │   ├── regnet.py
│   │   │   │   ├── resnet.py
│   │   │   │   ├── swin_transformer.py
│   │   │   │   └── vit.py
│   │   │   ├── detection/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_detection.py
│   │   │   │   ├── mask_rcnn.py
│   │   │   │   ├── ssd.py
│   │   │   │   └── utils/
│   │   │   │       ├── __init__.py
│   │   │   │       └── rcnn_utils.py
│   │   │   ├── fsdp_wrapper.py
│   │   │   ├── language_modeling/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_lm.py
│   │   │   │   ├── general_gpt.py
│   │   │   │   └── kv_prediction.py
│   │   │   ├── multi_modal_img_text/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_multi_modal_img_text.py
│   │   │   │   └── clip.py
│   │   │   ├── segmentation/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_seg.py
│   │   │   │   ├── enc_dec.py
│   │   │   │   └── heads/
│   │   │   │       ├── __init__.py
│   │   │   │       ├── base_seg_head.py
│   │   │   │       ├── deeplabv3.py
│   │   │   │       ├── pspnet.py
│   │   │   │       └── simple_seg_head.py
│   │   │   └── video_classification/
│   │   │       ├── __init__.py
│   │   │       └── base_video_encoder.py
│   │   ├── modules/
│   │   │   ├── __init__.py
│   │   │   ├── aspp_block.py
│   │   │   ├── base_module.py
│   │   │   ├── efficientnet.py
│   │   │   ├── fastvit.py
│   │   │   ├── feature_pyramid.py
│   │   │   ├── flash_transformer.py
│   │   │   ├── mobilenetv2.py
│   │   │   ├── mobileone_block.py
│   │   │   ├── mobilevit_block.py
│   │   │   ├── pspnet_module.py
│   │   │   ├── regnet_modules.py
│   │   │   ├── resnet_modules.py
│   │   │   ├── squeeze_excitation.py
│   │   │   ├── ssd_heads.py
│   │   │   ├── swin_transformer_block.py
│   │   │   ├── transformer.py
│   │   │   └── windowed_transformer.py
│   │   ├── neural_augmentor/
│   │   │   ├── __init__.py
│   │   │   ├── neural_aug.py
│   │   │   └── utils/
│   │   │       ├── __init__.py
│   │   │       └── neural_aug_utils.py
│   │   └── text_encoders/
│   │       ├── __init__.py
│   │       ├── base_text_encoder.py
│   │       └── transformer.py
│   ├── optims/
│   │   ├── __init__.py
│   │   ├── adam.py
│   │   ├── adamw.py
│   │   ├── base_optim.py
│   │   ├── scheduler/
│   │   │   ├── __init__.py
│   │   │   ├── base_scheduler.py
│   │   │   ├── cosine.py
│   │   │   ├── cyclic.py
│   │   │   ├── fixed.py
│   │   │   ├── multi_step.py
│   │   │   └── polynomial.py
│   │   └── sgd.py
│   ├── options/
│   │   ├── __init__.py
│   │   ├── errors.py
│   │   ├── opts.py
│   │   ├── parse_args.py
│   │   └── utils.py
│   ├── third_party/
│   │   ├── __init__.py
│   │   ├── data/
│   │   │   ├── __init__.py
│   │   │   └── text_tokenizer/
│   │   │       ├── __init__.py
│   │   │       └── openai_clip_tokenizer.py
│   │   └── modeling/
│   │       ├── __init__.py
│   │       ├── lora.py
│   │       └── ssd_utils.py
│   ├── train_eval_pipelines/
│   │   ├── __init__.py
│   │   ├── base.py
│   │   ├── default_train_eval.py
│   │   └── fsdp_train_eval.py
│   └── utils/
│       ├── __init__.py
│       ├── activation_checkpointing_wrapper.py
│       ├── check.py
│       ├── checkpoint_utils.py
│       ├── color_map.py
│       ├── common_utils.py
│       ├── context_managers.py
│       ├── ddp_utils.py
│       ├── dict_utils.py
│       ├── download_utils.py
│       ├── file_logger.py
│       ├── fpdb.py
│       ├── hf_adapter_utils.py
│       ├── import_utils.py
│       ├── io_utils.py
│       ├── logger.py
│       ├── math_utils.py
│       ├── object_utils.py
│       ├── object_utils_test.py
│       ├── pytorch_to_coreml.py
│       ├── registry.py
│       ├── registry_test.py
│       ├── resources.py
│       ├── retry_utils.py
│       ├── tensor_utils.py
│       └── visualization_utils.py
├── mlx_examples/
│   ├── clip/
│   │   ├── README.md
│   │   ├── __init__.py
│   │   ├── clip.py
│   │   ├── image_processor.py
│   │   ├── main_clip_to_mlx.py
│   │   ├── main_test_clip_mlx.py
│   │   ├── model.py
│   │   ├── requirements.txt
│   │   ├── results/
│   │   │   └── .gitkeep
│   │   └── tokenizer.py
│   ├── open_elm/
│   │   ├── README.md
│   │   ├── __init__.py
│   │   ├── convert.py
│   │   ├── inference.py
│   │   └── open_elm.py
│   └── requirements.txt
├── projects/
│   ├── byteformer/
│   │   ├── README.md
│   │   ├── imagenet_file_encodings/
│   │   │   ├── encoding_type=PNG.yaml
│   │   │   ├── encoding_type=TIFF.yaml
│   │   │   ├── encoding_type=fCHW.yaml
│   │   │   └── encoding_type=fHWC.yaml
│   │   ├── imagenet_jpeg_q100/
│   │   │   ├── conv_kernel_size=16.yaml
│   │   │   ├── conv_kernel_size=32.yaml
│   │   │   └── conv_kernel_size=8.yaml
│   │   ├── imagenet_jpeg_q60/
│   │   │   ├── conv_kernel_size=16,window_sizes=[128].yaml
│   │   │   ├── conv_kernel_size=16,window_sizes=[32].yaml
│   │   │   ├── conv_kernel_size=32,window_sizes=[128].yaml
│   │   │   ├── conv_kernel_size=32,window_sizes=[32].yaml
│   │   │   ├── conv_kernel_size=4,window_sizes=[128].yaml
│   │   │   ├── conv_kernel_size=4,window_sizes=[32].yaml
│   │   │   ├── conv_kernel_size=8,window_sizes=[128].yaml
│   │   │   └── conv_kernel_size=8,window_sizes=[32].yaml
│   │   ├── imagenet_jpeg_shuffle_bytes/
│   │   │   ├── mode=cyclic_half_length.yaml
│   │   │   ├── mode=random_shuffle.yaml
│   │   │   ├── mode=reverse.yaml
│   │   │   ├── mode=stride.yaml
│   │   │   └── mode=window_shuffle.yaml
│   │   ├── imagenet_obfuscation/
│   │   │   ├── width_range=[-10,10].yaml
│   │   │   ├── width_range=[-20,20].yaml
│   │   │   ├── width_range=[-5,5].yaml
│   │   │   └── width_range=[0,0].yaml
│   │   ├── imagenet_privacy_preserving_camera/
│   │   │   ├── keep_frac=0.03,conv_kernel_size=4.yaml
│   │   │   ├── keep_frac=0.05,conv_kernel_size=4.yaml
│   │   │   ├── keep_frac=0.1,conv_kernel_size=4.yaml
│   │   │   ├── keep_frac=0.25,conv_kernel_size=8.yaml
│   │   │   ├── keep_frac=0.5,conv_kernel_size=16.yaml
│   │   │   └── keep_frac=0.75,conv_kernel_size=32.yaml
│   │   ├── speech_commands_mp3/
│   │   │   ├── conv_kernel_size=4,window_size=[128].yaml
│   │   │   ├── conv_kernel_size=4,window_size=[32].yaml
│   │   │   ├── conv_kernel_size=8,window_size=[128].yaml
│   │   │   └── conv_kernel_size=8,window_size=[32].yaml
│   │   └── speech_commands_wav/
│   │       ├── encoding_dtype=float32,conv_kernel_size=16.yaml
│   │       ├── encoding_dtype=float32,conv_kernel_size=32.yaml
│   │       ├── encoding_dtype=int16,conv_kernel_size=16.yaml
│   │       ├── encoding_dtype=int16,conv_kernel_size=32.yaml
│   │       ├── encoding_dtype=int16,conv_kernel_size=8.yaml
│   │       ├── encoding_dtype=int32,conv_kernel_size=16.yaml
│   │       ├── encoding_dtype=int32,conv_kernel_size=32.yaml
│   │       ├── encoding_dtype=uint8,conv_kernel_size=16.yaml
│   │       ├── encoding_dtype=uint8,conv_kernel_size=32.yaml
│   │       ├── encoding_dtype=uint8,conv_kernel_size=4.yaml
│   │       └── encoding_dtype=uint8,conv_kernel_size=8.yaml
│   ├── catlip/
│   │   ├── README-multi-label-object-classification.md
│   │   ├── README-object-detection.md
│   │   ├── README-pretraining.md
│   │   ├── README-semantic-segmentation.md
│   │   ├── README-single-label-object-classification.md
│   │   ├── README.md
│   │   ├── image_classification/
│   │   │   ├── imagenet/
│   │   │   │   ├── vit_base.yaml
│   │   │   │   ├── vit_base_512x512.yaml
│   │   │   │   ├── vit_huge.yaml
│   │   │   │   ├── vit_huge_512x512.yaml
│   │   │   │   ├── vit_large.yaml
│   │   │   │   └── vit_large_512x512.yaml
│   │   │   └── places365/
│   │   │       ├── vit_base.yaml
│   │   │       ├── vit_base_512x512.yaml
│   │   │       ├── vit_huge.yaml
│   │   │       ├── vit_huge_512x512.yaml
│   │   │       ├── vit_large.yaml
│   │   │       └── vit_large_512x512.yaml
│   │   ├── multi_label_image_classification/
│   │   │   ├── vit_base.yaml
│   │   │   └── vit_large.yaml
│   │   ├── object_detection/
│   │   │   ├── maskrcnn_vit_base.yaml
│   │   │   ├── maskrcnn_vit_huge.yaml
│   │   │   └── maskrcnn_vit_large.yaml
│   │   ├── pretraining/
│   │   │   ├── vit_base.yaml
│   │   │   ├── vit_huge.yaml
│   │   │   └── vit_large.yaml
│   │   └── semantic_segmentation/
│   │       ├── deeplabv3_vit_base.yaml
│   │       ├── deeplabv3_vit_huge.yaml
│   │       └── deeplabv3_vit_large.yaml
│   ├── clip/
│   │   ├── README.md
│   │   └── clip_vit_base.yaml
│   ├── fastvit/
│   │   ├── README.md
│   │   └── classification/
│   │       └── fastvit_t8_in1k.yaml
│   ├── kv-prediction/
│   │   ├── README.md
│   │   ├── openelm/
│   │   │   ├── openelm_1_1B_0_25.yaml
│   │   │   ├── openelm_1_1B_0_50.yaml
│   │   │   ├── openelm_1_1B_0_75.yaml
│   │   │   ├── openelm_1_1B_kvp_c_270M.yaml
│   │   │   ├── openelm_1_1B_kvp_c_450M.yaml
│   │   │   ├── openelm_1_1B_kvp_lp_0_25.yaml
│   │   │   ├── openelm_1_1B_kvp_lp_0_50.yaml
│   │   │   ├── openelm_1_1B_kvp_lp_0_75.yaml
│   │   │   ├── openelm_3B_kvp_c_1_1B.yaml
│   │   │   ├── openelm_3B_kvp_c_270M.yaml
│   │   │   ├── openelm_3B_kvp_c_450M.yaml
│   │   │   ├── openelm_3B_kvp_lp_0_25.yaml
│   │   │   ├── openelm_3B_kvp_lp_0_50.yaml
│   │   │   ├── openelm_3B_kvp_lp_0_75.yaml
│   │   │   ├── openelm_base_3B_aux_0_25l.yaml
│   │   │   ├── openelm_base_3B_aux_0_50l.yaml
│   │   │   └── openelm_base_3B_aux_0_75l.yaml
│   │   └── triviaqa-template.yaml
│   ├── mobilenet_v1/
│   │   ├── README.md
│   │   └── classification/
│   │       └── mobilenetv1_1.0_in1k.yaml
│   ├── mobilenet_v2/
│   │   ├── README.md
│   │   ├── classification/
│   │   │   └── mobilenetv2_1.0_in1k.yaml
│   │   └── segmentation/
│   │       └── deeplabv3_ade20k.yaml
│   ├── mobilenet_v3/
│   │   ├── README.md
│   │   └── classification/
│   │       └── mobilenetv3_large_in1k.yaml
│   ├── mobileone/
│   │   ├── README.md
│   │   └── classification/
│   │       └── mobileone_s1_in1k.yaml
│   ├── mobilevit/
│   │   └── README.md
│   ├── mobilevit_v2/
│   │   ├── README.md
│   │   ├── classification/
│   │   │   ├── mobilevitv2_2.0_ft_384x384.yaml
│   │   │   └── mobilevitv2_2.0_in1k.yaml
│   │   ├── detection/
│   │   │   └── mobilevitv2_2.0_ssd_coco.yaml
│   │   └── segmentation/
│   │       └── deeplabv3_mobilevitv2_1.0_ade20k.yaml
│   ├── openelm/
│   │   ├── README-instruct.md
│   │   ├── README-peft.md
│   │   ├── README-pretraining.md
│   │   ├── README.md
│   │   ├── instruction_tuning/
│   │   │   └── openelm-instruct.yaml
│   │   ├── peft_configs/
│   │   │   ├── openelm_lora_1_1B.yaml
│   │   │   ├── openelm_lora_270M.yaml
│   │   │   ├── openelm_lora_270M_eval.yaml
│   │   │   ├── openelm_lora_3B.yaml
│   │   │   └── openelm_lora_450M.yaml
│   │   └── pretraining_configs/
│   │       ├── openelm_1_1B.yaml
│   │       ├── openelm_270M.yaml
│   │       ├── openelm_3B.yaml
│   │       └── openelm_450M.yaml
│   ├── range_augment/
│   │   ├── README-classification.md
│   │   ├── README-clip.md
│   │   ├── README-distillation.md
│   │   ├── README-object-detection.md
│   │   ├── README-segmentation.md
│   │   ├── README.md
│   │   ├── classification/
│   │   │   ├── efficientnet_b0.yaml
│   │   │   ├── efficientnet_b1.yaml
│   │   │   ├── efficientnet_b2.yaml
│   │   │   ├── efficientnet_b3.yaml
│   │   │   ├── mobilenet_v1.yaml
│   │   │   ├── mobilenet_v2.yaml
│   │   │   ├── mobilenet_v3.yaml
│   │   │   ├── mobilevit_v1.yaml
│   │   │   ├── regnety_16gf.yaml
│   │   │   ├── resnet_101.yaml
│   │   │   ├── resnet_50.yaml
│   │   │   ├── se_resnet_50.yaml
│   │   │   ├── swin_transformer_small.yaml
│   │   │   └── swin_transformer_tiny.yaml
│   │   ├── clip/
│   │   │   ├── clip_vit_base.yaml
│   │   │   └── clip_vit_huge.yaml
│   │   ├── clip_finetune_imagenet/
│   │   │   ├── clip_vit_base.yaml
│   │   │   └── clip_vit_huge.yaml
│   │   ├── detection/
│   │   │   ├── maskrcnn_efficientnet_b3.yaml
│   │   │   ├── maskrcnn_mobilenet_v1.yaml
│   │   │   ├── maskrcnn_mobilenet_v2.yaml
│   │   │   ├── maskrcnn_mobilenet_v3.yaml
│   │   │   ├── maskrcnn_mobilevit.yaml
│   │   │   ├── maskrcnn_resnet_101.yaml
│   │   │   └── maskrcnn_resnet_50.yaml
│   │   ├── distillation/
│   │   │   ├── teacher_resnet101_student_mobilenet_v1.yaml
│   │   │   ├── teacher_resnet101_student_mobilenet_v2.yaml
│   │   │   ├── teacher_resnet101_student_mobilenet_v3.yaml
│   │   │   └── teacher_resnet101_student_mobilevit.yaml
│   │   └── segmentation/
│   │       ├── ade20k/
│   │       │   ├── deeplabv3_efficientnet_b3.yaml
│   │       │   ├── deeplabv3_mobilenet_v1.yaml
│   │       │   ├── deeplabv3_mobilenet_v2.yaml
│   │       │   ├── deeplabv3_mobilenet_v3.yaml
│   │       │   ├── deeplabv3_mobilevit.yaml
│   │       │   ├── deeplabv3_resnet_101.yaml
│   │       │   └── deeplabv3_resnet_50.yaml
│   │       └── pascal_voc/
│   │           ├── deeplabv3_efficientnet_b3.yaml
│   │           ├── deeplabv3_mobilenet_v1.yaml
│   │           ├── deeplabv3_mobilenet_v2.yaml
│   │           ├── deeplabv3_mobilenet_v3.yaml
│   │           ├── deeplabv3_resnet_101.yaml
│   │           └── deeplabv3_resnet_50.yaml
│   ├── resnet/
│   │   ├── README.md
│   │   ├── classification/
│   │   │   └── resnet50_in1k.yaml
│   │   └── detection/
│   │       └── ssd_resnet50_coco.yaml
│   └── vit/
│       ├── README.md
│       └── classification/
│           └── vit_base_in1k.yaml
├── pyproject.toml
├── requirements-optional.txt
├── requirements.txt
├── setup.py
├── tests/
│   ├── __init__.py
│   ├── configs.py
│   ├── data/
│   │   ├── __init__.py
│   │   ├── coco/
│   │   │   └── annotations/
│   │   │       ├── instances_train2017.json
│   │   │       └── instances_val2017.json
│   │   ├── collate_fns/
│   │   │   ├── __init__.py
│   │   │   ├── test_byteformer_collate_fn.py
│   │   │   └── test_collate_functions.py
│   │   ├── datasets/
│   │   │   ├── __init__.py
│   │   │   ├── audio_classification/
│   │   │   │   ├── __init__.py
│   │   │   │   └── test_speech_commands_v2.py
│   │   │   ├── classification/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── dummy_configs/
│   │   │   │   │   ├── coco.yaml
│   │   │   │   │   ├── image_classification_dataset.yaml
│   │   │   │   │   ├── imagenet.yaml
│   │   │   │   │   ├── imagenet_a.yaml
│   │   │   │   │   ├── imagenet_r.yaml
│   │   │   │   │   ├── imagenet_sketch.yaml
│   │   │   │   │   └── wordnet_tagged_classification.yaml
│   │   │   │   ├── mock_coco.py
│   │   │   │   ├── mock_imagenet.py
│   │   │   │   ├── mock_wordnet_tagged_classification.py
│   │   │   │   ├── test_base_image_classification_dataset.py
│   │   │   │   ├── test_mock_coco.py
│   │   │   │   ├── test_mock_imagenet.py
│   │   │   │   └── test_wordnet_tagged_classification.py
│   │   │   ├── detection/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── mock_coco_mask_rcnn.py
│   │   │   │   └── mock_coco_ssd.py
│   │   │   ├── language_modeling/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── dummy_commonsense_170k.yaml
│   │   │   │   ├── dummy_lm_dataset.yaml
│   │   │   │   ├── mock_general_lm.py
│   │   │   │   ├── test_commonsense_170k.py
│   │   │   │   └── test_general_lm.py
│   │   │   ├── multi_modal_img_text/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── dummy_img_text_tar_dataset.yaml
│   │   │   │   ├── mock_img_text_tar_dataset.py
│   │   │   │   ├── test_img_text_tar_dataset.py
│   │   │   │   └── zero_shot_image_classification/
│   │   │   │       ├── __init__.py
│   │   │   │       ├── dummy_configs/
│   │   │   │       │   ├── imagenet.yaml
│   │   │   │       │   ├── imagenet_a.yaml
│   │   │   │       │   ├── imagenet_r.yaml
│   │   │   │       │   └── imagenet_sketch.yaml
│   │   │   │       ├── mock_imagenet.py
│   │   │   │       └── test_mock_imagenet.py
│   │   │   ├── segmentation/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── dummy_ade20k_config.yaml
│   │   │   │   ├── dummy_cocostuff_config.yaml
│   │   │   │   ├── mock_ade20k.py
│   │   │   │   ├── mock_coco_stuff.py
│   │   │   │   ├── test_mock_ade20k.py
│   │   │   │   └── test_mock_coco_stuff.py
│   │   │   ├── test_dataset_base.py
│   │   │   ├── test_image_pil.py
│   │   │   └── utils/
│   │   │       ├── __init__.py
│   │   │       ├── test_common.py
│   │   │       └── test_video.py
│   │   ├── io/
│   │   │   ├── __init__.py
│   │   │   └── test_transfer_clients.py
│   │   ├── samplers/
│   │   │   ├── __init__.py
│   │   │   ├── test_batch_sampler_config.yaml
│   │   │   ├── test_chain_sampler.py
│   │   │   ├── test_chain_sampler_config.yaml
│   │   │   ├── test_data_samplers.py
│   │   │   ├── test_multi_scale_sampler_config.yaml
│   │   │   ├── test_variable_batch_sampler_config.yaml
│   │   │   └── test_video_clip_batch_sampler_config.yaml
│   │   ├── text_tokenizer/
│   │   │   ├── __init__.py
│   │   │   ├── test_clip_tokenizer.py
│   │   │   └── test_openai_clip_tokenizer.py
│   │   └── video_reader/
│   │       ├── __init__.py
│   │       ├── test_av_reader.py
│   │       └── test_ffmpeg_utils.py
│   ├── engine/
│   │   ├── __init__.py
│   │   ├── dummy_configs/
│   │   │   ├── ade20k_segmentation/
│   │   │   │   └── deeplabv3_mobilenetv2.yaml
│   │   │   ├── coco_detection/
│   │   │   │   ├── resnet_mask_rcnn.yaml
│   │   │   │   └── resnet_ssd.yaml
│   │   │   ├── image_text_clip/
│   │   │   │   └── clip_vit.yaml
│   │   │   ├── imagenet_classification/
│   │   │   │   ├── efficientnet_b0.yaml
│   │   │   │   ├── mobilevit.yaml
│   │   │   │   └── mobilevit_v2.yaml
│   │   │   └── language_modeling_gpt/
│   │   │       └── gpt.yaml
│   │   └── test_training_engine.py
│   ├── loss_fns/
│   │   ├── __init__.py
│   │   ├── language_modeling/
│   │   │   ├── __init__.py
│   │   │   ├── test_cross_entropy.py
│   │   │   └── test_cross_entropy_for_kv_prediction.py
│   │   ├── test_class_weighting.py
│   │   ├── test_classification_loss.py
│   │   ├── test_composite_loss.py
│   │   ├── test_contrastive_loss.py
│   │   ├── test_detection_loss.py
│   │   ├── test_focal_loss.py
│   │   ├── test_neural_aug.py
│   │   ├── test_neural_aug_compatibility.py
│   │   └── test_segmentation_loss.py
│   ├── metrics/
│   │   ├── __init__.py
│   │   ├── base.py
│   │   ├── test_coco_map.py
│   │   ├── test_image_text_retrieval_metrics.py
│   │   ├── test_iou.py
│   │   ├── test_misc.py
│   │   ├── test_multiclass_classification_pr.py
│   │   ├── test_probability_histogram.py
│   │   ├── test_psnr.py
│   │   ├── test_retrieval_cmc_metrics.py
│   │   ├── test_topk_accuracy.py
│   │   └── test_vqa_preset_score_metrics.py
│   ├── misc/
│   │   ├── __init__.py
│   │   ├── dummy_clip_config.yaml
│   │   ├── dummy_linear_probe_config.yaml
│   │   └── test_common.py
│   ├── modeling/
│   │   ├── __init__.py
│   │   ├── layers/
│   │   │   ├── __init__.py
│   │   │   ├── normalization_layers/
│   │   │   │   ├── __init__.py
│   │   │   │   └── test_rms_norm.py
│   │   │   ├── test_conv_layer.py
│   │   │   ├── test_multi_head_attn.py
│   │   │   ├── test_pos_embeddings.py
│   │   │   ├── test_rotary_embeddings.py
│   │   │   └── test_token_merging.py
│   │   ├── models/
│   │   │   ├── __init__.py
│   │   │   ├── audio_classification/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── test_base_audio_classification.py
│   │   │   │   └── test_byteformer.py
│   │   │   ├── classification/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── config/
│   │   │   │   │   ├── __init__.py
│   │   │   │   │   ├── test_byteformer.py
│   │   │   │   │   └── vit_config.yaml
│   │   │   │   ├── test_byteformer.py
│   │   │   │   └── test_vit.py
│   │   │   ├── language_modeling/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── config/
│   │   │   │   │   ├── gpt_config.yaml
│   │   │   │   │   └── kv_prediction_config.yaml
│   │   │   │   ├── test_general_gpt.py
│   │   │   │   └── test_kv_prediction.py
│   │   │   ├── test_activation_checkpointing_wrapper.py
│   │   │   ├── test_lora.py
│   │   │   └── test_neural_aug_utils.py
│   │   ├── modules/
│   │   │   ├── __init__.py
│   │   │   ├── test_transformer.py
│   │   │   └── test_windowed_transformer.py
│   │   └── test_model.py
│   ├── optims/
│   │   ├── __init__.py
│   │   └── scheduler/
│   │       ├── __init__.py
│   │       └── test_scheduler.py
│   ├── options/
│   │   ├── __init__.py
│   │   ├── test_parse_args.py
│   │   └── test_utils.py
│   ├── test_conventions.py
│   ├── test_utils.py
│   ├── transforms/
│   │   ├── __init__.py
│   │   ├── test_audio.py
│   │   ├── test_audio_bytes.py
│   │   ├── test_image.py
│   │   ├── test_image_bytes.py
│   │   └── test_video.py
│   └── utils/
│       ├── __init__.py
│       ├── test_check.py
│       ├── test_common_utils.py
│       ├── test_dict_utils.py
│       ├── test_download_utils.py
│       ├── test_file_logger.py
│       └── test_import_utils.py
├── tools/
│   ├── __init__.py
│   └── converter_coco_stuff.py
├── tox.ini
└── tutorials/
    ├── clip.ipynb
    ├── guide_slurm_and_multi_node_training.md
    ├── object_detection.ipynb
    ├── semantic_segmentation.ipynb
    └── train_a_new_model_on_a_new_dataset_from_scratch.ipynb

================================================
FILE CONTENTS
================================================

================================================
FILE: .dockerignore
================================================
# Docker-specific:
**/Dockerfile
setup_bolt.sh
.git
.gitignore
.dockerignore

# Mirroring .gitignore
# Note: dockerignore matches paths only from the root dir, while gitignore matches 
# paths from any nested directory. Thus, you'll need to add **/<path> for some paths.
.vscode/
.coverage
*.pyc
**/*.pyc
__pycache__
**/__pycache__
.DS_STORE
**/.DS_STORE
.idea

*.swp
.pytest_cache
.mypy_cache
.corenet_data_cache

build/

results*
vision_datasets/
exp_results/
exp_results*
results_*

*.so
**/*.so
model_zoo
model_zoo/*
pipeline.yaml

*.egg-info
**/*.egg-info

venv/

trash/
mlx_model/
.tox/

# The playground_* files get generated by tutorials/train_new_model_on_new_dataset_from_scratch.ipynb
**/playground_*


================================================
FILE: .flake8
================================================
[flake8]
max-line-length = 88
extend-ignore = E203


================================================
FILE: .gitattributes
================================================
*.tar filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*.zstd filter=lfs diff=lfs merge=lfs -text
*.ipynb filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.jpeg filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.mov filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.tif filter=lfs diff=lfs merge=lfs -text
*.tiff filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text


================================================
FILE: .gitignore
================================================
# Note: please mirror changes of this file to .dockerignore.

.vscode/
.coverage
*.pyc
__pycache__
.DS_STORE
.idea
*.swp
.pytest_cache
.mypy_cache
.corenet_data_cache

build/

/results*
vision_datasets/
exp_results/
exp_results*
results_*

*.so
model_zoo
model_zoo/*
pipeline.yaml

*.egg-info

venv/

trash

mlx_model/
.tox/

# The playground_* files get generated by tutorials/train_new_model_on_new_dataset_from_scratch.ipynb
playground_*


================================================
FILE: ACKNOWLEDGEMENTS
================================================
Acknowledgements
Portions of this Software may utilize the following copyrighted material, the use of which is hereby acknowledged.

Facebook (Fairseq)
    MIT License

    Copyright (c) Facebook, Inc. and its affiliates.

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.

Eleuther AI (LM Eval Harness)
   MIT License

   Copyright (c) 2020 EleutherAI

   Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

   The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Hao Gao (pytorch-ssd)
    MIT License

    Copyright (c) 2019 Hao Gao

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.

HuggingFace (PEFT)

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Max deGroot, Ellis Brown (ssd.pytorch)
    MIT License

    Copyright (c) 2017 Max deGroot, Ellis Brown

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.

Sachin Mehta (EdgeNets)
    MIT License

    Copyright (c) 2021 Sachin Mehta

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.

OpenMMLab (mmSegmentation)
    Copyright 2020 The MMSegmentation Authors. All rights reserved.

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright 2020 The MMSegmentation Authors.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

PyTorch (Torchvision)
    BSD 3-Clause License

    Copyright (c) Soumith Chintala 2016,
    All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this
      list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.

    * Neither the name of the copyright holder nor the names of its
      contributors may be used to endorse or promote products derived from
      this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

CLIP (OpenAI)
    MIT License

    Copyright (c) 2021 OpenAI

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.

TIMM Library (PyTorch Image Models)
                                     Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "{}"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright 2019 Ross Wightman

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Forked-PDB (Lightning AI)
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Zhiqiang Hu (LLM Adapters)
                                Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright 2023 Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: CODE_OF_CONDUCT.md
================================================
# Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
  advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
  address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
  professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the open source team at [opensource-conduct@group.apple.com](mailto:opensource-conduct@group.apple.com). All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4,
available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html)


================================================
FILE: CONTRIBUTING.md
================================================
# Contribution Guide

Thanks for your interest in contributing. This project was released to accompany a research paper for purposes of reproducibility, and beyond its publication there are limited plans for future development of the repository.

While we welcome new pull requests and issues please note that our response may be limited. Forks and out-of-tree improvements are strongly encouraged.

## Before you get started

By submitting a pull request, you represent that you have the right to license your contribution to Apple and the community, and agree by submitting the patch that your contributions are licensed under the [LICENSE](LICENSE).

We ask that all community members read and observe our [Code of Conduct](CODE_OF_CONDUCT.md).


================================================
FILE: LICENSE
================================================
Copyright (C) 2024 Apple Inc. All Rights Reserved.

Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms.  If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.

In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
"Apple Software"), to use, reproduce, modify and redistribute the Apple
Software, with or without modifications, in source and/or binary forms;
provided that if you redistribute the Apple Software in its entirety and
without modifications, you must retain this notice and the following
text and disclaimers in all such redistributions of the Apple Software.
Neither the name, trademarks, service marks or logos of Apple Inc. may
be used to endorse or promote products derived from the Apple Software
without specific prior written permission from Apple.  Except as
expressly stated in this notice, no other rights or licenses, express or
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.

The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.

IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.


-------------------------------------------------------------------------------
SOFTWARE DISTRIBUTED IN THIS REPOSITORY:

This software includes a number of subcomponents with separate
copyright notices and license terms - please see the file ACKNOWLEDGEMENTS.
-------------------------------------------------------------------------------


================================================
FILE: Makefile
================================================
SHELL := /bin/bash
YEAR = $$(date +%Y)
LAST_YEAR = $$(($(YEAR) - 1))
COLOR_LOG = \033[34m
COLOR_INFO = \033[32m
COLOR_WARNING = \033[33m
COLOR_ERROR = \033[31m
COLOR_END = \033[0m

SRC_DIRS = corenet tests

.PHONY: format install-githooks prepush-check update-copyright-year

update-copyright-year:
	@if [[ "$$CHECK_ONLY" == "" ]]; then \
		if ! command -v rg &>/dev/null; then \
			printf "$(COLOR_INFO)Installing ripgrep ...$(COLOR_END)\n"; \
			if [[ "$$OSTYPE" == "darwin"* ]]; then \
				brew install ripgrep; \
			else \
				sudo --preserve-env apt-get install ripgrep; \
			fi; \
		fi; \
		rg -l "\(C\) $(LAST_YEAR)" \
			| grep -v "ACKNOWLEDGEMENTS" \
			| xargs -r -n1 -P 10 sed -i.bak.copyright "s/(C) $(LAST_YEAR) Apple/(C) $(YEAR) Apple/g" \
			&& find . -name '*.bak.copyright' \
			| xargs -r -n1 -P 10 rm; \
	fi

format: format-init-files format-license-headers format-eof-new-lines format-isort format-black format-conventions
	# Formatting checks succeeded.

# The existence of __init__.py files is necessary for the inclusion of packages in the setup.py (i.e. pip-instsallable) package.
format-init-files:
	# Checking missing __init__.py files...
	@python_files=$$(find $(SRC_DIRS) -iname "*.py"); \
	for dir_name in $$(find $(SRC_DIRS) -type d -not -name __pycache__); do \
	    grep -q "^$$dir_name/" <(echo "$$python_files") || continue; \
	    init_file="$$dir_name/__init__.py"; \
	    [[ -f "$$init_file" ]] && continue; \
		if [[ "$$CHECK_ONLY" == "1" ]]; then \
			printf "$(COLOR_ERROR)Missing $$init_file. $(COLOR_END)\n"; \
		else \
			touch "$$init_file"; \
			printf "$(COLOR_LOG)Added $$init_file. $(COLOR_END)\n"; \
		fi \
	done

format-license-headers: update-copyright-year
	# Checking missing license headers files...
# Read the first 4 lines of each file to check if the Copyright notice header exists. 
# The Copyright note is usually found on line 3, but some files may have an additional 
# '#/bin/bash' or '#/usr/bin/env python' header line, hence reading 3+1 lines.
	@for f in $$(find . -iname "*.py"); do \
	    [ -s "$$f" ] || continue; \
		git check-ignore -q "$$f" && continue; \
	    export COPYRIGHT_NOTICE_LINES=4; \
	    (head -$$COPYRIGHT_NOTICE_LINES $$f | grep -q "# *Copyright (C) $(YEAR) Apple Inc. All Rights Reserved.") && continue; \
	    [[ "$$CHECK_ONLY" == "1" ]] && exit 1; \
	    sed -i '' -e "1s/^/#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) $(YEAR) Apple Inc. All Rights Reserved.\n#\n\n/" $$f; \
	    printf "$(COLOR_LOG)Added license header for $$f$(COLOR_END)\n"; \
	done

format-eof-new-lines:
	# Ensure newline at the end of all files...
# Inspired by https://unix.stackexchange.com/a/161853/55814
	@if [[ "$$CHECK_ONLY" == "" ]]; then \
	    git ls-files -z | while IFS= read -rd '' f; do \
	        if [[ -f "$$f" ]] && (file --mime-encoding "$$f" | grep -qv binary); then \
	            tail -c1 < "$$f" | read -r _ || (echo >> "$$f" && printf "$(COLOR_LOG) Added newline at the end of $$f$(COLOR_END)\n"); \
	        fi; \
	    done; \
	fi

format-isort:
	# Running isort...
	@if [[ "$$CHECK_ONLY" == "1" ]]; then \
	    isort --check-only .; \
	else \
	    isort .; \
	fi

format-black:
	# Running black formatter...
	@if [[ "$$CHECK_ONLY" == "1" ]]; then \
	    black --check .; \
	else \
	    black .; \
	fi

format-conventions:
	@if [[ "$$CHECK_ONLY" == "1" ]]; then \
	    echo "# Checking coding conventions..."; \
	    convention_test_files=(tests/test_conventions.py); \
	    [[ -d tests/internal ]] && convention_test_files+=(tests/internal/test_internal_conventions.py); \
		export _parallel_args="$$( (python -c "import xdist.plugin" 2>/dev/null && echo '-n 4') || true)"; \
	    if ! pytest --junit-xml="" -q "$${convention_test_files[@]}" $$_parallel_args; then \
	        printf "$(COLOR_ERROR) Please manually fix the above convention errors. $(COLOR_END)\n"; \
	        exit 1; \
	    fi; \
	fi


prepush-check:
	@printf "$(COLOR_LOG)[pre-push hook]$(COLOR_END)\n"
	@CHECK_ONLY=1 make format || (printf "$(COLOR_ERROR)Formatting checks failed.$(COLOR_END) Please run '$(COLOR_INFO)make format$(COLOR_END)' command, commit, and push again.\n" && exit 1);
	@if [ -n "$$(git status --porcelain)" ]; then \
	    printf "$(COLOR_WARNING)Formatting checks succeeded, but please consider committing UNCOMMITTED changes to the following files:$(COLOR_END)\n"; \
	    git status --short; \
	else \
	    printf "$(COLOR_INFO)Formatting checks succeeded.$(COLOR_END)\n"; \
	fi

install-githooks:
	@echo -e "#!/usr/bin/env bash\n" '\
set -euo pipefail\n\
# Check if Git LFS is installed\n\
if ! command -v git-lfs >/dev/null 2>&1; then\n\
	echo >&2 "Error: Git LFS is not installed. Please install Git LFS to continue."\n\
	exit 1\n\
fi\n\
\n\
git lfs pre-push "$$@"\n\n\
printf "$(COLOR_LOG)[pre-push hook]$(COLOR_END) Running formatting checks and fixes... To skip this hook, please run \"git push --no-verify\".\\n";\n\
if grep -q "^prepush-check:" Makefile 2>/dev/null; then\n\
		make prepush-check;\n\
else\n\
		printf "$(COLOR_WARNING)WARNING:$(COLOR_END) Skipping the pre-push formatting checks and fixes. The git hook is installed (probably on a different git branch), but Makefile is either missing or old on this branch.\\n";\n\
fi \
	' > "$$(git rev-parse --git-path hooks)/pre-push"
	chmod +x "$$(git rev-parse --git-path hooks)/pre-push"
	# Successfully installed the pre-push hook.

test-all:
##
# Notes:
# * Run all tests and set OMP/MKL threads 1 to allow pytest parallelization
# * The number of parallel tests will be 10 by default, which is good for running tests
#   locally. Larger numbers may cause OOM error. If PYTEST_WORKERS environment variable
#   is already set, the existing value gets used.
# * Currently, our tests fail when DDP is enabled. Hence, we set disable gpus for test
#   by setting CUDA_VISIBLE_DEVICES="".
##
	PYTEST_WORKERS="$${PYTEST_WORKERS:=10}"; CUDA_VISIBLE_DEVICES="" MKL_NUM_THREADS=1 NUMEXPR_NUM_THREADS=1 OMP_NUM_THREADS=1 pytest . -n $$PYTEST_WORKERS $(extra_args)

coverage-test-all:
	PYTEST_WORKERS="$${PYTEST_WORKERS:=10}"; CUDA_VISIBLE_DEVICES="" MKL_NUM_THREADS=1 NUMEXPR_NUM_THREADS=1 OMP_NUM_THREADS=1 coverage run -m pytest . -n $$PYTEST_WORKERS $(extra_args)


================================================
FILE: README.md
================================================
# CoreNet: A library for training deep neural networks

CoreNet is a deep neural network toolkit that allows researchers and engineers to train standard and novel small and large-scale models for variety of tasks, including foundation models (e.g., CLIP and LLM), object classification, object detection, and semantic segmentation.

## Table of contents

   * [What's new?](#whats-new)
   * [Research efforts at Apple using CoreNet](#research-efforts-at-apple-using-corenet)
   * [Installation](#installation)
   * [Directory Structure](#directory-structure)
   * [Maintainers](#maintainers)
   * [Contributing to CoreNet](#contributing-to-corenet)
   * [License](#license)
   * [Relationship with CVNets](#relationship-with-cvnets)
   * [Citation](#citation)

## What's new?

   * ***October 2024***: Version 0.1.1 of the CoreNet library includes
      * [KV Prediction](./projects/kv-prediction/)

## Research efforts at Apple using CoreNet

Below is the list of publications from Apple that uses CoreNet. Also, training and evaluation recipes, as well as links to pre-trained models, can be found inside the [projects](./projects/) folder. Please refer to it for further details.

   * [KV Prediction for Improved Time to First Token](https://arxiv.org/abs/2410.08391)
   * [OpenELM: An Efficient Language Model Family with Open Training and Inference Framework](https://arxiv.org/abs/2404.14619)
   * [CatLIP: CLIP-level Visual Recognition Accuracy with 2.7x Faster Pre-training on Web-scale Image-Text Data](https://arxiv.org/abs/2404.15653)
   * [Reinforce Data, Multiply Impact: Improved Model Accuracy and Robustness with Dataset Reinforcement](https://arxiv.org/abs/2303.08983)
   * [CLIP meets Model Zoo Experts: Pseudo-Supervision for Visual Enhancement](https://arxiv.org/abs/2310.14108)
   * [FastVit: A Fast Hybrid Vision Transformer using Structural Reparameterization](https://arxiv.org/abs/2303.14189)
   * [Bytes Are All You Need: Transformers Operating Directly on File Bytes](https://arxiv.org/abs/2306.00238)
   * [MobileOne: An Improved One millisecond Mobile Backbone](https://arxiv.org/abs/2206.04040)
   * [RangeAugment: Efficient Online Augmentation with Range Learning](https://arxiv.org/abs/2212.10553)
   * [Separable Self-attention for Mobile Vision Transformers (MobileViTv2)](https://arxiv.org/abs/2206.02680)
   * [CVNets: High performance library for Computer Vision, ACM MM'22](https://arxiv.org/abs/2206.02002)
   * [MobileViT: Light-weight, General-purpose, and Mobile-friendly Vision Transformer, ICLR'22](https://arxiv.org/abs/2110.02178)

## Installation

You will need Git LFS (instructions below) to run tests and Jupyter notebooks 
([instructions](https://jupyter.org/install)) in this repository,
and to contribute to it so we recommend that you install and activate it first.

On Linux we recommend to use Python 3.10+ and PyTorch (version >= v2.1.0), on
macOS system Python 3.9+ should be sufficient.

Note that the optional dependencies listed below are required if you'd like to
make contributions and/or run tests.

For Linux (substitute `apt` for your package manager):

```bash
sudo apt install git-lfs

git clone git@github.com:apple/corenet.git
cd corenet
git lfs install
git lfs pull
# The following venv command is optional, but recommended. Alternatively, you can create and activate a conda environment.
python3 -m venv venv && source venv/bin/activate
python3 -m pip install --editable .
```

To install optional dependencies for audio and video processing:

```bash
sudo apt install libsox-dev ffmpeg
```

For macOS, assuming you use Homebrew:

```bash
brew install git-lfs

git clone git@github.com:apple/corenet.git
cd corenet
cd \$(pwd -P)  # See the note below.
git lfs install
git lfs pull
# The following venv command is optional, but recommended. Alternatively, you can create and activate a conda environment.
python3 -m venv venv && source venv/bin/activate
python3 -m pip install --editable .
```

To install optional dependencies for audio and video processing:

```bash
brew install sox ffmpeg
```

Note that on macOS the file system is case insensitive, and case sensitivity
can cause issues with Git. You should access the repository on disk as if the
path were case sensitive, i.e. with the same capitalization as you see when you
list the directories `ls`. You can switch to such a path with the `cd $(pwd -P)`
command.


## Directory Structure

This section provides quick access and a brief description for important CoreNet directories.

<table>
<thead>
<tr>
<th> Description </th>
<th> Quick Access </th>
</tr>
</thead>
<tbody>
<!-- Row boilerplate (copy-paste the following commented snippet for adding a new row to the table.)
<tr> <td> <h3> title </h3> 
description
</td> <td> <pre>
folders
</pre> </td> </tr>
-->
<tr> <td> <h3> Getting Started </h3> 
Working with the examples is an easy way to get started with CoreNet. 
</td> <td> <pre>
└── tutorials
    ├── <a href="tutorials/train_a_new_model_on_a_new_dataset_from_scratch.ipynb">train_a_new_model_on_a_new_dataset_from_scratch.ipynb</a>
    ├── <a href="tutorials/guide_slurm_and_multi_node_training.md">guide_slurm_and_multi_node_training.md</a>
    ├── <a href="tutorials/clip.ipynb">clip.ipynb</a>
    ├── <a href="tutorials/semantic_segmentation.ipynb">semantic_segmentation.ipynb</a>
    └── <a href="tutorials/object_detection.ipynb">object_detection.ipynb</a>
</pre> </td> </tr>


<tr> <td> <h3> Training Recipes </h3>
CoreNet provides reproducible training recipes, in addition to the pretrained model 
weights and checkpoints for the publications that are listed in <code>projects/</code> directory.

Publication project directories generally contain the following contents:

* `README.md` provides documentation, links to the pretrained weights, and citations.
* `<task_name>/<model_name>.yaml` provides configuration for reproducing the trainings and evaluations.
</td> <td> <pre>
└── projects
    ├── <a href="projects/kv-prediction">kv-prediction</a> (*)
    ├── <a href="projects/byteformer">byteformer</a>
    ├── <a href="projects/catlip">catlip</a>
    ├── <a href="projects/clip">clip</a>
    ├── <a href="projects/fastvit">fastvit</a>
    ├── <a href="projects/mobilenet_v1">mobilenet_v1</a>
    ├── <a href="projects/mobilenet_v2">mobilenet_v2</a>
    ├── <a href="projects/mobilenet_v3">mobilenet_v3</a>
    ├── <a href="projects/mobileone">mobileone</a>
    ├── <a href="projects/mobilevit">mobilevit</a>
    ├── <a href="projects/mobilevit_v2">mobilevit_v2</a>
    ├── <a href="projects/openelm">openelm</a>
    ├── <a href="projects/range_augment">range_augment</a>
    ├── <a href="projects/resnet">resnet</a>
    └── <a href="projects/vit">vit</a>
<br>
(*) Newly released.
</pre> </td> </tr>


<tr> <td> <h3> MLX Examples </h3>
MLX examples demonstrate how to run CoreNet models efficiently on Apple Silicon.
Please find further information in the <code>README.md</code> file within the corresponding example directory.

</td> <td> <pre>
└──mlx_example
    ├── <a href="mlx_examples/clip">clip</a>
    └── <a href="mlx_examples/open_elm">open_elm</a>
</pre> </td> </tr>


<tr> <td> <h3> Model Implementations </h3> 
Models are organized by tasks (e.g. "classification"). You can find all model implementations for each
task in the corresponding task folder. 

Each model class is decorated by a 
`@MODEL_REGISTRY.register(name="<model_name>", type="<task_name>")` decorator. 
To use a model class in CoreNet training or evaluation,
assign `models.<task_name>.name = <model_name>` in the YAML configuration.

</td> <td> <pre>
└── corenet
    └── modeling
        └── <a href="corenet/modeling/models">models</a>
            ├── <a href="corenet/modeling/models/audio_classification">audio_classification</a>
            ├── <a href="corenet/modeling/models/classification">classification</a>
            ├── <a href="corenet/modeling/models/detection">detection</a>
            ├── <a href="corenet/modeling/models/language_modeling">language_modeling</a>
            ├── <a href="corenet/modeling/models/multi_modal_img_text">multi_modal_img_text</a>
            └── <a href="corenet/modeling/models/segmentation">segmentation</a>
</pre> </td> </tr>


<tr> <td> <h3> Datasets </h3> 
Similarly to the models, datasets are also categorized by tasks.
</td> <td> <pre>
└── corenet
    └── data
        └── <a href="corenet/data/datasets">datasets</a>
            ├── <a href="corenet/data/datasets/audio_classification">audio_classification</a>
            ├── <a href="corenet/data/datasets/classification">classification</a>
            ├── <a href="corenet/data/datasets/detection">detection</a>
            ├── <a href="corenet/data/datasets/language_modeling">language_modeling</a>
            ├── <a href="corenet/data/datasets/multi_modal_img_text">multi_modal_img_text</a>
            └── <a href="corenet/data/datasets/segmentation">segmentation</a>
</pre> </td> </tr>


<tr> <td> <h3> Other key directories </h3> 
In this section, we have highlighted the rest of the key directories that implement 
classes corresponding to the names that are referenced in the YAML configurations.
</td> <td> <pre>
└── corenet
    ├── <a href="corenet/loss_fn">loss_fn</a>
    ├── <a href="corenet/metrics">metrics</a>
    ├── <a href="corenet/optims">optims</a>
    │   └── <a href="corenet/optims/scheduler">scheduler</a>
    ├── <a href="corenet/train_eval_pipelines">train_eval_pipelines</a>
    ├── <a href="corenet/data">data</a>
    │   ├── <a href="corenet/data/collate_fns">collate_fns</a>
    │   ├── <a href="corenet/data/sampler">sampler</a>
    │   ├── <a href="corenet/data/text_tokenizer">text_tokenizer</a>
    │   ├── <a href="corenet/data/transforms">transforms</a>
    │   └── <a href="corenet/data/video_reader">video_reader</a>
    └── <a href="corenet/modeling">modeling</a>
        ├── <a href="corenet/modeling/layers">layers</a>
        ├── <a href="corenet/modeling/modules">modules</a>
        ├── <a href="corenet/modeling/neural_augmentor">neural_augmentor</a>
        └── <a href="corenet/modeling/text_encoders">text_encoders</a>
</pre> </td> </tr>

</tbody>
</table>

## Maintainers
This code is developed and maintained by <a href="https://mchorton.com" target="_blank">Maxwell Horton</a>, <a href="https://www.mohammad.pro" target="_blank">Mohammad Sekhavat</a> Yanzi Jin, and <a href="https://huggingface.co/depthwise" target="_blank">Dmitry Belenko</a>.

### Previous Maintainers
* <a href="https://sacmehta.github.io" target="_blank">Sachin Mehta</a>
* <a href="https://farzadab.github.io" target="_blank">Farzad Abdolhosseini</a>

## Contributing to CoreNet

We welcome PRs from the community! You can find information about contributing to CoreNet in our [contributing](CONTRIBUTING.md) document. 

Please remember to follow our [Code of Conduct](CODE_OF_CONDUCT.md).

## License

For license details, see [LICENSE](LICENSE). 

## Relationship with CVNets

CoreNet evolved from CVNets, to encompass a broader range of applications beyond computer vision. Its expansion facilitated the training of foundational models, including LLMs.

## Citation

If you find our work useful, please cite the following paper:

``` 
@inproceedings{mehta2022cvnets, 
     author = {Mehta, Sachin and Abdolhosseini, Farzad and Rastegari, Mohammad}, 
     title = {CVNets: High Performance Library for Computer Vision}, 
     year = {2022}, 
     booktitle = {Proceedings of the 30th ACM International Conference on Multimedia}, 
     series = {MM '22} 
}
```


================================================
FILE: conftest.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#

import os
import sys

# NOTE: This environment variable should be set before any corenet import.
os.environ["CORENET_ENTRYPOINT"] = "pytest"

if sys.platform == "darwin":
    # Necessary to find sox when pytest is run in multiprocess mode. macOS
    # normally strips DYLD_LIBRARY_PATH when starting subprocesses, as a
    # security measure.
    os.environ["DYLD_LIBRARY_PATH"] = "/opt/homebrew/lib"

import random
import signal
from types import FrameType
from typing import Optional

import numpy as np
import pytest
import torch

from corenet import suppress_known_warnings

session_timed_out = False


def handle_timeout(signum: int, frame: Optional[FrameType] = None) -> None:
    global session_timed_out
    session_timed_out = True
    # Not calling pytest.exit() directly to capture the output of the test. See: https://stackoverflow.com/a/59234261/1139196
    pytest.fail("timeout")


def pytest_sessionstart():
    suppress_known_warnings()
    timeout = os.environ.get("PYTEST_GLOBAL_TIMEOUT", "")
    if not timeout:
        return
    if timeout.endswith("s"):
        timeout = int(timeout[:-1])
    elif timeout.endswith("m"):
        timeout = int(timeout[:-1]) * 60
    else:
        raise ValueError(
            f"Timeout value {timeout} should either end with 'm' (minutes) or 's' (seconds)."
        )

    signal.signal(signal.SIGALRM, handle_timeout)
    signal.setitimer(signal.ITIMER_REAL, timeout)


def pytest_runtest_logfinish(nodeid, location):
    if session_timed_out:
        pytest.exit("timeout")


@pytest.fixture(autouse=True)
def set_random_seed(request):
    seed = 1
    random.seed(seed)
    torch.manual_seed(seed)
    np.random.seed(seed)


================================================
FILE: corenet/__init__.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#

import warnings

from corenet.constants import is_external_env, is_test_env
from corenet.utils.logger import match_warning_message

KNOWN_WARNINGS = [
    ##
    # Torchtext deprecation warning:
    ##
    match_warning_message(
        " /!\\ IMPORTANT WARNING ABOUT TORCHTEXT STATUS /!\\ Torchtext is deprecated"
        " and the last released version will be 0.18 (this one)."
    ),
    ##
    # The following warnings are raised by tests/metrics/test_coco_map.py:
    ##
    match_warning_message(
        "Creating a tensor from a list of numpy.ndarrays is extremely slow. Please"
        " consider converting the list to a single numpy.ndarray with numpy.array()"
        " before converting to a tensor."
    ),
    match_warning_message("unclosed file <"),
    ##
    # The following warnings are raised by tests/loss_fns/test_class_weighting.py:
    ##
    match_warning_message(
        "`torch.testing.assert_allclose()` is deprecated since 1.12 and will be removed"
        " in a future release. Please use `torch.testing.assert_close()` instead. You"
        " can find detailed upgrade instructions in"
        " https://github.com/pytorch/pytorch/issues/61844."
    ),
    ##
    # The following warnings are raised by "import torchvision.datasets":
    ##
    match_warning_message(
        "torch.utils._pytree._register_pytree_node is deprecated. Please use"
        " torch.utils._pytree.register_pytree_node instead."
    ),
    ##
    # The following warnings are raised by "import coremltools" (macOS only):
    ##
    match_warning_message(
        "Call to deprecated create function",
        "Note: Create unlinked descriptors is going to go away. Please use get/find"
        " descriptors from generated code or query the descriptor_pool.",
    ),
]


def suppress_known_warnings() -> None:
    """
    Suppresses warnings that are known to be safe for corenet, to avoid overwhelming
    the standard error outputs (especially with multiple subprocesses).

    Notes:
    - We should invoke this function as early as possible (i.e. in corenet/__init__.py)
        because some of the warnings are during the execution of the import statements.
        We should suppress the known warnings before importing other modules.
    - We SHOULD NOT invoke this function when corenet is imported from external
        libraries because it enters the `warnings.catch_warnings(record=True)` context
        manager without invoking its __exit__() method. This is only safe when we are
        not already inside a `with warnings.catch_warnings():` context, which is the
        case for corenet entrypoints.
    """
    try:
        # Importing corenet.internal inside the function to avoid cyclic dependency.
        from corenet.internal import KNOWN_WARNINGS_INTERNAL
    except ModuleNotFoundError:
        KNOWN_WARNINGS_INTERNAL = []

    known_warnings = KNOWN_WARNINGS + KNOWN_WARNINGS_INTERNAL
    if len(known_warnings) == 0:
        return

    if is_test_env():
        # In the test env, convert unsuppressed/unhandled warnings to errors.
        # Filters listed later take precedence over those listed before them. Invoking
        # filterwarnings("error") first so that it becomes the default when warning is
        # no handled by other filters.
        warnings.filterwarnings("error")

    warnings.catch_warnings(record=True).__enter__()
    for known_warning in known_warnings:
        warnings.filterwarnings("ignore", message=known_warning)


if not is_external_env():
    suppress_known_warnings()


================================================
FILE: corenet/__main__.py
================================================


================================================
FILE: corenet/__version__.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#
version = "0.1.1"


================================================
FILE: corenet/cli/__init__.py
================================================


================================================
FILE: corenet/cli/entrypoints.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#

from typing import Dict, Tuple

# Entrypoints is a mapping from shell executable name to (module, function) pair.
# Having too many entrypoints in setup.py limits us our ability to add features or
# refactor the code, because users who pull the latest changes will have to re-install
# corenet in order for `setup.py` changes to apply.
# A better practice is to stop introducing new entrypoints, and add subcommands to the
# main `corenet` entrypoint. Currently, `corenet train` is identical to `corenet-train`.
entrypoints: Dict[str, Tuple[str, str]] = {
    "corenet-train": ("corenet.cli.main_train", "main_worker"),
    "corenet-eval": ("corenet.cli.main_eval", "main_worker"),
    "corenet-eval-llmadapters": (
        "corenet.cli.main_eval_llmadapters",
        "main_eval_llmadapters",
    ),
    "corenet-eval-seg": ("corenet.cli.main_eval", "main_worker_segmentation"),
    "corenet-eval-det": ("corenet.cli.main_eval", "main_worker_detection"),
    "corenet-convert": ("corenet.cli.main_conversion", "main_worker_conversion"),
    "corenet": ("corenet.cli.main", "main"),
}

console_scripts = [
    f"{entrypoint} = {module}:{func}"
    for entrypoint, (module, func) in entrypoints.items()
]


================================================
FILE: corenet/cli/main.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#

import argparse
import importlib
from itertools import chain
from typing import Dict, List, Optional, Tuple

from corenet.cli.entrypoints import entrypoints as oss_entrypoints

try:
    from corenet.internal.cli.entrypoints import entrypoints as internal_entrypoints
except ModuleNotFoundError:
    internal_entrypoints = {}


def main(args: Optional[List[str]] = None) -> None:
    """
    We are planning to deprecate `corenet-train`, `corenet-eval`, ... commands for
    `corenet train` (the dash is removed), `corenet eval`, ... because adding/renaming
    entrypoints will require `pip install -e .`. Most users don't reinstall corenet
    after pulling the git repo. Hence, relying on a single entrypoint `corenet` with
    subcommands is more future proof.
    """
    entrypoints = {
        k.replace("corenet-", ""): v
        for k, v in chain(oss_entrypoints.items(), internal_entrypoints.items())
    }
    parser = argparse.ArgumentParser()
    parser.add_argument("entrypoint", choices=list(entrypoints.keys()))
    entrypoint_opts, args = parser.parse_known_args(args)
    module_name, func_name = entrypoints[entrypoint_opts.entrypoint]
    getattr(importlib.import_module(module_name), func_name)(args)


================================================
FILE: corenet/cli/main_benchmark.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#

import time
from typing import Optional

import torch
from torch.cuda.amp import autocast

from corenet.engine.utils import autocast_fn
from corenet.modeling import get_model
from corenet.options.opts import get_benchmarking_arguments
from corenet.utils import logger
from corenet.utils.common_utils import device_setup
from corenet.utils.pytorch_to_coreml import convert_pytorch_to_coreml
from corenet.utils.tensor_utils import create_rand_tensor


def cpu_timestamp(*args, **kwargs):
    # perf_counter returns time in seconds
    return time.perf_counter()


def cuda_timestamp(cuda_sync=False, device=None, *args, **kwargs):
    if cuda_sync:
        torch.cuda.synchronize(device=device)
    # perf_counter returns time in seconds
    return time.perf_counter()


def step(
    time_fn,
    model,
    example_inputs,
    autocast_enable: False,
    amp_precision: Optional[str] = "float16",
):
    start_time = time_fn()
    with autocast_fn(enabled=autocast_enable, amp_precision=amp_precision):
        model(example_inputs)
    end_time = time_fn(cuda_sync=True)
    return end_time - start_time


def main_benchmark():
    # set-up
    opts = get_benchmarking_arguments()
    # device set-up
    opts = device_setup(opts)

    norm_layer = getattr(opts, "model.normalization.name", "batch_norm")
    if norm_layer.find("sync") > -1:
        norm_layer = norm_layer.replace("sync_", "")
        setattr(opts, "model.normalization.name", norm_layer)
    device = getattr(opts, "dev.device", torch.device("cpu"))
    if torch.cuda.device_count() == 0:
        device = torch.device("cpu")
    time_fn = cpu_timestamp if device == torch.device("cpu") else cuda_timestamp
    warmup_iterations = getattr(opts, "benchmark.warmup_iter", 10)
    iterations = getattr(opts, "benchmark.n_iter", 50)
    batch_size = getattr(opts, "benchmark.batch_size", 1)
    mixed_precision = (
        False
        if device == torch.device("cpu")
        else getattr(opts, "common.mixed_precision", False)
    )
    mixed_precision_dtype = getattr(opts, "common.mixed_precision_dtype", "float16")

    # load the model
    model = get_model(opts)
    model.eval()
    # print model information
    model.info()

    example_inp = create_rand_tensor(opts=opts, device="cpu", batch_size=batch_size)

    # cool down for 5 seconds
    time.sleep(5)

    if getattr(opts, "benchmark.use_jit_model", False):
        converted_models_dict = convert_pytorch_to_coreml(
            opts=None,
            pytorch_model=model,
            input_tensor=example_inp,
            jit_model_only=True,
        )
        model = converted_models_dict["jit"]
    model = model.to(device=device)
    example_inp = example_inp.to(device=device)
    model.eval()

    with torch.no_grad():
        # warm-up
        for i in range(warmup_iterations):
            step(
                time_fn=time_fn,
                model=model,
                example_inputs=example_inp,
                autocast_enable=mixed_precision,
                amp_precision=mixed_precision_dtype,
            )

        n_steps = n_samples = 0.0

        # run benchmark
        for i in range(iterations):
            step_time = step(
                time_fn=time_fn,
                model=model,
                example_inputs=example_inp,
                autocast_enable=mixed_precision,
                amp_precision=mixed_precision_dtype,
            )
            n_steps += step_time
            n_samples += batch_size

        logger.info(
            "Number of samples processed per second: {:.3f}".format(n_samples / n_steps)
        )


if __name__ == "__main__":
    main_benchmark()


================================================
FILE: corenet/cli/main_conversion.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#

import os
from typing import List, Optional

import coremltools as ct
import torch

from corenet.constants import TMP_RES_FOLDER
from corenet.modeling import get_model
from corenet.options.opts import get_conversion_arguments
from corenet.utils import logger
from corenet.utils.checkpoint_utils import CHECKPOINT_EXTN
from corenet.utils.pytorch_to_coreml import convert_pytorch_to_coreml


def main_worker_conversion(args: Optional[List[str]] = None):
    opts = get_conversion_arguments(args=args)

    # set coreml conversion flag to true
    setattr(opts, "common.enable_coreml_compatible_module", True)

    norm_layer = getattr(opts, "model.normalization.name", "batch_norm")
    if norm_layer.find("sync") > -1:
        norm_layer = norm_layer.replace("sync_", "")
        setattr(opts, "model.normalization.name", norm_layer)

    model = get_model(opts)
    model_name = model.__class__.__name__

    model.eval()

    coreml_extn = getattr(opts, "conversion.coreml_extn", "mlmodel")

    results_folder = getattr(opts, "common.results_loc", TMP_RES_FOLDER)
    if not os.path.isdir(results_folder):
        os.makedirs(results_folder)

    model_dst_loc = "{}/{}.{}".format(results_folder, model_name, coreml_extn)

    if os.path.isfile(model_dst_loc):
        os.remove(model_dst_loc)

    try:
        convert_to = "mlprogram" if coreml_extn == "mlpackage" else "neuralnetwork"
        minimum_deployment_target = getattr(
            opts, "conversion.minimum_deployment_target"
        )
        if minimum_deployment_target is not None:
            minimum_deployment_target = ct.target[minimum_deployment_target]
        compute_precision = getattr(opts, "conversion.compute_precision")
        if compute_precision is not None:
            compute_precision = ct.precision[compute_precision]

        converted_models_dict = convert_pytorch_to_coreml(
            opts=opts,
            pytorch_model=model,
            convert_to=convert_to,
            minimum_deployment_target=minimum_deployment_target,
            compute_precision=compute_precision,
        )
        coreml_model = converted_models_dict["coreml"]
        jit_model = converted_models_dict["jit"]
        jit_optimized = converted_models_dict["jit_optimized"]

        coreml_model.save(model_dst_loc)

        torch.jit.save(
            jit_model,
            model_dst_loc.replace(f".{coreml_extn}", f"_jit.{CHECKPOINT_EXTN}"),
        )
        jit_optimized._save_for_lite_interpreter(
            model_dst_loc.replace(f".{coreml_extn}", f"_jit_opt.{CHECKPOINT_EXTN}")
        )

        logger.log("PyTorch model converted to CoreML successfully.")
        logger.log("CoreML model location: {}".format(model_dst_loc))
    except Exception as e:
        logger.error(
            "PyTorch to CoreML conversion failed. See below for error details:\n {}".format(
                e
            )
        )


if __name__ == "__main__":
    main_worker_conversion()


================================================
FILE: corenet/cli/main_eval.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#
from typing import List, Optional

from corenet.options.opts import get_training_arguments
from corenet.train_eval_pipelines import (
    TRAIN_EVAL_PIPELINE_REGISTRY,
    BaseTrainEvalPipeline,
)


def main(train_eval_pipeline: BaseTrainEvalPipeline):
    """
    This function will be invoked on each gpu worker process.

    Args:
        train_eval_pipeline: Provides major pipeline components. The class to be used is
            configurable by "--train-eval-pipeline.name" opt. By default, an instance of
            ``train_eval_pipelines.TrainEvalPipeline`` will be passed to this function.
    """
    evaluation_engine = train_eval_pipeline.evaluation_engine
    evaluation_engine.run()


def main_worker(args: Optional[List[str]] = None):
    opts = get_training_arguments(args=args)
    pipeline_name = getattr(opts, "train_eval_pipeline.name")
    train_eval_pipeline = TRAIN_EVAL_PIPELINE_REGISTRY[pipeline_name](opts=opts)
    launcher = train_eval_pipeline.launcher
    launcher(main)


# for segmentation and detection, we follow a different evaluation pipeline that allows to save the results too
def main_worker_segmentation(args: Optional[List[str]] = None, **kwargs):
    from corenet.engine.eval_segmentation import main_segmentation_evaluation

    main_segmentation_evaluation(args=args, **kwargs)


def main_worker_detection(args: Optional[List[str]] = None, **kwargs):
    from corenet.engine.eval_detection import main_detection_evaluation

    main_detection_evaluation(args=args, **kwargs)


if __name__ == "__main__":
    main_worker()


================================================
FILE: corenet/cli/main_eval_llmadapters.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#

"""
Evaluate commonsense reasoning performance on 8 commonsense reasoning tasks,
collectively called "CommonSense 170k" in LLM-Adapters <https://arxiv.org/abs/2304.01933>.

Code is adapted from https://github.com/AGI-Edgerunners/LLM-Adapters

In addition to the generation-style evaluation used by LLM-Adapters, we add a
multiple-choice-style evaluation. This massively improves results for small
models.

Currently, this only supports the LLama tokenizer. We may add support for
other tokenizers in the future.
"""

import collections
import copy
import json
import os
import random
import re
from typing import Any, Dict, List, Optional, Tuple

import numpy as np
from tqdm import tqdm

from corenet.data.datasets.language_modeling import commonsense_170k
from corenet.data.text_tokenizer import build_tokenizer

# Needs to be imported in a special way due to the hyphenated name.
try:
    llmadapters = __import__("LLM-Adapters.commonsense_evaluate")
except:
    llmadapters = None
import argparse
import torch

from corenet.options.opts import get_lm_eval_arguments
from corenet.utils import hf_adapter_utils, logger
from corenet.utils.download_utils import get_local_path

try:
    # For multiple-choice-style evaluation.
    from lm_eval.models.huggingface import HFLM

except:
    HFLM = object

try:
    from transformers import AutoTokenizer, GenerationConfig, LlamaTokenizer
except ModuleNotFoundError as mnfe:
    LlamaTokenizer = None
    AutoTokenizer = None
    GenerationConfig = None


class CoreNetLMEvalWrapper(HFLM):
    """
    A wrapper to build a CoreNet model that inherits the HFLM API.

    Args:
        opts: The global arguments object.
    """

    def __init__(self, opts: argparse.Namespace) -> None:

        device = "cuda" if torch.cuda.is_available() else "cpu"
        hf_config = hf_adapter_utils.CorenetToHFPretrainedConfig(**vars(opts))
        tokenizer_path = getattr(opts, f"text_tokenizer.sentence_piece.model_path")
        tokenizer_path = get_local_path(opts, tokenizer_path)
        # Currently, we only support LLamaTokenizer for this evaluation.
        hf_tokenizer = LlamaTokenizer.from_pretrained(tokenizer_path)
        vocab_size = hf_tokenizer.vocab_size
        hf_model = hf_adapter_utils.CorenetToHFPretrainedModel(hf_config, vocab_size)
        hf_model.to(device=device)
        # To ensure padding and batching don't cause issues, for now we only support
        # a batch_size of 1. In some cases, our code handles position ids differently
        # than other codebases, so we are extra cautious.
        batch_size = 1

        super().__init__(
            pretrained=hf_model,
            tokenizer=hf_tokenizer,
            batch_size=batch_size,
            max_length=getattr(opts, "dataset.language_modeling.sequence_length"),
            trust_remote_code=True,
            add_bos_token=getattr(opts, "lm_eval_wrapper.add_sot_token"),
        )

        self.opts = opts


def main_eval_llmadapters(args: Optional[List[str]] = None) -> None:
    """Main entry point for evaluation using LLM Adapters.

    This differs from the lm-eval-harness because it uses a different prompting strategy.
    We currently only support commonsense reasoning tasks.

    Args:
      args: A list of strings, as input on the command line.
    """
    opts = get_lm_eval_arguments(args=args)
    model_eval_wrapper = CoreNetLMEvalWrapper(opts)
    tasks = getattr(opts, "llmadapters_evaluation.datasets")
    dataset_dir = getattr(opts, "llmadapters_evaluation.dataset_dir")
    device = "cuda" if torch.cuda.is_available() else "cpu"
    results_loc = getattr(opts, "common.results_loc")
    limit = getattr(opts, "llmadapters_evaluation.limit")
    if limit is None:
        limit = int(1e9)
    multiple_choice = getattr(opts, "llmadapters_evaluation.multiple_choice")
    os.makedirs(results_loc, exist_ok=True)

    if multiple_choice:
        main_func = main_multiple_choice
    else:
        main_func = main_generation

    results = {}
    for task in tasks:
        save_file = f"{results_loc}/{task}.json"
        results[task] = main_func(
            task,
            dataset_dir,
            save_file,
            model_eval_wrapper,
            model_eval_wrapper.tokenizer,
            device,
            limit=limit,
        )
    with open(f"{results_loc}/results.json", "w+") as f:
        json.dump(results, f, indent=4)


### Functions for generation-style evaluation.
def main_generation(
    dataset_name: str,
    dataset_dir: str,
    save_file: str,
    model: CoreNetLMEvalWrapper,
    tokenizer: AutoTokenizer,
    device: str,
    limit: int = 1e9,
) -> None:
    """
    Run generation-style evaluation for the given dataset and model.

    Adapted from LLM-Adapters: https://github.com/AGI-Edgerunners/LLM-Adapters

    Args:
        dataset_name: The name of the dataset. E.g. "boolq" or "piqa".
        dataset_dir: The directory which contains a dataset with the given name.
        save_file: The path to which to save the results.
        model: The model to evaluate.
        tokenizer: The tokenizer to use with the model.
        device: The device on which to evaluate.
        limit: The maximum number of samples to process.
    """
    dataset = json.load(open(os.path.join(dataset_dir, dataset_name, "test.json"), "r"))
    # Shuffle the data. This is mainly useful if the ``limit''
    # option is used. This way, results will be sampled from
    # throughout the validation set.
    random.seed(83652)
    random.shuffle(dataset)
    dataset = dataset[:limit]

    total = len(dataset)
    correct = 0
    seen = 0
    output_data = []
    pbar = tqdm(total=total)
    for idx, elem in enumerate(dataset):
        seen += 1
        instruction = elem.get("instruction")

        output = evaluate_sample_with_generation(model, tokenizer, instruction, device)

        label = elem.get("answer")
        is_correct = False
        predict = extract_answer_from_generation(dataset_name, output)
        if label == predict:
            correct += 1
            is_correct = True
        new_elem = copy.deepcopy(elem)
        new_elem["output_pred"] = output
        new_elem["pred"] = predict
        new_elem["is_correct"] = is_correct
        output_data.append(new_elem)
        logger.info(f"EXAMPLE:")
        logger.info(f'> INSTRUCTION: {elem["instruction"]}')
        logger.info(f"> OUTPUT: {output}")
        logger.info(f"> PREDICTION: {predict}")
        logger.info(f"> LABEL: {label}")
        logger.info("---------------")
        logger.info(f"\rtest:{idx + 1}/{total} | accuracy: {correct / seen}")
        logger.info("---------------")
        with open(save_file, "w+") as f:
            json.dump(output_data, f, indent=4)
        pbar.update(1)
    pbar.close()
    logger.info("\n")
    logger.info("Test finished.")
    return {"acc": correct / seen}


def evaluate_sample_with_generation(
    model: CoreNetLMEvalWrapper,
    tokenizer: AutoTokenizer,
    instruction: str,
    device: str,
    temperature: float = 0.1,
    top_p: float = 0.75,
    top_k: int = 40,
    num_beams: int = 4,
    max_new_tokens: int = 32,
    **kwargs: Dict[str, Any],
) -> str:
    """
    Evaluate a sample with the given model.

    Adapted from LLM-Adapters.

    Args:
        model: The model to evaluate.
        tokenizer: The tokenizer to use with the model.
        instruction: A common sense reasoning input.
        device: The device on which to run.
        temperature: The temperature parameter for generation.
        top_p: The top_p parameter for generation.
        top_k: The top_k parameter for generation.
        num_beams: The number of beams to use in generation.
        max_new_tokens: The maximum number of tokens to generate.
        kwargs: Additional kwargs to pass to the GenerationConfig.
    """
    prompt = llmadapters.commonsense_evaluate.generate_prompt(instruction)
    tokenized_inputs = tokenizer(prompt, return_tensors="pt", padding=True)
    input_ids = tokenized_inputs["input_ids"].to(device)
    generation_config = GenerationConfig(
        temperature=temperature,
        top_p=top_p,
        top_k=top_k,
        num_beams=num_beams,
        **kwargs,
    )
    with torch.no_grad():
        generation_output = model._model.generate(
            input_ids=input_ids,
            generation_config=generation_config,
            return_dict_in_generate=True,
            output_scores=True,
            max_new_tokens=max_new_tokens,
            use_cache=False,
        )
    # The batch size is 1. We remove the batch dimension.
    (s,) = generation_output.sequences
    output = tokenizer.decode(s, skip_special_tokens=True)
    output = output.split("### Response:")[1].strip()
    return output


def extract_answer_from_generation(dataset: str, sentence: str) -> str:
    """
    Extract the multiple-choice answer from a sentence output by the model.

    Adapted from LLM-Adapters: https://github.com/AGI-Edgerunners/LLM-Adapters

    Args:
        dataset: The name of the dataset.
        sentence: The sentence from which to extract the answer.
    Returns:
        A string representing the answer.
    """
    if dataset == "boolq":
        sentence_ = sentence.strip()
        pred_answers = re.findall(r"true|false", sentence_)
        if not pred_answers:
            return ""
        return pred_answers[0]
    elif dataset == "piqa":
        sentence_ = sentence.strip()
        pred_answers = re.findall(r"solution1|solution2", sentence_)
        if not pred_answers:
            return ""
        return pred_answers[0]
    elif dataset in ["social_i_qa", "ARC-Challenge", "ARC-Easy", "openbookqa"]:
        sentence_ = sentence.strip()
        pred_answers = re.findall(r"answer1|answer2|answer3|answer4|answer5", sentence_)
        if not pred_answers:
            return ""
        return pred_answers[0]
    elif dataset == "hellaswag":
        sentence_ = sentence.strip()
        pred_answers = re.findall(r"ending1|ending2|ending3|ending4", sentence_)
        if not pred_answers:
            return ""
        return pred_answers[0]
    elif dataset == "winogrande":
        sentence_ = sentence.strip()
        pred_answers = re.findall(r"option1|option2", sentence_)
        if not pred_answers:
            return ""
        return pred_answers[0]
    else:
        raise ValueError(f"Invalid dataset {dataset}.")


### Functions for MC-style evaluation.
def main_multiple_choice(
    dataset_name: str,
    dataset_dir: str,
    save_file: str,
    model: CoreNetLMEvalWrapper,
    tokenizer: AutoTokenizer,
    device: str,
    limit: int = 1e9,
) -> None:
    """
    Run multiple-choice style evaluation.

    NOTE: The tokenizer and device are unused, but are passed to make
    the API consistent with @main_generation.

    Args:
        dataset_name: The name of the dataset. E.g. "boolq" or "piqa".
        dataset_dir: The directory which contains a dataset with the given name.
        save_file: The path to which to save the results.
        model: The model to evaluate.
        tokenizer: The tokenizer to use with the model.
        device: The device on which to evaluate.
        limit: The maximum number of samples to process.

    """
    dataset = json.load(open(os.path.join(dataset_dir, dataset_name, "test.json"), "r"))
    # Shuffle the data. This is mainly useful if the ``limit''
    # option is used. This way, results will be sampled from
    # throughout the validation set.
    random.seed(83652)
    random.shuffle(dataset)
    dataset = dataset[:limit]

    total = len(dataset)
    correct = 0
    correct_norm = 0
    seen = 0
    output_data = []
    pbar = tqdm(total=total)
    for idx, elem in enumerate(dataset):
        seen += 1

        chosen_value, chosen_norm_value = evaluate_likelihood(model, elem)

        label = elem.get("answer")
        is_correct = False
        is_correct_norm = False
        if label == chosen_value:
            correct += 1
            is_correct = True
        if label == chosen_norm_value:
            correct_norm += 1
            is_correct_norm = True
        new_elem = copy.deepcopy(elem)
        new_elem["output_pred"] = chosen_value
        new_elem["output_norm_pred"] = chosen_norm_value
        new_elem["is_correct"] = is_correct
        new_elem["is_correct_norm"] = is_correct_norm
        output_data.append(new_elem)
        logger.info("EXAMPLE:")
        logger.info(f"INSTRUCTION: {elem['instruction']}")
        logger.info(f"OUTPUT: {chosen_value}")
        logger.info(f"OUTPUT NORM: {chosen_norm_value}")
        logger.info(f"LABEL: {label}")
        logger.info("---------------")
        logger.info(
            f"\rtest:{idx + 1}/{total} | accuracy: {correct / seen} | accuracy norm {correct_norm / seen}"
        )
        logger.info("---------------")
        with open(save_file, "w+") as f:
            json.dump(output_data, f, indent=4)
        pbar.update(1)
    pbar.close()
    logger.info("\n")
    logger.info("Test finished.")
    return {"acc": correct / seen, "acc_norm": correct_norm / seen}


def evaluate_likelihood(
    model: CoreNetLMEvalWrapper, data: Dict[str, str]
) -> Tuple[str, str]:
    """
    Evaluate the likelihood of all possible answers for a prompt. Return
    the most likely one.

    Args:
        model: The model to use for evaluation.
        data: The data point to use. It contains the prompt and all
            possible answers. It contains the following keys: "instruction",
            "input", "output", "answer".
    Returns:
        A tuple containing the strings representing the most likely answers
        as measured by maximum loglikelihood and maximum normalized
        loglikelihood.
    """
    # Generate the set of possible instructions.
    requests = get_loglikelihood_inputs(data)
    model_outputs = model.loglikelihood(requests)

    # Get the log likelihoods and the most likely answer..
    likelihoods = [o[0] for o in model_outputs]
    index = np.argmax(likelihoods)
    output = requests[index].args[1].split(" ")[-1]

    # Get the log likelihoods (normalized by response length)
    # and the most likely answer.
    normalized_likelihoods = [
        likelihoods[i] / len(requests[i].args[1]) for i in range(len(requests))
    ]
    index = np.argmax(normalized_likelihoods)
    output_norm = requests[index].args[1].split(" ")[-1]

    return output, output_norm


Request = collections.namedtuple("Request", "args")


def get_loglikelihood_inputs(data: Dict[str, str]) -> List[Request]:
    """
    Helper function to create the inputs to the model's loglikelihood function.

    Args:
        data: The data point to use. It contains the prompt and all
            possible answers. It contains the following keys: "instruction",
            "input", "output", "answer".

    Returns:
        A list of Requests for the loglikelihood function.
    """

    def generate_response(response_value):
        return f"the correct answer is {response_value}"

    possible_answers = []
    instruction = data["instruction"]
    instruction_end = instruction.split("\n")[-1]
    if re.match(".*Answer format: true/false", instruction_end):
        possible_answers = ["true", "false"]
    else:
        for word in ["answer", "ending", "option", "solution"]:
            if re.match(rf".*Answer format: .*{word}(\d)$", instruction_end):
                num_answers = int(instruction_end[-1])
                possible_answers = [f"{word}{num}" for num in range(1, num_answers + 1)]

    if len(possible_answers) == 0:
        raise ValueError(f"Could not find answer type.")

    context = commonsense_170k.generate_prompt_and_response(
        {"instruction": instruction, "output": "", "input": ""}
    )
    request = []
    for elem in possible_answers:
        obj = Request(((context, generate_response(elem))))
        request.append(obj)
    return request


if __name__ == "__main__":
    main_eval_llmadapters()


================================================
FILE: corenet/cli/main_train.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#

from typing import List, Optional

from torch.distributed.elastic.multiprocessing import errors

from corenet.options.opts import get_training_arguments
from corenet.train_eval_pipelines import (
    TRAIN_EVAL_PIPELINE_REGISTRY,
    BaseTrainEvalPipeline,
)


@errors.record
def callback(train_eval_pipeline: BaseTrainEvalPipeline) -> None:
    """
    This function will be invoked on each gpu worker process.

    Args:
        train_eval_pipeline: Provides major pipeline components. The class to be used is
            configurable by "--train-eval-pipeline.name" opt. By default, an instance of
            ``train_eval_pipelines.TrainEvalPipeline`` will be passed to this function.
    """
    train_sampler = train_eval_pipeline.train_sampler
    train_eval_pipeline.training_engine.run(train_sampler=train_sampler)


def main_worker(args: Optional[List[str]] = None):
    opts = get_training_arguments(args=args)
    pipeline_name = getattr(opts, "train_eval_pipeline.name")
    train_eval_pipeline = TRAIN_EVAL_PIPELINE_REGISTRY[pipeline_name](opts=opts)
    launcher = train_eval_pipeline.launcher
    launcher(callback)


if __name__ == "__main__":
    main_worker()


================================================
FILE: corenet/constants.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#
import os
import re
import sys
from pathlib import Path
from typing import Any, Literal

# LIBRARY_ROOT is the folder that contains `corenet/` module.
LIBRARY_ROOT = Path(__file__).parent.parent

MIN_TORCH_VERSION = "1.11.0"

SUPPORTED_IMAGE_EXTNS = [".png", ".jpg", ".jpeg"]  # Add image formats here
SUPPORTED_VIDEO_CLIP_VOTING_FN = ["sum", "max"]
SUPPORTED_VIDEO_READER = ["pyav", "decord"]

DEFAULT_IMAGE_WIDTH = DEFAULT_IMAGE_HEIGHT = 256
DEFAULT_IMAGE_CHANNELS = 3
DEFAULT_VIDEO_FRAMES = 8
DEFAULT_LOG_FREQ = 500

DEFAULT_ITERATIONS = 300000
DEFAULT_EPOCHS = 300
DEFAULT_MAX_ITERATIONS = DEFAULT_MAX_EPOCHS = 10000000

DEFAULT_RESULTS_DIR = "results"
DEFAULT_LOGS_DIR = "results/logs"

TMP_RES_FOLDER = "results_tmp"

TMP_CACHE_LOC = "/tmp/corenet"

Path(TMP_CACHE_LOC).mkdir(parents=True, exist_ok=True)

DATA_CACHE_DIR = ".corenet_data_cache"

Path(DATA_CACHE_DIR).mkdir(parents=True, exist_ok=True)


def get_corenet_env() -> Literal["pytest", "default", "external"]:
    """
    Returns:
        One of the following values:
        * "pytest" iff corenet is loaded by pytest. For further details, please read
            the documentation of @is_test_env function.
        * "external" iff corenet is imported by modules other than the corenet itself
            and pytest.
        * "default" iff corenet is imported by one of its own entrypoints.

    Note: Please do not move this function to any module that has imports from corenet
        or imports for third-party non-builtin modules. The reason is that we invoke
        this function in corenet/__init__.py in order to suppress warnings *before*
        importing third-party libraries.
    """
    result = os.environ.get("CORENET_ENTRYPOINT")
    if result in (None, ""):
        # We fallback to "external", unless we detect corenet's default entrypoints
        # in sys.argv.
        result = "external"

        if len(sys.argv) > 0 and Path(sys.argv[0]).name.startswith("corenet-"):
            # This branch activates when running "corenet-train", etc. in commandline.
            os.environ["CORENET_ENTRYPOINT"] = "default"
            result = "default"
        elif len(sys.argv) > 1 and any(
            re.match(r"corenet[./](internal[./])?cli[./]", arg) for arg in sys.argv[1:]
        ):
            # This branch activates when running "python corenet/cli/main_train.py"
            # or running "python -m corenet.cli.main_train."
            os.environ["CORENET_ENTRYPOINT"] = "default"
            result = "default"

    if result not in ("pytest", "default", "external"):
        raise ValueError(
            f"Got invalid value for environment variable CORENET_ENTRYPOINT={result}."
        )
    return result


def is_test_env() -> bool:
    """
    Returns:
        True iff the corenet module is loaded by pytest.

    Note:
        - `CORENET_ENTRYPOINT=pytest` environment variable is set by `conftest.py` file.

        - Previously, we used to rely on the existence of "PYTEST_CURRENT_TEST" env var,
        which is set automatically by pytest, rather than CORENET_ENTRYPOINT=pytest.
        But the issue was that the `conftest.py` itself and some fixtures are run before
        "PYTEST_CURRENT_TEST" gets set.
    """
    return get_corenet_env() == "pytest"


def is_external_env() -> bool:
    """
    Returns:
        True iff the corenet module is loaded by modules other than the corenet itself
            and pytest
    """
    return get_corenet_env() == "external"


def if_test_env(then: Any, otherwise: Any) -> Any:
    return then if get_corenet_env() == "pytest" else otherwise


================================================
FILE: corenet/data/__init__.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#

from corenet.data.data_loaders import create_test_loader, create_train_val_loader


================================================
FILE: corenet/data/collate_fns/__init__.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#

import argparse

from corenet.utils import logger
from corenet.utils.registry import Registry

COLLATE_FN_REGISTRY = Registry(
    "collate_fn",
    lazy_load_dirs=["corenet/data/collate_fns"],
    internal_dirs=["corenet/internal", "corenet/internal/projects/*"],
)


def arguments_collate_fn(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
    """Add arguments related to collate function"""
    group = parser.add_argument_group("Collate function arguments")
    group.add_argument(
        "--dataset.collate-fn-name-train",
        type=str,
        default="pytorch_default_collate_fn",
        help="Name of collate function for training. Defaults to pytorch_default_collate_fn.",
    )
    group.add_argument(
        "--dataset.collate-fn-name-val",
        type=str,
        default="pytorch_default_collate_fn",
        help="Name of collate function for validation. Defaults to pytorch_default_collate_fn.",
    )
    group.add_argument(
        "--dataset.collate-fn-name-test",
        type=str,
        default="pytorch_default_collate_fn",
        help="Name of collate function used for evaluation. "
        "Default is pytorch_default_collate_fn.",
    )
    return parser


def build_collate_fn(opts, *args, **kwargs):
    collate_fn_name_train = getattr(opts, "dataset.collate_fn_name_train")

    if collate_fn_name_train is None:
        logger.error(
            "Please specify collate function for training dataset using "
            "--dataset.collate-fn-name-train"
        )

    collate_fn_name_val = getattr(opts, "dataset.collate_fn_name_val")
    if collate_fn_name_val is None:
        logger.error(
            "Please specify collate function for training dataset using "
            "--dataset.collate-fn-name-val"
        )

    collate_fn_train = COLLATE_FN_REGISTRY[collate_fn_name_train]
    collate_fn_val = COLLATE_FN_REGISTRY[collate_fn_name_val]
    return collate_fn_train, collate_fn_val


def build_test_collate_fn(opts, *args, **kwargs):
    collate_fn_name_test = getattr(opts, "dataset.collate_fn_name_test")
    # for test time
    if collate_fn_name_test is not None:
        return COLLATE_FN_REGISTRY[collate_fn_name_test]
    return None


================================================
FILE: corenet/data/collate_fns/byteformer_collate_functions.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#

"""This file contains collate functions used by ByteFormer.

Since the model operates on a variety of input types, these collate functions
are not associated with a particular dataset.

These transforms are applied before the model (rather than inside the model) to
take advantage of parallelism, and to avoid the need to move tensors from the
GPU, back to the CPU, then back to GPU (since these transforms cannot be done
on GPU).
"""

import argparse
from typing import Dict, List, Mapping, Optional, Union

import torch
from torch import Tensor
from torch.nn import functional

from corenet.data.collate_fns import COLLATE_FN_REGISTRY, collate_functions
from corenet.data.transforms import audio_bytes, image_bytes


@COLLATE_FN_REGISTRY.register(name="byteformer_image_collate_fn")
def byteformer_image_collate_fn(
    batch: List[Mapping[str, Tensor]], opts: argparse.Namespace
) -> Mapping[str, Tensor]:
    """
    Apply augmentations specific to `ByteFormer <https://arxiv.org/abs/2306.00238>`_
    image training, then perform padded collation.

    Args:
        batch: The batch of data.
        opts: The global arguments.

    Returns:
        The modified batch.
    """
    batch = apply_pil_save(batch, opts)
    batch = apply_shuffle_bytes(batch, opts)
    batch = apply_mask_positions(batch, opts)
    batch = apply_random_uniform_noise(batch, opts)
    batch = apply_byte_permutation(batch, opts)
    batch = apply_padding(batch, opts)
    batch = collate_functions.pytorch_default_collate_fn(batch, opts)
    return batch


def apply_padding(
    batch: List[Mapping[str, Union[Dict[str, Tensor], Tensor]]],
    opts: argparse.Namespace,
    key: Optional[str] = None,
) -> List[Mapping[str, Tensor]]:
    """
    Apply padding to make samples the same length.

    The input is a list of dictionaries of the form:
        [{"samples": @entry, ...}, ...].
    If @key is specified, @entry has the form {@key: @value}, where @value
    corresponds to the entry that should be padded. Otherwise, @entry is assumed
    to be a tensor.

    The tensor mentioned in the above paragraph will have shape [batch_size,
        sequence_length, ...].

    Args:
        batch: The batch of data.
        opts: The global arguments.
        key: The key of the sample element to pad. If @key is None, the entry
            is assumed to be a tensor.

    Returns:
        The modified batch of size [batch_size, padded_sequence_length, ...].
    """

    def get_entry(
        entry: Union[Dict[str, Tensor], Tensor], key: Optional[str]
    ) -> Tensor:
        """
        Helper function to deal with the cases where entries in the samples.

        Args:
            entry: Either a tensor of shape [batch_size, sequence_length, ...],
                or a dictionary containing {@key: tensor of shape
                [batch_size, sequence_length, ...]}.
        Returns:
            A tensor of shape [batch_size, ...].
        """
        if isinstance(entry, dict):
            return entry[key]
        if key is not None:
            raise ValueError(f"Key should not be specified if entries are not dicts.")
        return entry

    if get_entry(batch[0]["samples"], key).dim() != 1:
        # Padding only applies to 1d tensors.
        return batch
    padding_idx = getattr(opts, "model.classification.byteformer.padding_index")
    # Tensors have shape [batch_size, sequence_length, ...]. Get the maximum
    # sequence length.
    padded_seq_len = max(get_entry(be["samples"], key).shape[0] for be in batch)
    for elem in batch:
        sample = get_entry(elem["samples"], key)  # [batch_size, sequence_length, ...].
        sample = functional.pad(
            sample, (0, padded_seq_len - sample.shape[0]), value=padding_idx
        )  # [batch_size, padded_sequence_length, ...].
        if isinstance(elem["samples"], dict):
            elem["samples"][key] = sample
        else:
            elem["samples"] = sample
    return batch


def apply_pil_save(
    batch: List[Mapping[str, Tensor]],
    opts: argparse.Namespace,
) -> List[Mapping[str, Tensor]]:
    """
    Apply the PILSave transform to each batch element.

    Args:
        batch: The batch of data.
        opts: The global arguments.

    Returns:
        The modified batch.
    """
    if getattr(opts, "image_augmentation.pil_save.enable"):
        transform = image_bytes.PILSave(opts)
        for i, elem in enumerate(batch):
            batch[i] = transform(elem)
    return batch


def apply_shuffle_bytes(
    batch: List[Mapping[str, Tensor]],
    opts: argparse.Namespace,
) -> List[Mapping[str, Tensor]]:
    """
    Apply the ShuffleBytes transform to each batch element.

    Args:
        batch: The batch of data.
        opts: The global arguments.

    Returns:
        The modified batch.
    """
    if getattr(opts, "image_augmentation.shuffle_bytes.enable"):
        transform = image_bytes.ShuffleBytes(opts)
        for i, elem in enumerate(batch):
            batch[i] = transform(elem)
    return batch


def apply_mask_positions(
    batch: List[Mapping[str, Tensor]], opts: argparse.Namespace
) -> List[Mapping[str, Tensor]]:
    """
    Apply the MaskPositions transform to each batch element.

    Args:
        batch: The batch of data.
        opts: The global arguments.

    Returns:
        The modified batch.
    """
    if getattr(opts, "image_augmentation.mask_positions.enable"):
        transform = image_bytes.MaskPositions(opts)
        for i, elem in enumerate(batch):
            batch[i] = transform(elem)
    return batch


def apply_random_uniform_noise(
    batch: List[Mapping[str, Tensor]], opts: argparse.Namespace
) -> List[Mapping[str, Tensor]]:
    """
    Apply the RandomUniformNoise transform to each batch element.

    Args:
        batch: The batch of data.
        opts: The global arguments.

    Returns:
        The modified batch.
    """
    if getattr(opts, "image_augmentation.random_uniform.enable"):
        transform = image_bytes.RandomUniformNoise(opts)
        for i, elem in enumerate(batch):
            batch[i] = transform(elem)
    return batch


def apply_byte_permutation(
    batch: List[Mapping[str, Tensor]], opts: argparse.Namespace
) -> List[Mapping[str, Tensor]]:
    """
    Apply the BytePermutation transform to each batch element.

    Args:
        batch: The batch of data.
        opts: The global arguments.

    Returns:
        The modified batch.
    """
    if getattr(opts, "image_augmentation.byte_permutation.enable"):
        transform = image_bytes.BytePermutation(opts)
        for i, elem in enumerate(batch):
            batch[i] = transform(elem)
    return batch


def apply_torchaudio_save(
    batch: List[Mapping[str, Tensor]], opts: argparse.Namespace
) -> List[Mapping[str, Tensor]]:
    """
    Apply the TorchaudioSave transform to each batch element.

    Args:
        batch: The batch of data.
        opts: The global arguments.

    Returns:
        The modified batch.
    """
    if getattr(opts, "audio_augmentation.torchaudio_save.enable"):
        transform = audio_bytes.TorchaudioSave(opts)
        for i, elem in enumerate(batch):
            batch[i] = transform(elem)
    return batch


@COLLATE_FN_REGISTRY.register(name="byteformer_audio_collate_fn")
def byteformer_audio_collate_fn(
    batch: List[Mapping[str, Tensor]], opts: argparse.Namespace
) -> Mapping[str, Tensor]:
    """
    Apply augmentations specific to ByteFormer audio training, then perform
    padded collation.

    Args:
        batch: The batch of data.
        opts: The global arguments.

    Returns:
        The modified batch.
    """
    batch = apply_torchaudio_save(batch, opts)
    batch = apply_padding(batch, opts, "audio")
    # Remove the metadata, which is no longer needed.
    for elem in batch:
        del elem["metadata"]
    batch = collate_functions.pytorch_default_collate_fn(batch, opts)
    return batch


================================================
FILE: corenet/data/collate_fns/collate_functions.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#
import argparse
from typing import Any, List, Mapping

import torch
from torch import Tensor
from torch.utils.data import default_collate

from corenet.data.collate_fns import COLLATE_FN_REGISTRY
from corenet.utils import logger


@COLLATE_FN_REGISTRY.register(name="pytorch_default_collate_fn")
def pytorch_default_collate_fn(batch: Any, *args, **kwargs) -> Any:
    """A wrapper around PyTorch's default collate function."""
    batch = default_collate(batch)
    return batch


@COLLATE_FN_REGISTRY.register(name="unlabeled_image_data_collate_fn")
def unlabeled_image_data_collate_fn(
    batch: List[Mapping[str, Any]], opts: argparse.Namespace
) -> Mapping[str, Any]:
    """
    Combines a list of dictionaries into a single dictionary by concatenating matching fields.

    Each input dictionary is expected to have items with `samples` and `sample_id` as keys. The value for
    `samples` is expected to be a tensor and the value for `sample_id` is expected to be an integer.

    This function adds `targets` field to the output dictionary with dummy values to meet the expectations of
    training engine.

    Args:
        batch: A list of dictionaries
        opts: An argparse.Namespace instance.

    Returns:
        A dictionary with `samples`, `sample_id` and `targets` as keys.
    """
    batch_size = len(batch)
    sample_size = [batch_size, *batch[0]["samples"].shape]
    img_dtype = batch[0]["samples"].dtype

    samples = torch.zeros(size=sample_size, dtype=img_dtype)
    sample_ids = torch.zeros(size=[batch_size], dtype=torch.long)
    for i, batch_i in enumerate(batch):
        samples[i] = batch_i["samples"]
        sample_ids[i] = batch_i["sample_id"]

    channels_last = getattr(opts, "common.channels_last")
    if channels_last:
        samples = samples.to(memory_format=torch.channels_last)

    # Add dummy labels to meet the expectations of training engine.
    dummy_labels = torch.full(size=[batch_size], fill_value=0, dtype=torch.long)

    return {"samples": samples, "sample_id": sample_ids, "targets": dummy_labels}


@COLLATE_FN_REGISTRY.register(name="image_classification_data_collate_fn")
def image_classification_data_collate_fn(
    batch: List[Mapping[str, Any]], opts: argparse.Namespace
) -> Mapping[str, Any]:
    """Combines a list of dictionaries into a single dictionary by concatenating matching fields.

    Each input dictionary is expected  to have items with `samples`,`sample_id` and `targets` as keys. The value for
    `samples` is expected to be a tensor and the values for `sample_id` and `targets` are expected to be integers.

    Args:
        batch: A list of dictionaries
        opts: An argparse.Namespace instance.

    Returns:
        A dictionary with `samples`, `sample_id` and `targets` as keys.
    """
    batch_size = len(batch)
    img_size = [batch_size, *batch[0]["samples"].shape]
    img_dtype = batch[0]["samples"].dtype

    images = torch.zeros(size=img_size, dtype=img_dtype)
    sample_ids = torch.zeros(size=[batch_size], dtype=torch.long)
    labels = torch.full(size=[batch_size], fill_value=-1, dtype=torch.long)
    valid_indexes = []
    for i, batch_i in enumerate(batch):
        images[i] = batch_i["samples"]
        sample_ids[i] = batch_i["sample_id"]

        label_i = batch_i["targets"]
        labels[i] = label_i
        if label_i != -1:
            valid_indexes.append(i)

    valid_indexes = torch.tensor(valid_indexes, dtype=torch.long)
    images = torch.index_select(images, dim=0, index=valid_indexes)
    sample_ids = torch.index_select(sample_ids, dim=0, index=valid_indexes)
    labels = torch.index_select(labels, dim=0, index=valid_indexes)

    channels_last = getattr(opts, "common.channels_last")
    if channels_last:
        images = images.to(memory_format=torch.channels_last)

    return {"samples": images, "targets": labels, "sample_id": sample_ids}


@COLLATE_FN_REGISTRY.register(name="default_collate_fn")
def default_collate_fn(
    batch: List[Mapping[str, Tensor]], opts: argparse.Namespace
) -> Mapping[str, Tensor]:
    """Combines a list of dictionaries into a single dictionary by concatenating matching fields.

    Args:
        batch: A list of dictionaries
        opts: An argparse.Namespace instance.

    Returns:
        A dictionary with the same keys as batch[0].
    """
    batch_size = len(batch)

    # get the keys for first element in the list, assuming all elements have the same keys
    keys = list(batch[0].keys())

    new_batch = {k: [] for k in keys}
    for b in range(batch_size):
        for k in keys:
            new_batch[k].append(batch[b][k])

    # stack the keys
    for k in keys:
        batch_elements = new_batch.pop(k)

        if isinstance(batch_elements[0], (int, float)):
            # list of ints or floats
            batch_elements = torch.as_tensor(batch_elements)
        else:
            # stack tensors (including 0-dimensional)
            try:
                batch_elements = torch.stack(batch_elements, dim=0).contiguous()
            except Exception as e:
                logger.error("Unable to stack the tensors. Error: {}".format(e))

        new_batch[k] = batch_elements

    return new_batch


================================================
FILE: corenet/data/data_loaders.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#

import argparse
from functools import partial
from typing import Mapping, Optional, Tuple, Union

from torch.utils.data import IterableDataset
from torch.utils.data.sampler import Sampler

from corenet.data.collate_fns import build_collate_fn, build_test_collate_fn
from corenet.data.datasets import BaseDataset, get_test_dataset, get_train_val_datasets
from corenet.data.loader.dataloader import CoreNetDataLoader
from corenet.data.sampler import build_sampler
from corenet.utils import logger
from corenet.utils.ddp_utils import is_master
from corenet.utils.tensor_utils import image_size_from_opts


def create_test_loader(opts: argparse.Namespace) -> CoreNetDataLoader:
    """Helper function to create and return a dataset loader for test dataset from command-line arguments"""
    is_master_node = is_master(opts)
    test_dataset = get_test_dataset(opts)
    if isinstance(test_dataset, IterableDataset):
        test_sampler = None
        batch_size = getattr(opts, "dataset.eval_batch_size0")
        assert batch_size > 0, (
            f"For iterable datasets, we need batch size > 0 but got {batch_size}. "
            f"Please specify batch size using 'dataset.eval_batch_size0' argument in the config file."
        )
    else:
        n_test_samples = get_num_data_samples_as_int_or_mapping(test_dataset)

        # The sampler reads the batch size for validation/test jobs using 'dataset.val_batch_size0'
        # So, we override the value of validation batch size argument with evaluation batch size argument.
        setattr(
            opts,
            "dataset.val_batch_size0",
            getattr(opts, "dataset.eval_batch_size0"),
        )

        # we don't need variable batch sampler for evaluation
        sampler_name = getattr(opts, "sampler.name", "batch_sampler")
        crop_size_h, crop_size_w = image_size_from_opts(opts)
        if sampler_name.find("var") > -1:
            setattr(opts, "sampler.name", "batch_sampler")
            setattr(opts, "sampler.bs.crop_size_width", crop_size_w)
            setattr(opts, "sampler.bs.crop_size_height", crop_size_h)

        test_sampler = build_sampler(
            opts=opts,
            n_data_samples=n_test_samples,
            is_training=False,
            get_item_metadata=test_dataset.get_item_metadata,
        )
        # for non-iterable dataset, batch size is handled inside the sampler.
        batch_size = 1
        if is_master_node:
            logger.log(f"Evaluation sampler details: {test_sampler}")

    collate_fn_test = build_test_collate_fn(opts=opts)

    data_workers = getattr(opts, "dataset.workers")
    persistent_workers = getattr(opts, "dataset.persistent_workers") and (
        data_workers > 0
    )
    pin_memory = getattr(opts, "dataset.pin_memory")

    test_loader = CoreNetDataLoader(
        dataset=test_dataset,
        batch_size=batch_size,
        batch_sampler=test_sampler,
        num_workers=data_workers,
        pin_memory=pin_memory,
        persistent_workers=persistent_workers,
        collate_fn=(
            partial(collate_fn_test, opts=opts) if collate_fn_test is not None else None
        ),
    )
    return test_loader


def create_train_val_loader(
    opts: argparse.Namespace,
) -> Tuple[CoreNetDataLoader, Optional[CoreNetDataLoader], Sampler]:
    """Helper function to create training and validation data loaders.

    Args:
        opts: Command-line arguments

    Returns:
        A tuple containing training data loader, (optional) validation data loader, and training data sampler.
    """
    is_master_node = is_master(opts)
    train_dataset, valid_dataset = get_train_val_datasets(opts)

    if isinstance(train_dataset, IterableDataset):
        train_sampler = None
        train_batch_size = getattr(opts, "dataset.train_batch_size0")
        assert train_batch_size > 0, (
            f"For iterable datasets, we need batch size > 0 but got {train_batch_size}. "
            f"Please specify batch size using 'dataset.train_batch_size0' argument in the config file."
        )
    else:
        n_train_samples = get_num_data_samples_as_int_or_mapping(train_dataset)
        train_sampler = build_sampler(
            opts=opts,
            n_data_samples=n_train_samples,
            is_training=True,
            get_item_metadata=train_dataset.get_item_metadata,
        )
        # for non-iterable dataset, batch size is handled inside the sampler.
        train_batch_size = 1

    if valid_dataset is None:
        # Validation is disabled.
        valid_sampler = None
        val_batch_size = 1
    elif isinstance(valid_dataset, IterableDataset):
        # validation dataset is iterable
        valid_sampler = None
        val_batch_size = getattr(opts, "dataset.val_batch_size0")
        assert val_batch_size > 0, (
            f"For iterable datasets, we need batch size > 0 but got {val_batch_size}. "
            f"Please specify batch size using 'dataset.val_batch_size0' argument in the config file."
        )
    else:
        # validation dataset is map-style
        n_valid_samples = get_num_data_samples_as_int_or_mapping(valid_dataset)
        valid_sampler = build_sampler(
            opts=opts,
            n_data_samples=n_valid_samples,
            is_training=False,
            get_item_metadata=valid_dataset.get_item_metadata,
        )
        # for non-iterable dataset, batch size is handled inside the sampler.
        val_batch_size = 1

    data_workers = getattr(opts, "dataset.workers")
    persistent_workers = getattr(opts, "dataset.persistent_workers") and (
        data_workers > 0
    )
    pin_memory = getattr(opts, "dataset.pin_memory")
    prefetch_factor = getattr(opts, "dataset.prefetch_factor")

    collate_fn_train, collate_fn_val = build_collate_fn(opts=opts)

    train_loader = CoreNetDataLoader(
        dataset=train_dataset,
        batch_size=train_batch_size,
        num_workers=data_workers,
        pin_memory=pin_memory,
        batch_sampler=train_sampler,
        persistent_workers=persistent_workers,
        collate_fn=(
            partial(collate_fn_train, opts=opts)
            if collate_fn_train is not None
            else None
        ),
        prefetch_factor=prefetch_factor,
    )

    if valid_dataset is not None:
        val_loader = CoreNetDataLoader(
            dataset=valid_dataset,
            batch_size=val_batch_size,
            batch_sampler=valid_sampler,
            num_workers=data_workers,
            pin_memory=pin_memory,
            persistent_workers=persistent_workers,
            collate_fn=(
                partial(collate_fn_val, opts=opts)
                if collate_fn_val is not None
                else None
            ),
        )
    else:
        val_loader = None

    if is_master_node:
        if train_sampler is not None:
            logger.log(f"Training sampler details: {train_sampler}")

        if valid_sampler is not None:
            logger.log(f"Validation sampler details: {valid_sampler}")

        logger.log("Number of data workers: {}".format(data_workers))

    return train_loader, val_loader, train_sampler


def get_num_data_samples_as_int_or_mapping(
    dataset: BaseDataset,
) -> Union[int, Mapping[str, int]]:
    """Return the number of samples in the dataset.

    The dataset can be a single or composition of multiple datasets (as in multi-task learning). For a single
    dataset, the number of samples is integer while for multiple datasets, a dictionary is returned with task name and
    number of samples per task.

    Args:
        dataset: An instance of `corenet.data.datasets.BaseDataset` class

    Returns:
        An integer for single dataset and mapping for composite datasets.

    """
    if hasattr(dataset, "get_dataset_length_as_mapping"):
        return dataset.get_dataset_length_as_mapping()
    else:
        return len(dataset)


================================================
FILE: corenet/data/datasets/__init__.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#

import argparse
from typing import Optional, Tuple

from corenet.constants import if_test_env
from corenet.data.datasets.classification.base_image_classification_dataset import (
    BaseImageClassificationDataset,
)
from corenet.data.datasets.classification.base_imagenet_shift_dataset import (
    BaseImageNetShiftDataset,
)
from corenet.data.datasets.dataset_base import (
    BaseDataset,
    BaseImageDataset,
    BaseIterableDataset,
    BaseVideoDataset,
)
from corenet.data.datasets.detection.base_detection import BaseDetectionDataset
from corenet.data.datasets.language_modeling.base_lm import BaseLMIterableDataset
from corenet.data.datasets.multi_modal_img_text import arguments_multi_modal_img_text
from corenet.data.datasets.segmentation.base_segmentation import (
    BaseImageSegmentationDataset,
)
from corenet.utils import logger
from corenet.utils.ddp_utils import is_master
from corenet.utils.registry import Registry

DATASET_REGISTRY = Registry(
    registry_name="dataset_registry",
    base_class=BaseDataset,
    lazy_load_dirs=["corenet/data/datasets"]
    + if_test_env(
        then=["tests/data/datasets"],
        otherwise=[],
    ),
    internal_dirs=["corenet/internal", "corenet/internal/projects/*"],
)


def build_dataset_from_registry(
    opts: argparse.Namespace,
    is_training: bool = True,
    is_evaluation: bool = False,
    *args,
    **kwargs,
) -> BaseDataset:
    """Helper function to build a dataset from dataset registry

    Args:
        opts: Command-line arguments
        is_training: Training mode or not. Defaults to True.
        is_evaluation: Evaluation mode or not. Defaults to False.

    Returns:
        An instance of BaseDataset


    ...note:
        `is_training` is used to indicate whether the dataset is used for training or validation
        On the other hand, `is_evaluation` mode is used to indicate the dataset is used for testing.

        Theoretically, `is_training=False` and `is_evaluation=True` should be the same. However, for some datasets
        (especially segmentation), validation dataset transforms are different from
        test transforms because each image has different resolution, making it difficult to construct
        batches. Therefore, we treat these two modes different. For datasets, where validation and testing
        transforms are the same, we set evaluation transforms the same as the validation transforms (e.g., in ImageNet
        object classification).
    """

    dataset_category = getattr(opts, "dataset.category")

    if dataset_category is None:
        logger.error("Please specify dataset category using --dataset.category")

    dataset_name = getattr(opts, f"dataset.name")
    if dataset_name is None:
        logger.error("Please specify dataset name using --dataset.name")

    dataset = DATASET_REGISTRY[dataset_name, dataset_category](
        opts=opts, is_training=is_training, is_evaluation=is_evaluation, *args, **kwargs
    )
    return dataset


def get_test_dataset(opts: argparse.Namespace, *args, **kwargs) -> BaseDataset:
    """Helper function to build a dataset for testing.

    Args:
        opts: Command-line arguments

    Returns:
        An instance of BaseDataset
    """

    test_dataset = build_dataset_from_registry(
        opts, is_training=False, is_evaluation=True, *args, **kwargs
    )

    if is_master(opts):
        logger.log("Evaluation dataset details: ")
        print("{}".format(test_dataset))

    return test_dataset


def get_train_val_datasets(
    opts: argparse.Namespace, *args, **kwargs
) -> Tuple[BaseDataset, Optional[BaseDataset]]:
    """Helper function to build a dataset for training and validation.

    Args:
        opts: Command-line arguments

    Returns:
        Training and (optionally) validation datasets.
    """

    disable_val = getattr(opts, "dataset.disable_val")
    is_master_node = is_master(opts)
    train_dataset = build_dataset_from_registry(
        opts, is_training=True, is_evaluation=False, *args, **kwargs
    )
    if is_master_node:
        logger.log("Training dataset details are given below")
        print(train_dataset)

    valid_dataset = None
    if not disable_val:
        valid_dataset = build_dataset_from_registry(
            opts, is_training=False, is_evaluation=False, *args, **kwargs
        )
        if is_master_node:
            logger.log("Validation dataset details are given below")
            print(valid_dataset)

    return train_dataset, valid_dataset


def arguments_dataset(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
    """Add dataset-specific arguments from BaseDataset, BaseImageDataset,
    BaseImageClassificationDataset, BaseImageNetShiftDataset,
    BaseVideoDataset, zero-shot datasets, and DATASET_REGISTRY.
    """
    parser = BaseDataset.add_arguments(parser)
    parser = BaseImageDataset.add_arguments(parser)
    parser = BaseImageSegmentationDataset.add_arguments(parser)
    parser = BaseVideoDataset.add_arguments(parser)
    parser = BaseImageClassificationDataset.add_arguments(parser)
    parser = BaseImageNetShiftDataset.add_arguments(parser)
    parser = BaseDetectionDataset.add_arguments(parser)
    parser = BaseLMIterableDataset.add_arguments(parser)

    try:
        from corenet.internal.utils.server_utils import dataset_server_args

        parser = dataset_server_args(parser)
    except ImportError:
        pass

    # add multi-modal and zero-shot arguments
    parser = arguments_multi_modal_img_text(parser=parser)

    # add dataset specific arguments
    parser = DATASET_REGISTRY.all_arguments(parser)
    return parser


================================================
FILE: corenet/data/datasets/audio_classification/__init__.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#


================================================
FILE: corenet/data/datasets/audio_classification/speech_commands_v2.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#

import argparse
import json
import os
import random
from typing import Dict, Tuple, Union

import torch
import torchaudio
from torch import Tensor
from torch.nn import functional as F

from corenet.data.datasets import DATASET_REGISTRY, dataset_base
from corenet.data.transforms.audio import Noise, Roll, SetFixedLength
from corenet.data.transforms.common import Compose
from corenet.data.transforms.image_pil import BaseTransformation


@DATASET_REGISTRY.register(name="speech_commands_v2", type="audio_classification")
class SpeechCommandsv2Dataset(dataset_base.BaseDataset):
    """
    Google's Speech Commands dataset for keyword spotting (https://arxiv.org/abs/1804.03209).

    This contains the "v2" version for 12-way classification (10 commands,
    plus unknown and background categories).

    Args:
        opts: Command-line arguments
    """

    def __init__(
        self,
        opts: argparse.Namespace,
        *args,
        **kwargs,
    ) -> None:
        super().__init__(opts=opts, *args, **kwargs)
        mode_str = self.mode
        if self.mode == "val":
            # This value is needed to calculate the correct annotation .json paths.
            mode_str = "validation"

        self.dataset_config = os.path.join(self.root, f"{mode_str}_manifest.json")

        self._process_dataset_config()
        self.mixup = getattr(opts, "dataset.speech_commands_v2.mixup")

    def _process_dataset_config(self) -> None:
        """
        Process the dataset .json files to set up the dataset.

        The .json configs contain:
        [
            {
                "audio_filepath": relative path to audio from the dataset root directory,
                "duration": floating point duration in seconds,
                "command": the label of the spoken command.
            },
            ...
        ]
        """
        with open(self.dataset_config) as f:
            lines = f.readlines()

        self.dataset_entries = []
        for line in lines:
            self.dataset_entries.append(json.loads(line))

        for elem in self.dataset_entries:
            audio_path = elem["audio_filepath"]
            new_path = os.path.join(self.root, audio_path)
            elem["audio_filepath"] = new_path

        all_labels = sorted(set([elem["command"] for elem in self.dataset_entries]))
        self.label_to_index = {l: i for i, l in enumerate(all_labels)}

        if getattr(self.opts, "audio_augmentation.noise.enable"):
            # Cache this, since it loads files on initialization.
            background_dir = os.path.join(self.root, "_background_noise_")
            self.noise = Noise(self.opts, noise_files_dir=background_dir)

    @classmethod
    def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
        group = parser.add_argument_group(cls.__name__)
        group.add_argument(
            "--dataset.speech-commands-v2.mixup",
            action="store_true",
            help="If set, apply mixup inside the dataset.",
        )
        return parser

    def _training_transforms(self, *args, **kwargs) -> BaseTransformation:
        """
        Returns transformations applied to the input in training mode.
        """
        aug_list = [
            SetFixedLength(self.opts),
        ]

        if getattr(self.opts, "audio_augmentation.noise.enable"):
            aug_list.append(self.noise)
        if getattr(self.opts, "audio_augmentation.roll.enable"):
            aug_list.append(Roll(self.opts))
        return Compose(self.opts, aug_list)

    def _validation_transforms(self, *args, **kwargs) -> BaseTransformation:
        """
        Returns transformations applied to the input in validation mode.
        """
        aug_list = [SetFixedLength(self.opts)]
        return Compose(self.opts, aug_list)

    def get_sample(self, index: int) -> Tuple[Tensor, float, Tensor]:
        """
        Get the dataset sample at the given index.
        """
        dataset_entry = self.dataset_entries[index]
        waveform, audio_fps = torchaudio.load(dataset_entry["audio_filepath"])

        label = torch.tensor(
            self.label_to_index[dataset_entry["command"]], dtype=torch.long
        )
        return waveform, audio_fps, label

    def __getitem__(
        self, batch_indexes_tup: Tuple
    ) -> Dict[str, Union[Dict[str, Tensor], Tensor, int]]:
        """
        Returns the sample corresponding to the input sample index and applies
        transforms.

        If the class uses mixup, and is in training mode, this will additionally
        apply mixup.

        Args:
            batch_indexes_tup: Tuple of the form (crop_size_h, crop_size_w, sample_index).
                The first two parts are not needed, and are ignored by this function.

        Returns:
            A sample as a dictionary. It contains:
                {
                    "samples":
                        {
                            "audio": A [C, N] tensor, where C is the number of
                                channels, and N is the length.
                        }
                    "targets": an integer class label.
                    "sample_id": an integer giving the sample index.
                    "metadata":
                        {
                            "audio_fps": The sampling rate of the audio.
                        }
                }
        """
        _, _, index = batch_indexes_tup
        data = self.get_transformed_sample(index)

        if self.mixup and self.is_training:
            index = random.randint(0, len(self) - 1)
            data2 = self.get_transformed_sample(index)

            if data["metadata"]["audio_fps"] != data2["metadata"]["audio_fps"]:
                raise ValueError(
                    f"Inconsistent audio_fps ({data['metadata']['audio_fps']} and {data2['metadata']['audio_fps']})"
                )

            coefficient = torch.rand(1)
            data["samples"]["audio"] = data["samples"]["audio"] * coefficient + data2[
                "samples"
            ]["audio"] * (1.0 - coefficient)

            def to_onehot(targets: Tensor) -> Tensor:
                return F.one_hot(targets, num_classes=len(self.label_to_index))

            data["targets"] = to_onehot(data["targets"]) * coefficient + to_onehot(
                data2["targets"]
            ) * (1.0 - coefficient)

        return data

    def get_transformed_sample(
        self, index: int
    ) -> Dict[str, Union[Dict[str, Tensor], Tensor, int]]:
        """
        Get the sample at the index specified by @index.

        Args:
            index: The index of the sample.

        Returns:
            A sample as a dictionary. It contains:
                {
                    "samples":
                        {
                            "audio": A [C, N] tensor, where C is the number of
                                channels, and N is the length.
                        }
                    "targets": an integer class label.
                    "sample_id": an integer giving the sample index.
                    "metadata":
                        {
                            "audio_fps": The sampling rate of the audio.
                        }
                }
        """
        waveform, audio_fps, label = self.get_sample(index)

        data = {
            "samples": {"audio": waveform},
            "targets": label,
            "sample_id": index,
            "metadata": {"audio_fps": audio_fps},
        }

        transform_fn = self.get_augmentation_transforms()
        data = transform_fn(data)

        return data

    def __len__(self) -> int:
        return len(self.dataset_entries)


================================================
FILE: corenet/data/datasets/classification/__init__.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#


================================================
FILE: corenet/data/datasets/classification/base_image_classification_dataset.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#
import argparse
from typing import Any, Dict, Tuple, Union

import torch
from torchvision.datasets import ImageFolder

from corenet.data.datasets.dataset_base import BaseImageDataset
from corenet.data.datasets.utils.common import select_samples_by_category
from corenet.data.transforms import image_pil
from corenet.data.transforms.common import Compose
from corenet.utils import logger
from corenet.utils.ddp_utils import is_master


class BaseImageClassificationDataset(BaseImageDataset, ImageFolder):
    """Image Classification Dataset.


    This base class can be used to represent any image classification dataset which is stored in a way that meets the
    expectations of `torchvision.datasets.ImageFolder`. New image classification datasets can be derived from this
    similar to ImageNetDataset (imagenet.py) or Places365Dataset (places365.py) and overwrite the data transformations
    as needed. This dataset also supports sampling a random subset of the training set to be used for training. The
    subset size is determined by the arguments `dataset.num_samples_per_category` and `dataset.percentage_of_samples`
    in the input `opts`. Only one of these two should be specified. When `dataset.percentage_of_samples` is specified,
    data is sampled from all classes according to this percentage such that the distribution of classes does not change.
     The randomness in sampling is controlled by the `dataset.sample_selection_random_seed` in the input `opts`.

    Args:
        opts: An argparse.Namespace instance.
    """

    def __init__(
        self,
        opts: argparse.Namespace,
        *args,
        **kwargs,
    ) -> None:
        BaseImageDataset.__init__(
            self,
            opts=opts,
            *args,
            **kwargs,
        )
        root = self.root
        ImageFolder.__init__(
            self,
            root=root,
            transform=None,
            target_transform=None,
            is_valid_file=None,
        )

        self.n_classes = len(list(self.class_to_idx.keys()))

        master = is_master(self.opts)
        if master:
            logger.log("Number of categories: {}".format(self.n_classes))
            logger.log("Total number of samples: {}".format(len(self.samples)))

        num_samples_per_category = getattr(
            self.opts, "dataset.num_samples_per_category"
        )
        percentage_of_samples = getattr(self.opts, "dataset.percentage_of_samples")

        if self.is_training and (
            num_samples_per_category > 0 or (0 < percentage_of_samples < 100)
        ):
            if num_samples_per_category > 0 and (0 < percentage_of_samples < 100):
                raise ValueError(
                    "Both `dataset.num_samples_per_category` and `dataset.percentage_of_samples` are specified. "
                    "Please specify only one."
                )

            random_seed = getattr(self.opts, "dataset.sample_selection_random_seed")
            if num_samples_per_category > 0:
                selected_sample_indices = select_samples_by_category(
                    sample_category_labels=self.targets,
                    random_seed=random_seed,
                    num_samples_per_category=num_samples_per_category,
                )
                if master:
                    logger.log(
                        "Using {} samples per category.".format(
                            num_samples_per_category
                        )
                    )
            else:
                selected_sample_indices = select_samples_by_category(
                    sample_category_labels=self.targets,
                    random_seed=random_seed,
                    percentage_of_samples_per_category=percentage_of_samples,
                )
                if master:
                    logger.log(
                        "Using {} percentage of samples per category.".format(
                            percentage_of_samples
                        )
                    )

            self.samples = [self.samples[ind] for ind in selected_sample_indices]
            self.imgs = [self.imgs[ind] for ind in selected_sample_indices]
            self.targets = [self.targets[ind] for ind in selected_sample_indices]
        elif master:
            logger.log("Using all samples in the dataset.")

    @classmethod
    def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
        """
        Adds dataset related arguments to the parser.

        Args:
            parser: An argparse.Namespace instance

        Returns:
            Input argparse.Namespace instance with additional arguments.
        """
        if cls != BaseImageClassificationDataset:
            # Don't re-register arguments in subclasses that don't override `add_arguments()`.
            return parser
        group = parser.add_argument_group(title=cls.__name__)

        group.add_argument(
            "--dataset.num-samples-per-category",
            type=int,
            default=-1,
            help="Number of samples to use per category. If set to -1, all samples will be used.",
        )
        return parser

    def _training_transforms(
        self, size: Union[Tuple[int, int], int], *args, **kwargs
    ) -> image_pil.BaseTransformation:
        """
        Returns transformations applied to the input in training mode.

        Order of transformations: RandomResizedCrop, RandomHorizontalFlip, One of AutoAugment or RandAugment or
        TrivialAugmentWide, RandomErasing

        Batch-based augmentations such as Mixup and CutMix are implemented in trainer.

        Args:
            size: Size for resizing the input image. Expected to be an integer (width=height) or a tuple (height, width)

        Returns:
            An instance of `corenet.data.transforms.image_pil.BaseTransformation.`
        """
        if not getattr(self.opts, "image_augmentation.random_resized_crop.enable"):
            raise ValueError(
                "`image_augmentation.random_resized_crop.enable` must be set to True in input options."
            )

        aug_list = [image_pil.RandomResizedCrop(opts=self.opts, size=size)]

        if getattr(self.opts, "image_augmentation.random_horizontal_flip.enable"):
            aug_list.append(image_pil.RandomHorizontalFlip(opts=self.opts))

        auto_augment = getattr(self.opts, "image_augmentation.auto_augment.enable")
        rand_augment = getattr(self.opts, "image_augmentation.rand_augment.enable")
        trivial_augment_wide = getattr(
            self.opts, "image_augmentation.trivial_augment_wide.enable"
        )
        if bool(auto_augment) + bool(rand_augment) + bool(trivial_augment_wide) > 1:
            logger.error(
                "Only one of AutoAugment, RandAugment and TrivialAugmentWide should be used."
            )
        elif auto_augment:
            aug_list.append(image_pil.AutoAugment(opts=self.opts))
        elif rand_augment:
            if getattr(self.opts, "image_augmentation.rand_augment.use_timm_library"):
                aug_list.append(image_pil.RandAugmentTimm(opts=self.opts))
            else:
                aug_list.append(image_pil.RandAugment(opts=self.opts))
        elif trivial_augment_wide:
            aug_list.append(image_pil.TrivialAugmentWide(opts=self.opts))

        aug_list.append(image_pil.ToTensor(opts=self.opts))

        if getattr(self.opts, "image_augmentation.random_erase.enable"):
            aug_list.append(image_pil.RandomErasing(opts=self.opts))

        return Compose(opts=self.opts, img_transforms=aug_list)

    def _validation_transforms(self, *args, **kwargs) -> image_pil.BaseTransformation:
        """
        Returns transformations applied to the input in validation mode.

        Order of augmentations: Resize followed by CenterCrop
        """

        if not getattr(self.opts, "image_augmentation.resize.enable"):
            raise ValueError(
                "`image_augmentation.resize.enable` must be set to True in input options."
            )
        aug_list = [image_pil.Resize(opts=self.opts)]

        if not getattr(self.opts, "image_augmentation.center_crop.enable"):
            raise ValueError(
                "`image_augmentation.center_crop.enable` must be set to True in input options."
            )

        aug_list.append(image_pil.CenterCrop(opts=self.opts))
        aug_list.append(image_pil.ToTensor(opts=self.opts))

        return Compose(opts=self.opts, img_transforms=aug_list)

    def __getitem__(
        self, sample_size_and_index: Tuple[int, int, int]
    ) -> Dict[str, Any]:
        """Returns the sample corresponding to the input sample index.

        Returned sample is transformed into the size specified by the input.

        Args:
            sample_size_and_index: Tuple of the form (crop_size_h, crop_size_w, sample_index)

        Returns:
            A dictionary with `samples`, `sample_id` and `targets` as keys corresponding to input, index and label of
            a sample, respectively.

        Shapes:
            The output data dictionary contains three keys (samples, sample_id, and target). The values of these
            keys has the following shapes:
                data["samples"]: Shape is [Channels, Height, Width]
                data["sample_id"]: Shape is 1
                data["targets"]: Shape is 1
        """
        crop_size_h, crop_size_w, sample_index = sample_size_and_index
        transform_fn = self.get_augmentation_transforms(size=(crop_size_h, crop_size_w))

        img_path, target = self.samples[sample_index]
        input_img = self.read_image_pil(img_path)
        if input_img is None:
            # Sometimes images are corrupt
            # Skip such images
            logger.log("Img index {} is possibly corrupt.".format(sample_index))
            input_tensor = torch.zeros(
                size=(3, crop_size_h, crop_size_w), dtype=torch.float
            )
            target = -1
            data = {"image": input_tensor}
        else:
            data = {"image": input_img}
            data = transform_fn(data)

        data["samples"] = data.pop("image")
        data["targets"] = target
        data["sample_id"] = sample_index

        return data

    def __len__(self) -> int:
        return len(self.samples)

    def extra_repr(self) -> str:
        extra_repr_str = super().extra_repr()
        return extra_repr_str + f"\n\t num_classes={self.n_classes}"


================================================
FILE: corenet/data/datasets/classification/base_imagenet_shift_dataset.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#
"""Base class for ImageNet distribution shift datasets."""
import argparse
from typing import Any, Dict, Tuple

from corenet.data.datasets.classification.base_image_classification_dataset import (
    BaseImageClassificationDataset,
)


class BaseImageNetShiftDataset(BaseImageClassificationDataset):
    """ImageNet Distribution Shift Dataset.

    This base class supports ImageNet out-of-distribution datasets. The class names for
    datasets are a subset of ImageNet. The `__getitem__` method projects the
    labels to the classes of ImageNet to allow zero-shot evaluation.

    Args:
        opts: An argparse.Namespace instance.
    """

    def __init__(
        self,
        opts: argparse.Namespace,
        *args,
        **kwargs,
    ) -> None:
        """Initialize BaseImageNetShiftDataset."""
        BaseImageClassificationDataset.__init__(
            self,
            opts=opts,
            *args,
            **kwargs,
        )
        # The class ids are converted to their equivalent ImageNet class ids
        # We manually set the n_classes and overwrite the n_classes set by
        # ImageFolder
        self.n_classes = 1000

        self.post_init_checks()

    def post_init_checks(self) -> None:
        """Verify the dataset is correctly initialized. Also called in testing."""
        if self.is_training:
            raise Exception(
                "{} can only be used for evaluation".format(self.__class__.__name__)
            )
        model_classes = getattr(self.opts, "model.classification.n_classes")
        # Note: ImageNet distribution shift subsets can have classes less than 1000
        # In such a case, a proper mapping from ImageNet classes to ImageNet distribution shift dataset needs to be done.
        assert (
            self.n_classes <= model_classes
        ), f"The dataset expects {self.n_classes} unique labels, but the model is trained on {model_classes} unique labels. "

    @staticmethod
    def class_id_to_imagenet_class_id(class_id: int) -> int:
        """Return the corresponding class index from ImageNet given a class index."""
        raise NotImplementedError(
            "Subclasses should implement the mapping to imagenet class ids."
        )

    def __getitem__(
        self, sample_size_and_index: Tuple[int, int, int]
    ) -> Dict[str, Any]:
        """Return the sample corresponding to the input sample index.

        Returned sample is transformed into the size specified by the input.

        Args:
            sample_size_and_index: Tuple of the form (crop_size_h, crop_size_w,
                sample_index)

        Returns:
            A dictionary with `samples`, `sample_id` and `targets` as keys corresponding
            to input, index and label of a sample, respectively.

        Shapes:
            The output data dictionary contains three keys (samples, sample_id, and
            target). The values of these keys has the following shapes:
                data["samples"]: Shape is [Channels, Height, Width]
                data["sample_id"]: Shape is 1
                data["targets"]: Shape is 1
        """
        data = BaseImageClassificationDataset.__getitem__(self, sample_size_and_index)
        data["targets"] = self.class_id_to_imagenet_class_id(data["targets"])

        return data


================================================
FILE: corenet/data/datasets/classification/coco.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#

import argparse
import os
from functools import cached_property
from typing import Any, Dict, List, Tuple, Union

import torch
from pycocotools.coco import COCO

from corenet.data.datasets import DATASET_REGISTRY
from corenet.data.datasets.classification.base_image_classification_dataset import (
    BaseImageClassificationDataset,
    BaseImageDataset,
)
from corenet.data.transforms.image_pil import BaseTransformation


@DATASET_REGISTRY.register(name="coco", type="classification")
class COCOClassification(BaseImageDataset):
    """`COCO <https://cocodataset.org/#home>`_ dataset for multi-label object classification.

    Args:
        opts: Command-line arguments.
    """

    def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
        super().__init__(opts=opts, *args, **kwargs)
        year = 2017
        split = "train" if self.is_training else "val"
        ann_file = os.path.join(
            self.root, "annotations/instances_{}{}.json".format(split, year)
        )
        self.img_dir = os.path.join(self.root, "images/{}{}".format(split, year))
        self.coco = COCO(ann_file)
        self.ids = list(self.coco.imgs.keys())
        self.cat2cat = dict()
        for cat in self.coco.cats.keys():
            self.cat2cat[cat] = len(self.cat2cat)

    def __len__(self) -> int:
        """Number of samples in the dataset."""
        return len(self.ids)

    def _training_transforms(
        self, size: Union[int, Tuple[int, int]]
    ) -> BaseTransformation:
        """Returns transformations applied to the input image in training mode.

        These transformations are the same as the 'BaseImageClassificationDataset'.

        Args:
            size: Size for resizing the input image. Expected to be an integer (width=height) or a tuple (height, width)

        Returns:
            An instance of `corenet.data.transforms.image_pil.BaseTransformation.`
        """
        return BaseImageClassificationDataset._training_transforms(self, size)

    def _validation_transforms(
        self, *unused_args, **unused_kwargs
    ) -> BaseTransformation:
        """Returns transformations applied to the input in validation mode.

        These transformations are the same as the 'BaseImageClassificationDataset'.

        Returns:
            An instance of `corenet.data.transforms.image_pil.BaseTransformation.`
        """
        return BaseImageClassificationDataset._validation_transforms(self)

    def __getitem__(
        self, sample_size_and_index: Tuple[int, int, int]
    ) -> Dict[str, Any]:
        """Returns the sample corresponding to the input sample index.

        Returned sample is transformed into the size specified by the input.

        Args:
            sample_size_and_index: Tuple of the form (crop_size_h, crop_size_w, sample_index).

        Returns:
            A dictionary with `samples`, `sample_id` and `targets` as keys corresponding to input, index, and label of
            a sample, respectively.

        Shapes:
            The output data dictionary contains three keys (samples, sample_id, and target). The values of these
            keys has the following shapes:
                data["samples"]: Shape is [image_channels, image_height, image_width]
                data["sample_id"]: Shape is 1
                data["targets"]: Shape is [num_classes]
        """

        crop_size_h, crop_size_w, img_index = sample_size_and_index

        coco = self.coco
        img_id = self.ids[img_index]

        ann_ids = coco.getAnnIds(imgIds=img_id)
        annotations = coco.loadAnns(ann_ids)

        target = torch.zeros((3, self.n_classes), dtype=torch.long)
        # Steps to produce multi-label classification labels
        # Step 1: Group the target labels into three categories based on object area
        # Step 2: Produce the binary label for each class by computing maximum value
        #   along the first dimension (i.e., dim=0).

        # Step 1
        for obj in annotations:
            if obj["area"] < 32 * 32:  # small objects
                target[0][self.cat2cat[obj["category_id"]]] = 1
            elif obj["area"] < 96 * 96:  # medium objects
                target[1][self.cat2cat[obj["category_id"]]] = 1
            else:  # large objects
                target[2][self.cat2cat[obj["category_id"]]] = 1
        # Step 2
        target = target.amax(dim=0)

        img_path = os.path.join(self.img_dir, coco.loadImgs(img_id)[0]["file_name"])
        input_img = self.read_image_pil(img_path)

        transform_fn = self.get_augmentation_transforms(size=(crop_size_h, crop_size_w))

        data = transform_fn({"image": input_img})

        data["samples"] = data.pop("image")
        data["targets"] = target
        data["sample_id"] = img_index
        return data

    @cached_property
    def n_classes(self):
        return len(self.class_names)

    @cached_property
    def class_names(self) -> List[str]:
        """Returns the names of object classes in the COCO dataset."""
        return [
            "person",
            "bicycle",
            "car",
            "motorcycle",
            "airplane",
            "bus",
            "train",
            "truck",
            "boat",
            "traffic light",
            "fire",
            "hydrant",
            "stop sign",
            "parking meter",
            "bench",
            "bird",
            "cat",
            "dog",
            "horse",
            "sheep",
            "cow",
            "elephant",
            "bear",
            "zebra",
            "giraffe",
            "backpack",
            "umbrella",
            "handbag",
            "tie",
            "suitcase",
            "frisbee",
            "skis",
            "snowboard",
            "sports ball",
            "kite",
            "baseball bat",
            "baseball glove",
            "skateboard",
            "surfboard",
            "tennis racket",
            "bottle",
            "wine glass",
            "cup",
            "fork",
            "knife",
            "spoon",
            "bowl",
            "banana",
            "apple",
            "sandwich",
            "orange",
            "broccoli",
            "carrot",
            "hot dog",
            "pizza",
            "donut",
            "cake",
            "chair",
            "couch",
            "potted plant",
            "bed",
            "dining table",
            "toilet",
            "tv",
            "laptop",
            "mouse",
            "remote",
            "keyboard",
            "cell phone",
            "microwave oven",
            "toaster",
            "sink",
            "refrigerator",
            "book",
            "clock",
            "vase",
            "scissors",
            "teddy bear",
            "hair drier",
            "toothbrush",
        ]


================================================
FILE: corenet/data/datasets/classification/imagenet.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#

import argparse

from corenet.data.datasets import DATASET_REGISTRY
from corenet.data.datasets.classification.base_image_classification_dataset import (
    BaseImageClassificationDataset,
)


@DATASET_REGISTRY.register(name="imagenet", type="classification")
class ImageNetDataset(BaseImageClassificationDataset):
    """
    ImageNet dataset that follows the structure of ImageClassificationDataset.

    "ImageNet: A large-scale hierarchical image database"
    Jia Deng; Wei Dong; Richard Socher; Li-Jia Li; Kai Li; Li Fei-Fei
    2009 IEEE Conference on Computer Vision and Pattern Recognition
    """

    def __init__(
        self,
        opts: argparse.Namespace,
        *args,
        **kwargs,
    ) -> None:
        BaseImageClassificationDataset.__init__(
            self,
            opts=opts,
            *args,
            **kwargs,
        )


================================================
FILE: corenet/data/datasets/classification/imagenet_a.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#
"""ImageNetA dataset, a distribution shift of ImageNet."""
import argparse

from corenet.data.datasets import DATASET_REGISTRY
from corenet.data.datasets.classification.base_imagenet_shift_dataset import (
    BaseImageNetShiftDataset,
)
from corenet.data.datasets.classification.imagenet_synsets import (
    IMAGENET_A_SYNSETS,
    IMAGENET_SYNSETS,
)

IMAGENET_A_CLASS_SUBLIST = [
    IMAGENET_SYNSETS.index(IMAGENET_A_SYNSETS[synset])
    for synset in range(len(IMAGENET_A_SYNSETS))
]


@DATASET_REGISTRY.register(name="imagenet_a", type="classification")
class ImageNetADataset(BaseImageNetShiftDataset):
    """ImageNetA dataset, a distribution shift of ImageNet.

    ImageNet-A contains real-world, unmodified natural images that cause model accuracy
    to substantially degrade.

    @article{hendrycks2021nae,
    title={Natural Adversarial Examples},
    author={Dan Hendrycks and Kevin Zhao and Steven Basart and Jacob Steinhardt and Dawn
    Song},
    journal={CVPR},
    year={2021}
    }
    """

    def __init__(
        self,
        opts: argparse.Namespace,
        *args,
        **kwargs,
    ) -> None:
        """Initialize ImageNetA."""
        BaseImageNetShiftDataset.__init__(self, opts=opts, *args, **kwargs)

    @staticmethod
    def class_id_to_imagenet_class_id(class_id: int) -> int:
        """Return the mapped class index using precomputed mapping."""
        return IMAGENET_A_CLASS_SUBLIST[class_id]


================================================
FILE: corenet/data/datasets/classification/imagenet_r.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#
"""ImageNetR dataset, a distribution shift of ImageNet."""
import argparse

from corenet.data.datasets import DATASET_REGISTRY
from corenet.data.datasets.classification.base_imagenet_shift_dataset import (
    BaseImageNetShiftDataset,
)
from corenet.data.datasets.classification.imagenet_synsets import (
    IMAGENET_R_SYNSETS,
    IMAGENET_SYNSETS,
)

IMAGENET_R_CLASS_SUBLIST = [
    IMAGENET_SYNSETS.index(IMAGENET_R_SYNSETS[synset])
    for synset in range(len(IMAGENET_R_SYNSETS))
]


@DATASET_REGISTRY.register(name="imagenet_r", type="classification")
class ImageNetRDataset(BaseImageNetShiftDataset):
    """ImageNetR dataset, a distribution shift of ImageNet.

    ImageNet-R(endition) contains art, cartoons, deviantart, graffiti, embroidery,
    graphics, origami, paintings, patterns, plastic objects, plush objects, sculptures,
    sketches, tattoos, toys, and video game renditions of ImageNet classes.

    @article{hendrycks2021many,
    title={The Many Faces of Robustness: A Critical Analysis of Out-of-Distribution
    Generalization},
    author={Dan Hendrycks and Steven Basart and Norman Mu and Saurav Kadavath and Frank
    Wang and Evan Dorundo and Rahul Desai and Tyler Zhu and Samyak Parajuli and Mike Guo
    and Dawn Song and Jacob Steinhardt and Justin Gilmer},
    journal={ICCV},
    year={2021}
    }

    """

    def __init__(
        self,
        opts: argparse.Namespace,
        *args,
        **kwargs,
    ) -> None:
        """Initialize ImageNetR."""
        BaseImageNetShiftDataset.__init__(self, opts=opts, *args, **kwargs)

    @staticmethod
    def class_id_to_imagenet_class_id(class_id: int) -> int:
        """Return the mapped class index using precomputed mapping."""
        return IMAGENET_R_CLASS_SUBLIST[class_id]


================================================
FILE: corenet/data/datasets/classification/imagenet_sketch.py
================================================
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#
"""ImageNetSketch dataset, a distribution shift of ImageNet."""
import argparse

from corenet.data.datasets import DATASET_REGISTRY
from corenet.data.datasets.classification.base_imagenet_shift_dataset import (
    BaseImageNetShiftDataset,
)


@DATASET_REGISTRY.register(name="imagenet_sketch", type="classification")
class ImageNetSketchDataset(BaseImageNetShiftDataset):
    """ImageNetSketch dataset, a distribution shift of ImageNet.

    Data set is created from Google Image queries "sketch of __", where __ is the
    standard class name. Search is only within the "black and white" color scheme.

    @inproceedings{wang2019learning,
        title={Learning Robust Global Representations by Penalizing Local Predictive
        Power},
        author={Wang, Haohan and Ge, Songwei and Lipton, Zachary and Xing, Eric P},
        booktitle={Advances in Neural Information Processing Systems},
        pages={10506--10518},
        year={2019}
    }
    """

    def __init__(
        self,
        opts: argparse.Namespace,
        *args,
        **kwargs,
    ) -> None:
        """Initialize ImageNetSketchDataset."""
        BaseImageNetShiftDataset.__init__(self, opts=opts, *args, **kwargs)

    @staticmethod
    def class_id_to_imagenet_class_id(class_id: int) -> int:
        """Return `class_id` as the ImageNet Sketch classes are the same as ImageNet."""
        return class_id

Download .txt
gitextract_0z54odcq/

├── .dockerignore
├── .flake8
├── .gitattributes
├── .gitignore
├── ACKNOWLEDGEMENTS
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── Makefile
├── README.md
├── conftest.py
├── corenet/
│   ├── __init__.py
│   ├── __main__.py
│   ├── __version__.py
│   ├── cli/
│   │   ├── __init__.py
│   │   ├── entrypoints.py
│   │   ├── main.py
│   │   ├── main_benchmark.py
│   │   ├── main_conversion.py
│   │   ├── main_eval.py
│   │   ├── main_eval_llmadapters.py
│   │   └── main_train.py
│   ├── constants.py
│   ├── data/
│   │   ├── __init__.py
│   │   ├── collate_fns/
│   │   │   ├── __init__.py
│   │   │   ├── byteformer_collate_functions.py
│   │   │   └── collate_functions.py
│   │   ├── data_loaders.py
│   │   ├── datasets/
│   │   │   ├── __init__.py
│   │   │   ├── audio_classification/
│   │   │   │   ├── __init__.py
│   │   │   │   └── speech_commands_v2.py
│   │   │   ├── classification/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_image_classification_dataset.py
│   │   │   │   ├── base_imagenet_shift_dataset.py
│   │   │   │   ├── coco.py
│   │   │   │   ├── imagenet.py
│   │   │   │   ├── imagenet_a.py
│   │   │   │   ├── imagenet_r.py
│   │   │   │   ├── imagenet_sketch.py
│   │   │   │   ├── imagenet_synsets.py
│   │   │   │   ├── imagenet_v2.py
│   │   │   │   ├── places365.py
│   │   │   │   └── wordnet_tagged_classification.py
│   │   │   ├── dataset_base.py
│   │   │   ├── detection/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_detection.py
│   │   │   │   ├── coco_base.py
│   │   │   │   ├── coco_mask_rcnn.py
│   │   │   │   └── coco_ssd.py
│   │   │   ├── language_modeling/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_lm.py
│   │   │   │   ├── commonsense_170k.py
│   │   │   │   └── general_lm.py
│   │   │   ├── multi_modal_img_text/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_multi_modal_img_text.py
│   │   │   │   ├── flickr.py
│   │   │   │   ├── img_text_tar_dataset.py
│   │   │   │   └── zero_shot_image_classification/
│   │   │   │       ├── __init__.py
│   │   │   │       ├── base_zero_shot_image_classification.py
│   │   │   │       ├── imagenet.py
│   │   │   │       ├── imagenet_a.py
│   │   │   │       ├── imagenet_class_names.py
│   │   │   │       ├── imagenet_r.py
│   │   │   │       ├── imagenet_sketch.py
│   │   │   │       └── templates.py
│   │   │   ├── segmentation/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── ade20k.py
│   │   │   │   ├── base_segmentation.py
│   │   │   │   ├── coco_segmentation.py
│   │   │   │   ├── coco_stuff.py
│   │   │   │   └── pascal_voc.py
│   │   │   └── utils/
│   │   │       ├── __init__.py
│   │   │       ├── common.py
│   │   │       ├── text.py
│   │   │       └── video.py
│   │   ├── io/
│   │   │   ├── __init__.py
│   │   │   └── transfer_clients.py
│   │   ├── loader/
│   │   │   ├── __init__.py
│   │   │   └── dataloader.py
│   │   ├── sampler/
│   │   │   ├── __init__.py
│   │   │   ├── base_sampler.py
│   │   │   ├── batch_sampler.py
│   │   │   ├── chain_sampler.py
│   │   │   ├── multi_scale_sampler.py
│   │   │   ├── utils.py
│   │   │   ├── variable_batch_sampler.py
│   │   │   ├── video_batch_sampler.py
│   │   │   ├── video_clip_batch_sampler.py
│   │   │   └── video_variable_seq_sampler.py
│   │   ├── text_tokenizer/
│   │   │   ├── __init__.py
│   │   │   ├── base_tokenizer.py
│   │   │   ├── clip_tokenizer.py
│   │   │   └── sentencepiece_tokenizer.py
│   │   ├── transforms/
│   │   │   ├── __init__.py
│   │   │   ├── audio.py
│   │   │   ├── audio_aux/
│   │   │   │   ├── __init__.py
│   │   │   │   └── mfccs.py
│   │   │   ├── audio_bytes.py
│   │   │   ├── base_transforms.py
│   │   │   ├── common.py
│   │   │   ├── image_bytes.py
│   │   │   ├── image_pil.py
│   │   │   ├── image_torch.py
│   │   │   ├── utils.py
│   │   │   └── video.py
│   │   └── video_reader/
│   │       ├── __init__.py
│   │       ├── base_av_reader.py
│   │       ├── decord_reader.py
│   │       ├── ffmpeg_reader.py
│   │       ├── ffmpeg_utils.py
│   │       └── pyav_reader.py
│   ├── engine/
│   │   ├── __init__.py
│   │   ├── default_trainer.py
│   │   ├── detection_utils/
│   │   │   ├── __init__.py
│   │   │   └── coco_map.py
│   │   ├── eval_detection.py
│   │   ├── eval_segmentation.py
│   │   ├── evaluation_engine.py
│   │   ├── fsdp_trainer.py
│   │   ├── segmentation_utils/
│   │   │   ├── __init__.py
│   │   │   └── cityscapes_iou.py
│   │   └── utils.py
│   ├── loss_fn/
│   │   ├── __init__.py
│   │   ├── base_criteria.py
│   │   ├── classification/
│   │   │   ├── __init__.py
│   │   │   ├── base_classification_criteria.py
│   │   │   ├── binary_cross_entropy.py
│   │   │   ├── cross_entropy.py
│   │   │   └── focal_loss.py
│   │   ├── composite_loss.py
│   │   ├── detection/
│   │   │   ├── __init__.py
│   │   │   ├── base_detection_criteria.py
│   │   │   ├── mask_rcnn_loss.py
│   │   │   └── ssd_multibox_loss.py
│   │   ├── distillation/
│   │   │   ├── __init__.py
│   │   │   ├── base_distillation.py
│   │   │   ├── hard_distillation.py
│   │   │   └── soft_kl_distillation.py
│   │   ├── language_modeling/
│   │   │   ├── __init__.py
│   │   │   ├── base_lm.py
│   │   │   ├── cross_entropy.py
│   │   │   └── cross_entropy_for_kv_prediction.py
│   │   ├── multi_modal_img_text/
│   │   │   ├── __init__.py
│   │   │   ├── base_multi_modal_img_text_criteria.py
│   │   │   └── contrastive_loss_clip.py
│   │   ├── neural_augmentation.py
│   │   ├── segmentation/
│   │   │   ├── __init__.py
│   │   │   ├── base_segmentation_criteria.py
│   │   │   └── cross_entropy.py
│   │   └── utils/
│   │       ├── __init__.py
│   │       ├── build_helper.py
│   │       └── class_weighting.py
│   ├── metrics/
│   │   ├── __init__.py
│   │   ├── average_precision.py
│   │   ├── coco_map.py
│   │   ├── confusion_mat.py
│   │   ├── image_text_retrieval.py
│   │   ├── intersection_over_union.py
│   │   ├── metric_base.py
│   │   ├── metric_base_test.py
│   │   ├── misc.py
│   │   ├── multiclass_classification_pr.py
│   │   ├── probability_histograms.py
│   │   ├── psnr.py
│   │   ├── retrieval_cmc.py
│   │   ├── stats.py
│   │   ├── topk_accuracy.py
│   │   └── vqa_preset_score.py
│   ├── modeling/
│   │   ├── __init__.py
│   │   ├── anchor_generator/
│   │   │   ├── __init__.py
│   │   │   ├── base_anchor_generator.py
│   │   │   └── ssd_anchor_generator.py
│   │   ├── image_projection_layers/
│   │   │   ├── __init__.py
│   │   │   ├── attention_pool_2d.py
│   │   │   ├── base_image_projection.py
│   │   │   ├── global_pool_2d.py
│   │   │   └── simple_projection_head.py
│   │   ├── layers/
│   │   │   ├── __init__.py
│   │   │   ├── activation/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── gelu.py
│   │   │   │   ├── hard_sigmoid.py
│   │   │   │   ├── hard_swish.py
│   │   │   │   ├── leaky_relu.py
│   │   │   │   ├── prelu.py
│   │   │   │   ├── relu.py
│   │   │   │   ├── relu6.py
│   │   │   │   ├── sigmoid.py
│   │   │   │   ├── swish.py
│   │   │   │   └── tanh.py
│   │   │   ├── adaptive_pool.py
│   │   │   ├── base_layer.py
│   │   │   ├── conv_layer.py
│   │   │   ├── dropout.py
│   │   │   ├── embedding.py
│   │   │   ├── flash_multi_head_attention.py
│   │   │   ├── flatten.py
│   │   │   ├── global_pool.py
│   │   │   ├── identity.py
│   │   │   ├── linear_attention.py
│   │   │   ├── linear_layer.py
│   │   │   ├── multi_head_attention.py
│   │   │   ├── normalization/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── batch_norm.py
│   │   │   │   ├── group_norm.py
│   │   │   │   ├── instance_norm.py
│   │   │   │   ├── layer_norm.py
│   │   │   │   ├── rms_norm.py
│   │   │   │   └── sync_batch_norm.py
│   │   │   ├── normalization_layers.py
│   │   │   ├── pixel_shuffle.py
│   │   │   ├── pooling.py
│   │   │   ├── positional_embedding.py
│   │   │   ├── positional_encoding.py
│   │   │   ├── random_layers.py
│   │   │   ├── rotary_embeddings.py
│   │   │   ├── single_head_attention.py
│   │   │   ├── softmax.py
│   │   │   ├── stochastic_depth.py
│   │   │   ├── token_merging.py
│   │   │   └── upsample.py
│   │   ├── matcher_det/
│   │   │   ├── __init__.py
│   │   │   ├── base_matcher.py
│   │   │   └── ssd_matcher.py
│   │   ├── misc/
│   │   │   ├── __init__.py
│   │   │   ├── averaging_utils.py
│   │   │   ├── box_utils.py
│   │   │   ├── common.py
│   │   │   └── init_utils.py
│   │   ├── models/
│   │   │   ├── __init__.py
│   │   │   ├── audio_classification/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── audio_byteformer.py
│   │   │   │   └── base_audio_classification.py
│   │   │   ├── base_model.py
│   │   │   ├── classification/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_image_encoder.py
│   │   │   │   ├── byteformer.py
│   │   │   │   ├── config/
│   │   │   │   │   ├── __init__.py
│   │   │   │   │   ├── byteformer.py
│   │   │   │   │   ├── efficientnet.py
│   │   │   │   │   ├── fastvit.py
│   │   │   │   │   ├── mobilenetv1.py
│   │   │   │   │   ├── mobilenetv2.py
│   │   │   │   │   ├── mobilenetv3.py
│   │   │   │   │   ├── mobileone.py
│   │   │   │   │   ├── mobilevit.py
│   │   │   │   │   ├── mobilevit_v2.py
│   │   │   │   │   ├── regnet.py
│   │   │   │   │   ├── resnet.py
│   │   │   │   │   ├── swin_transformer.py
│   │   │   │   │   └── vit.py
│   │   │   │   ├── efficientnet.py
│   │   │   │   ├── fastvit.py
│   │   │   │   ├── mobilenetv1.py
│   │   │   │   ├── mobilenetv2.py
│   │   │   │   ├── mobilenetv3.py
│   │   │   │   ├── mobileone.py
│   │   │   │   ├── mobilevit.py
│   │   │   │   ├── mobilevit_v2.py
│   │   │   │   ├── regnet.py
│   │   │   │   ├── resnet.py
│   │   │   │   ├── swin_transformer.py
│   │   │   │   └── vit.py
│   │   │   ├── detection/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_detection.py
│   │   │   │   ├── mask_rcnn.py
│   │   │   │   ├── ssd.py
│   │   │   │   └── utils/
│   │   │   │       ├── __init__.py
│   │   │   │       └── rcnn_utils.py
│   │   │   ├── fsdp_wrapper.py
│   │   │   ├── language_modeling/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_lm.py
│   │   │   │   ├── general_gpt.py
│   │   │   │   └── kv_prediction.py
│   │   │   ├── multi_modal_img_text/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_multi_modal_img_text.py
│   │   │   │   └── clip.py
│   │   │   ├── segmentation/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── base_seg.py
│   │   │   │   ├── enc_dec.py
│   │   │   │   └── heads/
│   │   │   │       ├── __init__.py
│   │   │   │       ├── base_seg_head.py
│   │   │   │       ├── deeplabv3.py
│   │   │   │       ├── pspnet.py
│   │   │   │       └── simple_seg_head.py
│   │   │   └── video_classification/
│   │   │       ├── __init__.py
│   │   │       └── base_video_encoder.py
│   │   ├── modules/
│   │   │   ├── __init__.py
│   │   │   ├── aspp_block.py
│   │   │   ├── base_module.py
│   │   │   ├── efficientnet.py
│   │   │   ├── fastvit.py
│   │   │   ├── feature_pyramid.py
│   │   │   ├── flash_transformer.py
│   │   │   ├── mobilenetv2.py
│   │   │   ├── mobileone_block.py
│   │   │   ├── mobilevit_block.py
│   │   │   ├── pspnet_module.py
│   │   │   ├── regnet_modules.py
│   │   │   ├── resnet_modules.py
│   │   │   ├── squeeze_excitation.py
│   │   │   ├── ssd_heads.py
│   │   │   ├── swin_transformer_block.py
│   │   │   ├── transformer.py
│   │   │   └── windowed_transformer.py
│   │   ├── neural_augmentor/
│   │   │   ├── __init__.py
│   │   │   ├── neural_aug.py
│   │   │   └── utils/
│   │   │       ├── __init__.py
│   │   │       └── neural_aug_utils.py
│   │   └── text_encoders/
│   │       ├── __init__.py
│   │       ├── base_text_encoder.py
│   │       └── transformer.py
│   ├── optims/
│   │   ├── __init__.py
│   │   ├── adam.py
│   │   ├── adamw.py
│   │   ├── base_optim.py
│   │   ├── scheduler/
│   │   │   ├── __init__.py
│   │   │   ├── base_scheduler.py
│   │   │   ├── cosine.py
│   │   │   ├── cyclic.py
│   │   │   ├── fixed.py
│   │   │   ├── multi_step.py
│   │   │   └── polynomial.py
│   │   └── sgd.py
│   ├── options/
│   │   ├── __init__.py
│   │   ├── errors.py
│   │   ├── opts.py
│   │   ├── parse_args.py
│   │   └── utils.py
│   ├── third_party/
│   │   ├── __init__.py
│   │   ├── data/
│   │   │   ├── __init__.py
│   │   │   └── text_tokenizer/
│   │   │       ├── __init__.py
│   │   │       └── openai_clip_tokenizer.py
│   │   └── modeling/
│   │       ├── __init__.py
│   │       ├── lora.py
│   │       └── ssd_utils.py
│   ├── train_eval_pipelines/
│   │   ├── __init__.py
│   │   ├── base.py
│   │   ├── default_train_eval.py
│   │   └── fsdp_train_eval.py
│   └── utils/
│       ├── __init__.py
│       ├── activation_checkpointing_wrapper.py
│       ├── check.py
│       ├── checkpoint_utils.py
│       ├── color_map.py
│       ├── common_utils.py
│       ├── context_managers.py
│       ├── ddp_utils.py
│       ├── dict_utils.py
│       ├── download_utils.py
│       ├── file_logger.py
│       ├── fpdb.py
│       ├── hf_adapter_utils.py
│       ├── import_utils.py
│       ├── io_utils.py
│       ├── logger.py
│       ├── math_utils.py
│       ├── object_utils.py
│       ├── object_utils_test.py
│       ├── pytorch_to_coreml.py
│       ├── registry.py
│       ├── registry_test.py
│       ├── resources.py
│       ├── retry_utils.py
│       ├── tensor_utils.py
│       └── visualization_utils.py
├── mlx_examples/
│   ├── clip/
│   │   ├── README.md
│   │   ├── __init__.py
│   │   ├── clip.py
│   │   ├── image_processor.py
│   │   ├── main_clip_to_mlx.py
│   │   ├── main_test_clip_mlx.py
│   │   ├── model.py
│   │   ├── requirements.txt
│   │   ├── results/
│   │   │   └── .gitkeep
│   │   └── tokenizer.py
│   ├── open_elm/
│   │   ├── README.md
│   │   ├── __init__.py
│   │   ├── convert.py
│   │   ├── inference.py
│   │   └── open_elm.py
│   └── requirements.txt
├── projects/
│   ├── byteformer/
│   │   ├── README.md
│   │   ├── imagenet_file_encodings/
│   │   │   ├── encoding_type=PNG.yaml
│   │   │   ├── encoding_type=TIFF.yaml
│   │   │   ├── encoding_type=fCHW.yaml
│   │   │   └── encoding_type=fHWC.yaml
│   │   ├── imagenet_jpeg_q100/
│   │   │   ├── conv_kernel_size=16.yaml
│   │   │   ├── conv_kernel_size=32.yaml
│   │   │   └── conv_kernel_size=8.yaml
│   │   ├── imagenet_jpeg_q60/
│   │   │   ├── conv_kernel_size=16,window_sizes=[128].yaml
│   │   │   ├── conv_kernel_size=16,window_sizes=[32].yaml
│   │   │   ├── conv_kernel_size=32,window_sizes=[128].yaml
│   │   │   ├── conv_kernel_size=32,window_sizes=[32].yaml
│   │   │   ├── conv_kernel_size=4,window_sizes=[128].yaml
│   │   │   ├── conv_kernel_size=4,window_sizes=[32].yaml
│   │   │   ├── conv_kernel_size=8,window_sizes=[128].yaml
│   │   │   └── conv_kernel_size=8,window_sizes=[32].yaml
│   │   ├── imagenet_jpeg_shuffle_bytes/
│   │   │   ├── mode=cyclic_half_length.yaml
│   │   │   ├── mode=random_shuffle.yaml
│   │   │   ├── mode=reverse.yaml
│   │   │   ├── mode=stride.yaml
│   │   │   └── mode=window_shuffle.yaml
│   │   ├── imagenet_obfuscation/
│   │   │   ├── width_range=[-10,10].yaml
│   │   │   ├── width_range=[-20,20].yaml
│   │   │   ├── width_range=[-5,5].yaml
│   │   │   └── width_range=[0,0].yaml
│   │   ├── imagenet_privacy_preserving_camera/
│   │   │   ├── keep_frac=0.03,conv_kernel_size=4.yaml
│   │   │   ├── keep_frac=0.05,conv_kernel_size=4.yaml
│   │   │   ├── keep_frac=0.1,conv_kernel_size=4.yaml
│   │   │   ├── keep_frac=0.25,conv_kernel_size=8.yaml
│   │   │   ├── keep_frac=0.5,conv_kernel_size=16.yaml
│   │   │   └── keep_frac=0.75,conv_kernel_size=32.yaml
│   │   ├── speech_commands_mp3/
│   │   │   ├── conv_kernel_size=4,window_size=[128].yaml
│   │   │   ├── conv_kernel_size=4,window_size=[32].yaml
│   │   │   ├── conv_kernel_size=8,window_size=[128].yaml
│   │   │   └── conv_kernel_size=8,window_size=[32].yaml
│   │   └── speech_commands_wav/
│   │       ├── encoding_dtype=float32,conv_kernel_size=16.yaml
│   │       ├── encoding_dtype=float32,conv_kernel_size=32.yaml
│   │       ├── encoding_dtype=int16,conv_kernel_size=16.yaml
│   │       ├── encoding_dtype=int16,conv_kernel_size=32.yaml
│   │       ├── encoding_dtype=int16,conv_kernel_size=8.yaml
│   │       ├── encoding_dtype=int32,conv_kernel_size=16.yaml
│   │       ├── encoding_dtype=int32,conv_kernel_size=32.yaml
│   │       ├── encoding_dtype=uint8,conv_kernel_size=16.yaml
│   │       ├── encoding_dtype=uint8,conv_kernel_size=32.yaml
│   │       ├── encoding_dtype=uint8,conv_kernel_size=4.yaml
│   │       └── encoding_dtype=uint8,conv_kernel_size=8.yaml
│   ├── catlip/
│   │   ├── README-multi-label-object-classification.md
│   │   ├── README-object-detection.md
│   │   ├── README-pretraining.md
│   │   ├── README-semantic-segmentation.md
│   │   ├── README-single-label-object-classification.md
│   │   ├── README.md
│   │   ├── image_classification/
│   │   │   ├── imagenet/
│   │   │   │   ├── vit_base.yaml
│   │   │   │   ├── vit_base_512x512.yaml
│   │   │   │   ├── vit_huge.yaml
│   │   │   │   ├── vit_huge_512x512.yaml
│   │   │   │   ├── vit_large.yaml
│   │   │   │   └── vit_large_512x512.yaml
│   │   │   └── places365/
│   │   │       ├── vit_base.yaml
│   │   │       ├── vit_base_512x512.yaml
│   │   │       ├── vit_huge.yaml
│   │   │       ├── vit_huge_512x512.yaml
│   │   │       ├── vit_large.yaml
│   │   │       └── vit_large_512x512.yaml
│   │   ├── multi_label_image_classification/
│   │   │   ├── vit_base.yaml
│   │   │   └── vit_large.yaml
│   │   ├── object_detection/
│   │   │   ├── maskrcnn_vit_base.yaml
│   │   │   ├── maskrcnn_vit_huge.yaml
│   │   │   └── maskrcnn_vit_large.yaml
│   │   ├── pretraining/
│   │   │   ├── vit_base.yaml
│   │   │   ├── vit_huge.yaml
│   │   │   └── vit_large.yaml
│   │   └── semantic_segmentation/
│   │       ├── deeplabv3_vit_base.yaml
│   │       ├── deeplabv3_vit_huge.yaml
│   │       └── deeplabv3_vit_large.yaml
│   ├── clip/
│   │   ├── README.md
│   │   └── clip_vit_base.yaml
│   ├── fastvit/
│   │   ├── README.md
│   │   └── classification/
│   │       └── fastvit_t8_in1k.yaml
│   ├── kv-prediction/
│   │   ├── README.md
│   │   ├── openelm/
│   │   │   ├── openelm_1_1B_0_25.yaml
│   │   │   ├── openelm_1_1B_0_50.yaml
│   │   │   ├── openelm_1_1B_0_75.yaml
│   │   │   ├── openelm_1_1B_kvp_c_270M.yaml
│   │   │   ├── openelm_1_1B_kvp_c_450M.yaml
│   │   │   ├── openelm_1_1B_kvp_lp_0_25.yaml
│   │   │   ├── openelm_1_1B_kvp_lp_0_50.yaml
│   │   │   ├── openelm_1_1B_kvp_lp_0_75.yaml
│   │   │   ├── openelm_3B_kvp_c_1_1B.yaml
│   │   │   ├── openelm_3B_kvp_c_270M.yaml
│   │   │   ├── openelm_3B_kvp_c_450M.yaml
│   │   │   ├── openelm_3B_kvp_lp_0_25.yaml
│   │   │   ├── openelm_3B_kvp_lp_0_50.yaml
│   │   │   ├── openelm_3B_kvp_lp_0_75.yaml
│   │   │   ├── openelm_base_3B_aux_0_25l.yaml
│   │   │   ├── openelm_base_3B_aux_0_50l.yaml
│   │   │   └── openelm_base_3B_aux_0_75l.yaml
│   │   └── triviaqa-template.yaml
│   ├── mobilenet_v1/
│   │   ├── README.md
│   │   └── classification/
│   │       └── mobilenetv1_1.0_in1k.yaml
│   ├── mobilenet_v2/
│   │   ├── README.md
│   │   ├── classification/
│   │   │   └── mobilenetv2_1.0_in1k.yaml
│   │   └── segmentation/
│   │       └── deeplabv3_ade20k.yaml
│   ├── mobilenet_v3/
│   │   ├── README.md
│   │   └── classification/
│   │       └── mobilenetv3_large_in1k.yaml
│   ├── mobileone/
│   │   ├── README.md
│   │   └── classification/
│   │       └── mobileone_s1_in1k.yaml
│   ├── mobilevit/
│   │   └── README.md
│   ├── mobilevit_v2/
│   │   ├── README.md
│   │   ├── classification/
│   │   │   ├── mobilevitv2_2.0_ft_384x384.yaml
│   │   │   └── mobilevitv2_2.0_in1k.yaml
│   │   ├── detection/
│   │   │   └── mobilevitv2_2.0_ssd_coco.yaml
│   │   └── segmentation/
│   │       └── deeplabv3_mobilevitv2_1.0_ade20k.yaml
│   ├── openelm/
│   │   ├── README-instruct.md
│   │   ├── README-peft.md
│   │   ├── README-pretraining.md
│   │   ├── README.md
│   │   ├── instruction_tuning/
│   │   │   └── openelm-instruct.yaml
│   │   ├── peft_configs/
│   │   │   ├── openelm_lora_1_1B.yaml
│   │   │   ├── openelm_lora_270M.yaml
│   │   │   ├── openelm_lora_270M_eval.yaml
│   │   │   ├── openelm_lora_3B.yaml
│   │   │   └── openelm_lora_450M.yaml
│   │   └── pretraining_configs/
│   │       ├── openelm_1_1B.yaml
│   │       ├── openelm_270M.yaml
│   │       ├── openelm_3B.yaml
│   │       └── openelm_450M.yaml
│   ├── range_augment/
│   │   ├── README-classification.md
│   │   ├── README-clip.md
│   │   ├── README-distillation.md
│   │   ├── README-object-detection.md
│   │   ├── README-segmentation.md
│   │   ├── README.md
│   │   ├── classification/
│   │   │   ├── efficientnet_b0.yaml
│   │   │   ├── efficientnet_b1.yaml
│   │   │   ├── efficientnet_b2.yaml
│   │   │   ├── efficientnet_b3.yaml
│   │   │   ├── mobilenet_v1.yaml
│   │   │   ├── mobilenet_v2.yaml
│   │   │   ├── mobilenet_v3.yaml
│   │   │   ├── mobilevit_v1.yaml
│   │   │   ├── regnety_16gf.yaml
│   │   │   ├── resnet_101.yaml
│   │   │   ├── resnet_50.yaml
│   │   │   ├── se_resnet_50.yaml
│   │   │   ├── swin_transformer_small.yaml
│   │   │   └── swin_transformer_tiny.yaml
│   │   ├── clip/
│   │   │   ├── clip_vit_base.yaml
│   │   │   └── clip_vit_huge.yaml
│   │   ├── clip_finetune_imagenet/
│   │   │   ├── clip_vit_base.yaml
│   │   │   └── clip_vit_huge.yaml
│   │   ├── detection/
│   │   │   ├── maskrcnn_efficientnet_b3.yaml
│   │   │   ├── maskrcnn_mobilenet_v1.yaml
│   │   │   ├── maskrcnn_mobilenet_v2.yaml
│   │   │   ├── maskrcnn_mobilenet_v3.yaml
│   │   │   ├── maskrcnn_mobilevit.yaml
│   │   │   ├── maskrcnn_resnet_101.yaml
│   │   │   └── maskrcnn_resnet_50.yaml
│   │   ├── distillation/
│   │   │   ├── teacher_resnet101_student_mobilenet_v1.yaml
│   │   │   ├── teacher_resnet101_student_mobilenet_v2.yaml
│   │   │   ├── teacher_resnet101_student_mobilenet_v3.yaml
│   │   │   └── teacher_resnet101_student_mobilevit.yaml
│   │   └── segmentation/
│   │       ├── ade20k/
│   │       │   ├── deeplabv3_efficientnet_b3.yaml
│   │       │   ├── deeplabv3_mobilenet_v1.yaml
│   │       │   ├── deeplabv3_mobilenet_v2.yaml
│   │       │   ├── deeplabv3_mobilenet_v3.yaml
│   │       │   ├── deeplabv3_mobilevit.yaml
│   │       │   ├── deeplabv3_resnet_101.yaml
│   │       │   └── deeplabv3_resnet_50.yaml
│   │       └── pascal_voc/
│   │           ├── deeplabv3_efficientnet_b3.yaml
│   │           ├── deeplabv3_mobilenet_v1.yaml
│   │           ├── deeplabv3_mobilenet_v2.yaml
│   │           ├── deeplabv3_mobilenet_v3.yaml
│   │           ├── deeplabv3_resnet_101.yaml
│   │           └── deeplabv3_resnet_50.yaml
│   ├── resnet/
│   │   ├── README.md
│   │   ├── classification/
│   │   │   └── resnet50_in1k.yaml
│   │   └── detection/
│   │       └── ssd_resnet50_coco.yaml
│   └── vit/
│       ├── README.md
│       └── classification/
│           └── vit_base_in1k.yaml
├── pyproject.toml
├── requirements-optional.txt
├── requirements.txt
├── setup.py
├── tests/
│   ├── __init__.py
│   ├── configs.py
│   ├── data/
│   │   ├── __init__.py
│   │   ├── coco/
│   │   │   └── annotations/
│   │   │       ├── instances_train2017.json
│   │   │       └── instances_val2017.json
│   │   ├── collate_fns/
│   │   │   ├── __init__.py
│   │   │   ├── test_byteformer_collate_fn.py
│   │   │   └── test_collate_functions.py
│   │   ├── datasets/
│   │   │   ├── __init__.py
│   │   │   ├── audio_classification/
│   │   │   │   ├── __init__.py
│   │   │   │   └── test_speech_commands_v2.py
│   │   │   ├── classification/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── dummy_configs/
│   │   │   │   │   ├── coco.yaml
│   │   │   │   │   ├── image_classification_dataset.yaml
│   │   │   │   │   ├── imagenet.yaml
│   │   │   │   │   ├── imagenet_a.yaml
│   │   │   │   │   ├── imagenet_r.yaml
│   │   │   │   │   ├── imagenet_sketch.yaml
│   │   │   │   │   └── wordnet_tagged_classification.yaml
│   │   │   │   ├── mock_coco.py
│   │   │   │   ├── mock_imagenet.py
│   │   │   │   ├── mock_wordnet_tagged_classification.py
│   │   │   │   ├── test_base_image_classification_dataset.py
│   │   │   │   ├── test_mock_coco.py
│   │   │   │   ├── test_mock_imagenet.py
│   │   │   │   └── test_wordnet_tagged_classification.py
│   │   │   ├── detection/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── mock_coco_mask_rcnn.py
│   │   │   │   └── mock_coco_ssd.py
│   │   │   ├── language_modeling/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── dummy_commonsense_170k.yaml
│   │   │   │   ├── dummy_lm_dataset.yaml
│   │   │   │   ├── mock_general_lm.py
│   │   │   │   ├── test_commonsense_170k.py
│   │   │   │   └── test_general_lm.py
│   │   │   ├── multi_modal_img_text/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── dummy_img_text_tar_dataset.yaml
│   │   │   │   ├── mock_img_text_tar_dataset.py
│   │   │   │   ├── test_img_text_tar_dataset.py
│   │   │   │   └── zero_shot_image_classification/
│   │   │   │       ├── __init__.py
│   │   │   │       ├── dummy_configs/
│   │   │   │       │   ├── imagenet.yaml
│   │   │   │       │   ├── imagenet_a.yaml
│   │   │   │       │   ├── imagenet_r.yaml
│   │   │   │       │   └── imagenet_sketch.yaml
│   │   │   │       ├── mock_imagenet.py
│   │   │   │       └── test_mock_imagenet.py
│   │   │   ├── segmentation/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── dummy_ade20k_config.yaml
│   │   │   │   ├── dummy_cocostuff_config.yaml
│   │   │   │   ├── mock_ade20k.py
│   │   │   │   ├── mock_coco_stuff.py
│   │   │   │   ├── test_mock_ade20k.py
│   │   │   │   └── test_mock_coco_stuff.py
│   │   │   ├── test_dataset_base.py
│   │   │   ├── test_image_pil.py
│   │   │   └── utils/
│   │   │       ├── __init__.py
│   │   │       ├── test_common.py
│   │   │       └── test_video.py
│   │   ├── io/
│   │   │   ├── __init__.py
│   │   │   └── test_transfer_clients.py
│   │   ├── samplers/
│   │   │   ├── __init__.py
│   │   │   ├── test_batch_sampler_config.yaml
│   │   │   ├── test_chain_sampler.py
│   │   │   ├── test_chain_sampler_config.yaml
│   │   │   ├── test_data_samplers.py
│   │   │   ├── test_multi_scale_sampler_config.yaml
│   │   │   ├── test_variable_batch_sampler_config.yaml
│   │   │   └── test_video_clip_batch_sampler_config.yaml
│   │   ├── text_tokenizer/
│   │   │   ├── __init__.py
│   │   │   ├── test_clip_tokenizer.py
│   │   │   └── test_openai_clip_tokenizer.py
│   │   └── video_reader/
│   │       ├── __init__.py
│   │       ├── test_av_reader.py
│   │       └── test_ffmpeg_utils.py
│   ├── engine/
│   │   ├── __init__.py
│   │   ├── dummy_configs/
│   │   │   ├── ade20k_segmentation/
│   │   │   │   └── deeplabv3_mobilenetv2.yaml
│   │   │   ├── coco_detection/
│   │   │   │   ├── resnet_mask_rcnn.yaml
│   │   │   │   └── resnet_ssd.yaml
│   │   │   ├── image_text_clip/
│   │   │   │   └── clip_vit.yaml
│   │   │   ├── imagenet_classification/
│   │   │   │   ├── efficientnet_b0.yaml
│   │   │   │   ├── mobilevit.yaml
│   │   │   │   └── mobilevit_v2.yaml
│   │   │   └── language_modeling_gpt/
│   │   │       └── gpt.yaml
│   │   └── test_training_engine.py
│   ├── loss_fns/
│   │   ├── __init__.py
│   │   ├── language_modeling/
│   │   │   ├── __init__.py
│   │   │   ├── test_cross_entropy.py
│   │   │   └── test_cross_entropy_for_kv_prediction.py
│   │   ├── test_class_weighting.py
│   │   ├── test_classification_loss.py
│   │   ├── test_composite_loss.py
│   │   ├── test_contrastive_loss.py
│   │   ├── test_detection_loss.py
│   │   ├── test_focal_loss.py
│   │   ├── test_neural_aug.py
│   │   ├── test_neural_aug_compatibility.py
│   │   └── test_segmentation_loss.py
│   ├── metrics/
│   │   ├── __init__.py
│   │   ├── base.py
│   │   ├── test_coco_map.py
│   │   ├── test_image_text_retrieval_metrics.py
│   │   ├── test_iou.py
│   │   ├── test_misc.py
│   │   ├── test_multiclass_classification_pr.py
│   │   ├── test_probability_histogram.py
│   │   ├── test_psnr.py
│   │   ├── test_retrieval_cmc_metrics.py
│   │   ├── test_topk_accuracy.py
│   │   └── test_vqa_preset_score_metrics.py
│   ├── misc/
│   │   ├── __init__.py
│   │   ├── dummy_clip_config.yaml
│   │   ├── dummy_linear_probe_config.yaml
│   │   └── test_common.py
│   ├── modeling/
│   │   ├── __init__.py
│   │   ├── layers/
│   │   │   ├── __init__.py
│   │   │   ├── normalization_layers/
│   │   │   │   ├── __init__.py
│   │   │   │   └── test_rms_norm.py
│   │   │   ├── test_conv_layer.py
│   │   │   ├── test_multi_head_attn.py
│   │   │   ├── test_pos_embeddings.py
│   │   │   ├── test_rotary_embeddings.py
│   │   │   └── test_token_merging.py
│   │   ├── models/
│   │   │   ├── __init__.py
│   │   │   ├── audio_classification/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── test_base_audio_classification.py
│   │   │   │   └── test_byteformer.py
│   │   │   ├── classification/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── config/
│   │   │   │   │   ├── __init__.py
│   │   │   │   │   ├── test_byteformer.py
│   │   │   │   │   └── vit_config.yaml
│   │   │   │   ├── test_byteformer.py
│   │   │   │   └── test_vit.py
│   │   │   ├── language_modeling/
│   │   │   │   ├── __init__.py
│   │   │   │   ├── config/
│   │   │   │   │   ├── gpt_config.yaml
│   │   │   │   │   └── kv_prediction_config.yaml
│   │   │   │   ├── test_general_gpt.py
│   │   │   │   └── test_kv_prediction.py
│   │   │   ├── test_activation_checkpointing_wrapper.py
│   │   │   ├── test_lora.py
│   │   │   └── test_neural_aug_utils.py
│   │   ├── modules/
│   │   │   ├── __init__.py
│   │   │   ├── test_transformer.py
│   │   │   └── test_windowed_transformer.py
│   │   └── test_model.py
│   ├── optims/
│   │   ├── __init__.py
│   │   └── scheduler/
│   │       ├── __init__.py
│   │       └── test_scheduler.py
│   ├── options/
│   │   ├── __init__.py
│   │   ├── test_parse_args.py
│   │   └── test_utils.py
│   ├── test_conventions.py
│   ├── test_utils.py
│   ├── transforms/
│   │   ├── __init__.py
│   │   ├── test_audio.py
│   │   ├── test_audio_bytes.py
│   │   ├── test_image.py
│   │   ├── test_image_bytes.py
│   │   └── test_video.py
│   └── utils/
│       ├── __init__.py
│       ├── test_check.py
│       ├── test_common_utils.py
│       ├── test_dict_utils.py
│       ├── test_download_utils.py
│       ├── test_file_logger.py
│       └── test_import_utils.py
├── tools/
│   ├── __init__.py
│   └── converter_coco_stuff.py
├── tox.ini
└── tutorials/
    ├── clip.ipynb
    ├── guide_slurm_and_multi_node_training.md
    ├── object_detection.ipynb
    ├── semantic_segmentation.ipynb
    └── train_a_new_model_on_a_new_dataset_from_scratch.ipynb
Download .txt
Showing preview only (226K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (2560 symbols across 412 files)

FILE: conftest.py
  function handle_timeout (line 32) | def handle_timeout(signum: int, frame: Optional[FrameType] = None) -> None:
  function pytest_sessionstart (line 39) | def pytest_sessionstart():
  function pytest_runtest_logfinish (line 57) | def pytest_runtest_logfinish(nodeid, location):
  function set_random_seed (line 63) | def set_random_seed(request):

FILE: corenet/__init__.py
  function suppress_known_warnings (line 55) | def suppress_known_warnings() -> None:

FILE: corenet/cli/main.py
  function main (line 19) | def main(args: Optional[List[str]] = None) -> None:

FILE: corenet/cli/main_benchmark.py
  function cpu_timestamp (line 21) | def cpu_timestamp(*args, **kwargs):
  function cuda_timestamp (line 26) | def cuda_timestamp(cuda_sync=False, device=None, *args, **kwargs):
  function step (line 33) | def step(
  function main_benchmark (line 47) | def main_benchmark():

FILE: corenet/cli/main_conversion.py
  function main_worker_conversion (line 20) | def main_worker_conversion(args: Optional[List[str]] = None):

FILE: corenet/cli/main_eval.py
  function main (line 14) | def main(train_eval_pipeline: BaseTrainEvalPipeline):
  function main_worker (line 27) | def main_worker(args: Optional[List[str]] = None):
  function main_worker_segmentation (line 36) | def main_worker_segmentation(args: Optional[List[str]] = None, **kwargs):
  function main_worker_detection (line 42) | def main_worker_detection(args: Optional[List[str]] = None, **kwargs):

FILE: corenet/cli/main_eval_llmadapters.py
  class CoreNetLMEvalWrapper (line 61) | class CoreNetLMEvalWrapper(HFLM):
    method __init__ (line 69) | def __init__(self, opts: argparse.Namespace) -> None:
  function main_eval_llmadapters (line 97) | def main_eval_llmadapters(args: Optional[List[str]] = None) -> None:
  function main_generation (line 140) | def main_generation(
  function evaluate_sample_with_generation (line 210) | def evaluate_sample_with_generation(
  function extract_answer_from_generation (line 265) | def extract_answer_from_generation(dataset: str, sentence: str) -> str:
  function main_multiple_choice (line 312) | def main_multiple_choice(
  function evaluate_likelihood (line 390) | def evaluate_likelihood(
  function get_loglikelihood_inputs (line 430) | def get_loglikelihood_inputs(data: Dict[str, str]) -> List[Request]:

FILE: corenet/cli/main_train.py
  function callback (line 18) | def callback(train_eval_pipeline: BaseTrainEvalPipeline) -> None:
  function main_worker (line 31) | def main_worker(args: Optional[List[str]] = None):

FILE: corenet/constants.py
  function get_corenet_env (line 43) | def get_corenet_env() -> Literal["pytest", "default", "external"]:
  function is_test_env (line 83) | def is_test_env() -> bool:
  function is_external_env (line 99) | def is_external_env() -> bool:
  function if_test_env (line 108) | def if_test_env(then: Any, otherwise: Any) -> Any:

FILE: corenet/data/collate_fns/__init__.py
  function arguments_collate_fn (line 18) | def arguments_collate_fn(parser: argparse.ArgumentParser) -> argparse.Ar...
  function build_collate_fn (line 43) | def build_collate_fn(opts, *args, **kwargs):
  function build_test_collate_fn (line 64) | def build_test_collate_fn(opts, *args, **kwargs):

FILE: corenet/data/collate_fns/byteformer_collate_functions.py
  function byteformer_image_collate_fn (line 29) | def byteformer_image_collate_fn(
  function apply_padding (line 53) | def apply_padding(
  function apply_pil_save (line 118) | def apply_pil_save(
  function apply_shuffle_bytes (line 139) | def apply_shuffle_bytes(
  function apply_mask_positions (line 160) | def apply_mask_positions(
  function apply_random_uniform_noise (line 180) | def apply_random_uniform_noise(
  function apply_byte_permutation (line 200) | def apply_byte_permutation(
  function apply_torchaudio_save (line 220) | def apply_torchaudio_save(
  function byteformer_audio_collate_fn (line 241) | def byteformer_audio_collate_fn(

FILE: corenet/data/collate_fns/collate_functions.py
  function pytorch_default_collate_fn (line 17) | def pytorch_default_collate_fn(batch: Any, *args, **kwargs) -> Any:
  function unlabeled_image_data_collate_fn (line 24) | def unlabeled_image_data_collate_fn(
  function image_classification_data_collate_fn (line 64) | def image_classification_data_collate_fn(
  function default_collate_fn (line 109) | def default_collate_fn(

FILE: corenet/data/data_loaders.py
  function create_test_loader (line 22) | def create_test_loader(opts: argparse.Namespace) -> CoreNetDataLoader:
  function create_train_val_loader (line 85) | def create_train_val_loader(
  function get_num_data_samples_as_int_or_mapping (line 194) | def get_num_data_samples_as_int_or_mapping(

FILE: corenet/data/datasets/__init__.py
  function build_dataset_from_registry (line 44) | def build_dataset_from_registry(
  function get_test_dataset (line 89) | def get_test_dataset(opts: argparse.Namespace, *args, **kwargs) -> BaseD...
  function get_train_val_datasets (line 110) | def get_train_val_datasets(
  function arguments_dataset (line 143) | def arguments_dataset(parser: argparse.ArgumentParser) -> argparse.Argum...

FILE: corenet/data/datasets/audio_classification/speech_commands_v2.py
  class SpeechCommandsv2Dataset (line 24) | class SpeechCommandsv2Dataset(dataset_base.BaseDataset):
    method __init__ (line 35) | def __init__(
    method _process_dataset_config (line 52) | def _process_dataset_config(self) -> None:
    method add_arguments (line 87) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _training_transforms (line 96) | def _training_transforms(self, *args, **kwargs) -> BaseTransformation:
    method _validation_transforms (line 110) | def _validation_transforms(self, *args, **kwargs) -> BaseTransformation:
    method get_sample (line 117) | def get_sample(self, index: int) -> Tuple[Tensor, float, Tensor]:
    method __getitem__ (line 129) | def __getitem__(
    method get_transformed_sample (line 185) | def get_transformed_sample(
    method __len__ (line 224) | def __len__(self) -> int:

FILE: corenet/data/datasets/classification/base_image_classification_dataset.py
  class BaseImageClassificationDataset (line 19) | class BaseImageClassificationDataset(BaseImageDataset, ImageFolder):
    method __init__ (line 36) | def __init__(
    method add_arguments (line 111) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _training_transforms (line 134) | def _training_transforms(
    method _validation_transforms (line 187) | def _validation_transforms(self, *args, **kwargs) -> image_pil.BaseTra...
    method __getitem__ (line 210) | def __getitem__(
    method __len__ (line 255) | def __len__(self) -> int:
    method extra_repr (line 258) | def extra_repr(self) -> str:

FILE: corenet/data/datasets/classification/base_imagenet_shift_dataset.py
  class BaseImageNetShiftDataset (line 14) | class BaseImageNetShiftDataset(BaseImageClassificationDataset):
    method __init__ (line 25) | def __init__(
    method post_init_checks (line 45) | def post_init_checks(self) -> None:
    method class_id_to_imagenet_class_id (line 59) | def class_id_to_imagenet_class_id(class_id: int) -> int:
    method __getitem__ (line 65) | def __getitem__(

FILE: corenet/data/datasets/classification/coco.py
  class COCOClassification (line 23) | class COCOClassification(BaseImageDataset):
    method __init__ (line 30) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method __len__ (line 44) | def __len__(self) -> int:
    method _training_transforms (line 48) | def _training_transforms(
    method _validation_transforms (line 63) | def _validation_transforms(
    method __getitem__ (line 75) | def __getitem__(
    method n_classes (line 135) | def n_classes(self):
    method class_names (line 139) | def class_names(self) -> List[str]:

FILE: corenet/data/datasets/classification/imagenet.py
  class ImageNetDataset (line 15) | class ImageNetDataset(BaseImageClassificationDataset):
    method __init__ (line 24) | def __init__(

FILE: corenet/data/datasets/classification/imagenet_a.py
  class ImageNetADataset (line 24) | class ImageNetADataset(BaseImageNetShiftDataset):
    method __init__ (line 39) | def __init__(
    method class_id_to_imagenet_class_id (line 49) | def class_id_to_imagenet_class_id(class_id: int) -> int:

FILE: corenet/data/datasets/classification/imagenet_r.py
  class ImageNetRDataset (line 24) | class ImageNetRDataset(BaseImageNetShiftDataset):
    method __init__ (line 43) | def __init__(
    method class_id_to_imagenet_class_id (line 53) | def class_id_to_imagenet_class_id(class_id: int) -> int:

FILE: corenet/data/datasets/classification/imagenet_sketch.py
  class ImageNetSketchDataset (line 15) | class ImageNetSketchDataset(BaseImageNetShiftDataset):
    method __init__ (line 31) | def __init__(
    method class_id_to_imagenet_class_id (line 41) | def class_id_to_imagenet_class_id(class_id: int) -> int:

FILE: corenet/data/datasets/classification/imagenet_v2.py
  class Imagenetv2Dataset (line 37) | class Imagenetv2Dataset(BaseImageDataset):
    method __init__ (line 45) | def __init__(
    method add_arguments (line 80) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _validation_transforms (line 100) | def _validation_transforms(self, *args, **kwargs):
    method __getitem__ (line 116) | def __getitem__(self, sample_size_and_index: Tuple) -> Dict:
    method __len__ (line 166) | def __len__(self) -> int:

FILE: corenet/data/datasets/classification/places365.py
  class Places365Dataset (line 15) | class Places365Dataset(BaseImageClassificationDataset):
    method __init__ (line 24) | def __init__(

FILE: corenet/data/datasets/classification/wordnet_tagged_classification.py
  function extract_pos_offset_info_from_synset (line 59) | def extract_pos_offset_info_from_synset(synset: Synset) -> str:
  function check_valid_noun_synset (line 73) | def check_valid_noun_synset(synset: Synset, word: str) -> bool:
  class WordnetTaggedClassificationDataset (line 87) | class WordnetTaggedClassificationDataset(BaseImageDataset):
    method __init__ (line 97) | def __init__(
    method __post_init__ (line 113) | def __post_init__(self) -> None:
    method _get_vocab (line 118) | def _get_vocab(self) -> List[str]:
    method _metadata_file_path (line 168) | def _metadata_file_path(self) -> str:
    method _metadata (line 182) | def _metadata(self):
    method _download_and_extract_tar_file (line 215) | def _download_and_extract_tar_file(self, sample_index: int) -> int:
    method _convert_caption_to_labels (line 274) | def _convert_caption_to_labels(self, captions_str: str) -> List[int]:
    method _read_sample_with_wordnet_label_mining (line 313) | def _read_sample_with_wordnet_label_mining(
    method _training_transforms (line 358) | def _training_transforms(self, *args, **kwargs) -> BaseTransformation:
    method add_arguments (line 368) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _get_transfer_client (line 395) | def _get_transfer_client(self, file_path: str) -> BaseClient:
    method __getitem__ (line 422) | def __getitem__(
    method __len__ (line 461) | def __len__(self) -> int:
    method cache_loc (line 465) | def cache_loc(self) -> str:
    method vocab_size (line 469) | def vocab_size(self):
    method total_tar_files (line 473) | def total_tar_files(self) -> int:
    method max_files_per_tar (line 479) | def max_files_per_tar(self) -> int:
    method extra_repr (line 484) | def extra_repr(self) -> str:

FILE: corenet/data/datasets/dataset_base.py
  class BaseDataset (line 28) | class BaseDataset(data.Dataset, ABC):
    method __init__ (line 52) | def __init__(
    method add_arguments (line 88) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method load_from_server (line 224) | def load_from_server(
    method _training_transforms (line 244) | def _training_transforms(self, *args, **kwargs) -> BaseTransformation:
    method _validation_transforms (line 248) | def _validation_transforms(self, *args, **kwargs) -> BaseTransformation:
    method _evaluation_transforms (line 252) | def _evaluation_transforms(self, *args, **kwargs) -> BaseTransformation:
    method get_augmentation_transforms (line 256) | def get_augmentation_transforms(self, *args, **kwargs) -> BaseTransfor...
    method share_dataset_arguments (line 267) | def share_dataset_arguments(self) -> Dict[str, Any]:
    method __len__ (line 275) | def __len__(self) -> int:
    method __getitem__ (line 278) | def __getitem__(self, sample_size_and_index: Any) -> Any:
    method extra_repr (line 282) | def extra_repr(self) -> str:
    method __repr__ (line 289) | def __repr__(self) -> str:
    method get_item_metadata (line 298) | def get_item_metadata(self, item_idx: int) -> Dict:
    method worker_id (line 313) | def worker_id(self) -> int:
    method num_workers (line 328) | def num_workers(self) -> int:
    method is_master_node (line 343) | def is_master_node(self) -> bool:
    method is_start_rank_node (line 355) | def is_start_rank_node(self) -> bool:
    method world_size (line 367) | def world_size(self) -> int:
    method rank (line 376) | def rank(self) -> int:
  class BaseImageDataset (line 389) | class BaseImageDataset(BaseDataset, ABC):
    method read_image_pil (line 393) | def read_image_pil(path: str) -> Optional[Image.Image]:
    method extra_repr (line 410) | def extra_repr(self) -> str:
  class BaseVideoDataset (line 422) | class BaseVideoDataset(BaseDataset, ABC):
    method __init__ (line 429) | def __init__(
    method clips_per_video (line 443) | def clips_per_video(self) -> int:
    method _deprecated_set_clips_per_video (line 453) | def _deprecated_set_clips_per_video(self, value: int) -> None:
    method n_frames_per_clip (line 457) | def n_frames_per_clip(self) -> int:
    method _deprecated_set_n_frames_per_clip (line 467) | def _deprecated_set_n_frames_per_clip(self, value: int) -> None:
    method add_arguments (line 471) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_item_metadata (line 494) | def get_item_metadata(self, item_idx: int) -> VideoMetadataDict:
    method get_item_local_path (line 510) | def get_item_local_path(self, item_idx: int) -> str:
  class VideoMetadataDict (line 526) | class VideoMetadataDict(TypedDict, total=False):
  class BaseIterableDataset (line 540) | class BaseIterableDataset(BaseDataset, data.IterableDataset):

FILE: corenet/data/datasets/detection/base_detection.py
  class BaseDetectionDataset (line 11) | class BaseDetectionDataset(BaseImageDataset):
    method add_arguments (line 15) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...

FILE: corenet/data/datasets/detection/coco_base.py
  class COCODetection (line 24) | class COCODetection(BaseDetectionDataset):
    method __init__ (line 37) | def __init__(
    method add_arguments (line 76) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _evaluation_transforms (line 89) | def _evaluation_transforms(
    method __getitem__ (line 106) | def __getitem__(
    method __len__ (line 172) | def __len__(self):
    method get_boxes_and_labels (line 175) | def get_boxes_and_labels(
    method _xywh2xyxy (line 245) | def _xywh2xyxy(
    method get_image (line 257) | def get_image(self, image_id: int) -> Tuple:
    method extra_repr (line 264) | def extra_repr(self) -> str:
    method class_names (line 268) | def class_names() -> List[str]:

FILE: corenet/data/datasets/detection/coco_mask_rcnn.py
  class COCODetectionMaskRCNN (line 20) | class COCODetectionMaskRCNN(COCODetection):
    method add_arguments (line 24) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _training_transforms (line 38) | def _training_transforms(
    method _validation_transforms (line 71) | def _validation_transforms(
    method __getitem__ (line 90) | def __getitem__(
  function coco_mask_rcnn_collate_fn (line 163) | def coco_mask_rcnn_collate_fn(

FILE: corenet/data/datasets/detection/coco_ssd.py
  class COCODetectionSSD (line 24) | class COCODetectionSSD(COCODetection):
    method __init__ (line 31) | def __init__(
    method _training_transforms (line 54) | def _training_transforms(self, size: Tuple[int, int], *args, **kwargs)...
    method _validation_transforms (line 77) | def _validation_transforms(self, size: Tuple[int, int], *args, **kwarg...
    method generate_anchors (line 95) | def generate_anchors(self, height: int, width: int) -> Tensor:
    method __getitem__ (line 121) | def __getitem__(
    method extra_repr (line 183) | def extra_repr(self) -> str:
  function coco_ssd_collate_fn (line 193) | def coco_ssd_collate_fn(

FILE: corenet/data/datasets/language_modeling/base_lm.py
  function _process_text (line 19) | def _process_text(text: str) -> str:
  class BaseLMIterableDataset (line 46) | class BaseLMIterableDataset(BaseIterableDataset):
    method __init__ (line 53) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method pad_token_id (line 71) | def pad_token_id(self) -> int:
    method vocab_size (line 76) | def vocab_size(self) -> int:
    method seed (line 81) | def seed(self) -> int:
    method _tokenize_text (line 86) | def _tokenize_text(self, text: str) -> Optional[Dict[str, Tensor]]:
    method add_arguments (line 130) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method generate_sample (line 169) | def generate_sample(
    method __iter__ (line 198) | def __iter__(self) -> Iterator[Dict[str, Tensor]]:
    method extra_repr (line 213) | def extra_repr(self) -> str:

FILE: corenet/data/datasets/language_modeling/commonsense_170k.py
  class CommonSense170k (line 23) | class CommonSense170k(BaseLMIterableDataset):
    method __init__ (line 41) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method generate_sample (line 54) | def generate_sample(
    method add_arguments (line 69) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _download_if_required (line 83) | def _download_if_required(self, remote_file_path: str) -> str:
  function generate_prompt_and_response (line 117) | def generate_prompt_and_response(data_point: Dict[str, str]) -> str:

FILE: corenet/data/datasets/language_modeling/general_lm.py
  function check_list_of_dicts_with_mandatory_keys (line 30) | def check_list_of_dicts_with_mandatory_keys(
  class GeneralLMDataset (line 57) | class GeneralLMDataset(BaseLMIterableDataset):
    method __init__ (line 71) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 83) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _reset_data_state (line 123) | def _reset_data_state(self) -> None:
    method extra_repr (line 146) | def extra_repr(self) -> str:
    method reader_chunk_size (line 154) | def reader_chunk_size(self) -> int:
    method save_loc (line 161) | def save_loc(self) -> str:
    method num_files (line 170) | def num_files(self) -> int:
    method document_split_size (line 175) | def document_split_size(self) -> int:
    method _load_data_state (line 181) | def _load_data_state(self) -> None:
    method _save_data_state (line 215) | def _save_data_state(self, **kwargs) -> None:
    method _prepare_dataset (line 269) | def _prepare_dataset(self) -> Dict[str, List[str]]:
    method _download_if_required (line 366) | def _download_if_required(self, remote_file_path: str) -> str:
    method _skip_document_chunks (line 407) | def _skip_document_chunks(self, chunks: Iterable[Any]) -> Iterator[Any]:
    method _split_document_into_sequences (line 424) | def _split_document_into_sequences(
    method _read_data_from_parquet (line 446) | def _read_data_from_parquet(
    method _read_data_from_json (line 473) | def _read_data_from_json(
    method _get_file_reader (line 498) | def _get_file_reader(self, file_path: str) -> Callable:
    method generate_sample (line 512) | def generate_sample(
    method _shuffle_fn (line 601) | def _shuffle_fn(

FILE: corenet/data/datasets/multi_modal_img_text/__init__.py
  function arguments_multi_modal_img_text (line 16) | def arguments_multi_modal_img_text(

FILE: corenet/data/datasets/multi_modal_img_text/base_multi_modal_img_text.py
  class BaseMultiModalImgText (line 28) | class BaseMultiModalImgText(BaseImageDataset):
    method __init__ (line 40) | def __init__(
    method get_image_text_dataset (line 65) | def get_image_text_dataset(self) -> Optional[Any]:
    method _get_transfer_client (line 76) | def _get_transfer_client(self, file_path: str) -> BaseClient:
    method vocab_size (line 107) | def vocab_size(self) -> int:
    method padding_index (line 112) | def padding_index(self) -> Optional[int]:
    method context_length (line 122) | def context_length(self) -> int:
    method add_arguments (line 130) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _transform_text (line 160) | def _transform_text(self, text_tensor: Tensor) -> Tuple[Tensor, int]:
    method _training_transforms (line 184) | def _training_transforms(
    method _validation_transforms (line 226) | def _validation_transforms(
    method _process_img_caption (line 246) | def _process_img_caption(
    method get_zero_shot_image_text_pair (line 333) | def get_zero_shot_image_text_pair(
    method get_image_text_dataset_pair (line 351) | def get_image_text_dataset_pair(self, sample_index: int) -> Tuple[Imag...
    method __getitem__ (line 358) | def __getitem__(
    method __len__ (line 424) | def __len__(self) -> int:
    method __repr__ (line 427) | def __repr__(self) -> str:
  function multi_modal_img_text_collate_fn (line 434) | def multi_modal_img_text_collate_fn(

FILE: corenet/data/datasets/multi_modal_img_text/flickr.py
  class FlickrDataset (line 17) | class FlickrDataset(BaseMultiModalImgText):
    method get_image_text_dataset (line 35) | def get_image_text_dataset(self) -> List[Dict[str, str]]:
    method __getitem__ (line 76) | def __getitem__(

FILE: corenet/data/datasets/multi_modal_img_text/img_text_tar_dataset.py
  class ImgTextTarDataset (line 39) | class ImgTextTarDataset(BaseMultiModalImgText):
    method _metadata_file_path (line 90) | def _metadata_file_path(self) -> str:
    method _metadata (line 104) | def _metadata(self):
    method total_tar_files (line 138) | def total_tar_files(self) -> int:
    method max_files_per_tar (line 144) | def max_files_per_tar(self) -> int:
    method get_image_text_dataset (line 149) | def get_image_text_dataset(self) -> None:
    method _get_folder_index (line 156) | def _get_folder_index(self, sample_index) -> int:
    method add_arguments (line 171) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _download_and_extract_tar_file (line 185) | def _download_and_extract_tar_file(self, sample_index: int) -> int:
    method get_image_text_dataset_pair (line 244) | def get_image_text_dataset_pair(self, sample_index: int) -> Tuple[Imag...
    method __len__ (line 283) | def __len__(self) -> int:
    method extra_repr (line 298) | def extra_repr(self) -> str:

FILE: corenet/data/datasets/multi_modal_img_text/zero_shot_image_classification/__init__.py
  function arguments_zero_shot_image_classification_dataset (line 23) | def arguments_zero_shot_image_classification_dataset(
  function build_zero_shot_image_classification_dataset (line 32) | def build_zero_shot_image_classification_dataset(

FILE: corenet/data/datasets/multi_modal_img_text/zero_shot_image_classification/base_zero_shot_image_classification.py
  class BaseZeroShotImageClassificationDataset (line 17) | class BaseZeroShotImageClassificationDataset(BaseImageClassificationData...
    method add_arguments (line 26) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __getitem__ (line 38) | def __getitem__(self, img_index: int) -> Tuple[str, List[List[str]], i...
    method class_names (line 51) | def class_names(self) -> List[str]:
    method text_prompts (line 63) | def text_prompts(self) -> List[List[str]]:
    method generate_text_prompts (line 75) | def generate_text_prompts(self, class_name: str) -> List[str]:

FILE: corenet/data/datasets/multi_modal_img_text/zero_shot_image_classification/imagenet.py
  class ImageNetDatasetZeroShot (line 19) | class ImageNetDatasetZeroShot(BaseZeroShotImageClassificationDataset):
    method class_names (line 23) | def class_names(self) -> List[str]:

FILE: corenet/data/datasets/multi_modal_img_text/zero_shot_image_classification/imagenet_a.py
  class ImageNetADatasetZeroShot (line 24) | class ImageNetADatasetZeroShot(BaseZeroShotImageClassificationDataset):
    method class_names (line 28) | def class_names(self) -> List[str]:

FILE: corenet/data/datasets/multi_modal_img_text/zero_shot_image_classification/imagenet_r.py
  class ImageNetRDatasetZeroShot (line 24) | class ImageNetRDatasetZeroShot(
    method class_names (line 30) | def class_names(self) -> List[str]:

FILE: corenet/data/datasets/multi_modal_img_text/zero_shot_image_classification/imagenet_sketch.py
  class ImageNetSketchDatasetZeroShot (line 21) | class ImageNetSketchDatasetZeroShot(
    method class_names (line 27) | def class_names(self) -> List[str]:

FILE: corenet/data/datasets/multi_modal_img_text/zero_shot_image_classification/templates.py
  function generate_text_prompts_clip (line 92) | def generate_text_prompts_clip(class_name) -> List[str]:

FILE: corenet/data/datasets/segmentation/ade20k.py
  class ADE20KDataset (line 19) | class ADE20KDataset(BaseImageSegmentationDataset):
    method __init__ (line 34) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method adjust_mask_value (line 65) | def adjust_mask_value() -> int:
    method color_palette (line 71) | def color_palette() -> List[int]:
    method class_names (line 231) | def class_names() -> List[str]:

FILE: corenet/data/datasets/segmentation/base_segmentation.py
  class BaseImageSegmentationDataset (line 22) | class BaseImageSegmentationDataset(BaseImageDataset):
    method __init__ (line 30) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 41) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method check_dataset (line 108) | def check_dataset(self) -> None:
    method _training_transforms (line 119) | def _training_transforms(self, size: Tuple[int, int]) -> T.BaseTransfo...
    method _validation_transforms (line 161) | def _validation_transforms(
    method _evaluation_transforms (line 177) | def _evaluation_transforms(
    method adjust_mask_value (line 225) | def adjust_mask_value() -> int:
    method __len__ (line 231) | def __len__(self) -> int:
    method color_palette (line 236) | def color_palette() -> List[int]:
    method class_names (line 243) | def class_names() -> List[str]:
    method read_mask_pil (line 249) | def read_mask_pil(path: str) -> Optional[Image.Image]:
    method convert_mask_to_tensor (line 260) | def convert_mask_to_tensor(mask: Image.Image) -> Tensor:
    method __getitem__ (line 268) | def __getitem__(

FILE: corenet/data/datasets/segmentation/coco_segmentation.py
  class COCOSegmentationDataset (line 22) | class COCOSegmentationDataset(BaseImageSegmentationDataset):
    method __init__ (line 29) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method __getitem__ (line 45) | def __getitem__(
    method _gen_seg_mask (line 104) | def _gen_seg_mask(self, target, h: int, w: int) -> np.ndarray:
    method __len__ (line 125) | def __len__(self) -> int:
    method class_names (line 129) | def class_names() -> List[str]:
    method coco_to_pascal_mapping (line 156) | def coco_to_pascal_mapping() -> List[int]:

FILE: corenet/data/datasets/segmentation/coco_stuff.py
  class COCOStuffDataset (line 19) | class COCOStuffDataset(BaseImageSegmentationDataset):
    method __init__ (line 50) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method color_palette (line 76) | def color_palette() -> List[int]:
    method class_names (line 258) | def class_names() -> List[str]:

FILE: corenet/data/datasets/segmentation/pascal_voc.py
  class PascalVOCDataset (line 19) | class PascalVOCDataset(BaseImageSegmentationDataset):
    method __init__ (line 37) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 91) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method color_palette (line 112) | def color_palette() -> List[int]:
    method class_names (line 143) | def class_names() -> List[str]:

FILE: corenet/data/datasets/utils/common.py
  function file_has_valid_image_extension (line 24) | def file_has_valid_image_extension(filename: str) -> bool:
  function file_has_allowed_extension (line 28) | def file_has_allowed_extension(
  function get_image_paths (line 43) | def get_image_paths(directory: str) -> List[str]:
  function select_random_subset (line 55) | def select_random_subset(
  function select_samples_by_category (line 113) | def select_samples_by_category(

FILE: corenet/data/datasets/utils/text.py
  function caption_preprocessing (line 12) | def caption_preprocessing(caption: str) -> str:

FILE: corenet/data/datasets/utils/video.py
  function _simultaneous (line 38) | def _simultaneous(
  function _before (line 46) | def _before(this_timestamp: float, other_timestamp: float) -> bool:
  function fetch_labels_from_timestamps (line 53) | def fetch_labels_from_timestamps(
  function _make_fake_bbox (line 129) | def _make_fake_bbox(
  function _fetch_frame_label (line 162) | def _fetch_frame_label(
  function _assert_progress_repr (line 302) | def _assert_progress_repr(
  function _search_for_label_edge_timestamp (line 321) | def _search_for_label_edge_timestamp(
  function _interpolate_bounding_box (line 391) | def _interpolate_bounding_box(

FILE: corenet/data/io/transfer_clients.py
  class BaseClient (line 30) | class BaseClient(object):
    method __init__ (line 47) | def __init__(
    method add_arguments (line 75) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method start_rank_node (line 83) | def start_rank_node(self) -> bool:
    method sync_distributed_ranks (line 89) | def sync_distributed_ranks(self) -> bool:
    method _download_fn (line 96) | def _download_fn(self, remote_path: str, local_path: str) -> None:
    method _download_with_retries (line 107) | def _download_with_retries(self, remote_path: str, local_path: str) ->...
    method _download_single_file (line 116) | def _download_single_file(self, remote_path: str, dst_dir: str) -> str:
    method _download_multiple_files (line 169) | def _download_multiple_files(
    method download (line 200) | def download(
  class S3Client (line 233) | class S3Client(BaseClient):
    method __init__ (line 236) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method transfer_config (line 249) | def transfer_config(self) -> TransferConfig:
    method init_client (line 257) | def init_client(
    method add_arguments (line 291) | def add_arguments(cls, parser: ArgumentParser) -> ArgumentParser:
    method _download_fn (line 333) | def _download_fn(self, remote_path: str, local_path: str) -> None:
  class HTTPClient (line 343) | class HTTPClient(BaseClient):
    method __init__ (line 346) | def __init__(self, opts, *args, **kwargs) -> None:
    method proxies (line 350) | def proxies(self):
    method _download_fn (line 356) | def _download_fn(self, remote_path: str, local_path: str) -> None:
  class HTTPSClient (line 369) | class HTTPSClient(HTTPClient):
    method __init__ (line 372) | def __init__(self, opts, *args, **kwargs) -> None:
  function get_transfer_client (line 376) | def get_transfer_client(
  function transfer_client_arguments (line 430) | def transfer_client_arguments(

FILE: corenet/data/loader/dataloader.py
  class CoreNetDataLoader (line 16) | class CoreNetDataLoader(DataLoader):
    method __init__ (line 39) | def __init__(
    method update_indices (line 74) | def update_indices(self, new_indices: List, *args, **kwargs):
    method __len__ (line 81) | def __len__(self) -> int:
    method get_sample_indices (line 97) | def get_sample_indices(self) -> List:

FILE: corenet/data/sampler/__init__.py
  function build_sampler (line 23) | def build_sampler(
  function add_sampler_arguments (line 64) | def add_sampler_arguments(

FILE: corenet/data/sampler/base_sampler.py
  class BaseSampler (line 18) | class BaseSampler(Sampler):
    method __init__ (line 30) | def __init__(
    method add_arguments (line 69) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_indices (line 114) | def get_indices(self) -> List[int]:
    method __iter__ (line 140) | def __iter__(self) -> Iterator[Tuple[Any, ...]]:
    method __len__ (line 143) | def __len__(self) -> int:
    method set_epoch (line 146) | def set_epoch(self, epoch: int) -> None:
    method update_scales (line 150) | def update_scales(
    method update_indices (line 158) | def update_indices(self, new_indices: List[int]) -> None:
    method extra_repr (line 162) | def extra_repr(self) -> str:
    method __repr__ (line 169) | def __repr__(self) -> str:
  class BaseSamplerDDP (line 173) | class BaseSamplerDDP(Sampler):
    method __init__ (line 185) | def __init__(
    method get_indices_rank_i (line 241) | def get_indices_rank_i(self) -> List[int]:
    method __iter__ (line 329) | def __iter__(self) -> Iterator[Tuple[Any, ...]]:
    method __len__ (line 332) | def __len__(self) -> int:
    method add_arguments (line 338) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method set_epoch (line 359) | def set_epoch(self, epoch: int) -> None:
    method update_scales (line 363) | def update_scales(
    method update_indices (line 371) | def update_indices(self, new_indices: List[int]) -> None:
    method extra_repr (line 375) | def extra_repr(self) -> str:
    method __repr__ (line 384) | def __repr__(self):
  function get_batch_size_from_opts (line 388) | def get_batch_size_from_opts(

FILE: corenet/data/sampler/batch_sampler.py
  class BatchSampler (line 15) | class BatchSampler(BaseSampler):
    method __init__ (line 25) | def __init__(
    method __iter__ (line 43) | def __iter__(self) -> Iterator[Tuple[int, int, int]]:
    method extra_repr (line 61) | def extra_repr(self) -> str:
    method add_arguments (line 70) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
  class BatchSamplerDDP (line 91) | class BatchSamplerDDP(BaseSamplerDDP):
    method __init__ (line 100) | def __init__(
    method __iter__ (line 121) | def __iter__(self) -> Iterator[Tuple[int, int, int]]:
    method extra_repr (line 141) | def extra_repr(self) -> str:

FILE: corenet/data/sampler/chain_sampler.py
  class ChainSampler (line 22) | class ChainSampler(Sampler):
    method __init__ (line 69) | def __init__(
    method add_arguments (line 94) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method build_chain_sampler (line 112) | def build_chain_sampler(
    method _sequential_sampling (line 215) | def _sequential_sampling(self) -> List[Tuple]:
    method _interleave_sampling (line 231) | def _interleave_sampling(self) -> List[Tuple]:
    method __iter__ (line 264) | def __iter__(self) -> Iterator[Tuple]:
    method __len__ (line 270) | def __len__(self) -> int:
    method set_epoch (line 278) | def set_epoch(self, epoch: int) -> None:
    method update_scales (line 290) | def update_scales(
    method update_indices (line 308) | def update_indices(self, new_indices: List[int]) -> None:
    method __repr__ (line 323) | def __repr__(self) -> str:

FILE: corenet/data/sampler/multi_scale_sampler.py
  class MultiScaleSampler (line 18) | class MultiScaleSampler(BaseSampler):
    method __init__ (line 28) | def __init__(
    method add_arguments (line 87) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __iter__ (line 152) | def __iter__(self) -> Iterator[Tuple[int, int, int]]:
    method update_scales (line 170) | def update_scales(
    method extra_repr (line 182) | def extra_repr(self) -> str:
  class MultiScaleSamplerDDP (line 193) | class MultiScaleSamplerDDP(BaseSamplerDDP):
    method __init__ (line 202) | def __init__(
    method __iter__ (line 259) | def __iter__(self) -> Iterator[Tuple[int, int, int]]:
    method extra_repr (line 278) | def extra_repr(self) -> str:
    method update_scales (line 287) | def update_scales(

FILE: corenet/data/sampler/utils.py
  function image_batch_pairs (line 13) | def image_batch_pairs(
  function make_video_pairs (line 70) | def make_video_pairs(
  function create_intervallic_integer_list (line 123) | def create_intervallic_integer_list(
  function make_tuple_list (line 149) | def make_tuple_list(*val_list: List) -> List[Tuple]:

FILE: corenet/data/sampler/variable_batch_sampler.py
  class VariableBatchSampler (line 18) | class VariableBatchSampler(BaseSampler):
    method __init__ (line 28) | def __init__(
    method __iter__ (line 91) | def __iter__(self) -> Iterator[Tuple[int, int, int]]:
    method update_scales (line 109) | def update_scales(
    method extra_repr (line 144) | def extra_repr(self) -> str:
    method add_arguments (line 159) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
  class VariableBatchSamplerDDP (line 243) | class VariableBatchSamplerDDP(BaseSamplerDDP):
    method __init__ (line 252) | def __init__(
    method __iter__ (line 315) | def __iter__(self) -> Iterator[Tuple[int, int, int]]:
    method update_scales (line 333) | def update_scales(self, epoch: int, is_master_node=False, *args, **kwa...
    method extra_repr (line 366) | def extra_repr(self) -> str:

FILE: corenet/data/sampler/video_batch_sampler.py
  class VideoBatchSampler (line 14) | class VideoBatchSampler(BatchSampler):
    method __init__ (line 24) | def __init__(
    method __iter__ (line 39) | def __iter__(self) -> Iterator[Tuple[int, int, int, int, int]]:
    method add_arguments (line 65) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Na...
    method extra_repr (line 84) | def extra_repr(self) -> str:
  class VideoBatchSamplerDDP (line 94) | class VideoBatchSamplerDDP(BatchSamplerDDP):
    method __init__ (line 103) | def __init__(
    method __iter__ (line 117) | def __iter__(self) -> Iterator[Tuple[int, int, int, int, int]]:
    method extra_repr (line 144) | def extra_repr(self) -> str:

FILE: corenet/data/sampler/video_clip_batch_sampler.py
  class VideoClipBatchSampler (line 23) | class VideoClipBatchSampler(VariableBatchSampler):
    method add_arguments (line 57) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __init__ (line 131) | def __init__(
    method __iter__ (line 173) | def __iter__(self) -> Iterator[List]:
    method __repr__ (line 244) | def __repr__(self) -> str:
  class VideoClipBatchSamplerDDP (line 260) | class VideoClipBatchSamplerDDP(BaseSamplerDDP):
    method __init__ (line 269) | def __init__(
    method __iter__ (line 277) | def __iter__(self) -> Iterator[List]:
    method __len__ (line 290) | def __len__(self) -> int:
    method set_epoch (line 293) | def set_epoch(self, epoch: int) -> None:
    method update_scales (line 297) | def update_scales(self, *args, **kwargs) -> None:
    method update_indices (line 300) | def update_indices(self, new_indices: List[int]) -> None:
    method extra_repr (line 303) | def extra_repr(self) -> str:

FILE: corenet/data/sampler/video_variable_seq_sampler.py
  class VideoVariableSeqSampler (line 20) | class VideoVariableSeqSampler(VariableBatchSampler):
    method __init__ (line 31) | def __init__(
    method add_arguments (line 77) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __iter__ (line 123) | def __iter__(self) -> Iterator[Tuple[int, int, int, int, int]]:
    method update_scales (line 158) | def update_scales(
    method extra_repr (line 170) | def extra_repr(self) -> str:
  class VideoVariableSeqSamplerDDP (line 180) | class VideoVariableSeqSamplerDDP(VariableBatchSamplerDDP):
    method __init__ (line 189) | def __init__(
    method __iter__ (line 235) | def __iter__(self) -> Iterator[Tuple[int, int, int, int, int]]:
    method update_scales (line 270) | def update_scales(
    method extra_repr (line 281) | def extra_repr(self) -> str:

FILE: corenet/data/text_tokenizer/__init__.py
  function arguments_tokenizer (line 23) | def arguments_tokenizer(parser: argparse.ArgumentParser) -> argparse.Arg...
  function build_tokenizer (line 32) | def build_tokenizer(opts, *args, **kwargs) -> BaseTextTokenizer:

FILE: corenet/data/text_tokenizer/base_tokenizer.py
  class BaseTextTokenizer (line 14) | class BaseTextTokenizer(nn.Module):
    method __init__ (line 21) | def __init__(self, opts: argparse.Namespace) -> None:
    method add_arguments (line 26) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method vocab_size (line 59) | def vocab_size(self) -> int:
    method eot_token (line 64) | def eot_token(self) -> str:
    method eot_token_id (line 74) | def eot_token_id(self) -> int:
    method sot_token (line 79) | def sot_token(self) -> str:
    method sot_token_id (line 89) | def sot_token_id(self) -> int:
    method pad_token (line 94) | def pad_token(self) -> str:
    method pad_token_id (line 104) | def pad_token_id(self) -> int:
    method tok_encode (line 108) | def tok_encode(self, input_sentence: str) -> Tensor:
    method tok_decode (line 112) | def tok_decode(self, token_ids: Any) -> str:
    method forward (line 116) | def forward(self, input_sentence: str) -> Tensor:

FILE: corenet/data/text_tokenizer/clip_tokenizer.py
  class ClipTokenizer (line 18) | class ClipTokenizer(BaseTextTokenizer):
    method __init__ (line 28) | def __init__(self, opts: argparse.Namespace) -> None:
    method add_arguments (line 56) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method vocab_size (line 76) | def vocab_size(self) -> int:
    method eot_token (line 81) | def eot_token(self) -> str:
    method eot_token_id (line 86) | def eot_token_id(self) -> int:
    method sot_token (line 91) | def sot_token(self) -> str:
    method sot_token_id (line 96) | def sot_token_id(self) -> int:
    method tok_encode (line 100) | def tok_encode(self, input_sentence: str) -> Tensor:

FILE: corenet/data/text_tokenizer/sentencepiece_tokenizer.py
  class SentencePieceTokenizer (line 21) | class SentencePieceTokenizer(BaseTextTokenizer):
    method __init__ (line 35) | def __init__(self, opts: Namespace) -> None:
    method add_arguments (line 60) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method vocab_size (line 92) | def vocab_size(self) -> int:
    method sot_token_id (line 101) | def sot_token_id(self) -> int:
    method eot_token_id (line 110) | def eot_token_id(self) -> int:
    method pad_token_id (line 119) | def pad_token_id(self) -> int:
    method tok_encode (line 143) | def tok_encode(self, input_sentence: str) -> Tensor:
    method tok_decode (line 170) | def tok_decode(self, token_ids: Union[torch.Tensor, List[int]]) -> str:

FILE: corenet/data/transforms/__init__.py
  function arguments_augmentation (line 19) | def arguments_augmentation(parser: argparse.ArgumentParser) -> argparse....

FILE: corenet/data/transforms/audio.py
  class Gain (line 20) | class Gain(BaseTransformation):
    method __init__ (line 25) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 34) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 56) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 84) | def __repr__(self) -> str:
  class Noise (line 94) | class Noise(BaseTransformation):
    method __init__ (line 99) | def __init__(
    method load_noise_files (line 132) | def load_noise_files(self, cache_size: int) -> List[torch.TensorType]:
    method add_arguments (line 148) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 185) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 232) | def __repr__(self) -> str:
  class SetFixedLength (line 242) | class SetFixedLength(BaseTransformation):
    method __init__ (line 245) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 251) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 269) | def __call__(
    method __repr__ (line 297) | def __repr__(self) -> str:
  class Roll (line 302) | class Roll(BaseTransformation):
    method __init__ (line 305) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 311) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 329) | def __call__(
    method __repr__ (line 359) | def __repr__(self) -> str:
  class MFCCs (line 364) | class MFCCs(BaseTransformation):
    method __init__ (line 365) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 372) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 397) | def __call__(self, data: Dict, *args, **kwargs) -> Dict:
    method __repr__ (line 431) | def __repr__(self) -> str:
  class LambdaAudio (line 438) | class LambdaAudio(BaseTransformation):
    method __init__ (line 444) | def __init__(
    method __call__ (line 454) | def __call__(self, data: Dict, *args, **kwargs) -> Dict:
  class AudioResample (line 460) | class AudioResample(BaseTransformation):
    method add_arguments (line 464) | def add_arguments(cls, parser: argparse.ArgumentParser) -> None:
    method __init__ (line 481) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method __call__ (line 487) | def __call__(self, data: Dict, *args, **kwargs) -> Dict:
    method __repr__ (line 526) | def __repr__(self) -> str:
  class StandardizeChannels (line 531) | class StandardizeChannels(BaseTransformation):
    method __init__ (line 532) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 539) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 557) | def __call__(self, data: Dict, *args, **kwargs) -> Dict:
    method __repr__ (line 603) | def __repr__(self) -> str:
  class GaussianAudioNoise (line 608) | class GaussianAudioNoise(BaseTransformation):
    method __init__ (line 612) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 619) | def add_arguments(cls, parser: argparse.ArgumentParser) -> None:
    method __call__ (line 638) | def __call__(self, data: Dict, *args, **kwargs) -> Dict:
    method __repr__ (line 661) | def __repr__(self) -> str:

FILE: corenet/data/transforms/audio_aux/mfccs.py
  function get_mfccs (line 12) | def get_mfccs(
  function calculate_mfccs (line 57) | def calculate_mfccs(
  function get_mfcc_features (line 98) | def get_mfcc_features(
  function get_padded_features (line 138) | def get_padded_features(

FILE: corenet/data/transforms/audio_bytes.py
  function _stream_to_wav (line 17) | def _stream_to_wav(x: torch.Tensor, dtype: str, audio_fps: int, backend:...
  class TorchaudioSave (line 58) | class TorchaudioSave(BaseTransformation):
    method __init__ (line 66) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method __call__ (line 75) | def __call__(
    method __repr__ (line 132) | def __repr__(self) -> str:
    method add_arguments (line 136) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...

FILE: corenet/data/transforms/base_transforms.py
  class BaseTransformation (line 10) | class BaseTransformation(object):
    method __init__ (line 15) | def __init__(self, opts, *args, **kwargs) -> None:
    method __call__ (line 18) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 21) | def __repr__(self) -> str:
    method add_arguments (line 25) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...

FILE: corenet/data/transforms/common.py
  class Compose (line 11) | class Compose(BaseTransformation):
    method __init__ (line 16) | def __init__(self, opts, img_transforms: List, *args, **kwargs) -> None:
    method __call__ (line 20) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 25) | def __repr__(self) -> str:
  class Identity (line 32) | class Identity(BaseTransformation):
    method __call__ (line 37) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 40) | def __repr__(self) -> str:

FILE: corenet/data/transforms/image_bytes.py
  function _image_to_bytes (line 17) | def _image_to_bytes(x: torch.Tensor, **kwargs) -> io.BytesIO:
  function _bytes_to_int32 (line 41) | def _bytes_to_int32(byte_array: io.BytesIO) -> torch.Tensor:
  class PILSave (line 58) | class PILSave(BaseTransformation):
    method __init__ (line 63) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method __call__ (line 69) | def __call__(
    method __repr__ (line 102) | def __repr__(self) -> str:
    method add_arguments (line 106) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
  class ShuffleBytes (line 131) | class ShuffleBytes(BaseTransformation):
    method __init__ (line 136) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method __call__ (line 143) | def __call__(
    method add_arguments (line 194) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
  class MaskPositions (line 231) | class MaskPositions(BaseTransformation):
    method __init__ (line 236) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method _generate_masks (line 241) | def _generate_masks(self, N: int) -> torch.Tensor:
    method __call__ (line 253) | def __call__(
    method add_arguments (line 273) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
  class BytePermutation (line 292) | class BytePermutation(BaseTransformation):
    method __init__ (line 297) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method __call__ (line 304) | def __call__(
    method add_arguments (line 326) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
  class RandomUniformNoise (line 339) | class RandomUniformNoise(BaseTransformation):
    method __init__ (line 344) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method __call__ (line 352) | def __call__(
    method add_arguments (line 378) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...

FILE: corenet/data/transforms/image_pil.py
  function _interpolation_modes_from_str (line 34) | def _interpolation_modes_from_str(name: str) -> T.InterpolationMode:
  function _crop_fn (line 38) | def _crop_fn(data: Dict, top: int, left: int, height: int, width: int) -...
  function _resize_fn (line 90) | def _resize_fn(
  function _pad_fn (line 173) | def _pad_fn(
  class FixedSizeCrop (line 210) | class FixedSizeCrop(BaseTransformation):
    method __init__ (line 211) | def __init__(
    method add_arguments (line 235) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 265) | def __call__(self, data: Dict, *args, **kwargs) -> Dict:
    method __repr__ (line 294) | def __repr__(self):
  class ScaleJitter (line 305) | class ScaleJitter(BaseTransformation):
    method __init__ (line 308) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 356) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 387) | def __call__(self, data: Dict, *args, **kwargs) -> Dict:
    method __repr__ (line 408) | def __repr__(self):
  class RandomResizedCrop (line 418) | class RandomResizedCrop(BaseTransformation, T.RandomResizedCrop):
    method __init__ (line 423) | def __init__(
    method add_arguments (line 443) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_rrc_params (line 476) | def get_rrc_params(self, image: Image.Image) -> Tuple[int, int, int, i...
    method __call__ (line 481) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 497) | def __repr__(self) -> str:
  class AutoAugment (line 508) | class AutoAugment(BaseTransformation, T.AutoAugment):
    method __init__ (line 513) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 532) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 555) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 568) | def __repr__(self) -> str:
  class RandAugment (line 575) | class RandAugment(BaseTransformation, T.RandAugment):
    method __init__ (line 580) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 604) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 640) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 653) | def __repr__(self) -> str:
  class TrivialAugmentWide (line 664) | class TrivialAugmentWide(BaseTransformation, T.TrivialAugmentWide):
    method __init__ (line 669) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 693) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 717) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 730) | def __repr__(self) -> str:
  class RandomHorizontalFlip (line 739) | class RandomHorizontalFlip(BaseTransformation):
    method __init__ (line 744) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 750) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 766) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 792) | def __repr__(self) -> str:
  class RandomRotate (line 797) | class RandomRotate(BaseTransformation):
    method __init__ (line 802) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 808) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 830) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 854) | def __repr__(self) -> str:
  class Resize (line 861) | class Resize(BaseTransformation):
    method __init__ (line 874) | def __init__(
    method add_arguments (line 921) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 947) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 950) | def __repr__(self) -> str:
  class CenterCrop (line 960) | class CenterCrop(BaseTransformation):
    method __init__ (line 968) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 985) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 1003) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 1009) | def __repr__(self) -> str:
  class SSDCroping (line 1016) | class SSDCroping(BaseTransformation):
    method __init__ (line 1021) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 1038) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 1074) | def __call__(self, data: Dict) -> Dict:
  class PhotometricDistort (line 1194) | class PhotometricDistort(BaseTransformation):
    method __init__ (line 1202) | def __init__(self, opts, *args, **kwargs) -> None:
    method __repr__ (line 1246) | def __repr__(self) -> str:
    method add_arguments (line 1256) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _apply_transformations (line 1326) | def _apply_transformations(self, image):
    method __call__ (line 1354) | def __call__(self, data: Dict) -> Dict:
  class BoxPercentCoords (line 1361) | class BoxPercentCoords(BaseTransformation):
    method __init__ (line 1366) | def __init__(self, opts, *args, **kwargs) -> None:
    method __call__ (line 1369) | def __call__(self, data: Dict) -> Dict:
  class InstanceProcessor (line 1385) | class InstanceProcessor(BaseTransformation):
    method __init__ (line 1390) | def __init__(
    method __call__ (line 1400) | def __call__(self, data: Dict) -> Dict:
  class RandomResize (line 1454) | class RandomResize(BaseTransformation):
    method __init__ (line 1459) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 1498) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 1540) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 1566) | def __repr__(self) -> str:
  class RandomShortSizeResize (line 1578) | class RandomShortSizeResize(BaseTransformation):
    method __init__ (line 1583) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 1638) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 1673) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 1684) | def __repr__(self) -> str:
  class RandomErasing (line 1694) | class RandomErasing(BaseTransformation, T.RandomErasing):
    method __init__ (line 1700) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 1708) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 1725) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 1729) | def __repr__(self) -> str:
  class RandomGaussianBlur (line 1736) | class RandomGaussianBlur(BaseTransformation):
    method __init__ (line 1741) | def __init__(self, opts, *args, **kwargs):
    method add_arguments (line 1746) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 1763) | def __call__(self, data: Dict) -> Dict:
  class RandomCrop (line 1773) | class RandomCrop(BaseTransformation):
    method __init__ (line 1782) | def __init__(
    method add_arguments (line 1807) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_params (line 1837) | def get_params(img_h, img_w, target_h, target_w):
    method get_params_from_box (line 1846) | def get_params_from_box(boxes, img_h, img_w):
    method get_params_from_mask (line 1856) | def get_params_from_mask(self, data, i, j, h, w):
    method _resize_if_needed (line 1886) | def _resize_if_needed(self, data: Dict) -> Dict:
    method _pad_if_needed (line 1897) | def _pad_if_needed(self, data: Dict) -> Dict:
    method __call__ (line 1916) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 1944) | def __repr__(self) -> str:
  class ToTensor (line 1955) | class ToTensor(BaseTransformation):
    method __init__ (line 1960) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 2004) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __repr__ (line 2033) | def __repr__(self):
    method __call__ (line 2050) | def __call__(self, data: Dict) -> Dict:
  class RandomOrder (line 2098) | class RandomOrder(BaseTransformation):
    method __init__ (line 2103) | def __init__(self, opts, img_transforms: List, *args, **kwargs) -> None:
    method add_arguments (line 2113) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 2130) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 2136) | def __repr__(self):
  class RandAugmentTimm (line 2145) | class RandAugmentTimm(BaseTransformation):
    method __init__ (line 2151) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 2170) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 2186) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 2204) | def __repr__(self) -> str:

FILE: corenet/data/transforms/image_torch.py
  class RandomMixup (line 22) | class RandomMixup(BaseTransformation):
    method __init__ (line 32) | def __init__(
    method add_arguments (line 53) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _apply_mixup_transform (line 99) | def _apply_mixup_transform(
    method __call__ (line 139) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 206) | def __repr__(self) -> str:
  class RandomCutmix (line 213) | class RandomCutmix(BaseTransformation):
    method __init__ (line 223) | def __init__(
    method add_arguments (line 244) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _apply_cutmix_transform (line 290) | def _apply_cutmix_transform(
    method __call__ (line 344) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 410) | def __repr__(self) -> str:
  function apply_mixing_transforms (line 416) | def apply_mixing_transforms(opts: argparse.Namespace, data: Dict) -> Dict:

FILE: corenet/data/transforms/utils.py
  function setup_size (line 11) | def setup_size(size: Any, error_msg="Need a tuple of length 2"):
  function intersect (line 26) | def intersect(box_a, box_b):
  function jaccard_numpy (line 34) | def jaccard_numpy(box_a: np.ndarray, box_b: np.ndarray):

FILE: corenet/data/transforms/video.py
  function _check_interpolation (line 32) | def _check_interpolation(interpolation):
  function _crop_fn (line 41) | def _crop_fn(data: Dict, i: int, j: int, h: int, w: int) -> Dict:
  function _resize_fn (line 75) | def _resize_fn(
  function check_rgb_video_tensor (line 145) | def check_rgb_video_tensor(clip: torch.Tensor) -> None:
  class ToTensor (line 161) | class ToTensor(BaseTransformation):
    method __init__ (line 176) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method __call__ (line 179) | def __call__(self, data: Dict) -> Dict:
  class ToPixelArray (line 196) | class ToPixelArray(BaseTransformation):
    method __call__ (line 208) | def __call__(self, data: Dict) -> Dict:
  class SaveInputs (line 217) | class SaveInputs(BaseTransformation):
    method __init__ (line 218) | def __init__(
    method __call__ (line 258) | def __call__(self, data: Dict) -> Dict:
    method add_arguments (line 281) | def add_arguments(cls, parser: argparse.ArgumentParser) -> None:
    method _srt_format_timestamp (line 322) | def _srt_format_timestamp(t: float) -> str:
    method save_video_with_annotations (line 330) | def save_video_with_annotations(
    method __repr__ (line 418) | def __repr__(self) -> str:
  class RandomResizedCrop (line 431) | class RandomResizedCrop(BaseTransformation):
    method __init__ (line 436) | def __init__(self, opts, size: Union[Tuple, int], *args, **kwargs) -> ...
    method add_arguments (line 479) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_params (line 518) | def get_params(self, height: int, width: int) -> (int, int, int, int):
    method __call__ (line 548) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 558) | def __repr__(self) -> str:
  class RandomShortSizeResizeCrop (line 569) | class RandomShortSizeResizeCrop(BaseTransformation):
    method __init__ (line 579) | def __init__(self, opts, size: Union[Tuple, int], *args, **kwargs) -> ...
    method add_arguments (line 624) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_params (line 656) | def get_params(self, height, width) -> Tuple[int, int, int, int]:
    method __call__ (line 666) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 678) | def __repr__(self) -> str:
  class RandomCrop (line 690) | class RandomCrop(BaseTransformation):
    method __init__ (line 699) | def __init__(self, opts, size: Union[Tuple, int], *args, **kwargs) -> ...
    method add_arguments (line 706) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_params (line 719) | def get_params(self, height: int, width: int) -> Tuple[int, int, int, ...
    method __call__ (line 729) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 736) | def __repr__(self) -> str:
  class RandomHorizontalFlip (line 743) | class RandomHorizontalFlip(BaseTransformation):
    method __init__ (line 748) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 755) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 773) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 787) | def __repr__(self) -> str:
  class CenterCrop (line 795) | class CenterCrop(BaseTransformation):
    method __init__ (line 804) | def __init__(self, opts, size: Union[Sequence, int], *args, **kwargs) ...
    method add_arguments (line 818) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 831) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 837) | def __repr__(self) -> str:
  class Resize (line 844) | class Resize(BaseTransformation):
    method __init__ (line 855) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 883) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 914) | def __call__(self, data: Dict) -> Dict:
    method __repr__ (line 917) | def __repr__(self) -> str:
  class CropByBoundingBox (line 924) | class CropByBoundingBox(BaseTransformation):
    method __init__ (line 939) | def __init__(
    method __call__ (line 972) | def __call__(self, data: Dict, *args, **kwargs) -> Dict:
    method expand_boxes (line 1071) | def expand_boxes(
    method get_new_x0 (line 1119) | def get_new_x0(cls, multiplier: float) -> float:
    method add_arguments (line 1126) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __repr__ (line 1184) | def __repr__(self) -> str:
  class ShuffleAudios (line 1194) | class ShuffleAudios(BaseTransformation):
    method __init__ (line 1195) | def __init__(
    method add_arguments (line 1244) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _single_cycle_permutation (line 1304) | def _single_cycle_permutation(
    method _random_outcome (line 1348) | def _random_outcome(self, n: int) -> torch.Tensor:
    method _random_participants_mask (line 1365) | def _random_participants_mask(self, n: int) -> torch.BoolTensor:
    method __call__ (line 1373) | def __call__(self, data: Dict) -> Dict:

FILE: corenet/data/video_reader/__init__.py
  function arguments_video_reader (line 21) | def arguments_video_reader(parser: argparse.ArgumentParser):
  function get_video_reader (line 29) | def get_video_reader(

FILE: corenet/data/video_reader/base_av_reader.py
  class VideoDurationDoesNotMatchAudioDurationError (line 26) | class VideoDurationDoesNotMatchAudioDurationError(AssertionError):
  function check_audio_video_duration (line 33) | def check_audio_video_duration(
  class BaseAVReader (line 47) | class BaseAVReader(object):
    method add_arguments (line 57) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __init__ (line 93) | def __init__(
    method get_frame_transform (line 118) | def get_frame_transform(
    method __repr__ (line 163) | def __repr__(self):
    method check_video (line 170) | def check_video(self, filename: str) -> bool:
    method read_video (line 182) | def read_video(
    method build_video_metadata (line 194) | def build_video_metadata(
    method num_frames (line 213) | def num_frames(self, filename: str) -> int:
    method random_sampling (line 223) | def random_sampling(
    method uniform_sampling (line 262) | def uniform_sampling(
    method read_video_file_into_clips (line 305) | def read_video_file_into_clips(
    method _generate_video_clips (line 454) | def _generate_video_clips(
    method _generate_audio_clips (line 546) | def _generate_audio_clips(
    method dummy_audio_video_clips (line 600) | def dummy_audio_video_clips(
  function _downsample_frame_indices (line 647) | def _downsample_frame_indices(

FILE: corenet/data/video_reader/decord_reader.py
  class DecordAVReader (line 26) | class DecordAVReader(BaseAVReader):
    method __init__ (line 31) | def __init__(self, *args, **kwargs):
    method read_video (line 35) | def read_video(
    method build_video_metadata (line 97) | def build_video_metadata(
    method build_audio_metadata (line 126) | def build_audio_metadata(
    method _get_total_audio_frames (line 166) | def _get_total_audio_frames(video_path: str, sample_rate: Union[int, f...

FILE: corenet/data/video_reader/ffmpeg_reader.py
  class FFMPEGReader (line 29) | class FFMPEGReader(BaseAVReader):
    method __init__ (line 37) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method read_video (line 41) | def read_video(
    method _transform_video_frames (line 209) | def _transform_video_frames(
    method read_audio (line 237) | def read_audio(
    method build_video_metadata (line 298) | def build_video_metadata(cls, video_path: str) -> Dict[str, Union[str,...
    method build_audio_metadata (line 318) | def build_audio_metadata(cls, video_path: str) -> Dict[str, Union[str,...

FILE: corenet/data/video_reader/ffmpeg_utils.py
  class FFMPEGError (line 45) | class FFMPEGError(Exception):
    method __init__ (line 46) | def __init__(self, message: str, stderr: Union[IOBase, bytes, str]):
  function _parse_stream_duration (line 54) | def _parse_stream_duration(stream: Dict[str, Any]) -> float:
  function ffprobe (line 74) | def ffprobe(video_path: str, parse_json: bool = True) -> Union[str, Dict...
  function get_video_metadata (line 117) | def get_video_metadata(
  function get_audio_metadata (line 210) | def get_audio_metadata(
  function get_flags_to_replicate_audio_codec (line 256) | def get_flags_to_replicate_audio_codec(input_filename: str) -> Dict:
  function transform_video_file (line 314) | def transform_video_file(
  function _kill_subprocess (line 643) | def _kill_subprocess(process: subprocess.Popen, timeout_seconds: float =...
  function write_video (line 658) | def write_video(
  function write_audio (line 732) | def write_audio(

FILE: corenet/data/video_reader/pyav_reader.py
  class PyAVReader (line 18) | class PyAVReader(BaseAVReader):
    method read_video (line 23) | def read_video(
    method build_video_metadata (line 105) | def build_video_metadata(

FILE: corenet/engine/default_trainer.py
  class DefaultTrainer (line 41) | class DefaultTrainer(object):
    method __init__ (line 60) | def __init__(
    method compute_grad_norm (line 139) | def compute_grad_norm(self) -> torch.Tensor:
    method _zero_grad (line 161) | def _zero_grad(self) -> None:
    method _set_training_mode (line 174) | def _set_training_mode(self) -> None:
    method _set_eval_mode (line 181) | def _set_eval_mode(self) -> None:
    method _save_and_evaluate_interval_checkpoint (line 188) | def _save_and_evaluate_interval_checkpoint(
    method train_epoch (line 249) | def train_epoch(self, epoch: int) -> Tuple[float, float]:
    method val_epoch (line 408) | def val_epoch(
    method run (line 516) | def run(

FILE: corenet/engine/detection_utils/coco_map.py
  function coco_evaluation (line 19) | def coco_evaluation(
  function compute_quant_scores (line 105) | def compute_quant_scores(opts, predictions: List, *args, **kwargs) -> None:

FILE: corenet/engine/eval_detection.py
  function predict_and_save (line 39) | def predict_and_save(
  function read_and_process_image (line 172) | def read_and_process_image(
  function predict_labeled_dataset (line 205) | def predict_labeled_dataset(opts: argparse.Namespace) -> None:
  function predict_image (line 261) | def predict_image(opts: argparse.Namespace, file_path: str) -> None:
  function predict_images_in_folder (line 300) | def predict_images_in_folder(opts: argparse.Namespace) -> None:
  function main_detection_evaluation (line 356) | def main_detection_evaluation(args: Optional[List[str]] = None) -> None:

FILE: corenet/engine/eval_segmentation.py
  function predict_and_save (line 43) | def predict_and_save(
  function save_segmentation_masks (line 167) | def save_segmentation_masks(
  function apply_color_map_to_segmentation_masks (line 196) | def apply_color_map_to_segmentation_masks(
  function read_and_process_image (line 278) | def read_and_process_image(
  function predict_labeled_dataset (line 313) | def predict_labeled_dataset(opts: argparse.Namespace) -> None:
  function predict_image (line 396) | def predict_image(opts: argparse.Namespace, file_path: str) -> None:
  function predict_images_in_folder (line 441) | def predict_images_in_folder(opts: argparse.Namespace) -> None:
  function main_segmentation_evaluation (line 511) | def main_segmentation_evaluation(args: Optional[List[str]] = None) -> None:

FILE: corenet/engine/evaluation_engine.py
  class Evaluator (line 24) | class Evaluator:
    method __init__ (line 25) | def __init__(
    method eval_fn (line 70) | def eval_fn(self) -> None:
    method run (line 129) | def run(self) -> None:

FILE: corenet/engine/fsdp_trainer.py
  class FSDPTrainer (line 30) | class FSDPTrainer(DefaultTrainer):
    method __init__ (line 48) | def __init__(
    method train_epoch (line 90) | def train_epoch(self, epoch: int) -> Tuple[float, float]:

FILE: corenet/engine/segmentation_utils/cityscapes_iou.py
  function eval_cityscapes (line 14) | def eval_cityscapes(pred_dir: str, gt_dir: str) -> None:

FILE: corenet/engine/utils.py
  function autocast_fn (line 23) | def autocast_fn(enabled: bool, amp_precision: Optional[str] = "float16"):
  function get_batch_size (line 43) | def get_batch_size(x: Union[Tensor, Dict, List]) -> int:
  function log_metrics (line 57) | def log_metrics(
  function flatten (line 78) | def flatten(
  function step_log_metrics (line 103) | def step_log_metrics(
  function get_log_writers (line 130) | def get_log_writers(opts: argparse.Namespace, save_location: Optional[st...

FILE: corenet/loss_fn/__init__.py
  function build_loss_fn (line 22) | def build_loss_fn(
  function add_loss_fn_arguments (line 65) | def add_loss_fn_arguments(parser: argparse.ArgumentParser) -> argparse.A...

FILE: corenet/loss_fn/base_criteria.py
  class BaseCriteria (line 15) | class BaseCriteria(nn.Module, abc.ABC):
    method __init__ (line 22) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 29) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method forward (line 45) | def forward(
    method extra_repr (line 57) | def extra_repr(self) -> str:
    method __repr__ (line 60) | def __repr__(self) -> str:

FILE: corenet/loss_fn/classification/base_classification_criteria.py
  class BaseClassificationCriteria (line 14) | class BaseClassificationCriteria(BaseCriteria):
    method __init__ (line 21) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 25) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _compute_loss (line 40) | def _compute_loss(
    method forward (line 54) | def forward(

FILE: corenet/loss_fn/classification/binary_cross_entropy.py
  class BinaryCrossEntropy (line 18) | class BinaryCrossEntropy(BaseClassificationCriteria):
    method __init__ (line 25) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 33) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _compute_loss (line 49) | def _compute_loss(
    method extra_repr (line 88) | def extra_repr(self) -> str:

FILE: corenet/loss_fn/classification/cross_entropy.py
  class CrossEntropy (line 19) | class CrossEntropy(BaseClassificationCriteria):
    method __init__ (line 26) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 40) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _compute_loss (line 68) | def _compute_loss(
    method extra_repr (line 97) | def extra_repr(self) -> str:

FILE: corenet/loss_fn/classification/focal_loss.py
  class FocalLoss (line 19) | class FocalLoss(BaseClassificationCriteria):
    method __init__ (line 33) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 41) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _compute_loss (line 62) | def _compute_loss(
    method extra_repr (line 96) | def extra_repr(self) -> str:

FILE: corenet/loss_fn/composite_loss.py
  class CompositeLoss (line 21) | class CompositeLoss(BaseCriteria):
    method __init__ (line 53) | def __init__(
    method build_composite_loss_fn (line 70) | def build_composite_loss_fn(
    method add_arguments (line 150) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method forward (line 160) | def forward(
    method train (line 209) | def train(self, mode: bool = True) -> None:
    method eval (line 214) | def eval(self) -> None:
    method __repr__ (line 219) | def __repr__(self) -> str:

FILE: corenet/loss_fn/detection/base_detection_criteria.py
  class BaseDetectionCriteria (line 10) | class BaseDetectionCriteria(BaseCriteria):
    method __init__ (line 17) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 21) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...

FILE: corenet/loss_fn/detection/mask_rcnn_loss.py
  class MaskRCNNLoss (line 18) | class MaskRCNNLoss(BaseDetectionCriteria):
    method __init__ (line 26) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 45) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method forward (line 82) | def forward(
    method extra_repr (line 153) | def extra_repr(self) -> str:

FILE: corenet/loss_fn/detection/ssd_multibox_loss.py
  class SSDLoss (line 22) | class SSDLoss(BaseDetectionCriteria):
    method __init__ (line 29) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method reset_unscaled_loss_values (line 59) | def reset_unscaled_loss_values(self) -> None:
    method add_arguments (line 66) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method forward (line 102) | def forward(
    method extra_repr (line 216) | def extra_repr(self) -> str:

FILE: corenet/loss_fn/distillation/base_distillation.py
  class BaseDistillationCriteria (line 16) | class BaseDistillationCriteria(BaseCriteria):
    method __init__ (line 23) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 29) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _logits_from_teacher (line 44) | def _logits_from_teacher(self, input_sample: Tensor) -> Tensor:
    method _forward_distill (line 72) | def _forward_distill(
    method forward (line 90) | def forward(

FILE: corenet/loss_fn/distillation/hard_distillation.py
  class HardDistillationLoss (line 18) | class HardDistillationLoss(BaseDistillationCriteria):
    method __init__ (line 26) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 45) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _forward_distill (line 66) | def _forward_distill(
    method extra_repr (line 128) | def extra_repr(self) -> str:

FILE: corenet/loss_fn/distillation/soft_kl_distillation.py
  class SoftKLLoss (line 18) | class SoftKLLoss(BaseDistillationCriteria):
    method __init__ (line 26) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 38) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _forward_distill (line 52) | def _forward_distill(
    method extra_repr (line 80) | def extra_repr(self) -> str:

FILE: corenet/loss_fn/language_modeling/base_lm.py
  class BaseLanguageModelingCriteria (line 16) | class BaseLanguageModelingCriteria(BaseCriteria):
    method add_arguments (line 27) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _compute_loss (line 39) | def _compute_loss(self, prediction: Tensor, target: Tensor) -> Tensor:
    method forward (line 53) | def forward(

FILE: corenet/loss_fn/language_modeling/cross_entropy.py
  class CrossEntropyLM (line 17) | class CrossEntropyLM(BaseLanguageModelingCriteria):
    method __init__ (line 24) | def __init__(self, opts: argparse.Namespace) -> None:
    method add_arguments (line 46) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _compute_loss (line 78) | def _compute_loss(
    method extra_repr (line 117) | def extra_repr(self) -> str:

FILE: corenet/loss_fn/language_modeling/cross_entropy_for_kv_prediction.py
  class CrossEntropyForKVPrediction (line 20) | class CrossEntropyForKVPrediction(BaseCriteria):
    method __init__ (line 29) | def __init__(self, opts: argparse.Namespace) -> None:
    method add_arguments (line 62) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method forward (line 113) | def forward(
    method _compute_loss (line 179) | def _compute_loss(
    method extra_repr (line 276) | def extra_repr(self) -> str:
  function get_cache_losses (line 292) | def get_cache_losses(

FILE: corenet/loss_fn/multi_modal_img_text/base_multi_modal_img_text_criteria.py
  class BaseMultiModalImageTextCriteria (line 10) | class BaseMultiModalImageTextCriteria(BaseCriteria):
    method __init__ (line 17) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 21) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...

FILE: corenet/loss_fn/multi_modal_img_text/contrastive_loss_clip.py
  class ContrastiveLossClip (line 21) | class ContrastiveLossClip(BaseMultiModalImageTextCriteria):
    method __init__ (line 28) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method _forward_clip (line 35) | def _forward_clip(
    method forward (line 105) | def forward(
  function gather_features (line 144) | def gather_features(

FILE: corenet/loss_fn/neural_augmentation.py
  class NeuralAugmentation (line 20) | class NeuralAugmentation(BaseCriteria):
    method __init__ (line 30) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 142) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _forward_psnr (line 178) | def _forward_psnr(
    method _compute_loss (line 220) | def _compute_loss(
    method forward (line 246) | def forward(
    method extra_repr (line 300) | def extra_repr(self) -> str:
  function linear_curriculum (line 314) | def linear_curriculum(start: int, end: int, period: int) -> Tensor:
  function cosine_curriculum (line 328) | def cosine_curriculum(start: int, end: int, period: int) -> Tensor:

FILE: corenet/loss_fn/segmentation/base_segmentation_criteria.py
  class BaseSegmentationCriteria (line 10) | class BaseSegmentationCriteria(BaseCriteria):
    method __init__ (line 17) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 21) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...

FILE: corenet/loss_fn/segmentation/cross_entropy.py
  class SegCrossEntropy (line 21) | class SegCrossEntropy(BaseSegmentationCriteria):
    method __init__ (line 28) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 40) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _compute_loss (line 77) | def _compute_loss(
    method _forward_seg (line 120) | def _forward_seg(
    method forward (line 192) | def forward(
    method extra_repr (line 256) | def extra_repr(self) -> str:

FILE: corenet/loss_fn/utils/build_helper.py
  function build_cls_teacher_from_opts (line 14) | def build_cls_teacher_from_opts(opts: argparse.Namespace) -> nn.Module:

FILE: corenet/loss_fn/utils/class_weighting.py
  function compute_class_weights (line 10) | def compute_class_weights(

FILE: corenet/metrics/__init__.py
  function arguments_stats (line 17) | def arguments_stats(parser: argparse.ArgumentParser):

FILE: corenet/metrics/average_precision.py
  class AveragePrecisionMetric (line 21) | class AveragePrecisionMetric(EpochMetric):
    method compute_with_aggregates (line 22) | def compute_with_aggregates(

FILE: corenet/metrics/coco_map.py
  class COCOEvaluator (line 27) | class COCOEvaluator(BaseMetric):
    method __init__ (line 28) | def __init__(
    method reset (line 68) | def reset(self) -> None:
    method update (line 71) | def update(
    method prepare_cache_results (line 120) | def prepare_cache_results(
    method summarize_coco_results (line 213) | def summarize_coco_results(self) -> Dict:
    method compute (line 245) | def compute(self) -> Dict[str, float]:

FILE: corenet/metrics/confusion_mat.py
  class ConfusionMatrix (line 19) | class ConfusionMatrix(BaseMetric):
    method reset (line 24) | def reset(self):
    method update (line 28) | def update(
    method compute (line 62) | def compute(self) -> Union[Number, Dict[str, Union[Number, List[Number...

FILE: corenet/metrics/image_text_retrieval.py
  class ImageTextRetrievalMetric (line 21) | class ImageTextRetrievalMetric(BaseMetric):
    method __init__ (line 39) | def __init__(
    method add_arguments (line 60) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method reset (line 72) | def reset(self) -> None:
    method update (line 76) | def update(
    method get_aggregates (line 104) | def get_aggregates(self) -> Tuple[Tensor, Tensor]:
    method _text2image (line 110) | def _text2image(
    method _image2text (line 135) | def _image2text(
    method compute (line 161) | def compute(self) -> Union[Number, Dict[str, Number]]:
    method _rank_metrics (line 185) | def _rank_metrics(self, ranks: torch.LongTensor) -> Dict[str, Number]:

FILE: corenet/metrics/intersection_over_union.py
  function compute_miou_batch (line 18) | def compute_miou_batch(
  class IOUMetric (line 57) | class IOUMetric(AverageMetric):
    method gather_metrics (line 58) | def gather_metrics(
    method compute (line 86) | def compute(self) -> Union[Number, Dict[str, Number]]:

FILE: corenet/metrics/metric_base.py
  class BaseMetric (line 24) | class BaseMetric(abc.ABC):
    method __init__ (line 25) | def __init__(
    method add_arguments (line 41) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method reset (line 46) | def reset(self) -> None:
    method update (line 54) | def update(
    method compute (line 76) | def compute(
    method preprocess_predictions (line 94) | def preprocess_predictions(
    method preprocess_targets (line 102) | def preprocess_targets(self, target: Union[Tensor, Dict]) -> Union[Ten...
    method summary_string (line 108) | def summary_string(self, name: str, sep: str, values: Dict[str, Any]) ...
    method is_epoch_summary_enabled_for_metric (line 126) | def is_epoch_summary_enabled_for_metric(
    method flatten_metric (line 147) | def flatten_metric(
  class AverageMetric (line 165) | class AverageMetric(BaseMetric):
    method reset (line 166) | def reset(self):
    method gather_metrics (line 171) | def gather_metrics(
    method _aggregate_ddp_sum (line 181) | def _aggregate_ddp_sum(
    method update (line 200) | def update(
    method compute (line 239) | def compute(self) -> Union[Number, List, Dict[str, Any]]:
  class EpochMetric (line 249) | class EpochMetric(BaseMetric):
    method __init__ (line 250) | def __init__(
    method reset (line 261) | def reset(self):
    method update (line 265) | def update(
    method get_aggregates (line 304) | def get_aggregates(self) -> Tuple[Tensor, Tensor]:
    method compute_with_aggregates (line 318) | def compute_with_aggregates(self, predictions: Tensor, targets: Tensor):
    method compute (line 330) | def compute(self) -> Union[Number, List, Dict[str, Any]]:

FILE: corenet/metrics/metric_base_test.py
  class DummyMetric (line 14) | class DummyMetric(AverageMetric):
    method gather_metrics (line 15) | def gather_metrics(
  function test_average_metric_distributed_batchsize (line 24) | def test_average_metric_distributed_batchsize(mocker):

FILE: corenet/metrics/misc.py
  class LossMetric (line 18) | class LossMetric(AverageMetric):
    method gather_metrics (line 19) | def gather_metrics(
  class GradNormMetric (line 61) | class GradNormMetric(AverageMetric):
    method gather_metrics (line 62) | def gather_metrics(

FILE: corenet/metrics/multiclass_classification_pr.py
  function get_recall_at_precision (line 21) | def get_recall_at_precision(
  function compute_oi_f1 (line 56) | def compute_oi_f1(predictions: Tensor, targets: Tensor) -> Tuple[float, ...
  class MulticlassClassificationPR (line 133) | class MulticlassClassificationPR(BaseMetric):
    method __init__ (line 149) | def __init__(
    method add_arguments (line 170) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method reset (line 198) | def reset(self) -> None:
    method update (line 206) | def update(
    method compute (line 289) | def compute(self) -> Dict[str, Union[Number, List[List[Number]]]]:
    method is_epoch_summary_enabled_for_metric (line 393) | def is_epoch_summary_enabled_for_metric(
    method flatten_metric (line 427) | def flatten_metric(
    method summary_string (line 448) | def summary_string(self, name: str, sep: str, values: Dict[str, Any]) ...

FILE: corenet/metrics/probability_histograms.py
  class ProbabilityHistogramMetric (line 20) | class ProbabilityHistogramMetric(EpochMetric):
    method __init__ (line 21) | def __init__(
    method add_arguments (line 32) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method compute_with_aggregates (line 40) | def compute_with_aggregates(

FILE: corenet/metrics/psnr.py
  function compute_psnr (line 16) | def compute_psnr(
  class PSNRMetric (line 34) | class PSNRMetric(AverageMetric):
    method gather_metrics (line 35) | def gather_metrics(

FILE: corenet/metrics/retrieval_cmc.py
  function cosine_distance_matrix (line 25) | def cosine_distance_matrix(x: torch.Tensor, y: torch.Tensor) -> torch.Te...
  function l2_distance_matrix (line 47) | def l2_distance_matrix(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
  class RetrievalCMC (line 64) | class RetrievalCMC(EpochMetric):
    method __init__ (line 69) | def __init__(
    method add_arguments (line 97) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method compute_with_aggregates (line 125) | def compute_with_aggregates(
  function cmc_calculation (line 174) | def cmc_calculation(
  function mean_ap (line 204) | def mean_ap(

FILE: corenet/metrics/stats.py
  class Statistics (line 23) | class Statistics(object):
    method __init__ (line 24) | def __init__(
    method update (line 57) | def update(
    method _avg_statistics_all (line 94) | def _avg_statistics_all(self, sep=": ", metrics=None) -> List[str]:
    method _compute_avg_statistics_all (line 111) | def _compute_avg_statistics_all(self) -> Dict[str, Union[float, Dict]]:
    method avg_statistics (line 122) | def avg_statistics(
    method iter_summary (line 163) | def iter_summary(
    method epoch_summary (line 196) | def epoch_summary(

FILE: corenet/metrics/topk_accuracy.py
  function top_k_accuracy (line 15) | def top_k_accuracy(
  class TopKMetric (line 33) | class TopKMetric(AverageMetric):
    method gather_metrics (line 36) | def gather_metrics(
  class Top1Metric (line 109) | class Top1Metric(TopKMetric):
  class Top5Metric (line 114) | class Top5Metric(TopKMetric):

FILE: corenet/metrics/vqa_preset_score.py
  function vqa_preset_score_metric (line 17) | def vqa_preset_score_metric(output: Tensor, target: Tensor) -> list:
  class VQAPresetScoreMetric (line 43) | class VQAPresetScoreMetric(AverageMetric):
    method gather_metrics (line 46) | def gather_metrics(

FILE: corenet/modeling/__init__.py
  function modeling_arguments (line 21) | def modeling_arguments(parser: argparse.ArgumentParser) -> argparse.Argu...

FILE: corenet/modeling/anchor_generator/__init__.py
  function arguments_anchor_gen (line 21) | def arguments_anchor_gen(parser: argparse.ArgumentParser) -> argparse.Ar...
  function build_anchor_generator (line 33) | def build_anchor_generator(opts, *args, **kwargs):

FILE: corenet/modeling/anchor_generator/base_anchor_generator.py
  class BaseAnchorGenerator (line 13) | class BaseAnchorGenerator(torch.nn.Module):
    method __init__ (line 18) | def __init__(self, *args, **kwargs) -> None:
    method add_arguments (line 23) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method num_anchors_per_os (line 29) | def num_anchors_per_os(self):
    method _generate_anchors (line 34) | def _generate_anchors(
    method _get_anchors (line 46) | def _get_anchors(
    method forward (line 71) | def forward(

FILE: corenet/modeling/anchor_generator/ssd_anchor_generator.py
  class SSDAnchorGenerator (line 19) | class SSDAnchorGenerator(BaseAnchorGenerator):
    method __init__ (line 25) | def __init__(self, opts, *args, **kwargs) -> None:
    method __repr__ (line 74) | def __repr__(self):
    method add_arguments (line 85) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method num_anchors_per_os (line 135) | def num_anchors_per_os(self) -> List:
    method _generate_anchors (line 142) | def _generate_anchors(

FILE: corenet/modeling/image_projection_layers/__init__.py
  function arguments_image_projection_head (line 23) | def arguments_image_projection_head(
  function build_image_projection_head (line 35) | def build_image_projection_head(

FILE: corenet/modeling/image_projection_layers/attention_pool_2d.py
  class AttentionPool2dHead (line 21) | class AttentionPool2dHead(BaseImageProjectionHead):
    method __init__ (line 26) | def __init__(self, opts, in_dim: int, out_dim: int, *args, **kwargs) -...
    method add_arguments (line 80) | def add_arguments(cls, parser: argparse.ArgumentParser):
    method reset_parameters (line 116) | def reset_parameters(self):
    method forward (line 121) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:

FILE: corenet/modeling/image_projection_layers/base_image_projection.py
  class BaseImageProjectionHead (line 15) | class BaseImageProjectionHead(nn.Module):
    method __init__ (line 18) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 24) | def add_arguments(cls, parser: argparse.ArgumentParser):
    method reset_parameters (line 44) | def reset_parameters(self) -> None:
    method get_trainable_parameters (line 48) | def get_trainable_parameters(
    method forward (line 62) | def forward(self, input: Dict, *args, **kwargs) -> Dict:
  function get_in_feature_dimension (line 66) | def get_in_feature_dimension(image_classifier: nn.Module) -> int:

FILE: corenet/modeling/image_projection_layers/global_pool_2d.py
  class GlobalPool2D (line 22) | class GlobalPool2D(BaseImageProjectionHead):
    method __init__ (line 25) | def __init__(self, opts, in_dim: int, out_dim: int, *args, **kwargs) -...
    method add_arguments (line 55) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method reset_parameters (line 73) | def reset_parameters(self):
    method forward (line 76) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:

FILE: corenet/modeling/image_projection_layers/simple_projection_head.py
  class SimpleImageProjectionHead (line 21) | class SimpleImageProjectionHead(BaseImageProjectionHead):
    method __init__ (line 24) | def __init__(self, opts, in_dim: int, out_dim: int, *args, **kwargs) -...
    method add_arguments (line 53) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method reset_parameters (line 71) | def reset_parameters(self):
    method forward (line 74) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:

FILE: corenet/modeling/layers/__init__.py
  function layer_specific_args (line 82) | def layer_specific_args(parser: argparse.ArgumentParser):
  function arguments_nn_layers (line 101) | def arguments_nn_layers(parser: argparse.ArgumentParser):

FILE: corenet/modeling/layers/activation/__init__.py
  function register_act_fn (line 19) | def register_act_fn(name):
  function arguments_activation_fn (line 32) | def arguments_activation_fn(parser: argparse.ArgumentParser):
  function build_activation_layer (line 58) | def build_activation_layer(

FILE: corenet/modeling/layers/activation/gelu.py
  class GELU (line 12) | class GELU(nn.GELU):
    method __init__ (line 17) | def __init__(self, *args, **kwargs) -> None:

FILE: corenet/modeling/layers/activation/hard_sigmoid.py
  class Hardsigmoid (line 15) | class Hardsigmoid(nn.Hardsigmoid):
    method __init__ (line 20) | def __init__(self, inplace: Optional[bool] = False, *args, **kwargs) -...
    method forward (line 23) | def forward(self, input: Tensor, *args, **kwargs) -> Tensor:

FILE: corenet/modeling/layers/activation/hard_swish.py
  class Hardswish (line 15) | class Hardswish(nn.Hardswish):
    method __init__ (line 21) | def __init__(self, inplace: Optional[bool] = False, *args, **kwargs) -...
    method forward (line 24) | def forward(self, input: Tensor, *args, **kwargs) -> Tensor:

FILE: corenet/modeling/layers/activation/leaky_relu.py
  class LeakyReLU (line 14) | class LeakyReLU(nn.LeakyReLU):
    method __init__ (line 20) | def __init__(

FILE: corenet/modeling/layers/activation/prelu.py
  class PReLU (line 14) | class PReLU(nn.PReLU):
    method __init__ (line 19) | def __init__(

FILE: corenet/modeling/layers/activation/relu.py
  class ReLU (line 14) | class ReLU(nn.ReLU):
    method __init__ (line 19) | def __init__(self, inplace: Optional[bool] = False, *args, **kwargs) -...

FILE: corenet/modeling/layers/activation/relu6.py
  class ReLU6 (line 14) | class ReLU6(nn.ReLU6):
    method __init__ (line 19) | def __init__(self, inplace: Optional[bool] = False, *args, **kwargs) -...

FILE: corenet/modeling/layers/activation/sigmoid.py
  class Sigmoid (line 12) | class Sigmoid(nn.Sigmoid):
    method __init__ (line 17) | def __init__(self, *args, **kwargs) -> None:

FILE: corenet/modeling/layers/activation/swish.py
  class Swish (line 14) | class Swish(nn.SiLU):
    method __init__ (line 19) | def __init__(self, inplace: Optional[bool] = False, *args, **kwargs) -...

FILE: corenet/modeling/layers/activation/tanh.py
  class Tanh (line 12) | class Tanh(nn.Tanh):
    method __init__ (line 17) | def __init__(self, *args, **kwargs) -> None:

FILE: corenet/modeling/layers/adaptive_pool.py
  class AdaptiveAvgPool2d (line 11) | class AdaptiveAvgPool2d(nn.AdaptiveAvgPool2d):
    method __init__ (line 25) | def __init__(

FILE: corenet/modeling/layers/base_layer.py
  class BaseLayer (line 14) | class BaseLayer(nn.Module):
    method __init__ (line 19) | def __init__(self, *args, **kwargs) -> None:
    method add_arguments (line 23) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_trainable_parameters (line 27) | def get_trainable_parameters(
    method forward (line 58) | def forward(self, *args, **kwargs) -> Any:
    method __repr__ (line 62) | def __repr__(self):

FILE: corenet/modeling/layers/conv_layer.py
  class Conv2d (line 18) | class Conv2d(nn.Conv2d):
    method __init__ (line 42) | def __init__(
  class _BaseConvNormActLayer (line 69) | class _BaseConvNormActLayer(BaseLayer):
    method ndim (line 110) | def ndim(self) -> int:
    method module_cls (line 114) | def module_cls(self) -> Type[nn.Module]:
    method __init__ (line 117) | def __init__(
    method add_arguments (line 236) | def add_arguments(cls, parser: argparse.ArgumentParser):
    method forward (line 254) | def forward(self, x: Tensor) -> Tensor:
    method __repr__ (line 257) | def __repr__(self):
  class ConvLayer1d (line 270) | class ConvLayer1d(_BaseConvNormActLayer):
  class ConvLayer2d (line 275) | class ConvLayer2d(_BaseConvNormActLayer):
  class ConvLayer3d (line 280) | class ConvLayer3d(_BaseConvNormActLayer):
  class TransposeConvLayer2d (line 285) | class TransposeConvLayer2d(BaseLayer):
    method __init__ (line 316) | def __init__(
    method forward (line 435) | def forward(self, x: Tensor) -> Tensor:
    method __repr__ (line 438) | def __repr__(self):
  class NormActLayer (line 451) | class NormActLayer(BaseLayer):
    method __init__ (line 464) | def __init__(self, opts, num_features, *args, **kwargs):
    method forward (line 484) | def forward(self, x: Tensor) -> Tensor:
    method __repr__ (line 487) | def __repr__(self):
  class _BaseSeparableConv (line 494) | class _BaseSeparableConv(BaseLayer):
    method __init__ (line 528) | def __init__(
    method conv_layer_cls (line 582) | def conv_layer_cls(self):
    method __repr__ (line 585) | def __repr__(self):
    method forward (line 596) | def forward(self, x: Tensor) -> Tensor:
  class SeparableConv1d (line 602) | class SeparableConv1d(_BaseSeparableConv):
  class SeparableConv2d (line 606) | class SeparableConv2d(_BaseSeparableConv):
  class SeparableConv3d (line 610) | class SeparableConv3d(_BaseSeparableConv):

FILE: corenet/modeling/layers/dropout.py
  class Dropout (line 11) | class Dropout(nn.Dropout):
    method __init__ (line 26) | def __init__(
  class Dropout2d (line 32) | class Dropout2d(nn.Dropout2d):
    method __init__ (line 48) | def __init__(self, p: float = 0.5, inplace: bool = False):

FILE: corenet/modeling/layers/embedding.py
  class Embedding (line 16) | class Embedding(nn.Embedding):
    method __init__ (line 33) | def __init__(
    method reset_parameters (line 48) | def reset_parameters(self) -> None:

FILE: corenet/modeling/layers/flash_multi_head_attention.py
  class FlashMultiHeadSelfAttention (line 18) | class FlashMultiHeadSelfAttention(BaseLayer):
    method __init__ (line 32) | def __init__(
    method forward (line 75) | def forward(self, x: Tensor) -> Tensor:

FILE: corenet/modeling/layers/flatten.py
  class Flatten (line 11) | class Flatten(nn.Flatten):
    method __init__ (line 26) | def __init__(self, start_dim: Optional[int] = 1, end_dim: Optional[int...

FILE: corenet/modeling/layers/global_pool.py
  class GlobalPool (line 16) | class GlobalPool(BaseLayer):
    method __init__ (line 31) | def __init__(
    method add_arguments (line 49) | def add_arguments(cls, parser: argparse.ArgumentParser):
    method _global_pool (line 60) | def _global_pool(self, x: Tensor, dims: List):
    method forward (line 73) | def forward(self, x: Tensor) -> Tensor:
    method __repr__ (line 82) | def __repr__(self):

FILE: corenet/modeling/layers/identity.py
  class Identity (line 11) | class Identity(BaseLayer):
    method __init__ (line 16) | def __init__(self):
    method forward (line 19) | def forward(self, x: Tensor) -> Tensor:

FILE: corenet/modeling/layers/linear_attention.py
  class LinearSelfAttention (line 16) | class LinearSelfAttention(BaseLayer):
    method __init__ (line 40) | def __init__(
    method __repr__ (line 73) | def __repr__(self):
    method visualize_context_scores (line 79) | def visualize_context_scores(context_scores):
    method _forward_self_attn (line 134) | def _forward_self_attn(self, x: Tensor, *args, **kwargs) -> Tensor:
    method _forward_cross_attn (line 163) | def _forward_cross_attn(
    method forward (line 209) | def forward(

FILE: corenet/modeling/layers/linear_layer.py
  class LinearLayer (line 17) | class LinearLayer(BaseLayer):
    method __init__ (line 33) | def __init__(
    method add_arguments (line 53) | def add_arguments(cls, parser: argparse.ArgumentParser):
    method reset_params (line 68) | def reset_params(self):
    method forward (line 74) | def forward(self, x: Tensor) -> Tensor:
    method __repr__ (line 93) | def __repr__(self):
  class GroupLinear (line 106) | class GroupLinear(BaseLayer):
    method __init__ (line 124) | def __init__(
    method add_arguments (line 166) | def add_arguments(cls, parser: argparse.ArgumentParser):
    method reset_params (line 181) | def reset_params(self):
    method _forward (line 187) | def _forward(self, x: Tensor) -> Tensor:
    method forward (line 211) | def forward(self, x: Tensor) -> Tensor:
    method __repr__ (line 223) | def __repr__(self):

FILE: corenet/modeling/layers/multi_head_attention.py
  class MultiHeadAttention (line 18) | class MultiHeadAttention(BaseLayer):
    method __init__ (line 38) | def __init__(
    method __repr__ (line 76) | def __repr__(self):
    method forward_tracing (line 81) | def forward_tracing(
    method forward_default (line 139) | def forward_default(
    method forward_pytorch (line 249) | def forward_pytorch(
    method forward (line 283) | def forward(

FILE: corenet/modeling/layers/normalization/__init__.py
  function register_norm_fn (line 21) | def register_norm_fn(name):
  function build_normalization_layer (line 35) | def build_normalization_layer(
  function arguments_norm_layers (line 91) | def arguments_norm_layers(parser: argparse.ArgumentParser):

FILE: corenet/modeling/layers/normalization/batch_norm.py
  class BatchNorm2d (line 16) | class BatchNorm2d(nn.BatchNorm2d):
    method __init__ (line 33) | def __init__(
  class BatchNorm2dFP32 (line 53) | class BatchNorm2dFP32(BatchNorm2d):
    method __init__ (line 58) | def __init__(
    method forward (line 78) | def forward(self, input: Tensor) -> Tensor:
  class BatchNorm1d (line 84) | class BatchNorm1d(nn.BatchNorm1d):
    method __init__ (line 101) | def __init__(
  class BatchNorm3d (line 121) | class BatchNorm3d(nn.BatchNorm3d):
    method __init__ (line 122) | def __init__(

FILE: corenet/modeling/layers/normalization/group_norm.py
  class GroupNorm (line 14) | class GroupNorm(nn.GroupNorm):
    method __init__ (line 34) | def __init__(

FILE: corenet/modeling/layers/normalization/instance_norm.py
  class InstanceNorm2d (line 15) | class InstanceNorm2d(nn.InstanceNorm2d):
    method __init__ (line 32) | def __init__(
  class InstanceNorm1d (line 52) | class InstanceNorm1d(nn.InstanceNorm1d):
    method __init__ (line 69) | def __init__(

FILE: corenet/modeling/layers/normalization/layer_norm.py
  class LayerNorm (line 15) | class LayerNorm(nn.LayerNorm):
    method __init__ (line 37) | def __init__(
    method forward (line 51) | def forward(self, x: Tensor) -> Tensor:
  class LayerNorm2D_NCHW (line 77) | class LayerNorm2D_NCHW(nn.GroupNorm):
    method __init__ (line 92) | def __init__(
    method __repr__ (line 105) | def __repr__(self):
  class LayerNormFP32 (line 112) | class LayerNormFP32(LayerNorm):
    method __init__ (line 117) | def __init__(
    method forward (line 133) | def forward(self, x: Tensor) -> Tensor:

FILE: corenet/modeling/layers/normalization/rms_norm.py
  class RMSNorm (line 13) | class RMSNorm(nn.Module):
    method __init__ (line 14) | def __init__(
    method _norm (line 29) | def _norm(self, x: Tensor) -> Tensor:
    method forward (line 42) | def forward(self, x: Tensor) -> Tensor:
    method extra_repr (line 60) | def extra_repr(self) -> str:

FILE: corenet/modeling/layers/normalization/sync_batch_norm.py
  class SyncBatchNorm (line 15) | class SyncBatchNorm(nn.SyncBatchNorm):
    method __init__ (line 33) | def __init__(
  class SyncBatchNormFP32 (line 53) | class SyncBatchNormFP32(SyncBatchNorm):
    method __init__ (line 58) | def __init__(
    method forward (line 76) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:

FILE: corenet/modeling/layers/pixel_shuffle.py
  class PixelShuffle (line 9) | class PixelShuffle(nn.PixelShuffle):
    method __init__ (line 22) | def __init__(self, upscale_factor: int, *args, **kwargs) -> None:
    method __repr__ (line 25) | def __repr__(self):

FILE: corenet/modeling/layers/pooling.py
  class MaxPool2d (line 11) | class MaxPool2d(nn.MaxPool2d):
    method __init__ (line 27) | def __init__(
    method __repr__ (line 37) | def __repr__(self):
  class AvgPool2d (line 43) | class AvgPool2d(nn.AvgPool2d):
    method __init__ (line 62) | def __init__(
    method __repr__ (line 80) | def __repr__(self):

FILE: corenet/modeling/layers/positional_embedding.py
  class PositionalEmbedding (line 16) | class PositionalEmbedding(BaseLayer):
    method __init__ (line 17) | def __init__(
    method forward (line 46) | def forward(self, seq_len: int, *args, **kwargs) -> Tensor:
    method __repr__ (line 49) | def __repr__(self):
  class LearnablePositionalEmbedding (line 53) | class LearnablePositionalEmbedding(nn.Module):
    method __init__ (line 56) | def __init__(
    method reset_parameters (line 77) | def reset_parameters(self) -> None:
    method forward (line 83) | def forward(self, seq_len: int, *args, **kwargs) -> Tensor:
    method __repr__ (line 105) | def __repr__(self):
  class SinusoidalPositionalEmbedding (line 115) | class SinusoidalPositionalEmbedding(nn.Module):
    method __init__ (line 116) | def __init__(
    method get_weights (line 135) | def get_weights(self) -> Tensor:
    method forward (line 155) | def forward(self, seq_len: int, *args, **kwargs) -> Tensor:
    method __repr__ (line 173) | def __repr__(self):

FILE: corenet/modeling/layers/positional_encoding.py
  class SinusoidalPositionalEncoding (line 16) | class SinusoidalPositionalEncoding(BaseLayer):
    method __init__ (line 34) | def __init__(
    method forward_patch_last (line 69) | def forward_patch_last(
    method forward_others (line 84) | def forward_others(
    method forward (line 99) | def forward(self, x, indices: Optional[Tensor] = None, *args, **kwargs...
    method __repr__ (line 105) | def __repr__(self):
  class LearnablePositionEncoding (line 109) | class LearnablePositionEncoding(BaseLayer):
    method __init__ (line 126) | def __init__(
    method forward (line 142) | def forward(self, x, *args, **kwargs) -> Tensor:
    method __repr__ (line 150) | def __repr__(self):

FILE: corenet/modeling/layers/random_layers.py
  class RandomApply (line 15) | class RandomApply(BaseLayer):
    method __init__ (line 24) | def __init__(
    method forward (line 35) | def forward(self, x: Tensor) -> Tensor:
    method __repr__ (line 45) | def __repr__(self):

FILE: corenet/modeling/layers/rotary_embeddings.py
  function _negate_half (line 12) | def _negate_half(x: Tensor) -> Tensor:
  function _apply_rotary_pos_emb (line 26) | def _apply_rotary_pos_emb(x: Tensor, pos_sin: Tensor, pos_cos: Tensor) -...
  class RotaryEmbedding (line 43) | class RotaryEmbedding(torch.nn.Module):
    method __init__ (line 56) | def __init__(
    method extra_repr (line 75) | def extra_repr(self) -> str:
    method _compute_sin_cos_embeddings (line 78) | def _compute_sin_cos_embeddings(
    method forward (line 131) | def forward(

FILE: corenet/modeling/layers/single_head_attention.py
  class SingleHeadAttention (line 17) | class SingleHeadAttention(BaseLayer):
    method __init__ (line 33) | def __init__(
    method __repr__ (line 56) | def __repr__(self) -> str:
    method forward (line 61) | def forward(

FILE: corenet/modeling/layers/softmax.py
  class Softmax (line 11) | class Softmax(nn.Softmax):
    method __init__ (line 23) | def __init__(self, dim: Optional[int] = -1, *args, **kwargs):

FILE: corenet/modeling/layers/stochastic_depth.py
  class StochasticDepth (line 10) | class StochasticDepth(StochasticDepthTorch):
    method __init__ (line 17) | def __init__(self, p: float, mode: str) -> None:

FILE: corenet/modeling/layers/token_merging.py
  class TokenMerging (line 16) | class TokenMerging(nn.Module):
    method __init__ (line 29) | def __init__(self, dim: int, window: int = 2) -> None:
    method forward (line 36) | def forward(
    method extra_repr (line 75) | def extra_repr(self) -> str:
  function pad_x_and_mask (line 79) | def pad_x_and_mask(

FILE: corenet/modeling/layers/upsample.py
  class UpSample (line 12) | class UpSample(nn.Upsample):
    method __init__ (line 29) | def __init__(

FILE: corenet/modeling/matcher_det/__init__.py
  function arguments_box_matcher (line 21) | def arguments_box_matcher(parser: argparse.ArgumentParser):
  function build_matcher (line 34) | def build_matcher(opts, *args, **kwargs):

FILE: corenet/modeling/matcher_det/base_matcher.py
  class BaseMatcher (line 9) | class BaseMatcher(object):
    method __init__ (line 14) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 19) | def add_arguments(cls, parser: argparse.ArgumentParser):
    method __call__ (line 23) | def __call__(self, *args, **kwargs):

FILE: corenet/modeling/matcher_det/ssd_matcher.py
  class SSDMatcher (line 25) | class SSDMatcher(BaseMatcher):
    method __init__ (line 44) | def __init__(self, opts, bg_class_id: Optional[int] = 0, *args, **kwar...
    method __repr__ (line 61) | def __repr__(self):
    method add_arguments (line 70) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __call__ (line 96) | def __call__(
    method convert_to_boxes (line 131) | def convert_to_boxes(
  function check_variable (line 150) | def check_variable(val, args_str: str):

FILE: corenet/modeling/misc/averaging_utils.py
  class EMA (line 14) | class EMA(object):
    method __init__ (line 24) | def __init__(
    method update_parameters (line 43) | def update_parameters(self, model):
  function arguments_ema (line 58) | def arguments_ema(parser: argparse.ArgumentParser):

FILE: corenet/modeling/misc/box_utils.py
  function convert_locations_to_boxes (line 15) | def convert_locations_to_boxes(
  function convert_boxes_to_locations (line 51) | def convert_boxes_to_locations(
  function center_form_to_corner_form (line 82) | def center_form_to_corner_form(boxes: Tensor) -> Tensor:
  function corner_form_to_center_form (line 103) | def corner_form_to_center_form(boxes: torch.Tensor) -> torch.Tensor:

FILE: corenet/modeling/misc/common.py
  function clean_strip (line 20) | def clean_strip(
  function load_pretrained_model (line 35) | def load_pretrained_model(
  function parameter_list (line 122) | def parameter_list(
  function freeze_module (line 179) | def freeze_module(module: torch.nn.Module, force_eval: bool = True) -> t...
  function freeze_modules_based_on_opts (line 213) | def freeze_modules_based_on_opts(
  function get_tensor_sizes (line 280) | def get_tensor_sizes(data: Union[Dict, Tensor]) -> Union[List[str], List...

FILE: corenet/modeling/misc/init_utils.py
  function _init_nn_layers (line 31) | def _init_nn_layers(
  function initialize_conv_layer (line 79) | def initialize_conv_layer(
  function initialize_fc_layer (line 88) | def initialize_fc_layer(
  function initialize_norm_layers (line 98) | def initialize_norm_layers(module) -> None:
  function initialize_weights (line 110) | def initialize_weights(opts, modules) -> None:

FILE: corenet/modeling/models/__init__.py
  function get_model (line 28) | def get_model(
  function arguments_model (line 86) | def arguments_model(parser: argparse.ArgumentParser) -> argparse.Argumen...

FILE: corenet/modeling/models/audio_classification/audio_byteformer.py
  class AudioByteFormer (line 19) | class AudioByteFormer(ByteFormer, BaseAudioClassification):
    method forward (line 23) | def forward(self, x: Dict[str, Tensor], *args, **kwargs) -> Tensor:
    method dummy_input_and_label (line 38) | def dummy_input_and_label(self, batch_size: int) -> Dict:

FILE: corenet/modeling/models/audio_classification/base_audio_classification.py
  class BaseAudioClassification (line 12) | class BaseAudioClassification(BaseAnyNNModel):
    method __init__ (line 19) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 23) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...

FILE: corenet/modeling/models/base_model.py
  class BaseAnyNNModel (line 24) | class BaseAnyNNModel(nn.Module):
    method __init__ (line 27) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 32) | def add_arguments(cls, parser: argparse.ArgumentParser):
    method reset_parameters (line 88) | def reset_parameters(self, opts: argparse.Namespace) -> None:
    method forward (line 92) | def forward(self, x: Any, *args, **kwargs) -> Any:
    method _apply_layer_wise_lr (line 96) | def _apply_layer_wise_lr(
    method get_trainable_parameters (line 111) | def get_trainable_parameters(
    method dummy_input_and_label (line 144) | def dummy_input_and_label(self, batch_size: int) -> Dict:
    method get_exportable_model (line 150) | def get_exportable_model(self) -> nn.Module:
    method freeze_norm_layers (line 159) | def freeze_norm_layers(
    method build_model (line 187) | def build_model(cls, opts: argparse.Namespace, *args, **kwargs) -> Bas...
    method info (line 203) | def info(self) -> None:
    method get_fsdp_wrap_policy (line 279) | def get_fsdp_wrap_policy(self) -> Optional[Callable[[nn.Module, bool, ...
    method get_activation_checkpoint_submodule_class (line 297) | def get_activation_checkpoint_submodule_class(self) -> Callable:

FILE: corenet/modeling/models/classification/base_image_encoder.py
  class BaseImageEncoder (line 21) | class BaseImageEncoder(BaseAnyNNModel):
    method __init__ (line 24) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method n_classes (line 65) | def n_classes(self) -> int:
    method add_arguments (line 75) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method check_model (line 164) | def check_model(self) -> None:
    method update_classifier (line 180) | def update_classifier(self, opts: argparse.Namespace, n_classes: int) ...
    method _forward_layer (line 210) | def _forward_layer(self, layer: nn.Module, x: Tensor) -> Tensor:
    method extract_end_points_all (line 216) | def extract_end_points_all(
    method extract_end_points_l4 (line 265) | def extract_end_points_l4(self, x: Tensor, *args, **kwargs) -> Dict[st...
    method extract_features (line 271) | def extract_features(self, x: Tensor, *args, **kwargs) -> Tensor:
    method forward_classifier (line 286) | def forward_classifier(self, x: Tensor, *args, **kwargs) -> Tensor:
    method forward (line 295) | def forward(self, x: Any, *args, **kwargs) -> Any:
    method get_trainable_parameters (line 313) | def get_trainable_parameters(
    method dummy_input_and_label (line 345) | def dummy_input_and_label(self, batch_size: int) -> Dict:
    method get_exportable_model (line 367) | def get_exportable_model(self) -> nn.Module:
    method build_model (line 377) | def build_model(cls, opts: argparse.Namespace, *args, **kwargs) -> Bas...
  function set_model_specific_opts_before_model_building (line 401) | def set_model_specific_opts_before_model_building(
  function unset_model_specific_opts_after_model_building (line 441) | def unset_model_specific_opts_after_model_building(

FILE: corenet/modeling/models/classification/byteformer.py
  function unfold_tokens (line 27) | def unfold_tokens(t: Tensor, kernel_size: int) -> Tensor:
  class ByteFormer (line 49) | class ByteFormer(BaseAnyNNModel):
    method __init__ (line 54) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 169) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method dummy_input_and_label (line 275) | def dummy_input_and_label(self, batch_size: int) -> Dict:
    method apply_token_reduction_net (line 298) | def apply_token_reduction_net(
    method get_backbone_inputs (line 329) | def get_backbone_inputs(self, x: Tensor) -> Tuple[Tensor, Tensor]:
    method backbone_forward (line 357) | def backbone_forward(
    method get_downsampler_name (line 383) | def get_downsampler_name(self, idx: int) -> str:
    method get_downsampler (line 395) | def get_downsampler(self, idx: int) -> Optional[nn.Module]:
    method forward (line 411) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:
    method build_model (line 434) | def build_model(cls, opts: argparse.Namespace, *args, **kwargs) -> Bas...

FILE: corenet/modeling/models/classification/config/byteformer.py
  function get_configuration (line 11) | def get_configuration(opts: argparse.Namespace) -> Dict:

FILE: corenet/modeling/models/classification/config/efficientnet.py
  class CompoundScalingConfig (line 16) | class CompoundScalingConfig:
  class EfficientNetBlockConfig (line 25) | class EfficientNetBlockConfig:
    method __init__ (line 32) | def __init__(
  function get_configuration (line 51) | def get_configuration(opts) -> Dict:

FILE: corenet/modeling/models/classification/config/fastvit.py
  function get_configuration (line 13) | def get_configuration(opts: argparse.Namespace) -> Dict:

FILE: corenet/modeling/models/classification/config/mobilenetv1.py
  function get_configuration (line 12) | def get_configuration(opts) -> Dict:

FILE: corenet/modeling/models/classification/config/mobilenetv2.py
  function get_configuration (line 9) | def get_configuration(opts) -> Dict:

FILE: corenet/modeling/models/classification/config/mobilenetv3.py
  function get_configuration (line 11) | def get_configuration(opts) -> Dict:

FILE: corenet/modeling/models/classification/config/mobileone.py
  function get_configuration (line 11) | def get_configuration(opts: argparse.Namespace) -> Dict:

FILE: corenet/modeling/models/classification/config/mobilevit.py
  function get_configuration (line 11) | def get_configuration(opts) -> Dict:

FILE: corenet/modeling/models/classification/config/mobilevit_v2.py
  function get_configuration (line 11) | def get_configuration(opts) -> Dict:

FILE: corenet/modeling/models/classification/config/regnet.py
  class BlockParamsConfig (line 44) | class BlockParamsConfig:
    method __init__ (line 63) | def __init__(
    method _make_widths_compatible (line 127) | def _make_widths_compatible(
    method extra_repr (line 160) | def extra_repr(self) -> str:
    method __repr__ (line 171) | def __repr__(self) -> str:
  function get_configuration (line 175) | def get_configuration(

FILE: corenet/modeling/models/classification/config/resnet.py
  function add_squeeze_channels (line 11) | def add_squeeze_channels(
  function get_configuration (line 26) | def get_configuration(opts) -> Dict:

FILE: corenet/modeling/models/classification/config/swin_transformer.py
  function get_configuration (line 11) | def get_configuration(opts) -> Dict:

FILE: corenet/modeling/models/classification/config/vit.py
  function get_configuration (line 12) | def get_configuration(opts: argparse.Namespace) -> Dict:

FILE: corenet/modeling/models/classification/efficientnet.py
  class EfficientNet (line 23) | class EfficientNet(BaseImageEncoder):
    method __init__ (line 28) | def __init__(
    method _make_layer (line 118) | def _make_layer(
    method add_arguments (line 176) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_activation_checkpoint_submodule_class (line 190) | def get_activation_checkpoint_submodule_class(self) -> Callable:

FILE: corenet/modeling/models/classification/fastvit.py
  function basic_blocks (line 25) | def basic_blocks(
  class FastViT (line 101) | class FastViT(BaseImageEncoder):
    method __init__ (line 106) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 249) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_exportable_model (line 290) | def get_exportable_model(self) -> nn.Module:

FILE: corenet/modeling/models/classification/mobilenetv1.py
  class MobileNetv1 (line 26) | class MobileNetv1(BaseImageEncoder):
    method __init__ (line 31) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 130) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _make_layer (line 142) | def _make_layer(

FILE: corenet/modeling/models/classification/mobilenetv2.py
  class MobileNetV2 (line 20) | class MobileNetV2(BaseImageEncoder):
    method __init__ (line 25) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 148) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _make_layer (line 158) | def _make_layer(

FILE: corenet/modeling/models/classification/mobilenetv3.py
  class MobileNetV3 (line 21) | class MobileNetV3(BaseImageEncoder):
    method __init__ (line 26) | def __init__(self, opts, *args, **kwargs) -> None:
    method _make_layer (line 164) | def _make_layer(
    method add_arguments (line 207) | def add_arguments(cls, parser: argparse.ArgumentParser):

FILE: corenet/modeling/models/classification/mobileone.py
  class MobileOne (line 18) | class MobileOne(BaseImageEncoder):
    method __init__ (line 23) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 125) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _make_stage (line 142) | def _make_stage(
    method get_exportable_model (line 201) | def get_exportable_model(self) -> nn.Module:

FILE: corenet/modeling/models/classification/mobilevit.py
  class MobileViT (line 20) | class MobileViT(BaseImageEncoder):
    method __init__ (line 25) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 127) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _make_layer (line 186) | def _make_layer(
    method _make_mobilenet_layer (line 206) | def _make_mobilenet_layer(
    method _make_mit_layer (line 228) | def _make_mit_layer(
    method get_activation_checkpoint_submodule_class (line 301) | def get_activation_checkpoint_submodule_class(self) -> Callable:

FILE: corenet/modeling/models/classification/mobilevit_v2.py
  class MobileViTv2 (line 20) | class MobileViTv2(BaseImageEncoder):
    method __init__ (line 25) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 104) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method _make_layer (line 138) | def _make_layer(
    method _make_mobilenet_layer (line 152) | def _make_mobilenet_layer(
    method _make_mit_layer (line 174) | def _make_mit_layer(

FILE: corenet/modeling/models/classification/regnet.py
  class RegNet (line 29) | class RegNet(BaseImageEncoder):
    method __init__ (line 34) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method _make_stage (line 134) | def _make_stage(
    method add_arguments (line 167) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...

FILE: corenet/modeling/models/classification/resnet.py
  class ResNet (line 27) | class ResNet(BaseImageEncoder):
    method __init__ (line 37) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method _block_stochastic_depth_prob (line 173) | def _block_stochastic_depth_prob(
    method _make_layer (line 185) | def _make_layer(
    method add_arguments (line 249) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...

FILE: corenet/modeling/models/classification/swin_transformer.py
  class SwinTransformer (line 29) | class SwinTransformer(BaseImageEncoder):
    method __init__ (line 37) | def __init__(self, opts, *args, **kwargs) -> None:
    method extract_end_points_all (line 190) | def extract_end_points_all(
    method add_arguments (line 253) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...

FILE: corenet/modeling/models/classification/vit.py
  class VisionTransformer (line 35) | class VisionTransformer(BaseImageEncoder):
    method __init__ (line 52) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method _build_patch_embedding_layer (line 155) | def _build_patch_embedding_layer(
    method _build_naive_transformer_layer (line 221) | def _build_naive_transformer_layer(
    method _build_transformer_layer_with_flash_attention (line 268) | def _build_transformer_layer_with_flash_attention(
    method update_layer_norm_eps (line 335) | def update_layer_norm_eps(self) -> None:
    method reset_simple_fpn_params (line 341) | def reset_simple_fpn_params(self) -> None:
    method _apply_layer_wise_lr (line 348) | def _apply_layer_wise_lr(
    method _build_simple_fpn_layers (line 481) | def _build_simple_fpn_layers(
    method add_arguments (line 562) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method extract_patch_embeddings (line 621) | def extract_patch_embeddings(self, x: Tensor) -> Tuple[Tensor, Tuple[i...
    method _features_from_transformer (line 660) | def _features_from_transformer(self, x: Tensor) -> Tuple[Tensor, Tuple...
    method extract_features (line 676) | def extract_features(
    method forward_classifier (line 721) | def forward_classifier(
    method forward (line 744) | def forward(
    method extract_end_points_all (line 781) | def extract_end_points_all(
    method get_activation_checkpoint_submodule_class (line 836) | def get_activation_checkpoint_submodule_class(self) -> Callable:
    method get_fsdp_wrap_policy (line 843) | def get_fsdp_wrap_policy(

FILE: corenet/modeling/models/detection/base_detection.py
  class BaseDetection (line 18) | class BaseDetection(BaseAnyNNModel):
    method __init__ (line 26) | def __init__(
    method add_arguments (line 55) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method reset_layer_parameters (line 103) | def reset_layer_parameters(layer: nn.Module, opts: argparse.Namespace)...
    method build_model (line 108) | def build_model(cls, opts: argparse.Namespace, *args, **kwargs) -> Bas...
  function check_feature_map_output_channels (line 126) | def check_feature_map_output_channels(config: Dict, layer_name: str) -> ...

FILE: corenet/modeling/models/detection/mask_rcnn.py
  class MaskRCNNEncoder (line 34) | class MaskRCNNEncoder(nn.Module):
    method __init__ (line 35) | def __init__(
    method get_augmented_tensor (line 122) | def get_augmented_tensor(self) -> Tensor:
    method forward (line 125) | def forward(self, x: Tensor) -> Dict[str, Tensor]:
    method get_trainable_parameters (line 159) | def get_trainable_parameters(
    method get_activation_checkpoint_submodule_class (line 261) | def get_activation_checkpoint_submodule_class(self) -> Callable:
  class MaskRCNNDetector (line 267) | class MaskRCNNDetector(BaseDetection):
    method __init__ (line 275) | def __init__(self, opts, encoder: BaseImageEncoder, *args, **kwargs) -...
    method update_layer_norm_eps (line 495) | def update_layer_norm_eps(self):
    method set_norm_layer_opts (line 500) | def set_norm_layer_opts(self):
    method reset_norm_layer_opts (line 511) | def reset_norm_layer_opts(self, default_norm):
    method add_arguments (line 515) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method reset_generalized_rcnn_transform (line 734) | def reset_generalized_rcnn_transform(self, height, width):
    method get_trainable_parameters (line 737) | def get_trainable_parameters(
    method forward (line 793) | def forward(
    method predict (line 844) | def predict(self, x: Tensor, *args, **kwargs) -> DetectionPredTuple:
    method dummy_input_and_label (line 890) | def dummy_input_and_label(self, batch_size: int) -> Dict:
    method get_activation_checkpoint_submodule_class (line 929) | def get_activation_checkpoint_submodule_class(self) -> Callable:

FILE: corenet/modeling/models/detection/ssd.py
  class SingleShotMaskDetector (line 29) | class SingleShotMaskDetector(BaseDetection):
    method __init__ (line 40) | def __init__(self, opts, encoder: BaseImageEncoder) -> None:
    method add_arguments (line 186) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method reset_layers (line 287) | def reset_layers(module) -> None:
    method process_anchors_ar (line 293) | def process_anchors_ar(anchor_ar: List) -> List:
    method get_backbone_features (line 302) | def get_backbone_features(self, x: Tensor) -> Dict[str, Tensor]:
    method ssd_forward (line 326) | def ssd_forward(
    method forward (line 359) | def forward(
    method predict (line 396) | def predict(self, x: Tensor, *args, **kwargs) -> DetectionPredTuple:
    method postprocess_detections (line 421) | def postprocess_detections(
    method dummy_input_and_label (line 489) | def dummy_input_and_label(self, batch_size: int) -> Dict:

FILE: corenet/modeling/models/detection/utils/rcnn_utils.py
  class FastRCNNConvFCHead (line 22) | class FastRCNNConvFCHead(nn.Sequential):
    method __init__ (line 23) | def __init__(
  class RPNHead (line 75) | class RPNHead(nn.Module):
    method __init__ (line 85) | def __init__(self, opts, in_channels: int, num_anchors: int, conv_dept...
    method forward (line 131) | def forward(self, x: List[Tensor]) -> Tuple[List[Tensor], List[Tensor]]:
  class MaskRCNNHeads (line 141) | class MaskRCNNHeads(nn.Sequential):
    method __init__ (line 142) | def __init__(self, opts, in_channels: int, layers: List, dilation: int):
  class MaskRCNNPredictor (line 181) | class MaskRCNNPredictor(nn.Sequential):
    method __init__ (line 182) | def __init__(
  class FastRCNNPredictor (line 220) | class FastRCNNPredictor(nn.Module):
    method __init__ (line 230) | def __init__(self, in_channels: int, num_classes: int) -> None:
    method forward (line 239) | def forward(self, x: Tensor) -> Tuple[Tensor, Tensor]:
  function replace_syncbn_with_syncbnfp32 (line 252) | def replace_syncbn_with_syncbnfp32(opts, num_features: int) -> nn.Module:

FILE: corenet/modeling/models/fsdp_wrapper.py
  class FullyShardedDataParallelWrapper (line 55) | class FullyShardedDataParallelWrapper(FullyShardedDataParallel):
    method __init__ (line 56) | def __init__(
    method add_arguments (line 131) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
  function get_fsdp_model_optimizer_state_dict_on_rank0 (line 194) | def get_fsdp_model_optimizer_state_dict_on_rank0(

FILE: corenet/modeling/models/language_modeling/base_lm.py
  class BaseLanguageModel (line 16) | class BaseLanguageModel(BaseAnyNNModel):
    method add_arguments (line 24) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method dummy_input_and_label (line 44) | def dummy_input_and_label(self, batch_size: int) -> Dict[str, Tensor]:
    method build_model (line 59) | def build_model(cls, opts: argparse.Namespace, *args, **kwargs) -> Bas...

FILE: corenet/modeling/models/language_modeling/general_gpt.py
  function compute_heads (line 32) | def compute_heads(model_dim: int, head_dim: int) -> int:
  class GPTConfig (line 52) | class GPTConfig:
    method __post_init__ (line 83) | def __post_init__(self) -> None:
    method from_name (line 163) | def from_name(
  class MultiHeadCausalAttention (line 248) | class MultiHeadCausalAttention(nn.Module):
    method __init__ (line 257) | def __init__(
    method extra_repr (line 312) | def extra_repr(self) -> str:
    method forward (line 318) | def forward(
  class FeedForwardNetwork (line 437) | class FeedForwardNetwork(nn.Module):
    method __init__ (line 446) | def __init__(
    method extra_repr (line 488) | def extra_repr(self) -> str:
    method forward (line 491) | def forward(self, x: Tensor) -> Tensor:
  class TransformerDecoderLayer (line 509) | class TransformerDecoderLayer(nn.Module):
    method __init__ (line 518) | def __init__(
    method forward (line 539) | def forward(
  class GeneralGPTModel (line 584) | class GeneralGPTModel(BaseLanguageModel):
    method __init__ (line 593) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 655) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method forward (line 686) | def forward(
    method get_fsdp_wrap_policy (line 815) | def get_fsdp_wrap_policy(
    method get_activation_checkpoint_submodule_class (line 825) | def get_activation_checkpoint_submodule_class(self) -> Callable:
    method reset_parameters (line 829) | def reset_parameters(self, model_config: GPTConfig) -> None:
    method head_dim_at_layer (line 861) | def head_dim_at_layer(self, i: int) -> int:
    method k_dim_at_layer (line 864) | def k_dim_at_layer(self, i: int) -> int:
    method v_dim_at_layer (line 867) | def v_dim_at_layer(self, i: int) -> int:
    method k_num_heads_at_layer (line 870) | def k_num_heads_at_layer(self, i: int) -> int:
    method v_num_heads_at_layer (line 873) | def v_num_heads_at_layer(self, i: int) -> int:

FILE: corenet/modeling/models/language_modeling/kv_prediction.py
  class LayerPrunedGPTConfig (line 32) | class LayerPrunedGPTConfig(general_gpt.GPTConfig):
    method __post_init__ (line 35) | def __post_init__(self) -> None:
    method from_name (line 46) | def from_name(
  class LayerPrunedGeneralGPTModel (line 206) | class LayerPrunedGeneralGPTModel(general_gpt.GeneralGPTModel):
  class AuxLayerToBaseLayer (line 216) | class AuxLayerToBaseLayer(nn.Module):
    method __init__ (line 230) | def __init__(self, auxkv_num_layers_to_basekv_num_layers: List[int]) -...
    method forward (line 236) | def forward(
  class LinearAuxKVToBaseKV (line 253) | class LinearAuxKVToBaseKV(nn.Module):
    method __init__ (line 273) | def __init__(
    method forward (line 301) | def forward(
    method set_as_identity (line 347) | def set_as_identity(self) -> None:
  class KVPredicter (line 359) | class KVPredicter(nn.Module):
    method __init__ (line 382) | def __init__(
    method base_layers (line 406) | def base_layers(self) -> int:
    method auxiliary_layers (line 410) | def auxiliary_layers(self) -> int:
    method build_kv_cache_predicters (line 413) | def build_kv_cache_predicters(self) -> None:
    method forward (line 447) | def forward(
  function get_overrided_opts (line 477) | def get_overrided_opts(
  class KVPredictionLLM (line 498) | class KVPredictionLLM(BaseLanguageModel):
    method __init__ (line 505) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 562) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method predict_kv_cache (line 584) | def predict_kv_cache(self, auxiliary_outputs: Dict[str, Any]) -> List[...
    method forward (line 610) | def forward(
    method merge_outputs (line 821) | def merge_outputs(self, aux_logits: Tensor, base_logits: Tensor) -> Te...
    method get_fsdp_wrap_policy (line 833) | def get_fsdp_wrap_policy(
    method get_activation_checkpoint_submodule_class (line 839) | def get_activation_checkpoint_submodule_class(self) -> Callable:

FILE: corenet/modeling/models/multi_modal_img_text/base_multi_modal_img_text.py
  class BaseMultiModalImageText (line 12) | class BaseMultiModalImageText(BaseAnyNNModel):
    method __init__ (line 19) | def __init__(self, opts, *args, **kwargs) -> None:
    method add_arguments (line 29) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...

FILE: corenet/modeling/models/multi_modal_img_text/clip.py
  class CLIP (line 28) | class CLIP(BaseMultiModalImageText):
    method __init__ (line 39) | def __init__(
    method add_arguments (line 56) | def add_arguments(cls, parser: argparse.ArgumentParser):
    method reset_parameters (line 68) | def reset_parameters(self) -> None:
    method get_trainable_parameters (line 75) | def get_trainable_parameters(
    method dummy_input_and_label (line 135) | def dummy_input_and_label(
    method _exponentiate_and_clip_logits (line 168) | def _exponentiate_and_clip_logits(self, max_scale: float = 100.0) -> T...
    method _reset_cached_text_features (line 181) | def _reset_cached_text_features(self, mode_str: str) -> None:
    method train (line 194) | def train(self, mode: bool = True):
    method forward (line 207) | def forward(self, input: Dict[str, Optional[Tensor]]) -> Dict[str, Ten...
    method build_model (line 300) | def build_model(cls, opts: argparse.Namespace, *args, **kwargs) -> Bas...
    method get_activation_checkpoint_submodule_class (line 341) | def get_activation_checkpoint_submodule_class(
  function update_image_classifier (line 362) | def update_image_classifier(

FILE: corenet/modeling/models/segmentation/base_seg.py
  class BaseSegmentation (line 16) | class BaseSegmentation(BaseAnyNNModel):
    method __init__ (line 24) | def __init__(self, opts, encoder: BaseImageEncoder, *args, **kwargs) -...
    method add_arguments (line 35) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method maybe_seg_norm_layer (line 150) | def maybe_seg_norm_layer(self):
    method set_default_norm_layer (line 156) | def set_default_norm_layer(self):
    method dummy_input_and_label (line 159) | def dummy_input_and_label(self, batch_size: int) -> Dict:
    method update_classifier (line 175) | def update_classifier(self, opts, n_classes: int) -> None:
    method set_model_specific_opts_before_model_building (line 180) | def set_model_specific_opts_before_model_building(
  function set_model_specific_opts_before_model_building (line 214) | def set_model_specific_opts_before_model_building(
  function unset_model_specific_opts_after_model_building (line 253) | def unset_model_specific_opts_after_model_building(

FILE: corenet/modeling/models/segmentation/enc_dec.py
  class SegEncoderDecoder (line 21) | class SegEncoderDecoder(BaseSegmentation):
    method __init__ (line 31) | def __init__(
    method get_trainable_parameters (line 47) | def get_trainable_parameters(
    method forward (line 95) | def forward(
    method update_classifier (line 113) | def update_classifier(self, opts, n_classes: int) -> None:
    method build_model (line 121) | def build_model(cls, opts: argparse.Namespace, *args, **kwargs) -> Bas...

FILE: corenet/modeling/models/segmentation/heads/base_seg_head.py
  class BaseSegHead (line 19) | class BaseSegHead(BaseAnyNNModel):
    method __init__ (line 24) | def __init__(
    method forward_aux_head (line 93) | def forward_aux_head(self, enc_out: Dict) -> Tensor:
    method forward_seg_head (line 97) | def forward_seg_head(self, enc_out: Dict) -> Tensor:
    method forward (line 100) | def forward(self, enc_out: Dict, *args, **kwargs) -> Union[Tensor, Tup...
    method reset_head_parameters (line 117) | def reset_head_parameters(self, opts) -> None:
    method add_arguments (line 122) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_trainable_parameters (line 137) | def get_trainable_parameters(
    method update_classifier (line 153) | def update_classifier(self, opts, n_classes: int) -> None:
    method build_model (line 160) | def build_model(cls, opts: argparse.Namespace, *args, **kwargs) -> Bas...
  function _check_out_channels (line 164) | def _check_out_channels(config: dict, layer_name: str) -> int:

FILE: corenet/modeling/models/segmentation/heads/deeplabv3.py
  class DeeplabV3 (line 22) | class DeeplabV3(BaseSegHead):
    method __init__ (line 51) | def __init__(
    method add_arguments (line 101) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method forward_seg_head (line 135) | def forward_seg_head(self, enc_out: Dict) -> Tensor:
  class MultiScaleDeeplabV3 (line 156) | class MultiScaleDeeplabV3(DeeplabV3):
    method __init__ (line 187) | def __init__(self, opts, enc_conf: Dict, *args, **kwargs) -> None:
    method add_arguments (line 247) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method forward_seg_head (line 267) | def forward_seg_head(self, enc_out: Dict) -> Tensor:

FILE: corenet/modeling/models/segmentation/heads/pspnet.py
  class PSPNet (line 19) | class PSPNet(BaseSegHead):
    method __init__ (line 28) | def __init__(
    method update_classifier (line 63) | def update_classifier(self, opts, n_classes: int) -> None:
    method add_arguments (line 83) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method forward_seg_head (line 106) | def forward_seg_head(self, enc_out: Dict) -> Tensor:

FILE: corenet/modeling/models/segmentation/heads/simple_seg_head.py
  class SimpleSegHead (line 17) | class SimpleSegHead(BaseSegHead):
    method __init__ (line 27) | def __init__(
    method add_arguments (line 51) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method forward_seg_head (line 54) | def forward_seg_head(self, enc_out: Dict) -> Tensor:

FILE: corenet/modeling/models/video_classification/base_video_encoder.py
  class BaseVideoEncoder (line 14) | class BaseVideoEncoder(BaseAnyNNModel):
    method __init__ (line 21) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 30) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method reset_module_parameters (line 101) | def reset_module_parameters(opts, module) -> None:

FILE: corenet/modeling/modules/aspp_block.py
  class ASPP (line 24) | class ASPP(BaseModule):
    method __init__ (line 41) | def __init__(
    method forward (line 110) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:
    method __repr__ (line 119) | def __repr__(self):
  class ASPPConv2d (line 130) | class ASPPConv2d(ConvLayer2d):
    method __init__ (line 144) | def __init__(
    method adjust_atrous_rate (line 158) | def adjust_atrous_rate(self, rate: int) -> None:
  class ASPPSeparableConv2d (line 166) | class ASPPSeparableConv2d(SeparableConv2d):
    method __init__ (line 180) | def __init__(
    method adjust_atrous_rate (line 194) | def adjust_atrous_rate(self, rate: int) -> None:
  class ASPPPooling (line 202) | class ASPPPooling(BaseLayer):
    method __init__ (line 215) | def __init__(
    method forward (line 239) | def forward(self, x: Tensor) -> Tensor:
    method __repr__ (line 245) | def __repr__(self):

FILE: corenet/modeling/modules/base_module.py
  class BaseModule (line 12) | class BaseModule(nn.Module):
    method __init__ (line 15) | def __init__(self, *args, **kwargs):
    method forward (line 18) | def forward(self, x: Any, *args, **kwargs) -> Any:
    method __repr__ (line 21) | def __repr__(self):

FILE: corenet/modeling/modules/efficientnet.py
  class EfficientNetBlock (line 12) | class EfficientNetBlock(InvertedResidualSE):
    method __init__ (line 27) | def __init__(self, stochastic_depth_prob: float, *args, **kwargs) -> N...
    method forward (line 31) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:
    method __repr__ (line 40) | def __repr__(self) -> str:

FILE: corenet/modeling/modules/fastvit.py
  function convolutional_stem (line 17) | def convolutional_stem(
  class PatchEmbed (line 72) | class PatchEmbed(BaseModule):
    method __init__ (line 84) | def __init__(
    method forward (line 124) | def forward(self, x: torch.Tensor, *args, **kwargs) -> torch.Tensor:
  class RepMixer (line 139) | class RepMixer(BaseModule):
    method __init__ (line 155) | def __init__(
    method forward (line 205) | def forward(self, x: torch.Tensor, *args, **kwargs) -> torch.Tensor:
    method reparameterize (line 226) | def reparameterize(self) -> None:
  class ConvFFN (line 267) | class ConvFFN(BaseModule):
    method __init__ (line 279) | def __init__(
    method forward (line 314) | def forward(self, x: torch.Tensor, *args, **kwargs) -> torch.Tensor:
  class RepMixerBlock (line 332) | class RepMixerBlock(BaseModule):
    method __init__ (line 350) | def __init__(
    method forward (line 390) | def forward(self, x: torch.Tensor, *args, **kwargs) -> torch.Tensor:
  class AttentionBlock (line 409) | class AttentionBlock(BaseModule):
    method __init__ (line 425) | def __init__(
    method _apply_mhsa (line 464) | def _apply_mhsa(self, x: torch.Tensor) -> torch.Tensor:
    method forward (line 483) | def forward(self, x: torch.Tensor, *args, **kwargs) -> torch.Tensor:
  class RepCPE (line 502) | class RepCPE(BaseModule):
    method __init__ (line 516) | def __init__(
    method forward (line 565) | def forward(self, x: torch.Tensor, *args, **kwargs) -> torch.Tensor:
    method reparameterize (line 583) | def reparameterize(self) -> None:

FILE: corenet/modeling/modules/feature_pyramid.py
  class FeaturePyramidNetwork (line 21) | class FeaturePyramidNetwork(BaseModule):
    method __init__ (line 33) | def __init__(
    method reset_weights (line 91) | def reset_weights(self) -> None:
    method forward (line 99) | def forward(self, x: Dict[str, Tensor], *args, **kwargs) -> Dict[str, ...
    method __repr__ (line 127) | def __repr__(self):

FILE: corenet/modeling/modules/flash_transformer.py
  class FlashTransformerEncoder (line 24) | class FlashTransformerEncoder(BaseModule):
    method __init__ (line 51) | def __init__(
    method forward (line 108) | def forward(self, x: Tensor) -> Tensor:

FILE: corenet/modeling/modules/mobilenetv2.py
  class InvertedResidualSE (line 16) | class InvertedResidualSE(BaseModule):
    method __init__ (line 39) | def __init__(
    method forward (line 123) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:
    method __repr__ (line 127) | def __repr__(self) -> str:
  class InvertedResidual (line 141) | class InvertedResidual(BaseModule):
    method __init__ (line 163) | def __init__(
    method forward (line 231) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:
    method __repr__ (line 237) | def __repr__(self) -> str:

FILE: corenet/modeling/modules/mobileone_block.py
  class MobileOneBlock (line 17) | class MobileOneBlock(BaseModule):
    method __init__ (line 25) | def __init__(
    method forward (line 137) | def forward(self, x: torch.Tensor, *args, **kwargs) -> torch.Tensor:
    method reparameterize (line 171) | def reparameterize(self) -> None:
    method _get_kernel_bias (line 207) | def _get_kernel_bias(self) -> Tuple[torch.Tensor, torch.Tensor]:
    method _fuse_branch_ops (line 243) | def _fuse_branch_ops(
    method _fuse_conv_bn (line 277) | def _fuse_conv_bn(
  class RepLKBlock (line 304) | class RepLKBlock(BaseModule):
    method __init__ (line 322) | def __init__(
    method forward (line 390) | def forward(self, x: torch.Tensor, *args, **kwargs) -> torch.Tensor:
    method _get_kernel_bias (line 411) | def _get_kernel_bias(self) -> Tuple[torch.Tensor, torch.Tensor]:
    method reparameterize (line 433) | def reparameterize(self) -> None:

FILE: corenet/modeling/modules/mobilevit_block.py
  class MobileViTBlock (line 19) | class MobileViTBlock(BaseModule):
    method __init__ (line 41) | def __init__(
    method __repr__ (line 150) | def __repr__(self) -> str:
    method unfolding (line 186) | def unfolding(self, feature_map: Tensor) -> Tuple[Tensor, Dict]:
    method folding (line 233) | def folding(self, patches: Tensor, info_dict: Dict) -> Tensor:
    method forward_spatial (line 269) | def forward_spatial(self, x: Tensor) -> Tensor:
    method forward_temporal (line 290) | def forward_temporal(
    method forward (line 316) | def forward(
  class MobileViTBlockv2 (line 329) | class MobileViTBlockv2(BaseModule):
    method __init__ (line 349) | def __init__(
    method _compute_unfolding_weights (line 438) | def _compute_unfolding_weights(self) -> Tensor:
    method _build_attn_layer (line 449) | def _build_attn_layer(
    method __repr__ (line 497) | def __repr__(self) -> str:
    method unfolding_pytorch (line 526) | def unfolding_pytorch(self, feature_map: Tensor) -> Tuple[Tensor, Tupl...
    method folding_pytorch (line 542) | def folding_pytorch(self, patches: Tensor, output_size: Tuple[int, int...
    method unfolding_coreml (line 557) | def unfolding_coreml(self, feature_map: Tensor) -> Tuple[Tensor, Tuple...
    method folding_coreml (line 578) | def folding_coreml(self, patches: Tensor, output_size: Tuple[int, int]...
    method resize_input_if_needed (line 595) | def resize_input_if_needed(self, x):
    method forward_spatial (line 605) | def forward_spatial(self, x: Tensor, *args, **kwargs) -> Tensor:
    method forward_temporal (line 628) | def forward_temporal(
    method forward (line 657) | def forward(

FILE: corenet/modeling/modules/pspnet_module.py
  class PSP (line 17) | class PSP(BaseModule):
    method __init__ (line 29) | def __init__(
    method _make_psp_layer (line 78) | def _make_psp_layer(
    method forward (line 94) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:
    method __repr__ (line 106) | def __repr__(self):

FILE: corenet/modeling/modules/regnet_modules.py
  class XRegNetBlock (line 16) | class XRegNetBlock(BaseModule):
    method __init__ (line 34) | def __init__(
    method forward (line 131) | def forward(self, x: Tensor) -> Tensor:
    method __repr__ (line 151) | def __repr__(self) -> str:
  class AnyRegNetStage (line 164) | class AnyRegNetStage(BaseModule):
    method __init__ (line 185) | def __init__(
    method forward (line 227) | def forward(self, x: Tensor) -> Tensor:
    method __repr__ (line 242) | def __repr__(self) -> str:

FILE: corenet/modeling/modules/resnet_modules.py
  class BasicResNetBlock (line 16) | class BasicResNetBlock(BaseModule):
    method __init__ (line 39) | def __init__(
    method forward (line 129) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:
    method __repr__ (line 137) | def __repr__(self) -> str:
  class BottleneckResNetBlock (line 150) | class BottleneckResNetBlock(BaseModule):
    method __init__ (line 172) | def __init__(
    method forward (line 279) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:
    method __repr__ (line 287) | def __repr__(self) -> str:

FILE: corenet/modeling/modules/squeeze_excitation.py
  class SqueezeExcitation (line 17) | class SqueezeExcitation(BaseModule):
    method __init__ (line 33) | def __init__(
    method forward (line 80) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:
    method __repr__ (line 83) | def __repr__(self) -> str:

FILE: corenet/modeling/modules/ssd_heads.py
  class SSDHead (line 17) | class SSDHead(BaseModule):
    method __init__ (line 34) | def __init__(
    method __repr__ (line 91) | def __repr__(self) -> str:
    method reset_parameters (line 107) | def reset_parameters(self) -> None:
    method _sample_fm (line 112) | def _sample_fm(self, x: Tensor) -> Tensor:
    method forward (line 135) | def forward(self, x: Tensor, *args, **kwargs) -> Tuple[Tensor, Tensor]:
  class SSDInstanceHead (line 159) | class SSDInstanceHead(BaseModule):
    method __init__ (line 164) | def __init__(
    method __repr__ (line 224) | def __repr__(self) -> str:
    method reset_parameters (line 232) | def reset_parameters(self) -> None:
    method forward (line 237) | def forward(self, x: Tensor, boxes: Tensor, *args, **kwargs) -> Tensor:

FILE: corenet/modeling/modules/swin_transformer_block.py
  function _patch_merging_pad (line 26) | def _patch_merging_pad(x):
  class Permute (line 32) | class Permute(BaseModule):
    method __init__ (line 38) | def __init__(self, dims: List[int]):
    method forward (line 42) | def forward(self, x: Tensor) -> Tensor:
    method __repr__ (line 45) | def __repr__(self) -> str:
  class PatchMerging (line 50) | class PatchMerging(BaseModule):
    method __init__ (line 58) | def __init__(self, opts, dim: int, norm_layer: str, strided: Optional[...
    method forward (line 69) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:
    method __repr__ (line 91) | def __repr__(self) -> str:
  function shifted_window_attention (line 96) | def shifted_window_attention(
  class ShiftedWindowAttention (line 234) | class ShiftedWindowAttention(BaseModule):
    method __init__ (line 239) | def __init__(
    method __repr__ (line 290) | def __repr__(self) -> str:
    method forward (line 301) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:
  class SwinTransformerBlock (line 331) | class SwinTransformerBlock(BaseModule):
    method __init__ (line 347) | def __init__(
    method __repr__ (line 400) | def __repr__(self) -> str:
    method forward (line 412) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:

FILE: corenet/modeling/modules/transformer.py
  class TransformerEncoder (line 26) | class TransformerEncoder(BaseModule):
    method __init__ (line 46) | def __init__(
    method __repr__ (line 116) | def __repr__(self) -> str:
    method forward (line 129) | def forward(
  class LinearAttnFFN (line 159) | class LinearAttnFFN(BaseModule):
    method __init__ (line 177) | def __init__(
    method __repr__ (line 237) | def __repr__(self) -> str:
    method forward (line 248) | def forward(

FILE: corenet/modeling/modules/windowed_transformer.py
  function window_partition (line 16) | def window_partition(t: torch.Tensor, window_size: int) -> torch.Tensor:
  function window_partition_reverse (line 41) | def window_partition_reverse(
  function get_windows_shift_mask (line 61) | def get_windows_shift_mask(
  function window_x_and_key_padding_mask (line 90) | def window_x_and_key_padding_mask(
  function unwindow_x (line 135) | def unwindow_x(x_windows: torch.Tensor, B: int, N: int, C: int, window_s...
  class WindowedTransformerEncoder (line 162) | class WindowedTransformerEncoder(transformer.TransformerEncoder):
    method __init__ (line 190) | def __init__(
    method forward (line 224) | def forward(
    method __repr__ (line 270) | def __repr__(self) -> str:

FILE: corenet/modeling/neural_augmentor/__init__.py
  function arguments_neural_augmentor (line 13) | def arguments_neural_augmentor(

FILE: corenet/modeling/neural_augmentor/neural_aug.py
  class BaseNeuralAugmentor (line 27) | class BaseNeuralAugmentor(nn.Module):
    method __init__ (line 32) | def __init__(self, opts, *args, **kwargs):
    method _is_valid_aug_fn_list (line 48) | def _is_valid_aug_fn_list(self, aug_fns):
    method get_trainable_parameters (line 57) | def get_trainable_parameters(
    method __repr__ (line 72) | def __repr__(self):
    method add_arguments (line 101) | def add_arguments(cls, parser: argparse.ArgumentParser):
    method _build_aug_fns (line 141) | def _build_aug_fns(self, opts) -> List:
    method _apply_brightness (line 144) | def _apply_brightness(self, x: Tensor, *args, **kwargs) -> Tensor:
    method _apply_contrast (line 161) | def _apply_contrast(self, x: Tensor, *args, **kwargs) -> Tensor:
    method _apply_noise (line 179) | def _apply_noise(self, x: Tensor, *args, **kwargs) -> Tensor:
    method forward (line 194) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:
  class BasicNeuralAugmentor (line 219) | class BasicNeuralAugmentor(BaseNeuralAugmentor):
    method __init__ (line 227) | def __init__(self, opts, *args, **kwargs) -> None:
    method _build_aug_fns (line 235) | def _build_aug_fns(self, opts) -> List:
  class DistributionNeuralAugmentor (line 256) | class DistributionNeuralAugmentor(BaseNeuralAugmentor):
    method __init__ (line 264) | def __init__(self, opts, *args, **kwargs) -> None:
    method _build_aug_fns_with_uniform_dist (line 271) | def _build_aug_fns_with_uniform_dist(self, opts) -> List:
  function build_neural_augmentor (line 304) | def build_neural_augmentor(opts, *args, **kwargs):

FILE: corenet/modeling/neural_augmentor/utils/neural_aug_utils.py
  class Clip (line 12) | class Clip(nn.Module):
    method __init__ (line 13) | def __init__(
    method forward (line 26) | def forward(self, x: Any) -> Any:
    method __repr__ (line 33) | def __repr__(self):
  class Identity (line 42) | class Identity(nn.Module):
    method __init__ (line 43) | def __init__(self, *args, **kwargs):
    method forward (line 46) | def forward(self, x: Any) -> Any:
  class FixedSampler (line 50) | class FixedSampler(nn.Module):
    method __init__ (line 51) | def __init__(
    method forward (line 62) | def forward(
    method __repr__ (line 68) | def __repr__(self):
  class UniformSampler (line 75) | class UniformSampler(nn.Module):
    method __init__ (line 76) | def __init__(
    method forward (line 91) | def forward(
    method high (line 99) | def high(self):
    method low (line 103) | def low(self):
    method __repr__ (line 106) | def __repr__(self):
  function random_noise (line 114) | def random_noise(x: Tensor, variance: Tensor, *args, **kwargs) -> Tensor:
  function random_contrast (line 121) | def random_contrast(x: Tensor, magnitude: Tensor, *args, **kwargs) -> Te...
  function random_brightness (line 131) | def random_brightness(x: Tensor, magnitude: Tensor, *args, **kwargs) -> ...
  function identity (line 139) | def identity(x: Tensor, *args, **kwargs) -> Tensor:

FILE: corenet/modeling/text_encoders/__init__.py
  function arguments_text_encoder (line 20) | def arguments_text_encoder(parser: argparse.ArgumentParser) -> argparse....
  function build_text_encoder (line 30) | def build_text_encoder(opts, projection_dim: int, *args, **kwargs) -> Ba...

FILE: corenet/modeling/text_encoders/base_text_encoder.py
  class BaseTextEncoder (line 18) | class BaseTextEncoder(nn.Module):
    method __init__ (line 21) | def __init__(self, opts, projection_dim: int, *args, **kwargs) -> None:
    method vocab_size (line 29) | def vocab_size(self):
    method context_length (line 37) | def context_length(self):
    method add_arguments (line 45) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method padding_index (line 79) | def padding_index(self) -> int:
    method reset_parameters (line 87) | def reset_parameters(self):
    method get_trainable_parameters (line 91) | def get_trainable_parameters(
    method freeze_norm_layers (line 108) | def freeze_norm_layers(self) -> None:
    method forward (line 116) | def forward(
    method dummy_input_and_label (line 126) | def dummy_input_and_label(self, batch_size: int) -> Dict:
    method get_activation_checkpoint_submodule_class (line 137) | def get_activation_checkpoint_submodule_class(self) -> Callable:

FILE: corenet/modeling/text_encoders/transformer.py
  class TextTransformer (line 25) | class TextTransformer(BaseTextEncoder):
    method __init__ (line 33) | def __init__(self, opts, projection_dim: int, *args, **kwargs) -> None:
    method build_causal_attention_mask (line 159) | def build_causal_attention_mask(
    method reset_parameters_clip_style (line 194) | def reset_parameters_clip_style(self) -> None:
    method add_arguments (line 222) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method forward_embedding (line 326) | def forward_embedding(self, text_tokens: Tensor) -> Tensor:
    method encode_text (line 345) | def encode_text(
    method forward_zero_shot (line 395) | def forward_zero_shot(
    method forward (line 479) | def forward(
    method get_activation_checkpoint_submodule_class (line 543) | def get_activation_checkpoint_submodule_class(self) -> Callable:

FILE: corenet/optims/__init__.py
  function check_trainable_parameters (line 24) | def check_trainable_parameters(
  function remove_param_name_key (line 86) | def remove_param_name_key(model_params: List) -> None:
  function build_optimizer (line 115) | def build_optimizer(model: torch.nn.Module, opts, *args, **kwargs) -> Ba...
  function arguments_optimizer (line 150) | def arguments_optimizer(parser: argparse.ArgumentParser) -> argparse.Arg...

FILE: corenet/optims/adam.py
  class AdamOptimizer (line 17) | class AdamOptimizer(BaseOptim, Adam):
    method __init__ (line 26) | def __init__(
    method add_arguments (line 49) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...

FILE: corenet/optims/adamw.py
  class AdamWOptimizer (line 17) | class AdamWOptimizer(BaseOptim, AdamW):
    method __init__ (line 26) | def __init__(
    method add_arguments (line 49) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...

FILE: corenet/optims/base_optim.py
  class BaseOptim (line 11) | class BaseOptim(object):
    method __init__ (line 18) | def __init__(self, opts: argparse.Namespace, *args, **kwargs) -> None:
    method add_arguments (line 24) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method __repr__ (line 64) | def __repr__(self) -> str:

FILE: corenet/optims/scheduler/__init__.py
  function build_scheduler (line 20) | def build_scheduler(opts: argparse.Namespace, *args, **kwargs) -> BaseLR...
  function general_lr_sch_args (line 33) | def general_lr_sch_args(parser: argparse.ArgumentParser) -> argparse.Arg...
  function arguments_scheduler (line 78) | def arguments_scheduler(parser: argparse.ArgumentParser) -> argparse.Arg...

FILE: corenet/optims/scheduler/base_scheduler.py
  class BaseLRScheduler (line 11) | class BaseLRScheduler(object):
    method __init__ (line 12) | def __init__(self, opts) -> None:
    method add_arguments (line 34) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_lr (line 37) | def get_lr(self, epoch: int, curr_iter: int):
    method update_lr (line 40) | def update_lr(self, optimizer, epoch: int, curr_iter: int):
    method retrieve_lr (line 55) | def retrieve_lr(optimizer) -> list:
    method extra_repr (line 61) | def extra_repr(self) -> str:
    method __repr__ (line 66) | def __repr__(self) -> str:

FILE: corenet/optims/scheduler/cosine.py
  class CosineScheduler (line 14) | class CosineScheduler(BaseLRScheduler):
    method __init__ (line 19) | def __init__(self, opts, **kwargs) -> None:
    method add_arguments (line 42) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_lr (line 61) | def get_lr(self, epoch: int, curr_iter: int) -> float:
    method __repr__ (line 82) | def __repr__(self) -> str:

FILE: corenet/optims/scheduler/cyclic.py
  class CyclicLRScheduler (line 19) | class CyclicLRScheduler(BaseLRScheduler):
    method __init__ (line 24) | def __init__(self, opts, **kwargs) -> None:
    method _lr_per_cycle (line 77) | def _lr_per_cycle(self) -> None:
    method add_arguments (line 85) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_lr (line 135) | def get_lr(self, epoch: int, curr_iter: int) -> float:
    method __repr__ (line 162) | def __repr__(self):

FILE: corenet/optims/scheduler/fixed.py
  class FixedLRScheduler (line 13) | class FixedLRScheduler(BaseLRScheduler):
    method __init__ (line 18) | def __init__(self, opts, **kwargs) -> None:
    method add_arguments (line 41) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_lr (line 52) | def get_lr(self, epoch: int, curr_iter: int) -> float:
    method __repr__ (line 59) | def __repr__(self) -> str:

FILE: corenet/optims/scheduler/multi_step.py
  class MultiStepLRScheduler (line 13) | class MultiStepLRScheduler(BaseLRScheduler):
    method __init__ (line 18) | def __init__(self, opts, **kwargs) -> None:
    method add_arguments (line 50) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_lr (line 74) | def get_lr(self, epoch: int, curr_iter: int) -> float:
    method __repr__ (line 83) | def __repr__(self) -> str:

FILE: corenet/optims/scheduler/polynomial.py
  class PolynomialScheduler (line 13) | class PolynomialScheduler(BaseLRScheduler):
    method __init__ (line 18) | def __init__(self, opts, **kwargs) -> None:
    method add_arguments (line 39) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method get_lr (line 65) | def get_lr(self, epoch: int, curr_iter: int) -> float:
    method __repr__ (line 81) | def __repr__(self) -> str:

FILE: corenet/optims/sgd.py
  class SGDOptimizer (line 17) | class SGDOptimizer(BaseOptim, SGD):
    method __init__ (line 26) | def __init__(
    method add_arguments (line 47) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...

FILE: corenet/options/errors.py
  class UnrecognizedYamlConfigEntry (line 9) | class UnrecognizedYamlConfigEntry(Warning):
    method __init__ (line 11) | def __init__(self, key: str) -> None:

FILE: corenet/options/opts.py
  class ParseKwargs (line 29) | class ParseKwargs(argparse.Action):
    method __call__ (line 30) | def __call__(self, parser, namespace, values, option_string=None):
  function arguments_common (line 77) | def arguments_common(parser: argparse.ArgumentParser) -> argparse.Argume...
  function arguments_ddp (line 255) | def arguments_ddp(parser: argparse.ArgumentParser) -> argparse.ArgumentP...
  function arguments_train_eval_pipeline (line 302) | def arguments_train_eval_pipeline(
  function arguments_lm_eval (line 318) | def arguments_lm_eval(parser: argparse.ArgumentParser) -> argparse.Argum...
  function parser_to_opts (line 389) | def parser_to_opts(parser: argparse.ArgumentParser, args: Optional[List[...
  function get_training_arguments (line 396) | def get_training_arguments(
  function get_lm_eval_arguments (line 475) | def get_lm_eval_arguments(
  function get_conversion_arguments (line 490) | def get_conversion_arguments(args: Optional[List[str]] = None):
  function get_benchmarking_arguments (line 540) | def get_benchmarking_arguments(args: Optional[List[str]] = None):

FILE: corenet/options/parse_args.py
  function parse_validation_metric_names (line 10) | def parse_validation_metric_names(opts):
  class JsonValidator (line 48) | class JsonValidator:
    method __init__ (line 49) | def __init__(self, expected_type: type):
    method _validate_and_cast (line 64) | def _validate_and_cast(cls, json_value: Any, expected_type: Any):
    method __call__ (line 114) | def __call__(self, str_value: str) -> Any:
    method __repr__ (line 121) | def __repr__(self):

FILE: corenet/options/utils.py
  function flatten_yaml_as_dict (line 38) | def flatten_yaml_as_dict(d, parent_key="", sep="."):
  function load_config_file (line 49) | def load_config_file(opts):
  function extend_selected_args_with_prefix (line 107) | def extend_selected_args_with_prefix(
  function extract_opts_with_prefix_replacement (line 157) | def extract_opts_with_prefix_replacement(

FILE: corenet/third_party/data/text_tokenizer/openai_clip_tokenizer.py
  function bytes_to_unicode (line 21) | def bytes_to_unicode() -> Dict[int, str]:
  function get_pairs (line 47) | def get_pairs(word: Tuple[str, ...]) -> Set[Tuple[str, str]]:
  class OpenAIClipTokenizer (line 60) | class OpenAIClipTokenizer(BaseTextTokenizer):
    method __init__ (line 84) | def __init__(self, opts: argparse.Namespace) -> None:
    method add_arguments (line 133) | def add_arguments(cls, parser: argparse.ArgumentParser) -> argparse.Ar...
    method vocab_size (line 149) | def vocab_size(self) -> int:
    method eot_token (line 154) | def eot_token(self) -> str:
    method eot_token_id (line 159) | def eot_token_id(self) -> int:
    method sot_token (line 164) | def sot_token(self) -> str:
    method sot_token_id (line 169) | def sot_token_id(self) -> int:
    method pad_token_id (line 174) | def pad_token_id(self) -> int:
    method _bpe (line 178) | def _bpe(self, token: str) -> str:
    method tok_encode (line 227) | def tok_encode(self, input_sentence: str) -> Tensor:
    method tok_decode (line 254) | def tok_decode(self, token_ids: Union[List[int], Tensor]) -> str:

FILE: corenet/third_party/modeling/lora.py
  function check_adapters_to_merge (line 27) | def check_adapters_to_merge(
  class BaseTunerLayer (line 61) | class BaseTunerLayer(ABC):
    method get_base_layer (line 88) | def get_base_layer(self) -> nn.Module:
    method weight (line 103) | def weight(self) -> torch.Tensor:
    method bias (line 113) | def bias(self) -> torch.Tensor:
    method merge (line 122) | def merge(
    method unmerge (line 137) | def unmerge(self) -> None:
    method merged (line 144) | def merged(self) -> bool:
    method disable_adapters (line 154) | def disable_adapters(self) -> bool:
    method active_adapter (line 166) | def active_adapter(self) -> Union[List[str], str]:
    method active_adapters (line 178) | def active_adapters(self) -> List[str]:
    method enable_adapters (line 190) | def enable_adapters(self, enabled: bool) -> None:
    method set_adapter (line 208) | def set_adapter(self, adapter_names: Union[str, List[str]]) -> None:
    method _all_available_adapter_names (line 239) | def _all_available_adapter_names(self) -> List[str]:
    method delete_adapter (line 255) | def delete_adapter(self, adapter_name: str) -> None:
  class LoraLayer (line 293) | class LoraLayer(BaseTunerLayer):
    method __init__ (line 309) | def __init__(self, base_layer: nn.Module) -> None:
    method update_layer (line 342) | def update_layer(
    method reset_lora_parameters (line 365) | def reset_lora_parameters(
    method _get_weight_norm (line 395) | def _get_weight_norm(
    method dora_init (line 419) | def dora_init(self, adapter_name: str) -> None:
    method _cache_store (line 446) | def _cache_store(self, key: str, value: Any) -> None:
    method _cache_pop (line 456) | def _cache_pop(self, key: str) -> Any:
    method _apply_dora (line 469) | def _apply_dora(
    method set_scale (line 515) | def set_scale(self, adapter: str, scale: float) -> None:
    method scale_layer (line 529) | def scale_layer(self, scale: float) -> None:
    method unscale_layer (line 543) | def unscale_layer(self, scale: float = None) -> None:
    method _check_forward_args (line 561) | def _check_forward_args(
    method _mixed_batch_forward (line 595) | def _mixed_batch_forward(
  class Linear (line 642) | class Linear(nn.Module, LoraLayer):
    method __init__ (line 658) | def __init__(
    method update_layer (line 683) | def update_layer(
    method merge (line 740) | def merge(
    method unmerge (line 815) | def unmerge(self) -> None:
    method get_delta_weight (line 837) | def get_delta_weight(self, adapter: str) -> torch.Tensor:
    method forward (line 875) | def forward(
    method __repr__ (line 923) | def __repr__(self) -> str:
  class Embedding (line 934) | class Embedding(nn.Module, LoraLayer):
    method __init__ (line 950) | def __init__(
    method update_layer (line 979) | def update_layer(
    method merge (line 1034) | def merge(
    method unmerge (line 1074) | def unmerge(self) -> None:
    method get_delta_weight (line 1088) | def get_delta_weight(self, adapter: str) -> torch.Tensor:
    method _mixed_batch_forward (line 1126) | def _mixed_batch_forward(
    method _embed (line 1172) | def _embed(self, input: torch.Tensor, weight: torch.Tensor) -> torch.T...
    method forward (line 1193) | def forward(
    method __repr__ (line 1234) | def __repr__(self) -> str:
  class LoRAParams (line 1246) | class LoRAParams:
    method from_json (line 1270) | def from_json(cls, config: Dict[str, Any]) -> LayerConfig:
    method to_json (line 1282) | def to_json(self) -> Dict[str, Any]:
  class LayerConfig (line 1293) | class LayerConfig:
    method from_json (line 1309) | def from_json(cls, config: Dict[str, Any]) -> LayerConfig:
  class LoRAConfig (line 1327) | class LoRAConfig:
    method from_json (line 1338) | def from_json(cls, config: Dict[str, Any]) -> LoRAConfig:
  function make_lora_layer (line 1355) | def make_lora_layer(module: nn.Module, layer_config: LoRAConfig) -> Lora...
  function get_module_to_parents (line 1371) | def get_module_to_parents(
  function add_lora_layers (line 1395) | def add_lora_layers(model: nn.Module, lora_config: Dict[str, Any]) -> None:

FILE: corenet/third_party/modeling/ssd_utils.py
  function assign_priors (line 22) | def assign_priors(
  function box_iou (line 70) | def box_iou(
  function hard_negative_mining (line 105) | def hard_negative_mining(

FILE: corenet/train_eval_pipelines/base.py
  function Callback (line 14) | def Callback(Protocol):
  class BaseTrainEvalPipeline (line 18) | class BaseTrainEvalPipeline:
    method __init__ (line 19) | def __init__(
    method __init_subclass__ (line 38) | def __init_subclass__(cls) -> None:
    method __getstate__ (line 50) | def __getstate__(self) -> argparse.Namespace:
    method __setstate__ (line 53) | def __setstate__(self, opts: argparse.Namespace) -> None:
    method evaluation_engine (line 57) | def evaluation_engine(self) -> Evaluator:
    method training_engine (line 62) | def training_engine(self) -> DefaultTrainer:
    method launcher (line 67) | def launcher(self) -> Callable[[Callback], None]:

FILE: corenet/train_eval_pipelines/default_train_eval.py
  class DefaultTrainEvalPipeline (line 48) | class DefaultTrainEvalPipeline(BaseTrainEvalPipeline):
    method is_master_node (line 64) | def is_master_node(self) -> bool:
    method device (line 76) | def device(self) -> torch.device:
    method _train_val_loader_sampler (line 80) | def _train_val_loader_sampler(
    method train_val_loader (line 90) | def train_val_loader(self) -> Tuple[CoreNetDataLoader, CoreNetDataLoad...
    method train_sampler (line 98) | def train_sampler(self) -> BaseSampler:
    method test_loader (line 106) | def test_loader(self) -> CoreNetDataLoader:
    method scheduler (line 111) | def scheduler(self) -> BaseLRScheduler:
    method _prepare_model (line 140) | def _prepare_model(self) -> Tuple[BaseAnyNNModel, Optional[torch.nn.Mo...
    method model (line 174) | def model(self) -> torch.nn.Module:
    method criteria (line 212) | def criteria(self) -> BaseCriteria:
    method optimizer (line 224) | def optimizer(self) -> BaseOptim:
    method gradient_scaler (line 236) | def gradient_scaler(self) -> GradScaler:
    method launcher (line 245) | def launcher(self) -> Callable[[Callback], None]:
    method model_ema (line 317) | def model_ema(self) -> Optional[EMA]:
    method training_engine (line 334) | def training_engine(self) -> DefaultTrainer:
    method evaluation_engine (line 395) | def evaluation_engine(self) -> Evaluator:
    method _launcher_distributed_spawn_fn (line 405) | def _launcher_distributed_spawn_fn(

FILE: corenet/train_eval_pipelines/fsdp_train_eval.py
  class FSDPTrainEvalPipeline (line 26) | class FSDPTrainEvalPipeline(DefaultTrainEvalPipeline):
    method gradient_scaler (line 35) | def gradient_scaler(self) -> GradScaler:
    method model (line 41) | def model(self) -> torch.nn.Module:
    method training_engine (line 57) | def training_engine(self) -> FSDPTrainer:

FILE: corenet/utils/activation_checkpointing_wrapper.py
  function activation_checkpointing (line 13) | def activation_checkpointing(

FILE: corenet/utils/check.py
  function check (line 12) | def check(

FILE: corenet/utils/checkpoint_utils.py
  function get_model_optimizer_state_dict (line 28) | def get_model_optimizer_state_dict(
  function load_state_dict (line 52) | def load_state_dict(
  function average_ckpts (line 73) | def average_ckpts(ckpt_loc_list: List[str]) -> Dict[str, Any]:
  function avg_and_save_k_checkpoints (line 105) | def avg_and_save_k_checkpoints(
  function get_training_state (line 169) | def get_training_state(
  function save_checkpoint (line 221) | def save_checkpoint(
  function load_checkpoint (line 366) | def load_checkpoint(
  function load_model_state (line 463) | def load_model_state(

FILE: corenet/utils/color_map.py
  class Colormap (line 11) | class Colormap(object):
    method __init__ (line 19) | def __init__(self, n: Optional[int] = 256, normalized: Optional[bool] ...
    method get_bit_at_idx (line 25) | def get_bit_at_idx(val, idx):
    method get_color_map (line 28) | def get_color_map(self) -> np.ndarray:
    method get_box_color_codes (line 45) | def get_box_color_codes(self) -> List:
    method get_color_map_list (line 59) | def get_color_map_list(self) -> List:

FILE: corenet/utils/common_utils.py
  function construct_local_path_from_remote (line 23) | def construct_local_path_from_remote(remote_path: str, local_dir: str) -...
  function unwrap_model_fn (line 51) | def unwrap_model_fn(model: torch.nn.Module) -> torch.nn.Module:
  function check_compatibility (line 76) | def check_compatibility() -> None:
  function check_frozen_norm_layer (line 86) | def check_frozen_norm_layer(model: torch.nn.Module) -> Tuple[bool, int]:
  function device_setup (line 100) | def device_setup(opts: argparse.Namespace) -> argparse.Namespace:
  function create_directories (line 157) | def create_directories(dir_path: str, is_master_node: bool) -> None:
  function move_to_device (line 168) | def move_to_device(
  function is_coreml_conversion (line 191) | def is_coreml_conversion(opts) -> bool:

FILE: corenet/utils/context_managers.py
  function context_env_vars (line 11) | def context_env_vars(**env: str) -> ContextManager[None]:
  function context_tensor_threads (line 41) | def context_tensor_threads(num_cpu_threads: int) -> ContextManager[None]:

FILE: corenet/utils/ddp_utils.py
  function is_master (line 17) | def is_master(opts) -> bool:
  function dist_barrier (line 22) | def dist_barrier():
  function dist_monitored_barrier (line 26) | def dist_monitored_barrier(
  function is_start_rank_node (line 34) | def is_start_rank_node(opts) -> bool:
  function get_world_size (line 40) | def get_world_size():
  function get_node_rank (line 44) | def get_node_rank():
  function distributed_init (line 48) | def distributed_init(opts) -> int:
  function is_rank_0_worker_0 (line 99) | def is_rank_0_worker_0(opts: argparse.Namespace) -> bool:

FILE: corenet/utils/dict_utils.py
  function filter_keys (line 8) | def filter_keys(

FILE: corenet/utils/download_utils.py
  function get_local_path (line 21) | def get_local_path(
  class DownloadFunc (line 77) | class DownloadFunc(Protocol):
    method __call__ (line 78) | def __call__(
  function download_assets_in_parallel (line 91) | def download_assets_in_parallel(

FILE: corenet/utils/file_logger.py
  class FileLogger (line 14) | class FileLogger:
    method __init__ (line 19) | def __init__(self, fname: str) -> None:
    method add_scalar (line 43) | def add_scalar(
    method close (line 62) | def close(self) -> None:

FILE: corenet/utils/fpdb.py
  class _ForkedPdb (line 11) | class _ForkedPdb(pdb.Pdb):
    method __init__ (line 26) | def __init__(self, lockfile: str) -> None:
    method interaction (line 30) | def interaction(self, *args, **kwargs) -> None:
  function set_trace (line 49) | def set_trace(lockfile: str = "/tmp/_corenet_fpdb.lockfile") -> None:

FILE: corenet/utils/hf_adapter_utils.py
  class CorenetToHFPretrainedConfig (line 22) | class CorenetToHFPretrainedConfig(PretrainedConfig):
    method __init__ (line 35) | def __init__(self, **kwargs: Dict[str, Any]) -> None:
  class CorenetToHFPretrainedModel (line 39) | class CorenetToHFPretrainedModel(PreTrainedModel):
    method __init__ (line 55) | def __init__(self, config: CorenetToHFPretrainedConfig, vocab_size: in...
    method forward (line 67) | def forward(
    method prepare_inputs_for_generation (line 184) | def prepare_inputs_for_generation(

FILE: corenet/utils/import_utils.py
  function import_modules_from_folder (line 16) | def import_modules_from_folder(
  function ensure_library_is_available (line 64) | def ensure_library_is_available(module_name: str) -> None:
  function import_core_modules (line 103) | def import_core_modules():

FILE: corenet/utils/io_utils.py
  function make_temp_file (line 10) | def make_temp_file(

FILE: corenet/utils/logger.py
  function get_curr_time_stamp (line 25) | def get_curr_time_stamp() -> str:
  function error (line 29) | def error(message: str) -> None:
  function color_text (line 53) | def color_text(in_text: str) -> str:
  function log (line 57) | def log(message: str, end="\n") -> None:
  function warning (line 65) | def warning(message: Union[str, Warning]) -> None:
  function ignore_exception_with_warning (line 79) | def ignore_exception_with_warning(message: str) -> None:
  function info (line 99) | def info(message: str, print_line: Optional[bool] = False) -> None:
  function debug (line 109) | def debug(message: str) -> None:
  function double_dash_line (line 120) | def double_dash_line(dashes: Optional[int] = 75) -> None:
  function singe_dash_line (line 124) | def singe_dash_line(dashes: Optional[int] = 67) -> None:
  function print_header (line 128) | def print_header(header: str) -> None:
  function print_header_minor (line 140) | def print_header_minor(header: str) -> None:
  function disable_printing (line 150) | def disable_printing():
  function enable_printing (line 154) | def enable_printing():
  function match_warning_message (line 158) | def match_warning_message(*message_segments: str) -> str:
  function indent (line 183) | def indent(multiline_str: str, prefix: str = "\t") -> str:
  function truncate (line 200) | def truncate(text: str, max_len: int = 79) -> str:

FILE: corenet/utils/math_utils.py
  function make_divisible (line 9) | def make_divisible(
  function bound_fn (line 33) | def bound_fn(

FILE: corenet/utils/object_utils.py
  function is_iterable (line 14) | def is_iterable(x):
  function apply_recursively (line 18) | def apply_recursively(x, cb, *args, **kwargs):
  function flatten_to_dict (line 28) | def flatten_to_dict(
  function is_pytest_environment (line 62) | def is_pytest_environment() -> bool:

FILE: corenet/utils/object_utils_test.py
  function test_apply_on_values (line 9) | def test_apply_on_values():
  function test_flatten_to_dict (line 22) | def test_flatten_to_dict():

FILE: corenet/utils/pytorch_to_coreml.py
  function convert_pytorch_to_coreml (line 20) | def convert_pytorch_to_coreml(
  function assertion_check (line 137) | def assertion_check(

FILE: corenet/utils/registry.py
  class Registry (line 26) | class Registry:
    method __init__ (line 51) | def __init__(
    method _load_all (line 82) | def _load_all(self) -> None:
    method items (line 99) | def items(self) -> List[Tuple[str, RegistryItem]]:
    method keys (line 103) | def keys(self) -> List[str]:
    method __iter__ (line 107) | def __iter__(self) -> Iterable[str]:
    method __getitem__ (line 111) | def __getitem__(self, key: Union[Tuple[str, str], str]) -> RegistryItem:
    method __contains__ (line 141) | def __contains__(self, key: str) -> bool:
    method register (line 146) | def register(self, name: str, type: str = "") -> Callable:
    method all_arguments (line 173) | def all_arguments(self, parser: argparse.ArgumentParser) -> argparse.A...
    method parse_key (line 187) | def parse_key(self, key: str) -> Tuple[str, Dict[str, str]]:

FILE: corenet/utils/registry_test.py
  function test_functional_registry (line 9) | def test_functional_registry() -> None:
  function test_basic_registration (line 21) | def test_basic_registration() -> None:

FILE: corenet/utils/retry_utils.py
  function run_with_retries (line 13) | def run_with_retries(

FILE: corenet/utils/tensor_utils.py
  function image_size_from_opts (line 22) | def image_size_from_opts(opts) -> Tuple[int, int]:
  function video_size_from_opts (line 40) | def video_size_from_opts(opts) -> Tuple[int, int, int]:
  function create_rand_tensor (line 62) | def create_rand_tensor(
  function reduce_tensor (line 95) | def reduce_tensor(inp_tensor: torch.Tensor) -> torch.Tensor:
  function reduce_tensor_sum (line 104) | def reduce_tensor_sum(inp_tensor: torch.Tensor) -> torch.Tensor:
  function all_gather_list (line 111) | def all_gather_list(data: Union[List, Tensor, Dict[str, Tensor]]):
  function gather_all_features (line 119) | def gather_all_features(features: Tensor, dim=0):
  function tensor_to_python_float (line 128) | def tensor_to_python_float(
  function to_numpy (line 163) | def to_numpy(img_tensor: torch.Tensor) -> np.ndarray:

FILE: corenet/utils/visualization_utils.py
  function visualize_boxes_xyxy (line 30) | def visualize_boxes_xyxy(image: np.ndarray, boxes: np.ndarray) -> np.nda...
  function create_colored_mask (line 50) | def create_colored_mask(
  function draw_bounding_boxes (line 64) | def draw_bounding_boxes(
  function convert_to_cityscape_format (line 128) | def convert_to_cityscape_format(img: Tensor) -> Tensor:

FILE: mlx_examples/clip/clip.py
  function load (line 18) | def load(model_dir: str) -> Tuple[CLIPModel, CLIPTokenizer, CLIPImagePro...
  function main (line 25) | def main() -> None:

FILE: mlx_examples/clip/image_processor.py
  class CLIPImageProcessor (line 17) | class CLIPImageProcessor:
    method __init__ (line 24) | def __init__(
    method __call__ (line 43) | def __call__(self, images: List[Image]) -> mx.array:
    method _preprocess (line 48) | def _preprocess(self, image: Image) -> mx.array:
    method from_pretrained (line 60) | def from_pretrained(path: str) -> "CLIPImageProcessor":
  function resize (line 67) | def resize(image: Image, short_size: int) -> Image:
  function center_crop (line 82) | def center_crop(image: Image, size: Tuple[int, int]) -> Image:
  function rescale (line 97) | def rescale(image: mx.array) -> mx.array:
  function normalize (line 102) | def normalize(image: mx.array, mean: mx.array, std: mx.array) -> mx.array:

FILE: mlx_examples/clip/main_clip_to_mlx.py
  function is_apple_silicon_macos (line 29) | def is_apple_silicon_macos() -> bool:
  function mlx_naming_remap (line 33) | def mlx_naming_remap(corenet_k: str) -> str:
  function make_shards (line 87) | def make_shards(
  function save_weights (line 106) | def save_weights(save_path: Union[str, Path], weights: Dict[str, Any]) -...
  function get_hf_clip_model_path (line 158) | def get_hf_clip_model_path() -> Path:
  function ascontiguousarray (line 178) | def ascontiguousarray(mx_array: mx.array) -> mx.array:
  function sanitize (line 190) | def sanitize(state_dict: Dict[str, mx.array]) -> Dict[str, mx.array]:
  function torch_to_mx (line 234) | def torch_to_mx(a: torch.Tensor, *, dtype: str) -> mx.array:
  function main (line 241) | def main() -> None:

FILE: mlx_examples/clip/main_test_clip_mlx.py
  function load_mlx_model (line 43) | def load_mlx_model(model_dir: str) -> CLIPModel:
  function get_mlx_output (line 51) | def get_mlx_output(
  function transform_image (line 65) | def transform_image(img: Image.Image, size: int = 224) -> torch.Tensor:
  function text_transform (line 75) | def text_transform(tokeized_text_tensor: torch.Tensor) -> torch.Tensor:
  function get_tokenized_input (line 83) | def get_tokenized_input(
  function get_preprocessed_img (line 100) | def get_preprocessed_img(class_names: List[str]) -> torch.Tensor:
  function get_input_images_and_tokenized_text (line 112) | def get_input_images_and_tokenized_text(
  function get_torch_output (line 121) | def get_torch_output(
  function torch_to_mx (line 143) | def torch_to_mx(a: torch.Tensor, *, dtype: str) -> mx.array:
  function main_test (line 150) | def main_test() -> None:

FILE: mlx_examples/clip/model.py
  class CLIPVisionOutput (line 24) | class CLIPVisionOutput:
  class CLIPTextOutput (line 31) | class CLIPTextOutput:
  class CLIPModelOutput (line 37) | class CLIPModelOutput:
  class CLIPTextConfig (line 46) | class CLIPTextConfig:
  class CLIPVisionConfig (line 59) | class CLIPVisionConfig:
  class CLIPConfig (line 73) | class CLIPConfig:
  function quick_gelu (line 80) | def quick_gelu(x: mx.array) -> mx.array:
  function get_hidden_act (line 87) | def get_hidden_act(
  function clip_loss (line 99) | def clip_loss(logits: mx.array) -> mx.array:
  class Attention (line 107) | class Attention(nn.Module):
    method __init__ (line 110) | def __init__(
    method __call__ (line 141) | def __call__(
  class MLP (line 168) | class MLP(nn.Module):
    method __init__ (line 171) | def __init__(self, config: CLIPTextConfig) -> None:
    method __call__ (line 178) | def __call__(self, x: mx.array) -> mx.array:
  class EncoderLayer (line 184) | class EncoderLayer(nn.Module):
    method __init__ (line 187) | def __init__(self, config: CLIPTextConfig) -> None:
    method __call__ (line 198) | def __call__(self, x: mx.array, mask: Optional[mx.array] = None) -> mx...
  class TextEmbeddings (line 207) | class TextEmbeddings(nn.Module):
    method __init__ (line 210) | def __init__(self, config: CLIPTextConfig) -> None:
    method __call__ (line 219) | def __call__(self, x: mx.array) -> mx.array:
  class Encoder (line 225) | class Encoder(nn.Module):
    method __init__ (line 228) | def __init__(self, config: Union[CLIPTextConfig, CLIPVisionConfig]) ->...
    method __call__ (line 231) | def __call__(self) -> None:
  function create_additive_causual_mask (line 235) | def create_additive_causual_mask(
  class ClipTextModel (line 247) | class ClipTextModel(nn.Module):
    method __init__ (line 250) | def __init__(self, config: CLIPTextConfig) -> None:
    method __call__ (line 257) | def __call__(self, x: mx.array) -> CLIPTextOutput:
  class VisionEmbeddings (line 273) | class VisionEmbeddings(nn.Module):
    method __init__ (line 276) | def __init__(self, config: CLIPVisionConfig) -> None:
    method __call__ (line 328) | def __call__(self, x: mx.array) -> mx.array:
  class ClipVisionModel (line 363) | class ClipVisionModel(nn.Module):
    method __init__ (line 366) | def __init__(self, config: CLIPVisionConfig) -> None:
    method __call__ (line 376) | def __call__(
  class CLIPModel (line 401) | class CLIPModel(nn.Module):
    method __init__ (line 404) | def __init__(self, config: CLIPConfig) -> None:
    method get_text_features (line 418) | def get_text_features(self, x: mx.array) -> mx.array:
    method get_image_features (line 421) | def get_image_features(self, x: mx.array) -> mx.array:
    method __call__ (line 424) | def __call__(
    method from_pretrained (line 465) | def from_pretrained(path: str) -> "CLIPModel":
    method sanitize (line 521) | def sanitize(weights: Dict[str, mx.array]) -> Dict[str, mx.array]:

FILE: mlx_examples/clip/tokenizer.py
  class CLIPTokenizer (line 16) | class CLIPTokenizer:
    method __init__ (line 22) | def __init__(self, bpe_ranks: Dict[Tuple[str], int], vocab: Dict[str, ...
    method bos (line 32) | def bos(self) -> str:
    method bos_token (line 36) | def bos_token(self) -> int:
    method eos (line 40) | def eos(self) -> str:
    method eos_token (line 44) | def eos_token(self) -> int:
    method bpe (line 47) | def bpe(self, text: str) -> List[str]:
    method __call__ (line 92) | def __call__(self, *args: Any, **kwargs: Any) -> Any:
    method tokenize (line 95) | def tokenize(
    method from_pretrained (line 120) | def from_pretrained(path: str) -> "CLIPTokenizer":

FILE: mlx_examples/open_elm/convert.py
  function torch_to_mlx (line 29) | def torch_to_mlx(x: torch.Tensor) -> mx.array:
  function quantize_weights (line 48) | def quantize_weights(
  function convert_open_elm (line 81) | def convert_open_elm(

FILE: mlx_examples/open_elm/inference.py
  function generate_token (line 24) | def generate_token(
  function generate (line 74) | def generate(

FILE: mlx_examples/open_elm/open_elm.py
  function get_normalization_layer (line 18) | def get_normalization_layer(num_features: int, norm_type: str) -> nn.Mod...
  function compute_heads (line 24) | def compute_heads(model_dim: int, head_dim: int) -> int:
  function make_divisible (line 33) | def make_divisible(val: Union[int, float], divisor: int) -> int:
  class GPTConfig (line 55) | class GPTConfig:
    method __post_init__ (line 88) | def __post_init__(self) -> None:
    method from_name (line 172) | def from_name(
  class MultiHeadCausalAttention (line 231) | class MultiHeadCausalAttention(nn.Module):
    method __init__ (line 239) | def __init__(self, model_config: GPTConfig, layer_idx: int) -> None:
    method extra_repr (line 289) | def extra_repr(self) -> str:
    method __call__ (line 297) | def __call__(
  class FeedForwardNetwork (line 386) | class FeedForwardNetwork(nn.Module):
    method __init__ (line 395) | def __init__(self, model_config: GPTConfig, layer_idx: int) -> None:
    method extra_repr (line 436) | def extra_repr(self) -> str:
    method __call__ (line 439) | def __call__(self, x):
  class TransformerDecoderLayer (line 457) | class TransformerDecoderLayer(nn.Module):
    method __init__ (line 466) | def __init__(self, model_config: GPTConfig, layer_idx: int) -> None:
    method __call__ (line 481) | def __call__(
  class OpenELM (line 514) | class OpenELM(nn.Module):
    method __init__ (line 526) | def __init__(
    method __call__ (line 563) | def __call__(
    method reset_parameters (line 614) | def reset_parameters(self, model_config: GPTConfig) -> None:
  function load_model (line 655) | def load_model(

FILE: setup.py
  function is_apple_silicon_macos (line 16) | def is_apple_silicon_macos() -> bool:
  function parse_requirements (line 20) | def parse_requirements(path: str) -> List[str]:
  function main (line 33) | def main() -> None:
  function get_files (line 120) | def get_files(path, relative_to=".") -> List[str]:

FILE: tests/configs.py
  function get_config (line 14) | def get_config(
  function default_training_opts (line 56) | def default_training_opts() -> argparse.Namespace:
  function modify_attr (line 61) | def modify_attr(opts: argparse.Namespace, key: str, value: Any) -> None:

FILE: tests/data/collate_fns/test_byteformer_collate_fn.py
  function test_byteformer_image_collate_fn (line 13) | def test_byteformer_image_collate_fn() -> None:
  function test_wav_collate (line 46) | def test_wav_collate() -> None:

FILE: tests/data/collate_fns/test_collate_functions.py
  function test_image_data_collate_functions (line 28) | def test_image_data_collate_functions(

FILE: tests/data/datasets/audio_classification/test_speech_commands_v2.py
  function mock_load (line 20) | def mock_load(filepath: str) -> Tuple[Tensor, int]:
  function mock_process_dataset_config (line 28) | def mock_process_dataset_config(self) -> None:
  function test_getitem (line 52) | def test_getitem(

FILE: tests/data/datasets/classification/mock_coco.py
  class MockCOCOClassification (line 16) | class MockCOCOClassification(COCOClassification):
    method read_image_pil (line 18) | def read_image_pil(path: str) -> Optional[Image.Image]:

FILE: tests/data/datasets/classification/mock_imagenet.py
  class MockImageNetDataset (line 28) | class MockImageNetDataset(ImageNetDataset):
    method __init__ (line 29) | def __init__(
    method n_classes (line 55) | def n_classes(self):
    method read_image_pil (line 59) | def read_image_pil(path: str) -> Optional[Image.Image]:
  class MockImageN
Condensed preview — 738 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (8,081K chars).
[
  {
    "path": ".dockerignore",
    "chars": 712,
    "preview": "# Docker-specific:\n**/Dockerfile\nsetup_bolt.sh\n.git\n.gitignore\n.dockerignore\n\n# Mirroring .gitignore\n# Note: dockerignor"
  },
  {
    "path": ".flake8",
    "chars": 51,
    "preview": "[flake8]\nmax-line-length = 88\nextend-ignore = E203\n"
  },
  {
    "path": ".gitattributes",
    "chars": 941,
    "preview": "*.tar filter=lfs diff=lfs merge=lfs -text\n*.gz filter=lfs diff=lfs merge=lfs -text\n*.zip filter=lfs diff=lfs merge=lfs -"
  },
  {
    "path": ".gitignore",
    "chars": 441,
    "preview": "# Note: please mirror changes of this file to .dockerignore.\n\n.vscode/\n.coverage\n*.pyc\n__pycache__\n.DS_STORE\n.idea\n*.swp"
  },
  {
    "path": "ACKNOWLEDGEMENTS",
    "chars": 65727,
    "preview": "Acknowledgements\nPortions of this Software may utilize the following copyrighted material, the use of which is hereby ac"
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "chars": 3358,
    "preview": "# Code of Conduct\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, we as\ncontributors and"
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 748,
    "preview": "# Contribution Guide\n\nThanks for your interest in contributing. This project was released to accompany a research paper "
  },
  {
    "path": "LICENSE",
    "chars": 2672,
    "preview": "Copyright (C) 2024 Apple Inc. All Rights Reserved.\n\nDisclaimer: IMPORTANT:  This Apple software is supplied to you by Ap"
  },
  {
    "path": "Makefile",
    "chars": 6222,
    "preview": "SHELL := /bin/bash\nYEAR = $$(date +%Y)\nLAST_YEAR = $$(($(YEAR) - 1))\nCOLOR_LOG = \\033[34m\nCOLOR_INFO = \\033[32m\nCOLOR_WA"
  },
  {
    "path": "README.md",
    "chars": 11534,
    "preview": "# CoreNet: A library for training deep neural networks\n\nCoreNet is a deep neural network toolkit that allows researchers"
  },
  {
    "path": "conftest.py",
    "chars": 1788,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport os\nimpor"
  },
  {
    "path": "corenet/__init__.py",
    "chars": 3651,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport warnings"
  },
  {
    "path": "corenet/__main__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "corenet/__version__.py",
    "chars": 122,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\nversion = \"0.1.1"
  },
  {
    "path": "corenet/cli/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "corenet/cli/entrypoints.py",
    "chars": 1309,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/cli/main.py",
    "chars": 1326,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/cli/main_benchmark.py",
    "chars": 3756,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport time\nfro"
  },
  {
    "path": "corenet/cli/main_conversion.py",
    "chars": 3064,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport os\nfrom "
  },
  {
    "path": "corenet/cli/main_eval.py",
    "chars": 1671,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\nfrom typing impo"
  },
  {
    "path": "corenet/cli/main_eval_llmadapters.py",
    "chars": 16103,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\n\"\"\"\nEvaluate co"
  },
  {
    "path": "corenet/cli/main_train.py",
    "chars": 1284,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/constants.py",
    "chars": 3703,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\nimport os\nimport"
  },
  {
    "path": "corenet/data/__init__.py",
    "chars": 187,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom corenet.da"
  },
  {
    "path": "corenet/data/collate_fns/__init__.py",
    "chars": 2313,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/collate_fns/byteformer_collate_functions.py",
    "chars": 8036,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\n\"\"\"This file co"
  },
  {
    "path": "corenet/data/collate_fns/collate_functions.py",
    "chars": 5307,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\nimport argparse\n"
  },
  {
    "path": "corenet/data/data_loaders.py",
    "chars": 7991,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/__init__.py",
    "chars": 5736,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/audio_classification/__init__.py",
    "chars": 104,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n"
  },
  {
    "path": "corenet/data/datasets/audio_classification/speech_commands_v2.py",
    "chars": 7807,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/classification/__init__.py",
    "chars": 104,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n"
  },
  {
    "path": "corenet/data/datasets/classification/base_image_classification_dataset.py",
    "chars": 10593,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\nimport argparse\n"
  },
  {
    "path": "corenet/data/datasets/classification/base_imagenet_shift_dataset.py",
    "chars": 3411,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\"\"\"Base class fo"
  },
  {
    "path": "corenet/data/datasets/classification/coco.py",
    "chars": 6972,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/classification/imagenet.py",
    "chars": 968,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/classification/imagenet_a.py",
    "chars": 1546,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\"\"\"ImageNetA dat"
  },
  {
    "path": "corenet/data/datasets/classification/imagenet_r.py",
    "chars": 1876,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\"\"\"ImageNetR dat"
  },
  {
    "path": "corenet/data/datasets/classification/imagenet_sketch.py",
    "chars": 1499,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\"\"\"ImageNetSketc"
  },
  {
    "path": "corenet/data/datasets/classification/imagenet_synsets.py",
    "chars": 24154,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\n# Folder names/"
  },
  {
    "path": "corenet/data/datasets/classification/imagenet_v2.py",
    "chars": 6010,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/classification/places365.py",
    "chars": 976,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/classification/wordnet_tagged_classification.py",
    "chars": 18161,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/dataset_base.py",
    "chars": 19099,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom __future__"
  },
  {
    "path": "corenet/data/datasets/detection/__init__.py",
    "chars": 104,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n"
  },
  {
    "path": "corenet/data/datasets/detection/base_detection.py",
    "chars": 1852,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/detection/coco_base.py",
    "chars": 11501,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/detection/coco_mask_rcnn.py",
    "chars": 6884,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/detection/coco_ssd.py",
    "chars": 9098,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/language_modeling/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "corenet/data/datasets/language_modeling/base_lm.py",
    "chars": 9019,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/language_modeling/commonsense_170k.py",
    "chars": 5237,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\n\nimport argpars"
  },
  {
    "path": "corenet/data/datasets/language_modeling/general_lm.py",
    "chars": 25142,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\n\nimport argpars"
  },
  {
    "path": "corenet/data/datasets/multi_modal_img_text/__init__.py",
    "chars": 629,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/multi_modal_img_text/base_multi_modal_img_text.py",
    "chars": 19129,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/multi_modal_img_text/flickr.py",
    "chars": 4693,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport json\nimp"
  },
  {
    "path": "corenet/data/datasets/multi_modal_img_text/img_text_tar_dataset.py",
    "chars": 11926,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/multi_modal_img_text/zero_shot_image_classification/__init__.py",
    "chars": 1505,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/multi_modal_img_text/zero_shot_image_classification/base_zero_shot_image_classification.py",
    "chars": 2831,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/multi_modal_img_text/zero_shot_image_classification/imagenet.py",
    "chars": 852,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/multi_modal_img_text/zero_shot_image_classification/imagenet_a.py",
    "chars": 1216,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/data/datasets/multi_modal_img_text/zero_shot_image_classification/imagenet_class_names.py",
    "chars": 18947,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\n\nIMAGENET_CLASS"
  },
  {
    "path": "corenet/data/datasets/multi_modal_img_text/zero_shot_image_classification/imagenet_r.py",
    "chars": 1228,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/data/datasets/multi_modal_img_text/zero_shot_image_classification/imagenet_sketch.py",
    "chars": 1086,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/data/datasets/multi_modal_img_text/zero_shot_image_classification/templates.py",
    "chars": 3462,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/data/datasets/segmentation/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "corenet/data/datasets/segmentation/ade20k.py",
    "chars": 10026,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/segmentation/base_segmentation.py",
    "chars": 12904,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/segmentation/coco_segmentation.py",
    "chars": 5380,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/segmentation/coco_stuff.py",
    "chars": 11478,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/segmentation/pascal_voc.py",
    "chars": 5809,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/datasets/utils/__init__.py",
    "chars": 104,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n"
  },
  {
    "path": "corenet/data/datasets/utils/common.py",
    "chars": 6173,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport collecti"
  },
  {
    "path": "corenet/data/datasets/utils/text.py",
    "chars": 724,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport re\nimpor"
  },
  {
    "path": "corenet/data/datasets/utils/video.py",
    "chars": 17322,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\"\"\"Contains help"
  },
  {
    "path": "corenet/data/io/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "corenet/data/io/transfer_clients.py",
    "chars": 17162,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\n\nimport argpars"
  },
  {
    "path": "corenet/data/loader/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "corenet/data/loader/dataloader.py",
    "chars": 4111,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport sys\nfrom"
  },
  {
    "path": "corenet/data/sampler/__init__.py",
    "chars": 2406,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/sampler/base_sampler.py",
    "chars": 16111,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/sampler/batch_sampler.py",
    "chars": 4881,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/sampler/chain_sampler.py",
    "chars": 12773,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom __future__"
  },
  {
    "path": "corenet/data/sampler/multi_scale_sampler.py",
    "chars": 11146,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/sampler/utils.py",
    "chars": 5477,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/data/sampler/variable_batch_sampler.py",
    "chars": 15165,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/sampler/video_batch_sampler.py",
    "chars": 5010,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/sampler/video_clip_batch_sampler.py",
    "chars": 12033,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/sampler/video_variable_seq_sampler.py",
    "chars": 11269,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/text_tokenizer/__init__.py",
    "chars": 1617,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/text_tokenizer/base_tokenizer.py",
    "chars": 4187,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/text_tokenizer/clip_tokenizer.py",
    "chars": 3871,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/text_tokenizer/sentencepiece_tokenizer.py",
    "chars": 7167,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/transforms/__init__.py",
    "chars": 770,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/transforms/audio.py",
    "chars": 24561,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/transforms/audio_aux/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "corenet/data/transforms/audio_aux/mfccs.py",
    "chars": 5787,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\nimport math\n\nimp"
  },
  {
    "path": "corenet/data/transforms/audio_bytes.py",
    "chars": 6091,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\nimport argparse\n"
  },
  {
    "path": "corenet/data/transforms/base_transforms.py",
    "chars": 611,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/transforms/common.py",
    "chars": 1249,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\nfrom typing impo"
  },
  {
    "path": "corenet/data/transforms/image_bytes.py",
    "chars": 14197,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/transforms/image_pil.py",
    "chars": 80622,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/transforms/image_torch.py",
    "chars": 17258,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/transforms/utils.py",
    "chars": 1396,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/data/transforms/video.py",
    "chars": 53746,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\nimport argparse\n"
  },
  {
    "path": "corenet/data/video_reader/__init__.py",
    "chars": 1765,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/video_reader/base_av_reader.py",
    "chars": 28970,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/video_reader/decord_reader.py",
    "chars": 7017,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport sys\nfrom"
  },
  {
    "path": "corenet/data/video_reader/ffmpeg_reader.py",
    "chars": 13421,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/data/video_reader/ffmpeg_utils.py",
    "chars": 29109,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\nimport argparse\n"
  },
  {
    "path": "corenet/data/video_reader/pyav_reader.py",
    "chars": 5143,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/engine/__init__.py",
    "chars": 218,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom corenet.en"
  },
  {
    "path": "corenet/engine/default_trainer.py",
    "chars": 25279,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/engine/detection_utils/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "corenet/engine/detection_utils/coco_map.py",
    "chars": 3417,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport io\nimpor"
  },
  {
    "path": "corenet/engine/eval_detection.py",
    "chars": 15241,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/engine/eval_segmentation.py",
    "chars": 21148,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\nimport argparse\n"
  },
  {
    "path": "corenet/engine/evaluation_engine.py",
    "chars": 4800,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/engine/fsdp_trainer.py",
    "chars": 8815,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/engine/segmentation_utils/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "corenet/engine/segmentation_utils/cityscapes_iou.py",
    "chars": 1465,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport glob\nimp"
  },
  {
    "path": "corenet/engine/utils.py",
    "chars": 6273,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\nimport argparse\n"
  },
  {
    "path": "corenet/loss_fn/__init__.py",
    "chars": 2725,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/loss_fn/base_criteria.py",
    "chars": 1777,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport abc\nimpo"
  },
  {
    "path": "corenet/loss_fn/classification/__init__.py",
    "chars": 104,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n"
  },
  {
    "path": "corenet/loss_fn/classification/base_classification_criteria.py",
    "chars": 3626,
    "preview": "#  For licensing see accompanying LICENSE file.\n#  Copyright (C) 2024 Apple Inc. All Rights Reserved.\n\nimport argparse\nf"
  },
  {
    "path": "corenet/loss_fn/classification/binary_cross_entropy.py",
    "chars": 3232,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/loss_fn/classification/cross_entropy.py",
    "chars": 3650,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/loss_fn/classification/focal_loss.py",
    "chars": 3561,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/loss_fn/composite_loss.py",
    "chars": 9310,
    "preview": "#  For licensing see accompanying LICENSE file.\n#  Copyright (C) 2024 Apple Inc. All Rights Reserved.\n\nfrom __future__ i"
  },
  {
    "path": "corenet/loss_fn/detection/__init__.py",
    "chars": 104,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n"
  },
  {
    "path": "corenet/loss_fn/detection/base_detection_criteria.py",
    "chars": 1116,
    "preview": "#  For licensing see accompanying LICENSE file.\n#  Copyright (C) 2024 Apple Inc. All Rights Reserved.\n\nimport argparse\n\n"
  },
  {
    "path": "corenet/loss_fn/detection/mask_rcnn_loss.py",
    "chars": 5871,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/loss_fn/detection/ssd_multibox_loss.py",
    "chars": 8907,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/loss_fn/distillation/__init__.py",
    "chars": 104,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n"
  },
  {
    "path": "corenet/loss_fn/distillation/base_distillation.py",
    "chars": 4911,
    "preview": "#  For licensing see accompanying LICENSE file.\n#  Copyright (C) 2024 Apple Inc. All Rights Reserved.\n\nimport argparse\nf"
  },
  {
    "path": "corenet/loss_fn/distillation/hard_distillation.py",
    "chars": 4833,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/loss_fn/distillation/soft_kl_distillation.py",
    "chars": 2752,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/loss_fn/language_modeling/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "corenet/loss_fn/language_modeling/base_lm.py",
    "chars": 4079,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/loss_fn/language_modeling/cross_entropy.py",
    "chars": 4955,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/loss_fn/language_modeling/cross_entropy_for_kv_prediction.py",
    "chars": 13062,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/loss_fn/multi_modal_img_text/__init__.py",
    "chars": 104,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n"
  },
  {
    "path": "corenet/loss_fn/multi_modal_img_text/base_multi_modal_img_text_criteria.py",
    "chars": 1156,
    "preview": "#  For licensing see accompanying LICENSE file.\n#  Copyright (C) 2024 Apple Inc. All Rights Reserved.\n\nimport argparse\n\n"
  },
  {
    "path": "corenet/loss_fn/multi_modal_img_text/contrastive_loss_clip.py",
    "chars": 6550,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\nimport argparse\n"
  },
  {
    "path": "corenet/loss_fn/neural_augmentation.py",
    "chars": 12941,
    "preview": "#  For licensing see accompanying LICENSE file.\n#  Copyright (C) 2024 Apple Inc. All Rights Reserved.\n\nimport argparse\ni"
  },
  {
    "path": "corenet/loss_fn/segmentation/__init__.py",
    "chars": 104,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n"
  },
  {
    "path": "corenet/loss_fn/segmentation/base_segmentation_criteria.py",
    "chars": 1112,
    "preview": "#  For licensing see accompanying LICENSE file.\n#  Copyright (C) 2024 Apple Inc. All Rights Reserved.\n\nimport argparse\n\n"
  },
  {
    "path": "corenet/loss_fn/segmentation/cross_entropy.py",
    "chars": 10386,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/loss_fn/utils/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "corenet/loss_fn/utils/build_helper.py",
    "chars": 1091,
    "preview": "#  For licensing see accompanying LICENSE file.\n#  Copyright (C) 2024 Apple Inc. All Rights Reserved.\n\nimport argparse\n\n"
  },
  {
    "path": "corenet/loss_fn/utils/class_weighting.py",
    "chars": 1528,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport torch\nfr"
  },
  {
    "path": "corenet/metrics/__init__.py",
    "chars": 1299,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/metrics/average_precision.py",
    "chars": 1653,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport tracebac"
  },
  {
    "path": "corenet/metrics/coco_map.py",
    "chars": 8875,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\nimport io\nimport"
  },
  {
    "path": "corenet/metrics/confusion_mat.py",
    "chars": 2821,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom numbers im"
  },
  {
    "path": "corenet/metrics/image_text_retrieval.py",
    "chars": 7145,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/metrics/intersection_over_union.py",
    "chars": 3410,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom numbers im"
  },
  {
    "path": "corenet/metrics/metric_base.py",
    "chars": 11487,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport abc\nimpo"
  },
  {
    "path": "corenet/metrics/metric_base_test.py",
    "chars": 1272,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/metrics/misc.py",
    "chars": 3131,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom numbers im"
  },
  {
    "path": "corenet/metrics/multiclass_classification_pr.py",
    "chars": 18279,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\nimport argparse\n"
  },
  {
    "path": "corenet/metrics/probability_histograms.py",
    "chars": 1831,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/metrics/psnr.py",
    "chars": 4203,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/metrics/retrieval_cmc.py",
    "chars": 7872,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/metrics/stats.py",
    "chars": 8782,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/metrics/topk_accuracy.py",
    "chars": 4351,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/metrics/vqa_preset_score.py",
    "chars": 2981,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\"\"\"Preset score "
  },
  {
    "path": "corenet/modeling/__init__.py",
    "chars": 1867,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/modeling/anchor_generator/__init__.py",
    "chars": 1626,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/modeling/anchor_generator/base_anchor_generator.py",
    "chars": 2750,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/modeling/anchor_generator/ssd_anchor_generator.py",
    "chars": 6902,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/modeling/image_projection_layers/__init__.py",
    "chars": 2086,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\n\nimport argpars"
  },
  {
    "path": "corenet/modeling/image_projection_layers/attention_pool_2d.py",
    "chars": 6791,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/modeling/image_projection_layers/base_image_projection.py",
    "chars": 2717,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/modeling/image_projection_layers/global_pool_2d.py",
    "chars": 2998,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/modeling/image_projection_layers/simple_projection_head.py",
    "chars": 2782,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/modeling/layers/__init__.py",
    "chars": 3727,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/modeling/layers/activation/__init__.py",
    "chars": 3470,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/modeling/layers/activation/gelu.py",
    "chars": 435,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom torch impo"
  },
  {
    "path": "corenet/modeling/layers/activation/hard_sigmoid.py",
    "chars": 771,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/modeling/layers/activation/hard_swish.py",
    "chars": 857,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/modeling/layers/activation/leaky_relu.py",
    "chars": 681,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/modeling/layers/activation/prelu.py",
    "chars": 623,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/modeling/layers/activation/relu.py",
    "chars": 464,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/modeling/layers/activation/relu6.py",
    "chars": 455,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/modeling/layers/activation/sigmoid.py",
    "chars": 386,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom torch impo"
  },
  {
    "path": "corenet/modeling/layers/activation/swish.py",
    "chars": 514,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/modeling/layers/activation/tanh.py",
    "chars": 370,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom torch impo"
  },
  {
    "path": "corenet/modeling/layers/adaptive_pool.py",
    "chars": 1014,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/modeling/layers/base_layer.py",
    "chars": 1987,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/modeling/layers/conv_layer.py",
    "chars": 21332,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/modeling/layers/dropout.py",
    "chars": 1549,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/modeling/layers/embedding.py",
    "chars": 1956,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/modeling/layers/flash_multi_head_attention.py",
    "chars": 4278,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/modeling/layers/flatten.py",
    "chars": 895,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom typing imp"
  },
  {
    "path": "corenet/modeling/layers/global_pool.py",
    "chars": 2604,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  },
  {
    "path": "corenet/modeling/layers/identity.py",
    "chars": 417,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nfrom torch impo"
  },
  {
    "path": "corenet/modeling/layers/linear_attention.py",
    "chars": 8248,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\nfrom typing impo"
  },
  {
    "path": "corenet/modeling/layers/linear_layer.py",
    "chars": 7349,
    "preview": "#\n# For licensing see accompanying LICENSE file.\n# Copyright (C) 2024 Apple Inc. All Rights Reserved.\n#\n\nimport argparse"
  }
]

// ... and 538 more files (download for full content)

About this extraction

This page contains the full source code of the apple/corenet GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 738 files (7.5 MB), approximately 2.0M tokens, and a symbol index with 2560 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!