code: def __init__(
      self,
      n_classes: int = 97,
      pretrained_bert: str = None,
      bert_tokenizer_config_file: str = None,
      bert_config_file: str = None,
      emb_size: int = 768,
      block_size: int = 8,  # 64
      num_ner_tags: int = 6,  # number of ner tags
      threshold: float = None,
      device: str = "gpu",
  ):
      super().__init__()
      self.n_classes = n_classes
      self.pretrained_bert = pretrained_bert
      self.bert_config_file = bert_config_file
      self.num_ner_tags = num_ner_tags
      self.emb_size = emb_size
      self.block_size = block_size
      self.threshold = threshold
  
      self.loss_fnt = ATLoss()
      self.device = torch.device(
          "cuda"
          if torch.cuda.is_available() and device == "gpu"
          else "cpu"
      )
  
      # initialize parameters that would be filled later
      self.model, self.config, self.bert_config = None, None, None
      self.load()
  
      # initialize tokenizer to call resize_token_embeddings function for model with increased tokenizer size (due to
      # the additional <ENT> token) and get CLS and SEP token ids
      if Path(bert_tokenizer_config_file).is_file():
          vocab_file = str(expand_path(bert_tokenizer_config_file))
          self.tokenizer = BertTokenizer(vocab_file=vocab_file)
      else:
          tokenizer = BertTokenizer.from_pretrained(pretrained_bert)
      self.model.resize_token_embeddings(len(tokenizer) + 1)
      self.cls_token_id = tokenizer.cls_token_id
      self.sep_token_id = tokenizer.sep_token_id
  
      self.hidden_size = self.config.hidden_size
      self.head_extractor = nn.Linear(
          2 * self.hidden_size + self.num_ner_tags, self.emb_size
      )
      self.tail_extractor = nn.Linear(
          2 * self.hidden_size + self.num_ner_tags, self.emb_size
      )
      self.bilinear = nn.Linear(
          self.emb_size * self.block_size, self.n_classes
      )
  
file_path: DeepPavlov/deeppavlov/models/classifiers/re_bert.py
imports: import logging
  from pathlib import Path
  from typing import Tuple, Union, Any, List
  import torch
  from torch import Tensor
  import torch.nn
  from opt_einsum import contract
  from transformers import AutoConfig, BertModel, BertTokenizer
  from deeppavlov.core.commands.utils import expand_path
  from deeppavlov.core.common.errors import ConfigError
  from deeppavlov.models.relation_extraction.losses import ATLoss
label_desc: Use image node_id 1 to create a new BertWithAdaThresholdLocContextPooling object from inherited base classes: nn with example: obj = BertWithAdaThresholdLocContextPooling(n_classes, pretrained_bert, bert_tokenizer_config_file, bert_config_file, emb_size, block_size, num_ner_tags, threshold, device)