code: def test_torch_grad_clip_callback(
      accumulation_steps, fp16, clip_type, clip_value
  ):
      if not torch.cuda.is_available() and fp16:
          pytest.skip("No cuda, cannot test fp16.")
      device = "cuda" if fp16 else "cpu"
      kwargs = get_trainer_args(lr=1, device=device)
      callbacks = []
      callbacks.append(
          TorchGradClipCallback(
              clip_value=clip_value, clip_type=clip_type
          )
      )
      callbacks.append(
          CheckClipCallback(
              kwargs["model"].parameters(), clip_type, clip_value
          )
      )
      trainer = Trainer(**kwargs, callbacks=callbacks, fp16=fp16)
      trainer.run()
  
file_path: fastNLP/tests/core/callbacks/torch_callbacks/test_torch_grad_clip_callback.py
imports: import pytest
  import numpy
  from fastNLP.core.callbacks import TorchGradClipCallback, Callback
  from fastNLP import Trainer
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH
  from tests.helpers.callbacks.prepare_trainer_args_for_torch_test import get_trainer_args
label_desc: Use image node_id 1 for calling a global function with example usage: test_torch_grad_clip_callback(accumulation_steps, fp16, clip_type, clip_value) without return types