class_docstr: Classifier based on cosine similarity between vectorized sentences
  
  Parameters:
      save_path: path to save the model
      load_path: path to load the model
class_docstr_tok: ["Classifier","based","on","cosine","similarity","between","vectorized","sentences","Parameters",":","save_path",":","path","to","save","the","model","load_path",":","path","to","load","the","model"]
docstr: Found most similar answer for input vectorized question
  
  Parameters:
      q_vects: vectorized questions
  
  Returns:
      Tuple of Answer and Score
docstr_tok: ["Found","most","similar","answer","for","input","vectorized","question","Parameters",":","q_vects",":","vectorized","questions","Returns",":","Tuple","of","Answer","and","Score"]
code: def __call__(
      self, q_vects: Union[csr_matrix, List]
  ) -> Tuple[List[str], List[int]]:
      """Found most similar answer for input vectorized question
  
      Parameters:
          q_vects: vectorized questions
  
      Returns:
          Tuple of Answer and Score
      """
  
      if isinstance(q_vects[0], csr_matrix):
          q_norm = sparse_norm(q_vects)
          if q_norm == 0.0:
              cos_similarities = np.zeros(
                  (q_vects.shape[0], self.x_train_features.shape[0])
              )
          else:
              norm = q_norm * sparse_norm(self.x_train_features, axis=1)
              cos_similarities = np.array(
                  q_vects.dot(self.x_train_features.T).todense()
              )
              cos_similarities = cos_similarities / norm
      elif isinstance(q_vects[0], np.ndarray):
          q_vects = np.array(q_vects)
          self.x_train_features = np.array(self.x_train_features)
          norm = np.linalg.norm(q_vects) * np.linalg.norm(
              self.x_train_features, axis=1
          )
          cos_similarities = q_vects.dot(self.x_train_features.T) / norm
      elif q_vects[0] is None:
          cos_similarities = np.zeros(len(self.x_train_features))
      else:
          raise NotImplementedError(
              "Not implemented this type of vectors"
          )
  
      # get cosine similarity for each class
      y_labels = np.unique(self.y_train)
      labels_scores = np.zeros((len(cos_similarities), len(y_labels)))
      for i, label in enumerate(y_labels):
          labels_scores[:, i] = np.max(
              [
                  cos_similarities[:, i]
                  for i, value in enumerate(self.y_train)
                  if value == label
              ],
              axis=0,
          )
  
      labels_scores_sum = labels_scores.sum(axis=1, keepdims=True)
      labels_scores = np.divide(
          labels_scores,
          labels_scores_sum,
          out=np.zeros_like(labels_scores),
          where=(labels_scores_sum != 0),
      )
  
      answer_ids = np.argsort(labels_scores)[:, -self.top_n :]
  
      # generate top_n answers and scores
      answers = []
      scores = []
      for i in range(len(answer_ids)):
          answers.extend([y_labels[id] for id in answer_ids[i, ::-1]])
          scores.extend(
              [
                  np.round(labels_scores[i, id], 2)
                  for id in answer_ids[i, ::-1]
              ]
          )
  
      return answers, scores
  
file_path: DeepPavlov/deeppavlov/models/classifiers/cos_sim_classifier.py
imports: from logging import getLogger
  from typing import List, Tuple, Union
  import numpy
  from scipy.sparse import vstack, csr_matrix
  from scipy.sparse.linalg import norm
  from deeppavlov.core.common.file import load_pickle
  from deeppavlov.core.common.file import save_pickle
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.models.estimator import Estimator
  from deeppavlov.core.models.serializable import Serializable
label_desc: Use image node_id 2 for calling the CosineSimilarityClassifier obj's underlying member method code with example usage: obj.__call__(q_vects) and returns: answers,  scores