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: Loads a data file into a list of `InputBatch`s
  `cls_token_at_end` define the location of the CLS token:
      - False (Default, BERT/XLM pattern): [CLS] + A + [SEP] + B + [SEP]
      - True (XLNet/GPT pattern): A + [SEP] + B + [SEP] + [CLS]
  `cls_token_segment_id` define the segment id associated to the CLS token
  (0 for BERT, 2 for XLNet)
docstr_tok: ["Loads","a","data","file","into","a","list","of","`","InputBatch","`","s","`","cls_token_at_end","`","define","the","location","of","the","CLS","token",":","-","False","(","Default",",","BERT\/XLM","pattern",")",":","[","CLS","]","+","A","+","[","SEP","]","+","B","+","[","SEP","]","-","True","(","XLNet\/GPT","pattern",")",":","A","+","[","SEP","]","+","B","+","[","SEP","]","+","[","CLS","]","`","cls_token_segment_id","`","define","the","segment","id","associated","to","the","CLS","token","(","0","for","BERT",",","2","for","XLNet",")"]
code: def _convert_examples_to_features(
      self,
      examples,
      max_seq_length,
      tokenizer,
      task_type,
      include_labels=True,
      pad_on_left=False,
      pad_token=0,
      pad_token_segment_id=0,
      mask_padding_with_zero=True,
  ):
      """Loads a data file into a list of `InputBatch`s
      `cls_token_at_end` define the location of the CLS token:
          - False (Default, BERT/XLM pattern): [CLS] + A + [SEP] + B + [SEP]
          - True (XLNet/GPT pattern): A + [SEP] + B + [SEP] + [CLS]
      `cls_token_segment_id` define the segment id associated to the CLS token
      (0 for BERT, 2 for XLNet)
      """
  
      if include_labels:
          label_map = {label: i for i, label in enumerate(self.labels)}
  
      features = []
      for ex_index, example in enumerate(examples):
          if ex_index % 10000 == 0:
              logger.info(
                  "Writing example %d of %d", ex_index, len(examples)
              )
  
          inputs = tokenizer.encode_plus(
              example.text,
              example.text_b,
              add_special_tokens=True,
              max_length=max_seq_length,
          )
          input_ids, token_type_ids = (
              inputs["input_ids"],
              inputs["token_type_ids"],
          )
  
          attention_mask = [1 if mask_padding_with_zero else 0] * len(
              input_ids
          )
  
          padding_length = max_seq_length - len(input_ids)
          if pad_on_left:
              input_ids = ([pad_token] * padding_length) + input_ids
              attention_mask = (
                  [0 if mask_padding_with_zero else 1] * padding_length
              ) + attention_mask
              token_type_ids = (
                  [pad_token_segment_id] * padding_length
              ) + token_type_ids
          else:
              input_ids = input_ids + ([pad_token] * padding_length)
              attention_mask = attention_mask + (
                  [0 if mask_padding_with_zero else 1] * padding_length
              )
              token_type_ids = token_type_ids + (
                  [pad_token_segment_id] * padding_length
              )
  
          assert len(input_ids) == max_seq_length
          assert len(attention_mask) == max_seq_length
          assert len(token_type_ids) == max_seq_length
  
          if include_labels:
              if task_type == "classification":
                  label_id = label_map[example.label]
              elif task_type == "regression":
                  label_id = float(example.label)
              else:
                  raise KeyError(task_type)
          else:
              label_id = None
  
          features.append(
              InputFeatures(
                  input_ids=input_ids,
                  input_mask=attention_mask,
                  segment_ids=token_type_ids,
                  label_id=label_id,
              )
          )
      return features
  
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 7 for calling the TransformerSequenceClassifier obj's underlying member method code with example usage: obj._convert_examples_to_features(examples, max_seq_length, tokenizer, task_type, include_labels, pad_on_left, pad_token, pad_token_segment_id, mask_padding_with_zero) and returns: features