code: def test_torch_dl():
      from fastNLP import TorchDataLoader
      from fastNLP import DataSet
      import numpy as np
      import torch
  
      ds = DataSet(
          {
              "x": [1, 2],
              "y": [[1, 2], [3]],
              "z": [np.ones((1, 2)), np.ones((2, 3))],
              "i": [{"j": [1, 2]}, {"j": [3]}],
              "j": ["a", "b"],
          }
      )
  
      dl = TorchDataLoader(ds, batch_size=2)
      batch = next(iter(dl))
      assert (
          "x" in batch
          and "y" in batch
          and "z" in batch
          and "i" in batch
          and "j" in batch
      )
      assert isinstance(batch["z"], torch.FloatTensor)
      assert isinstance(batch["j"], list)
      assert isinstance(batch["i"]["j"], torch.LongTensor)
  
      dl.set_ignore("x")
      batch = next(iter(dl))
      assert "x" not in batch and "y" in batch and "z" in batch
  
      dl.set_pad("y", pad_val=None)
      batch = next(iter(dl))
      assert "x" not in batch and "y" in batch and "z" in batch
      assert isinstance(batch["y"], list)
      assert len(batch["y"][0]) != len(batch["y"][1])  # 没有 pad
  
      dl.set_pad(("i", "j"), pad_val=None)
      batch = next(iter(dl))
      assert "x" not in batch and "y" in batch and "z" in batch
      assert isinstance(batch["y"], list)
      assert len(batch["y"][0]) != len(batch["y"][1])  # 没有 pad
      assert isinstance(batch["i"]["j"], list)
      assert len(batch["i"]["j"][0]) != len(
          batch["i"]["j"][1]
      )  # 没有 pad
  
      with pytest.raises(KeyError):
          dl.set_pad("i", pad_val=None)
  
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 4 for calling a global function with example usage: test_torch_dl() without return types