code: def test_text_semantic_search():
      corpus = [
          "A man is eating food.",
          "A man is eating a piece of bread.",
          "The girl is carrying a baby.",
          "A man is riding a horse.",
          "A woman is playing violin.",
          "Two men pushed carts through the woods.",
          "A man is riding a white horse on an enclosed ground.",
          "A monkey is playing drums.",
          "A cheetah is running behind its prey.",
      ]
      queries = [
          "A man is eating pasta.",
          "Someone in a gorilla costume is playing a set of drums.",
          "A cheetah chases prey on across a field.",
      ]
  
      matcher = MultiModalPredictor(
          problem_type="text_similarity",
          hyperparameters={
              "model.hf_text.checkpoint_name": "sentence-transformers/all-MiniLM-L6-v2"
          },
      )
      hits = semantic_search(
          matcher=matcher,
          query_data=queries,
          response_data=corpus,
          top_k=5,
      )
      # extract embeddings first and then do semantic search
      query_embeddings = matcher.extract_embedding(queries)
      response_embeddings = matcher.extract_embedding(corpus)
      hits_2 = semantic_search(
          matcher=matcher,
          query_embeddings=query_embeddings,
          response_embeddings=response_embeddings,
          top_k=5,
      )
  
      hits_gt = [
          [
              {"response_id": 0, "score": 0.7035943269729614},
              {"response_id": 1, "score": 0.527172327041626},
              {"response_id": 3, "score": 0.18880528211593628},
              {"response_id": 6, "score": 0.10461556911468506},
              {"response_id": 8, "score": 0.09811049699783325},
          ],
          [
              {"response_id": 7, "score": 0.6432060599327087},
              {"response_id": 4, "score": 0.2563084363937378},
              {"response_id": 3, "score": 0.1389961689710617},
              {"response_id": 6, "score": 0.11907944828271866},
              {"response_id": 8, "score": 0.1079183965921402},
          ],
          [
              {"response_id": 8, "score": 0.8252813816070557},
              {"response_id": 0, "score": 0.13986822962760925},
              {"response_id": 7, "score": 0.1292111724615097},
              {"response_id": 6, "score": 0.10977005213499069},
              {"response_id": 3, "score": 0.06506325304508209},
          ],
      ]
  
      for per_query_hits, per_query_hits_2, per_query_hit_gt in zip(
          hits, hits_2, hits_gt
      ):
          for per_hit, per_hit_2, per_hit_gt in zip(
              per_query_hits, per_query_hits_2, per_query_hit_gt
          ):
              assert (
                  per_hit["response_id"]
                  == per_hit_2["response_id"]
                  == per_hit_gt["response_id"]
              )
              npt.assert_allclose(
                  per_hit["score"], per_hit_2["score"], 1e-3, 1e-3
              )
              npt.assert_allclose(
                  per_hit["score"], per_hit_gt["score"], 1e-3, 1e-3
              )
  
file_path: autogluon/multimodal/tests/unittests/others/test_matcher.py
imports: import copy
  import os
  import pickle
  import shutil
  import tempfile
  import numpy.testing
  import pytest
  from autogluon.multimodal import MultiModalPredictor
  from autogluon.multimodal.constants import BINARY, MULTICLASS, QUERY, RESPONSE, UNIFORM_SOUP
  from autogluon.multimodal.utils import convert_data_for_ranking, semantic_search
  from ..utils.unittest_datasets import Flickr30kDataset, IDChangeDetectionDataset
  from ..utils.utils import get_home_dir
label_desc: Use image node_id 6 for calling a global function with example usage: test_text_semantic_search() without return types