class_docstr: Transformer word tagging classifier
  Args:
      model_type(str): model family (classifier head), choose between bert/quant_bert/xlnet
      labels (List[str], optional): list of tag labels
class_docstr_tok: ["Transformer","word","tagging","classifier","Args",":","model_type","(","str",")",":","model","family","(","classifier","head",")",",","choose","between","bert\/quant_bert\/xlnet","labels","(","List","[","str","]",",","optional",")",":","list","of","tag","labels"]
docstr: Convert examples to tensor dataset
  
  Args:
      examples (List[SequenceClsInputExample]): examples
      max_seq_length (int, optional): max sequence length. Defaults to 128.
      include_labels (bool, optional): include labels. Defaults to True.
  
  Returns:
      TensorDataset:
docstr_tok: ["Convert","examples","to","tensor","dataset","Args",":","examples","(","List","[","SequenceClsInputExample","]",")",":","examples","max_seq_length","(","int",",","optional",")",":","max","sequence","length",".","Defaults","to","128.","include_labels","(","bool",",","optional",")",":","include","labels",".","Defaults","to","True",".","Returns",":","TensorDataset",":"]
code: def convert_to_tensors(
      self,
      examples: List[TokenClsInputExample],
      max_seq_length: int = 128,
      include_labels: bool = True,
  ) -> TensorDataset:
      """
      Convert examples to tensor dataset
  
      Args:
          examples (List[SequenceClsInputExample]): examples
          max_seq_length (int, optional): max sequence length. Defaults to 128.
          include_labels (bool, optional): include labels. Defaults to True.
  
      Returns:
          TensorDataset:
      """
      features = self._convert_examples_to_features(
          examples,
          max_seq_length,
          self.tokenizer,
          include_labels,
          # xlnet has a cls token at the end
          cls_token_at_end=bool(self.model_type in ["xlnet"]),
          cls_token=self.tokenizer.cls_token,
          cls_token_segment_id=2 if self.model_type in ["xlnet"] else 0,
          sep_token=self.tokenizer.sep_token,
          sep_token_extra=bool(self.model_type in ["roberta"]),
          # pad on the left for xlnet
          pad_on_left=bool(self.model_type in ["xlnet"]),
          pad_token=self.tokenizer.convert_tokens_to_ids(
              [self.tokenizer.pad_token]
          )[0],
          pad_token_segment_id=4 if self.model_type in ["xlnet"] else 0,
      )
      # Convert to Tensors and build dataset
      all_input_ids = torch.tensor(
          [f.input_ids for f in features], dtype=torch.long
      )
      all_input_mask = torch.tensor(
          [f.input_mask for f in features], dtype=torch.long
      )
      all_segment_ids = torch.tensor(
          [f.segment_ids for f in features], dtype=torch.long
      )
      all_valid_ids = torch.tensor(
          [f.valid_ids for f in features], dtype=torch.long
      )
  
      if include_labels:
          all_label_ids = torch.tensor(
              [f.label_id for f in features], dtype=torch.long
          )
          dataset = TensorDataset(
              all_input_ids,
              all_input_mask,
              all_segment_ids,
              all_valid_ids,
              all_label_ids,
          )
      else:
          dataset = TensorDataset(
              all_input_ids,
              all_input_mask,
              all_segment_ids,
              all_valid_ids,
          )
      return dataset
  
imports: import logging
  from typing import List, Union
  import torch
  from torch.nn import CrossEntropyLoss, Dropout, Linear
  from torch.nn import functional
  from torch.utils.data import DataLoader, SequentialSampler, TensorDataset
  from transformers import ROBERTA_PRETRAINED_MODEL_ARCHIVE_MAP, BertForTokenClassification, BertPreTrainedModel, RobertaConfig, RobertaModel, XLNetModel, XLNetPreTrainedModel
  from nlp_architect.data.sequential_tagging import TokenClsInputExample
  from nlp_architect.models.transformers.base_model import InputFeatures, TransformerBase
  from nlp_architect.models.transformers.quantized_bert import QuantizedBertForTokenClassification
  from nlp_architect.utils.metrics import tagging
label_desc: Use image node_id 6 for calling the TransformerTokenClassifier obj's underlying member method code with example usage: obj.convert_to_tensors(examples, max_seq_length, include_labels) and returns: dataset