class_docstr: Ernie Model for Named entity tasks(NER)
class_docstr_tok: ["Ernie","Model","for","Named","entity","tasks","(","NER",")"]
docstr: Args:
      labels (optional, `Variable` of shape [batch_size, seq_len]):
          ground truth label id for each token
  Returns:
      loss (`Variable` of shape []):
          Cross entropy loss mean over batch and time, ignore positions where label == -100
          if labels not set, returns None
      logits (`Variable` of shape [batch_size, seq_len, hidden_size]):
          output logits of classifier
      loss_weights (`Variable` of shape [batch_size, seq_len]):
          weigths of loss for each tokens.
      ignore_index (int):
          when label == `ignore_index`, this token will not contribute to loss
docstr_tok: ["Args",":","labels","(","optional",",","`","Variable","`","of","shape","[","batch_size",",","seq_len","]",")",":","ground","truth","label","id","for","each","token","Returns",":","loss","(","`","Variable","`","of","shape","[","]",")",":","Cross","entropy","loss","mean","over","batch","and","time",",","ignore","positions","where","label","==","-100","if","labels","not","set",",","returns","None","logits","(","`","Variable","`","of","shape","[","batch_size",",","seq_len",",","hidden_size","]",")",":","output","logits","of","classifier","loss_weights","(","`","Variable","`","of","shape","[","batch_size",",","seq_len","]",")",":","weigths","of","loss","for","each","tokens",".","ignore_index","(","int",")",":","when","label","==","`","ignore_index","`",",","this","token","will","not","contribute","to","loss"]
code: def forward(self, *args, **kwargs):
      """
      Args:
          labels (optional, `Variable` of shape [batch_size, seq_len]):
              ground truth label id for each token
      Returns:
          loss (`Variable` of shape []):
              Cross entropy loss mean over batch and time, ignore positions where label == -100
              if labels not set, returns None
          logits (`Variable` of shape [batch_size, seq_len, hidden_size]):
              output logits of classifier
          loss_weights (`Variable` of shape [batch_size, seq_len]):
              weigths of loss for each tokens.
          ignore_index (int):
              when label == `ignore_index`, this token will not contribute to loss
      """
      ignore_index = kwargs.pop("ignore_index", -100)
      labels = kwargs.pop("labels", None)
      loss_weights = kwargs.pop("loss_weights", None)
      pooled, encoded = super(
          ErnieModelForTokenClassification, self
      ).forward(*args, **kwargs)
      hidden = self.dropout(encoded)  # maybe not?
      logits = self.classifier(hidden)
  
      if labels is not None:
          if len(labels.shape) != 2:
              labels = labels.squeeze()
          loss = F.cross_entropy(
              logits,
              labels,
              ignore_index=ignore_index,
              reduction="none",
          )
          if loss_weights is not None:
              loss = loss * loss_weights
          loss = loss.mean()
      else:
          loss = None
      return loss, logits
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import json
  import logging
  import math
  import six
  import numpy
  import paddle
  from paddle import nn
  from paddle.nn import functional
  from disco_diffusion_ernievil_base.vit_b_16x.ernievil2.transformers.file_utils import _fetch_from_remote, add_docstring
label_desc: Use image node_id 2 for calling the ErnieModelForTokenClassification obj's underlying member method code with example usage: obj.forward() and returns: loss,  logits