docstr: Transformer-based model on PyTorch for relation extraction. It predicts a relation hold between entities in a
  text sample (one or several sentences).
  Args:
      n_classes: number of output classes
      num_ner_tags: number of NER tags
      pretrained_bert: key title of pretrained Bert model (e.g. "bert-base-uncased")
      return_probas: set this to `True` if you need the probabilities instead of raw answers
      threshold: manually set value for defining the positively predicted classes (instead of adaptive one)
docstr_tok: ["Transformer-based","model","on","PyTorch","for","relation","extraction",".","It","predicts","a","relation","hold","between","entities","in","a","text","sample","(","one","or","several","sentences",")",".","Args",":","n_classes",":","number","of","output","classes","num_ner_tags",":","number","of","NER","tags","pretrained_bert",":","key","title","of","pretrained","Bert","model","(","e.g",".","``","bert-base-uncased","''",")","return_probas",":","set","this","to","`","True","`","if","you","need","the","probabilities","instead","of","raw","answers","threshold",":","manually","set","value","for","defining","the","positively","predicted","classes","(","instead","of","adaptive","one",")"]
code: def __init__(
      self,
      n_classes: int,
      num_ner_tags: int,
      pretrained_bert: str = None,
      return_probas: bool = False,
      threshold: Optional[float] = None,
      **kwargs,
  ) -> None:
      """
      Transformer-based model on PyTorch for relation extraction. It predicts a relation hold between entities in a
      text sample (one or several sentences).
      Args:
          n_classes: number of output classes
          num_ner_tags: number of NER tags
          pretrained_bert: key title of pretrained Bert model (e.g. "bert-base-uncased")
          return_probas: set this to `True` if you need the probabilities instead of raw answers
          threshold: manually set value for defining the positively predicted classes (instead of adaptive one)
      """
      self.n_classes = n_classes
      self.return_probas = return_probas
  
      if self.n_classes == 0:
          raise ConfigError("Please provide a valid number of classes.")
  
      model = BertWithAdaThresholdLocContextPooling(
          n_classes=self.n_classes,
          pretrained_bert=pretrained_bert,
          bert_tokenizer_config_file=pretrained_bert,
          num_ner_tags=num_ner_tags,
          threshold=threshold,
      )
  
      super().__init__(model, **kwargs)
  
file_path: DeepPavlov/deeppavlov/models/relation_extraction/relation_extraction_bert.py
imports: from logging import getLogger
  from typing import List, Optional, Union
  import numpy
  import torch
  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.classifiers.re_bert import BertWithAdaThresholdLocContextPooling
label_desc: Use image node_id 1 to create a new REBertModel object from inherited base classes: TorchModel with example: obj = REBertModel(n_classes, num_ner_tags, pretrained_bert, return_probas, threshold)