class_docstr: RoBERTa token classification head with linear classifier.
  This head's forward ignores word piece tokens in its linear layer.
  
  The forward requires an additional 'valid_ids' map that maps the tensors
  for valid tokens (e.g., ignores additional word piece tokens generated by
  the tokenizer, as in NER task the 'X' label).
class_docstr_tok: ["RoBERTa","token","classification","head","with","linear","classifier",".","This","head","'s","forward","ignores","word","piece","tokens","in","its","linear","layer",".","The","forward","requires","an","additional","'valid_ids","'","map","that","maps","the","tensors","for","valid","tokens","(","e.g.",",","ignores","additional","word","piece","tokens","generated","by","the","tokenizer",",","as","in","NER","task","the","'","X","'","label",")","."]
code: def forward(
      self,
      input_ids,
      attention_mask=None,
      token_type_ids=None,
      position_ids=None,
      head_mask=None,
      labels=None,
      valid_ids=None,
  ):
      outputs = self.roberta(
          input_ids,
          attention_mask=attention_mask,
          token_type_ids=token_type_ids,
          position_ids=position_ids,
          head_mask=head_mask,
      )
  
      sequence_output = outputs[0]
  
      sequence_output = self.dropout(sequence_output)
      logits = self.classifier(sequence_output)
  
      if labels is not None:
          loss_fct = CrossEntropyLoss(ignore_index=0)
          active_positions = valid_ids.view(-1) != 0.0
          active_labels = labels.view(-1)[active_positions]
          active_logits = logits.view(-1, self.num_labels)[
              active_positions
          ]
          loss = loss_fct(active_logits, active_labels)
          return (
              loss,
              logits,
          )
      return (logits,)
  
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 2 for calling the RobertaForTokenClassificationHead obj's underlying member method code with example usage: obj.forward(input_ids, attention_mask, token_type_ids, position_ids, head_mask, labels, valid_ids) and returns: logits, loss,  logits