class_docstr: A base class for embedding model which supports serving.
class_docstr_tok: ["A","base","class","for","embedding","model","which","supports","serving","."]
docstr: Calculate similarities of giving word pairs.
docstr_tok: ["Calculate","similarities","of","giving","word","pairs","."]
code: def calc_similarity(self, data: List[List[str]]):
      """
      Calculate similarities of giving word pairs.
      """
      results = []
      for word_pair in data:
          if len(word_pair) != 2:
              raise RuntimeError(
                  f"The input must have two words, but got {len(word_pair)}. Please check your inputs."
              )
          if not isinstance(word_pair[0], str) or not isinstance(
              word_pair[1], str
          ):
              raise RuntimeError(
                  f"The types of text pair must be (str, str), but got"
                  f" ({type(word_pair[0]).__name__}, {type(word_pair[1]).__name__}). Please check your inputs."
              )
  
          for word in word_pair:
              if self.get_idx_from_word(word) == self.get_idx_from_word(
                  self.vocab.unk_token
              ):
                  raise RuntimeError(
                      f'Word "{word}" is not in vocab. Please check your inputs.'
                  )
          results.append(str(self.cosine_sim(*word_pair)))
      return results
  
imports: import copy
  import functools
  import inspect
  import io
  import json
  import os
  import six
  from typing import List, Tuple, Union
  import paddle
  import paddle.nn
  from packaging.version import Version
  from paddle.dataset.common import DATA_HOME
  from paddle.utils.download import get_path_from_url
  from paddlehub.module.module import serving, RunModule, runnable
  from paddlehub.utils.log import logger
  from paddlehub.utils.utils import reseg_token_label
  import paddlenlp
  from paddlenlp.embeddings.token_embedding import EMBEDDING_HOME, EMBEDDING_URL_ROOT
  from paddlenlp.data import JiebaTokenizer
  from paddlehub.compat.module.nlp_module import DataFormatError
label_desc: Use image node_id 1 for calling the EmbeddingServing obj's underlying member method code with example usage: obj.calc_similarity(data) and returns: results