class_docstr: Class for ranking of entities by context and description
  Args:
      encoder_save_path: path to save the encoder checkpoint
      bilinear_save_path: path to save bilinear layer checkpoint
      block_size: size of block in bilinear layer
      emb_size: entity embedding size
      pretrained_bert: pretrained Bert checkpoint path or key title (e.g. "bert-base-uncased")
      bert_config_file: path to Bert configuration file, or None, if `pretrained_bert` is a string name
      return_probas: set this to `True` if you need the probabilities instead of raw answers
docstr: Predicts entity labels (1 if the entity description is appropriate to the context, 0 - otherwise)
  
  Args:
      q_features: batch of indices of text subwords
      c_features: batch of indices of entity description subwords
      entity_tokens_pos: list of indices of special tokens
  
  Returns:
      Label indices or class probabilities for each token (not subtoken)
docstr_tok: ["Predicts","entity","labels","(","1","if","the","entity","description","is","appropriate","to","the","context",",","0","-","otherwise",")","Args",":","q_features",":","batch","of","indices","of","text","subwords","c_features",":","batch","of","indices","of","entity","description","subwords","entity_tokens_pos",":","list","of","indices","of","special","tokens","Returns",":","Label","indices","or","class","probabilities","for","each","token","(","not","subtoken",")"]
code: def __call__(
      self,
      q_features: List[Dict],
      c_features: List[Dict],
      entity_tokens_pos: List[int],
  ) -> Union[List[int], List[np.ndarray]]:
      """Predicts entity labels (1 if the entity description is appropriate to the context, 0 - otherwise)
  
      Args:
          q_features: batch of indices of text subwords
          c_features: batch of indices of entity description subwords
          entity_tokens_pos: list of indices of special tokens
  
      Returns:
          Label indices or class probabilities for each token (not subtoken)
  
      """
      self.model.eval()
  
      _input = {"entity_tokens_pos": entity_tokens_pos}
      for elem in ["input_ids", "attention_mask"]:
          inp_elem = [getattr(f, elem) for f in q_features]
          _input[f"q_{elem}"] = torch.LongTensor(inp_elem).to(
              self.device
          )
      for elem in ["input_ids", "attention_mask"]:
          inp_elem = [getattr(f, elem) for f in c_features]
          _input[f"c_{elem}"] = torch.LongTensor(inp_elem).to(
              self.device
          )
  
      with torch.no_grad():
          softmax_scores = self.model(**_input)
          if self.return_probas:
              pred = softmax_scores
          else:
              pred = torch.argmax(softmax_scores, dim=1).cpu().numpy()
  
      return pred
  
imports: from logging import getLogger
  from pathlib import Path
  from typing import List, Optional, Dict, Tuple, Union, Any
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch import Tensor
  from transformers import AutoConfig, AutoTokenizer, AutoModel
  from deeppavlov.core.commands.utils import expand_path
  from deeppavlov.core.common.errors import ConfigError
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.models.torch_model import TorchModel
  from deeppavlov.models.preprocessors.torch_transformers_preprocessor import TorchTransformersEntityRankerPreprocessor
label_desc: Use image node_id 3 for calling the TorchTransformersElRanker obj's underlying member method code with example usage: obj.__call__(q_features, c_features, entity_tokens_pos) and returns: pred