class_docstr: 适配 :mod:`transformers` 中相关模型的 Accuracy metric 。
class_docstr_tok: ["\u9002\u914d",":","mod",":","`","transformers","`","\u4e2d\u76f8\u5173\u6a21\u578b\u7684","Accuracy","metric","\u3002"]
docstr: :meth:`update` 函数将针对一个批次的预测结果做评价指标的累计。
  
  :param logits: 形状为 ``[B, n_classes]`` 或 ``[B, max_len, n_classes]`` 。
  :param labels: 形状为 ``[B, ]`` 或 ``[B, max_len]``
  :param attention_mask: 序列长度标记。
docstr_tok: [":","meth",":","`","update","`","\u51fd\u6570\u5c06\u9488\u5bf9\u4e00\u4e2a\u6279\u6b21\u7684\u9884\u6d4b\u7ed3\u679c\u505a\u8bc4\u4ef7\u6307\u6807\u7684\u7d2f\u8ba1\u3002",":","param","logits",":","\u5f62\u72b6\u4e3a","``","[","B",",","n_classes","]","``","\u6216","``","[","B",",","max_len",",","n_classes","]","``","\u3002",":","param","labels",":","\u5f62\u72b6\u4e3a","``","[","B",",","]","``","\u6216","``","[","B",",","max_len","]","``",":","param","attention_mask",":","\u5e8f\u5217\u957f\u5ea6\u6807\u8bb0\u3002"]
code: def update(self, logits, labels, attention_mask=None):
      r"""
      :meth:`update` 函数将针对一个批次的预测结果做评价指标的累计。
  
      :param logits: 形状为 ``[B, n_classes]`` 或 ``[B, max_len, n_classes]`` 。
      :param labels: 形状为 ``[B, ]`` 或 ``[B, max_len]``
      :param attention_mask: 序列长度标记。
      """
      seq_len = attention_mask.sum(dim=-1)
      super().update(pred=logits, target=labels, seq_len=seq_len)
  
file_path: fastNLP/fastNLP/core/metrics/accuracy.py
imports: from typing import Union
  import numpy
  from fastNLP.core.metrics.metric import Metric
  from fastNLP.core.metrics.backend import Backend
  from fastNLP.core.utils.seq_len_to_mask import seq_len_to_mask
  from fastNLP.core.log import logger
label_desc: Use image node_id 1 for calling the TransformersAccuracy obj's underlying member method code with example usage: obj.update(logits, labels, attention_mask) without return types