code: def test_find_duplicates():
      X = np.array(
          [
              ["a", "y", "b"],
              ["b", "y", "a"],
              ["a", "y", "c"],
              ["c", "y", "a"],
              ["a", "y", "d"],
              ["c", "x", "d"],
              ["b", "y", "c"],
              ["f", "y", "e"],
              ["a", "z", "e"],
          ]
      )
      model = ScoringBasedEmbeddingModel(
          eta=5, k=10, scoring_type="ComplEx", seed=0
      )
  
      model.compile(optimizer="adam", loss="multiclass_nll")
  
      model.fit(X, batch_size=2, epochs=10)
  
      entities = set("a b c d e f".split())
      relations = set("x y z".split())
  
      def asserts(tol, dups, ent_rel, subspace):
          assert tol > 0.0
          assert len(dups) <= len(ent_rel)
          assert all(len(d) <= len(ent_rel) for d in dups)
          assert all(d.issubset(subspace) for d in dups)
  
      dups, tol = find_duplicates(
          X,
          model,
          mode="t",
          tolerance="auto",
          expected_fraction_duplicates=0.5,
          verbose=True,
      )
      asserts(tol, dups, X, {tuple(x) for x in X})
  
      dups, tol = find_duplicates(
          X, model, mode="t", tolerance=1.0, verbose=True
      )
      assert tol == 1.0
      asserts(tol, dups, X, {tuple(x) for x in X})
  
      dups, tol = find_duplicates(
          np.unique(X[:, 0]),
          model,
          mode="e",
          tolerance="auto",
          expected_fraction_duplicates=0.5,
          verbose=True,
      )
      asserts(tol, dups, entities, entities)
  
      dups, tol = find_duplicates(
          np.unique(X[:, 2]),
          model,
          mode="e",
          tolerance="auto",
          expected_fraction_duplicates=0.5,
          verbose=True,
      )
      asserts(tol, dups, entities, entities)
  
      dups, tol = find_duplicates(
          np.unique(X[:, 1]),
          model,
          mode="r",
          tolerance="auto",
          expected_fraction_duplicates=0.5,
          verbose=True,
      )
      asserts(tol, dups, relations, relations)
  
      with pytest.raises(ValueError):
          find_duplicates(X, model, mode="hah", verbose=True)
      with pytest.raises(ValueError):
          find_duplicates(X, model, mode="e", verbose=True)
      with pytest.raises(ValueError):
          find_duplicates(X, model, mode="r", verbose=True)
      with pytest.raises(ValueError):
          find_duplicates(
              np.unique(X[:, 0]), model, mode="t", verbose=True
          )
  
file_path: AmpliGraph/tests/ampligraph/discovery/test_discovery.py
imports: import numpy
  import pytest
  from sklearn.cluster import DBSCAN
  from ampligraph.discovery.discovery import discover_facts, generate_candidates, _setdiff2d, find_clusters, find_duplicates, query_topn
  from ampligraph.latent_features import ScoringBasedEmbeddingModel
label_desc: Use image node_id 5 for calling a global function with example usage: test_find_duplicates() without return types