class_docstr: Model wrapper for Named Entity Recognition
class_docstr_tok: ["Model","wrapper","for","Named","Entity","Recognition"]
code: def __init__(self, config, device):
      super().__init__()
      self.config = config
      self.device = device
      self.last_device = torch.cuda.device_count() - 1
  
      if "device_map" in config:
          self.config["device_map"] = {
              int(k): v for k, v in config["device_map"].items()
          }
  
      self.tz = T5Tokenizer.from_pretrained("t5-small")
      self.MENTION_START = "<m>"
      self.MENTION_END = "</m>"
      self.tz.add_tokens(self.MENTION_START)
      self.tz.add_tokens(self.MENTION_END)
  
      self.mention_start_id = self.tz.convert_tokens_to_ids(
          self.MENTION_START
      )
      self.mention_end_id = self.tz.convert_tokens_to_ids(
          self.MENTION_END
      )
  
      self.model = T5NER.from_pretrained(
          config["plm_pretrained_name_or_path"],
          asp_hidden_dim=config["hidden_size"],
          asp_dropout_rate=config["dropout_rate"],
          asp_init_std=config["init_std"],
          asp_feature_emb_size=config["feature_emb_size"],
          asp_activation=config["activation"],
          num_typing_classes=config["num_typing_classes"],
          mention_start_id=self.mention_start_id,
          mention_end_id=self.mention_end_id,
      )
  
      self.beam_size = config["beam_size"]
      self.model.resize_token_embeddings(self.tz.vocab_size + 2)
  
file_path: DeepKE/src/deepke/triple_extraction/ASP/models/model_ner.py
imports: import sys
  import os
  import torch
  import torch.nn
  import logging
  from transformers import T5Tokenizer
  from .t5_ner import T5NER
label_desc: Use image node_id 1 to create a new NERModel object from inherited base classes: torch.nn with example: obj = NERModel(config, device)