class_docstr: ALBERT model
class_docstr_tok: ["ALBERT","model"]
code: def forward(
      self,
      input_ids=None,
      token_type_ids=None,
      position_ids=None,
      attention_mask=None,
      query_input_ids=None,
      query_token_type_ids=None,
      query_position_ids=None,
      query_attention_mask=None,
      title_input_ids=None,
      title_token_type_ids=None,
      title_position_ids=None,
      title_attention_mask=None,
      seq_lengths=None,
      labels=None,
  ):
      if self.task != "text-matching":
          result = self.model(
              input_ids, token_type_ids, position_ids, attention_mask
          )
      else:
          query_result = self.model(
              query_input_ids,
              query_token_type_ids,
              query_position_ids,
              query_attention_mask,
          )
          title_result = self.model(
              title_input_ids,
              title_token_type_ids,
              title_position_ids,
              title_attention_mask,
          )
  
      if self.task == "seq-cls":
          logits = result
          probs = F.softmax(logits, axis=1)
          if labels is not None:
              loss = self.criterion(logits, labels)
              correct = self.metric.compute(probs, labels)
              acc = self.metric.update(correct)
              return probs, loss, {"acc": acc}
          return probs
      elif self.task == "token-cls":
          logits = result
          token_level_probs = F.softmax(logits, axis=-1)
          preds = token_level_probs.argmax(axis=-1)
          if labels is not None:
              loss = self.criterion(logits, labels.unsqueeze(-1))
              (
                  num_infer_chunks,
                  num_label_chunks,
                  num_correct_chunks,
              ) = self.metric.compute(None, seq_lengths, preds, labels)
              self.metric.update(
                  num_infer_chunks.numpy(),
                  num_label_chunks.numpy(),
                  num_correct_chunks.numpy(),
              )
              _, _, f1_score = map(float, self.metric.accumulate())
              return token_level_probs, loss, {"f1_score": f1_score}
          return token_level_probs
      elif self.task == "text-matching":
          query_token_embedding, _ = query_result
          query_token_embedding = self.dropout(query_token_embedding)
          query_attention_mask = paddle.unsqueeze(
              (query_input_ids != self.model.pad_token_id).astype(
                  self.model.pooler.dense.weight.dtype
              ),
              axis=2,
          )
          query_token_embedding = (
              query_token_embedding * query_attention_mask
          )
          query_sum_embedding = paddle.sum(
              query_token_embedding, axis=1
          )
          query_sum_mask = paddle.sum(query_attention_mask, axis=1)
          query_mean = query_sum_embedding / query_sum_mask
  
          title_token_embedding, _ = title_result
          title_token_embedding = self.dropout(title_token_embedding)
          title_attention_mask = paddle.unsqueeze(
              (title_input_ids != self.model.pad_token_id).astype(
                  self.model.pooler.dense.weight.dtype
              ),
              axis=2,
          )
          title_token_embedding = (
              title_token_embedding * title_attention_mask
          )
          title_sum_embedding = paddle.sum(
              title_token_embedding, axis=1
          )
          title_sum_mask = paddle.sum(title_attention_mask, axis=1)
          title_mean = title_sum_embedding / title_sum_mask
  
          sub = paddle.abs(paddle.subtract(query_mean, title_mean))
          projection = paddle.concat(
              [query_mean, title_mean, sub], axis=-1
          )
          logits = self.classifier(projection)
          probs = F.softmax(logits)
          if labels is not None:
              loss = self.criterion(logits, labels)
              correct = self.metric.compute(probs, labels)
              acc = self.metric.update(correct)
              return probs, loss, {"acc": acc}
          return probs
      else:
          sequence_output, pooled_output = result
          return sequence_output, pooled_output
  
file_path: PaddleHub/modules/text/language_model/albert-chinese-tiny/module.py
imports: import math
  import os
  from typing import Dict
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddlenlp.metrics import ChunkEvaluator
  from paddlenlp.transformers.albert.modeling import AlbertForSequenceClassification
  from paddlenlp.transformers.albert.modeling import AlbertForTokenClassification
  from paddlenlp.transformers.albert.modeling import AlbertModel
  from paddlenlp.transformers.albert.tokenizer import AlbertTokenizer
  from paddlehub.module.module import moduleinfo
  from paddlehub.module.nlp_module import TransformerModule
  from paddlehub.utils.log import logger
label_desc: Use image node_id 2 for calling the Albert obj's underlying member method code with example usage: obj.forward(input_ids, token_type_ids, position_ids, attention_mask, query_input_ids, query_token_type_ids, query_position_ids, query_attention_mask, title_input_ids, title_token_type_ids, title_position_ids, title_attention_mask, seq_lengths, labels) and returns: probs, probs,  loss,  dict, token_level_probs, token_level_probs,  loss,  dict, probs, sequence_output,  pooled_output, probs,  loss,  dict