code: def test_validate_every(self):
      def validate_every(trainer):
          pass
  
      _check_valid_parameters_number(
          validate_every, expected_params=["trainer"]
      )
  
      # 无默认值，多了报错
      def validate_every(trainer, other):
          pass
  
      with pytest.raises(TypeError) as exc_info:
          _check_valid_parameters_number(
              validate_every, expected_params=["trainer"]
          )
      print(exc_info.value.args[0])
  
      # 有默认值ok
      def validate_every(trainer, other=1):
          pass
  
      _check_valid_parameters_number(
          validate_every, expected_params=["trainer"]
      )
  
      # 参数多了
      def validate_every(trainer):
          pass
  
      with pytest.raises(TypeError) as exc_info:
          _check_valid_parameters_number(
              validate_every, expected_params=["trainer", "other"]
          )
      print(exc_info.value.args[0])
  
      # 使用partial
      def validate_every(trainer, other):
          pass
  
      _check_valid_parameters_number(
          partial(validate_every, other=1), expected_params=["trainer"]
      )
      with pytest.raises(TypeError):
          _check_valid_parameters_number(
              partial(validate_every, other=1),
              expected_params=["trainer", "other"],
          )
      with pytest.raises(TypeError) as exc_info:
          _check_valid_parameters_number(
              partial(validate_every, other=1),
              expected_params=["trainer", "other", "more"],
          )
      print(exc_info.value.args[0])
  
      # 如果存在 *args 或 *kwargs 不报错多的
      def validate_every(trainer, *args):
          pass
  
      _check_valid_parameters_number(
          validate_every, expected_params=["trainer", "other", "more"]
      )
  
      def validate_every(trainer, **kwargs):
          pass
  
      with pytest.raises(TypeError):
          _check_valid_parameters_number(
              partial(validate_every, trainer=1),
              expected_params=["trainer", "other", "more"],
          )
  
      # class 的方法删掉self
      class InnerClass:
          def demo(self, x):
              pass
  
          def no_param(self):
              pass
  
          def param_kwargs(self, **kwargs):
              pass
  
      inner = InnerClass()
      with pytest.raises(TypeError) as exc_info:
          _check_valid_parameters_number(
              inner.demo, expected_params=["trainer", "other", "more"]
          )
      _check_valid_parameters_number(
          inner.demo, expected_params=["trainer"]
      )
  
file_path: fastNLP/tests/core/utils/test_utils.py
imports: from functools import partial
  import pytest
  from fastNLP.core.utils.utils import auto_param_call, _check_valid_parameters_number, _get_fun_msg
  from fastNLP.core.metrics import Metric
label_desc: Use image node_id 1 for calling the TestCheckNumberOfParameters obj's underlying member method code with example usage: obj.test_validate_every() without return types