This report summarizes scanner evidence for KevinMusgrave/pytorch-metric-learning. SynthScan examined 65,420 lines of code across 388 source files, recording 856 pattern matches distributed across 6 syntactic categories. The legacy adjusted pattern signal is 13.4 (Moderate pattern signal); it is not an authorship estimate.
Use the findings to ask whether maintainers can explain intent, verify dependencies, simplify unnecessary scaffolding, and focus review effort. Risk Payload v1 adds ownership, supply-chain, over-engineering, and review-effort vectors when available. These are prompts for human verification, not probabilities, security findings, or measured maintenance costs.
Use each vector to guide manual verification of the underlying findings.
Payload schema: 1.0.0 · Engine: 2.0.0 · Scoring: heuristic-density-v1 · Scan date: 2026-10-31.
Can maintainers explain intent, assumptions, and trade-offs? 730 finding(s).
Are imports declared and package/API names verified? 110 finding(s).
Are wrappers, guards, and repeated structures necessary? 651 finding(s).
Which changes need focused human review? 856 finding(s).
Run additional scans to build a history of the legacy pattern signal. Score changes are not a measure of AI adoption or code quality.
Groups findings by configured severity weight. Severity is not a confidence estimate, security rating, or proof that a package is missing. Verify imports against the project's manifests and inspect each finding in its local design context.
This horizontal bar chart shows where configured pattern scores accumulate across directories. Treat the bars as locations to inspect, not as evidence of authorship or code quality. Use the file-level findings to decide whether a directory needs a focused ownership, dependency, complexity, or review check.
The scanner identified 856 distinct pattern matches across 6 syntactic categories. Each entry below represents a discrete location in the source code where the engine recorded a detector match to inspect in context. Expand any category row to inspect the individual file paths, line numbers, code snippets, and the lexical context (CODE, COMMENT, or STRING) in which each match was detected.
Reading the findings table: The Severity column indicates the configured finding weight (CRITICAL / HIGH / MEDIUM / LOW). The Context column identifies whether the match occurred inside executable code, an inline comment, or a string literal — legacy comment-context matches receive a ×1.5 score weight. The ⚡ bolt icon marks clustered matches: three or more patterns within a 10-line window, each receiving an additional ×1.5 density multiplier under the legacy scoring model.
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | conftest.py | 38 | def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item]): | CODE |
| LOW | tests/helpers.py | 11 | def use_deterministic_kernels(test) -> None: | CODE |
| LOW | tests/losses/test_circle_loss.py | 131 | def test_anchors_without_positives_and_negatives_are_excluded(self): | CODE |
| LOW | tests/losses/test_histogram_loss.py | 128 | def test_with_no_valid_triplets(self): | CODE |
| LOW | tests/losses/test_histogram_loss.py | 152 | def test_identical_and_opposite_embeddings(self): | CODE |
| LOW | tests/losses/test_histogram_loss.py | 171 | def test_collapsed_embeddings_have_unit_loss(self): | CODE |
| LOW | tests/losses/test_histogram_loss.py | 186 | def test_endpoint_mass_splits_between_first_and_last_nodes(self): | CODE |
| LOW | tests/losses/test_histogram_loss.py | 204 | def test_interior_interpolation_preserves_values_and_slopes(self): | CODE |
| LOW | tests/losses/test_pnp_loss.py | 203 | def test_negatives_that_have_no_positives(self): | CODE |
| LOW | tests/losses/test_pnp_loss.py | 211 | def test_anchors_without_other_positives_are_excluded(self): | CODE |
| LOW | tests/losses/test_pnp_loss.py | 246 | def test_batches_without_positive_pairs_give_differentiable_zero(self): | CODE |
| LOW | tests/losses/test_pnp_loss.py | 276 | def test_variants_match_scalar_values_and_analytic_gradients(self): | CODE |
| LOW | tests/losses/test_pnp_loss.py | 319 | def test_masked_comparisons_keep_backward_finite(self): | CODE |
| LOW | tests/losses/test_pnp_loss.py | 335 | def test_half_exponent_overflow_keeps_default_temperature_finite(self): | CODE |
| LOW | tests/losses/test_pnp_loss.py | 352 | def test_negative_tail_keeps_representable_values_and_gradients(self): | CODE |
| LOW | tests/losses/test_fastap_loss.py | 16 | def original_implementation_fast_ap_loss(input, target, num_bins): | CODE |
| LOW | tests/losses/test_margin_loss.py | 94 | def test_margin_loss_with_ref(self): | CODE |
| LOW | tests/losses/test_margin_loss.py | 105 | def test_with_no_valid_triplets(self): | CODE |
| LOW | tests/losses/test_margin_loss.py | 131 | def test_beta_follows_module_placement(self): | CODE |
| LOW | tests/losses/test_cross_batch_memory.py | 43 | def test_remove_self_comparisons(self): | CODE |
| LOW | tests/losses/test_cross_batch_memory.py | 139 | def test_memory_filled_each_batch_matches_inner_loss(self): | CODE |
| LOW | tests/losses/test_cross_batch_memory.py | 215 | def test_with_distance_weighted_miner(self): | CODE |
| LOW | tests/losses/test_cross_batch_memory.py | 585 | def test_reset_queue_keeps_placement(self): | CODE |
| LOW | tests/losses/test_cross_batch_memory.py | 606 | def test_easy_positive_miner_skips_each_anchors_queued_copy(self): | CODE |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 83 | def test_autocast_histogram_uses_buffer_precision(self) -> None: | CODE |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 110 | def test_autocast_training_steps_have_finite_gradients(self) -> None: | CODE |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 134 | def test_values_and_gradients_across_training_steps(self) -> None: | CODE |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 155 | def test_paired_batches_and_accumulated_backward(self) -> None: | CODE |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 185 | def test_reported_convolutional_training_loop(self) -> None: | CODE |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 206 | def test_earlier_graph_stays_out_of_later_steps(self) -> None: | CODE |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 219 | def test_forwards_before_backward_in_any_order(self) -> None: | CODE |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 229 | def test_forwards_summed_before_backward_match_separate_backward(self) -> None: | CODE |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 246 | def test_histogram_interpolation_endpoints_and_clipping(self) -> None: | CODE |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 266 | def test_supplied_triplets_without_labels_keep_reference_gradients(self) -> None: | CODE |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 291 | def test_coincident_and_opposite_embeddings_have_finite_gradients(self) -> None: | CODE |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 312 | def test_empty_valid_sets_preserve_histogram(self) -> None: | CODE |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 333 | def test_checkpoint_preserves_next_loss_and_gradient(self) -> None: | CODE |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 354 | def test_invalid_histogram_configuration(self) -> None: | CODE |
| LOW | tests/losses/test_lifted_structure_loss.py | 16 | def test_lifted_structure_loss(self): | CODE |
| LOW | tests/losses/test_lifted_structure_loss.py | 96 | def test_generalized_lifted_structure_loss(self): | CODE |
| LOW | tests/losses/test_lifted_structure_loss.py | 182 | def test_separate_reference_set_is_rejected(self): | CODE |
| LOW | tests/losses/test_lifted_structure_loss.py | 197 | def test_positive_pair_without_negatives_has_finite_zero_gradient(self): | CODE |
| LOW⚡ | tests/losses/test_multi_supcon_loss.py | 298 | def test_loss_dtype_follows_embeddings(self): | CODE |
| LOW⚡ | tests/losses/test_multi_supcon_loss.py | 303 | def test_unsupported_wrappers_reject_label_sets(self): | CODE |
| LOW⚡ | tests/losses/test_multi_supcon_loss.py | 310 | def test_multiple_losses_compose_label_set_losses(self): | CODE |
| LOW | tests/losses/test_multi_supcon_loss.py | 91 | def test_values_match_equation_three(self): | CODE |
| LOW | tests/losses/test_multi_supcon_loss.py | 106 | def test_value_matches_multisupcontrast(self): | CODE |
| LOW | tests/losses/test_multi_supcon_loss.py | 111 | def test_gradient_matches_reference(self): | CODE |
| LOW | tests/losses/test_multi_supcon_loss.py | 128 | def test_threshold_includes_exact_similarity(self): | CODE |
| LOW | tests/losses/test_multi_supcon_loss.py | 144 | def test_threshold_one_is_supcon(self): | CODE |
| LOW | tests/losses/test_multi_supcon_loss.py | 153 | def test_threshold_zero_counts_zero_weight_pairs(self): | CODE |
| LOW | tests/losses/test_multi_supcon_loss.py | 169 | def test_empty_label_sets_match_only_each_other(self): | CODE |
| LOW | tests/losses/test_multi_supcon_loss.py | 192 | def test_anchors_without_positives_have_no_term(self): | CODE |
| LOW | tests/losses/test_multi_supcon_loss.py | 203 | def test_batch_without_positives_is_differentiable_zero(self): | CODE |
| LOW | tests/losses/test_multi_supcon_loss.py | 217 | def test_empty_batch_is_differentiable_zero(self): | CODE |
| LOW | tests/losses/test_multi_supcon_loss.py | 224 | def test_references_keep_every_row(self): | CODE |
| LOW | tests/losses/test_multi_supcon_loss.py | 244 | def test_supplied_pairs_restrict_the_denominator(self): | CODE |
| LOW | tests/losses/test_multi_supcon_loss.py | 260 | def test_empty_supplied_pairs_select_nothing(self): | CODE |
| LOW | tests/losses/test_multi_supcon_loss.py | 266 | def test_inverted_distance_uses_negated_distances(self): | CODE |
| LOW | tests/losses/test_multi_supcon_loss.py | 341 | def test_queue_matches_stateless_reference(self): | CODE |
| 573 more matches not shown… | ||||
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | src/pytorch_metric_learning/types.py | 1 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 1 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 2 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 3 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 4 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 5 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 6 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 7 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 8 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 9 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 10 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 11 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 12 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 13 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 14 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 15 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 16 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 17 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 18 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 19 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 20 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 21 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 22 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 22 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 23 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 24 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 25 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 26 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 27 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 28 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 29 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 30 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 31 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 32 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 33 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 34 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 35 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 36 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 37 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 38 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 39 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 40 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 41 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 42 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 43 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 44 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 45 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 46 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 47 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 48 | CODE | |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 49 | CODE | |
| LOW | src/pytorch_metric_learning/utils/_common.py | 1 | CODE | |
| LOW | src/pytorch_metric_learning/regularizers/__init__.py | 1 | CODE | |
| LOW | src/pytorch_metric_learning/regularizers/__init__.py | 2 | CODE | |
| LOW | src/pytorch_metric_learning/regularizers/__init__.py | 3 | CODE | |
| LOW | src/pytorch_metric_learning/regularizers/__init__.py | 4 | CODE | |
| LOW | src/pytorch_metric_learning/regularizers/__init__.py | 5 | CODE | |
| LOW | src/pytorch_metric_learning/regularizers/__init__.py | 6 | CODE | |
| LOW | src/pytorch_metric_learning/regularizers/__init__.py | 7 | CODE | |
| LOW | src/pytorch_metric_learning/samplers/__init__.py | 1 | CODE | |
| 50 more matches not shown… | ||||
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | tests/losses/test_circle_loss.py | 13 | CODE | |
| LOW | tests/losses/test_pnp_loss.py | 111 | CODE | |
| LOW | tests/losses/test_pnp_loss.py | 276 | CODE | |
| LOW | tests/losses/test_pnp_loss.py | 319 | CODE | |
| LOW | tests/losses/test_margin_loss.py | 13 | CODE | |
| LOW | tests/losses/test_cross_batch_memory.py | 43 | CODE | |
| LOW | tests/losses/test_cross_batch_memory.py | 139 | CODE | |
| LOW | tests/losses/test_cross_batch_memory.py | 303 | CODE | |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 83 | CODE | |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 110 | CODE | |
| LOW | tests/losses/test_dynamic_soft_margin_loss.py | 155 | CODE | |
| LOW | tests/losses/test_lifted_structure_loss.py | 16 | CODE | |
| LOW | tests/losses/test_lifted_structure_loss.py | 96 | CODE | |
| LOW | tests/losses/test_losses_without_labels.py | 49 | CODE | |
| LOW | tests/losses/test_npairs_loss.py | 22 | CODE | |
| LOW | tests/losses/test_anchor_batched_backward.py | 101 | CODE | |
| LOW | tests/losses/test_anchor_batched_backward.py | 219 | CODE | |
| LOW | tests/losses/test_anchor_batched_backward.py | 284 | CODE | |
| LOW | tests/losses/test_anchor_batched_backward.py | 328 | CODE | |
| LOW | tests/losses/test_anchor_batched_backward.py | 368 | CODE | |
| LOW | tests/losses/test_proxy_nca_loss.py | 60 | CODE | |
| LOW | tests/losses/test_manifold_loss.py | 51 | CODE | |
| LOW | tests/losses/test_ranked_list_loss.py | 16 | CODE | |
| LOW | tests/losses/test_ranked_list_loss.py | 100 | CODE | |
| LOW | tests/losses/test_tuplet_margin_loss.py | 13 | CODE | |
| LOW | tests/losses/test_tuplet_margin_loss.py | 84 | CODE | |
| LOW | tests/losses/test_cross_batch_memory_state.py | 44 | CODE | |
| LOW | tests/losses/test_cross_batch_memory_state.py | 109 | CODE | |
| LOW | tests/losses/test_cross_batch_memory_state.py | 145 | CODE | |
| LOW | tests/losses/test_cross_batch_memory_state.py | 217 | CODE | |
| LOW | tests/losses/test_loss_composition.py | 50 | CODE | |
| LOW | tests/losses/test_loss_composition.py | 345 | CODE | |
| LOW | tests/losses/test_loss_composition.py | 406 | CODE | |
| LOW | tests/losses/test_ntxent_loss.py | 74 | CODE | |
| LOW | tests/losses/test_ntxent_loss.py | 163 | CODE | |
| LOW | tests/losses/test_ntxent_loss.py | 200 | CODE | |
| LOW | tests/losses/test_ntxent_loss.py | 326 | CODE | |
| LOW | tests/losses/test_nca_loss.py | 12 | CODE | |
| LOW | tests/losses/test_centroid_triplet_loss.py | 22 | CODE | |
| LOW | tests/losses/test_centroid_triplet_loss.py | 55 | CODE | |
| LOW | …ts/losses/test_selectively_contrastive_triplet_loss.py | 168 | CODE | |
| LOW | tests/losses/test_large_margin_softmax_loss.py | 23 | CODE | |
| LOW | tests/losses/test_large_margin_softmax_loss.py | 113 | CODE | |
| LOW | tests/losses/test_triplet_margin_loss.py | 201 | CODE | |
| LOW | tests/losses/test_rank_n_contrast_loss.py | 55 | CODE | |
| LOW | tests/losses/test_distance_matrix_input.py | 396 | CODE | |
| LOW | tests/losses/test_distance_matrix_input.py | 444 | CODE | |
| LOW | tests/losses/test_distance_matrix_input.py | 462 | CODE | |
| LOW | tests/losses/test_ge2e_loss.py | 62 | CODE | |
| LOW | tests/distributed/test_distributed.py | 803 | CODE | |
| LOW | tests/distributed/test_distributed_fallback.py | 66 | CODE | |
| LOW | tests/distributed/test_distributed_fallback.py | 117 | CODE | |
| LOW | tests/distributed/test_distributed_fallback.py | 166 | CODE | |
| LOW | tests/docs/test_documented_signatures.py | 89 | CODE | |
| LOW | tests/docs/test_public_surface.py | 29 | CODE | |
| LOW | tests/docs/test_public_surface.py | 50 | CODE | |
| LOW | tests/docs/test_documentation_paths.py | 58 | CODE | |
| LOW | tests/recipes/test_training.py | 301 | CODE | |
| LOW | tests/recipes/test_training.py | 36 | CODE | |
| LOW | tests/recipes/test_training.py | 359 | CODE | |
| 27 more matches not shown… | ||||
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | src/pytorch_metric_learning/types.py | 16 | __all__ = [ | CODE |
| LOW | src/pytorch_metric_learning/distributed.py | 13 | __all__ = ["DistributedLossWrapper", "DistributedMinerWrapper"] | CODE |
| LOW | src/pytorch_metric_learning/losses/__init__.py | 51 | __all__ = [ | CODE |
| LOW | src/pytorch_metric_learning/losses/center_loss.py | 56 | def update_centers(self, embeddings: Tensor, labels: Tensor) -> None: | CODE |
| LOW | …rch_metric_learning/losses/dynamic_soft_margin_loss.py | 115 | def update_histogram(self, data: Tensor) -> None: | CODE |
| LOW | src/pytorch_metric_learning/utils/indexing.py | 10 | __all__ = [ | CODE |
| LOW | src/pytorch_metric_learning/regularizers/__init__.py | 9 | __all__ = [ | CODE |
| LOW | …ic_learning/regularizers/sparse_centers_regularizer.py | 44 | def set_class_masks(self, num_classes: int, centers_per_class: int) -> None: | CODE |
| LOW | src/pytorch_metric_learning/samplers/__init__.py | 6 | __all__ = [ | CODE |
| LOW | src/pytorch_metric_learning/miners/__init__.py | 12 | __all__ = [ | CODE |
| LOW | src/pytorch_metric_learning/evaluation/thresholds.py | 9 | __all__ = [ | CODE |
| LOW | src/pytorch_metric_learning/evaluation/__init__.py | 25 | __all__ = [ | CODE |
| LOW | src/pytorch_metric_learning/evaluation/retrieval.py | 13 | __all__ = ["CustomKNN", "FaissKMeans", "FaissKNN", "MatchFinder"] | CODE |
| LOW | …orch_metric_learning/evaluation/accuracy_calculator.py | 25 | __all__ = [ | CODE |
| LOW | src/pytorch_metric_learning/distances/__init__.py | 8 | __all__ = [ | CODE |
| LOW | src/pytorch_metric_learning/reducers/__init__.py | 11 | __all__ = [ | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | tests/losses/test_margin_loss.py | 13 | def helper( | CODE |
| LOW | tests/losses/test_ntxent_loss.py | 74 | def helper( | CODE |
| LOW | tests/losses/test_angular_loss.py | 53 | def helper( | CODE |
| LOW | tests/losses/test_multi_similarity_loss.py | 57 | def helper( | CODE |
| LOW | tests/losses/test_triplet_margin_loss.py | 70 | def helper( | CODE |
| LOW | tests/miners/test_batch_easy_hard_miner.py | 344 | def helper(self, a1, p, a2, n, gt): | CODE |
| LOW | tests/miners/test_hdc_miner.py | 85 | def helper(self, pos_pairs, neg_pairs): | CODE |
| LOW | tests/miners/test_batch_hard_miner.py | 76 | def helper(self, a, p, n): | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | tests/losses/test_proxy_anchor_loss.py | 31 | CODE | |
| LOW | …orch_metric_learning/evaluation/accuracy_calculator.py | 312 | CODE |