class_docstr: Transformer sequence classifier
  
  Args:
      model_type (str): transformer base model type
      labels (List[str], optional): list of labels. Defaults to None.
      task_type (str, optional): task type (classification/regression). Defaults to
      classification.
      metric_fn ([type], optional): metric to use for evaluation. Defaults to
      simple_accuracy.
class_docstr_tok: ["Transformer","sequence","classifier","Args",":","model_type","(","str",")",":","transformer","base","model","type","labels","(","List","[","str","]",",","optional",")",":","list","of","labels",".","Defaults","to","None",".","task_type","(","str",",","optional",")",":","task","type","(","classification\/regression",")",".","Defaults","to","classification",".","metric_fn","(","[","type","]",",","optional",")",":","metric","to","use","for","evaluation",".","Defaults","to","simple_accuracy","."]
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[SequenceClsInputExample],
      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,
          self.task_type,
          include_labels,
          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
      )
      if include_labels:
          if self.task_type == "classification":
              all_label_ids = torch.tensor(
                  [f.label_id for f in features], dtype=torch.long
              )
          elif self.task_type == "regression":
              all_label_ids = torch.tensor(
                  [f.label_id for f in features], dtype=torch.float
              )
          return TensorDataset(
              all_input_ids,
              all_input_mask,
              all_segment_ids,
              all_label_ids,
          )
      return TensorDataset(
          all_input_ids, all_input_mask, all_segment_ids
      )
  
file_path: nlp-architect/nlp_architect/models/transformers/sequence_classification.py
imports: import logging
  import os
  from typing import List, Union
  import numpy
  import torch
  from torch.utils.data import DataLoader, SequentialSampler, TensorDataset
  from transformers import BertForSequenceClassification, RobertaForSequenceClassification, XLMForSequenceClassification, XLNetForSequenceClassification
  from nlp_architect.data.sequence_classification import SequenceClsInputExample
  from nlp_architect.models.transformers.base_model import InputFeatures, TransformerBase
  from nlp_architect.models.transformers.quantized_bert import QuantizedBertForSequenceClassification
  from nlp_architect.utils.metrics import accuracy
label_desc: Use image node_id 4 for calling the TransformerSequenceClassifier obj's underlying member method code with example usage: obj.convert_to_tensors(examples, max_seq_length, include_labels) and returns: TensorDataset, TensorDataset