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: 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
      labels: 1 if entity is appropriate to context, 0 - otherwise
  
  Returns:
      the value of loss
docstr_tok: ["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","labels",":","1","if","entity","is","appropriate","to","context",",","0","-","otherwise","Returns",":","the","value","of","loss"]
code: def train_on_batch(
      self,
      q_features: List[Dict],
      c_features: List[Dict],
      entity_tokens_pos: List[int],
      labels: List[int],
  ) -> float:
      """
  
      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
          labels: 1 if entity is appropriate to context, 0 - otherwise
  
      Returns:
          the value of loss
      """
      _input = {"labels": labels}
      _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
          )
  
      self.model.train()
      self.model.zero_grad()
      self.optimizer.zero_grad()  # zero the parameter gradients
  
      loss, softmax_scores = self.model(**_input)
      self._make_step(loss)
  
      return loss.item()
  
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 2 for calling the TorchTransformersElRanker obj's underlying member method code with example usage: obj.train_on_batch(q_features, c_features, entity_tokens_pos, labels) and returns: loss