code: def get_cosine_similarity(
      X: np.ndarray,
      verbose: bool = True,
      chunk_size: int = 1000,
      threshold: int = 10000,
      num_workers: int = 0,
  ) -> np.ndarray:
      n_rows = X.shape[0]
  
      if n_rows <= threshold:
          return cosine_similarity(X)
  
      else:
          logger.info(
              "Large feature matrix thus calculating cosine similarities in chunks..."
          )
          start_idxs = list(range(0, n_rows, chunk_size))
          end_idxs = start_idxs[1:] + [n_rows]
  
          if num_workers > 0:
              cos_sim = parallelise(
                  cosine_similarity_chunk,
                  [
                      (X, idxs)
                      for i, idxs in enumerate(
                          zip(start_idxs, end_idxs)
                      )
                  ],
                  verbose,
                  num_workers,
              )
          else:
              cos_sim = tuple(
                  cosine_similarity_chunk((X, idxs))
                  for idxs in tqdm(
                      zip(start_idxs, end_idxs), total=len(start_idxs)
                  )
              )
          return np.vstack(cos_sim)
  
imports: from multiprocessing import cpu_count
  import sys
  from typing import Callable, Dict, Union, Tuple
  import numpy
  from sklearn.metrics.pairwise import cosine_similarity
  from tqdm import tqdm
  from imagededup.handlers.search.bktree import BKTree
  from imagededup.handlers.search.brute_force import BruteForce
  from imagededup.handlers.search.brute_force_cython import BruteForceCython
  from imagededup.utils.general_utils import parallelise
  from imagededup.utils.logger import return_logger
label_desc: Use image node_id 2 for calling a global function with example usage: get_cosine_similarity(X, verbose, chunk_size, threshold, num_workers) and returns: cosine_similarity, np