code: def test_semantic_search() -> None:
      """Tests util.semantic_search function"""
      num_queries = 20
      num_k = 10
  
      doc_emb = torch.tensor(np.random.randn(1000, 100))
      q_emb = torch.tensor(np.random.randn(num_queries, 100))
      hits = util.semantic_search(
          q_emb,
          doc_emb,
          top_k=num_k,
          query_chunk_size=5,
          corpus_chunk_size=17,
      )
      assert len(hits) == num_queries
      assert len(hits[0]) == num_k
  
      # Sanity Check of the results
      cos_scores = util.pytorch_cos_sim(q_emb, doc_emb)
      cos_scores_values, cos_scores_idx = cos_scores.topk(num_k)
      cos_scores_values = cos_scores_values.cpu().tolist()
      cos_scores_idx = cos_scores_idx.cpu().tolist()
  
      for qid in range(num_queries):
          for hit_num in range(num_k):
              assert (
                  hits[qid][hit_num]["corpus_id"]
                  == cos_scores_idx[qid][hit_num]
              )
              assert (
                  np.abs(
                      hits[qid][hit_num]["score"]
                      - cos_scores_values[qid][hit_num]
                  )
                  < 0.001
              )
  
file_path: sentence-transformers/tests/test_util.py
imports: import numpy
  import sklearn
  import torch
  from sentence_transformers import SentenceTransformer, util
label_desc: Use image node_id 3 for calling a global function with example usage: test_semantic_search() without return types