code: def test_pad(self):
      dict_batch = [
          {
              "str": "1",
              "lst_str": ["1"],
              "int": 1,
              "lst_int": [1],
              "nest_lst_int": [[1]],
              "float": 1.1,
              "lst_float": [1.1],
              "bool": True,
              "numpy": np.ones(1),
              "dict": {"1": "1"},
              "set": {"1"},
              "nested_dict": {"a": 1, "b": [1, 2]},
          },
          {
              "str": "2",
              "lst_str": ["2", "2"],
              "int": 2,
              "lst_int": [1, 2],
              "nest_lst_int": [[1], [1, 2]],
              "float": 2.1,
              "lst_float": [2.1],
              "bool": False,
              "numpy": np.zeros(1),
              "dict": {"1": "2"},
              "set": {"2"},
              "nested_dict": {"a": 2, "b": [1, 2]},
          },
      ]
  
      raw_pad_batch = {
          "str": ["1", "2"],
          "lst_str": [["1"], ["2", "2"]],
          "int": [1, 2],
          "lst_int": [[1, 0], [1, 2]],
          "nest_lst_int": [[[1, 0], [0, 0]], [[1, 0], [1, 2]]],
          "float": [1.1, 2.1],
          "lst_float": [[1.1], [2.1]],
          "bool": [True, False],
          "numpy": [np.array([1.0]), np.array([0.0])],
          "dict": {"1": ["1", "2"]},
          "set": [{"1"}, {"2"}],
          "nested_dict": {"a": [1, 2], "b": [[1, 2], [1, 2]]},
      }
  
      # 测试 ignore
      collator = Collator(backend="raw")
      collator.set_ignore("str", "int", "lst_int", ("nested_dict", "a"))
      raw_pad_batch = {
          "lst_str": [["1"], ["2", "2"]],
          "nest_lst_int": [[[1, 0], [0, 0]], [[1, 0], [1, 2]]],
          "float": [1.1, 2.1],
          "lst_float": [[1.1], [2.1]],
          "bool": [True, False],
          "numpy": [np.array([1.0]), np.array([0.0])],
          "dict": {"1": ["1", "2"]},
          "set": [{"1"}, {"2"}],
          "nested_dict": {"b": [[1, 2], [1, 2]]},
      }
      findDictDiff(raw_pad_batch, collator(dict_batch))
  
      # 测试 set_pad
      collator = Collator(backend="raw")
      collator.set_pad("str", pad_val=1)
      with pytest.raises(BaseException):
          collator(dict_batch)
  
      # 测试设置 pad 值
      collator = Collator(backend="raw")
      collator.set_pad("nest_lst_int", pad_val=100)
      collator.set_ignore("str", "int", "lst_int", ("nested_dict", "a"))
      raw_pad_batch = {
          "lst_str": [["1"], ["2", "2"]],
          "nest_lst_int": [[[1, 100], [100, 100]], [[1, 100], [1, 2]]],
          "float": [1.1, 2.1],
          "lst_float": [[1.1], [2.1]],
          "bool": [True, False],
          "numpy": [np.array([1.0]), np.array([0.0])],
          "dict": {"1": ["1", "2"]},
          "set": [{"1"}, {"2"}],
          "nested_dict": {"b": [[1, 2], [1, 2]]},
      }
      findDictDiff(raw_pad_batch, collator(dict_batch))
  
      # 设置 backend 和 type
      collator.set_pad("float", pad_val=100, backend="numpy", dtype=int)
      raw_pad_batch = {
          "lst_str": [["1"], ["2", "2"]],
          "nest_lst_int": [[[1, 100], [100, 100]], [[1, 100], [1, 2]]],
          "float": np.array([1, 2]),
          "lst_float": [[1.1], [2.1]],
          "bool": [True, False],
          "numpy": [np.array([1.0]), np.array([0.0])],
          "dict": {"1": ["1", "2"]},
          "set": [{"1"}, {"2"}],
          "nested_dict": {"b": [[1, 2], [1, 2]]},
      }
      findDictDiff(raw_pad_batch, collator(dict_batch))
  
      # raw_pad_lst = [['1', '2'], [['1'], ['2', '2']], [1, 2], [[1, 0], [2, 2]], [[[1, 0], [0, 0]], [[1, 0], [1, 2]]],
      #                [1.1, 2.1], [[1.1], [2.1]], [True, False], [np.ones(1), np.ones(2)], [{'1': '1'}, {'2': '2'}],
      #                [{'1'}, {'2'}]]
      list_batch = [
          [
              "1",
              ["1"],
              1,
              [1],
              [[1]],
              1.1,
              [1.1],
              True,
              np.ones(1),
              {"1": "1"},
              {"1"},
          ],
          [
              "2",
              ["2", "2"],
              2,
              [2, 2],
              [[1], [1, 2]],
              2.1,
              [2.1],
              False,
              np.ones(2),
              {"2": "2"},
              {"2"},
          ],
      ]
      collator = Collator(backend="raw")
      collator.set_ignore("_0", "_3", "_1")
      collator.set_pad("_4", pad_val=None)
      raw_pad_lst = [
          [1, 2],
          [[[1]], [[1], [1, 2]]],
          [1.1, 2.1],
          [[1.1], [2.1]],
          [True, False],
          [[1, 0], [1, 1]],
          [{"1": "1"}, {"2": "2"}],
          [{"1"}, {"2"}],
      ]
      findListDiff(raw_pad_lst, collator(list_batch))
  
      collator = Collator(backend="raw")
      collator.set_pad("_0", pad_val=1)
      with pytest.raises(BaseException):
          collator(dict_batch)
  
      list_batch = [
          [
              "1",
              ["1"],
              1,
              [1],
              [[1]],
              1.1,
              [1.1],
              True,
              np.ones(1),
              {"1": "1"},
              {"1"},
          ],
          [
              "2",
              ["2", "2"],
              2,
              [2, 2],
              [[1], [1, 2]],
              2.1,
              [2.1],
              False,
              np.ones(2),
              {"2": "2"},
              {"2"},
          ],
      ]
      collator = Collator(backend="raw")
      collator.set_ignore("_0", "_3", "_1")
      collator.set_pad("_2", backend="numpy")
      collator.set_pad("_4", backend="numpy", pad_val=100)
      raw_pad_lst = [
          np.array([1, 2]),
          np.array([[[1, 100], [100, 100]], [[1, 100], [1, 2]]]),
          [1.1, 2.1],
          [[1.1], [2.1]],
          [True, False],
          [[1, 0], [1, 1]],
          [{"1": "1"}, {"2": "2"}],
          [{"1"}, {"2"}],
      ]
      findListDiff(raw_pad_lst, collator(list_batch))
  
      # _single
      collator = Collator()
      collator.set_pad("_single")
      findListDiff(list_batch, collator(list_batch))
  
imports: import numpy
  import pytest
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH, _NEED_IMPORT_PADDLE, _NEED_IMPORT_JITTOR, _NEED_IMPORT_ONEFLOW
  from fastNLP.core.collators.collator import Collator
  from ...helpers.utils import Capturing
label_desc: Use image node_id 6 for calling the TestCollator obj's underlying member method code with example usage: obj.test_pad() without return types