code: def test_seq_len(self):
      pred = torch.tensor(
          [
              [[0.3, 0.7, 0.1], [0.4, 0.1, 0.1], [0.3, 0.1, 0.7]],
              [[0.7, 0.1, 0.1], [0.5, 0.9, 0.1], [0.3, 0.1, 0.7]],
          ]
      )
      seq_len = torch.LongTensor([3, 2])
      target = torch.LongTensor([[1, 0, 2], [0, 1, 0]])
  
      # 不考虑长度
      metric = ClassifyFPreRecMetric(only_gross=True, f_type="macro")
      metric.update(pred, target)
      result_dict = metric.get_metric()
      for keys in ["f", "pre", "rec"]:
          assert result_dict[keys] != 1
  
      # 考虑长度
      metric = ClassifyFPreRecMetric(only_gross=True, f_type="macro")
      metric.update(pred, target, seq_len=seq_len)
      result_dict = metric.get_metric()
      for keys in ["f", "pre", "rec"]:
          assert result_dict[keys] == 1
  
file_path: fastNLP/tests/core/metrics/test_classify_f1_pre_rec_metric_torch.py
imports: from functools import partial
  import copy
  import pytest
  import numpy
  from fastNLP.core.metrics import ClassifyFPreRecMetric
  from fastNLP.core.dataset import DataSet
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH
  from .utils import find_free_network_port, setup_ddp
label_desc: Use image node_id 2 for calling the TestClassfiyFPreRecMetric obj's underlying member method code with example usage: obj.test_seq_len() without return types