code: def test_to_dlpack(
      ext_name, numpy_type, torch_type, set_dtype, set_ctx
  ):
      ctx = get_extension_context(ext_name)
      nn.set_default_context(ctx)
  
      # Init nnabla.NdArray
      a = nn.NdArray.from_numpy_array(np.ones((5, 5), dtype=numpy_type))
      a.cast(numpy_type, ctx)
  
      # NNabla to DLPack
      passed_dtype = numpy_type if set_dtype else None
      passed_ctx = ctx if set_ctx else None
      dlp = nn.utils.dlpack.to_dlpack(a, passed_dtype, passed_ctx)
  
      # DLPack to PyTorch
      t = torch.utils.dlpack.from_dlpack(dlp)
      assert t.dtype == torch_type
  
      # Check if the memory locations are still same.
      t.add_(1)  # in-place add
      assert np.all(a.data == t.to("cpu").detach().numpy().copy())
  
file_path: nnabla/python/test/utils/test_dlpack.py
imports: import pytest
  import nnabla
  import nnabla.utils.dlpack
  import numpy
  from nnabla.ext_utils import list_extensions, get_extension_context
  from nnabla.testing import assert_allclose
label_desc: Use image node_id 3 for calling a global function with example usage: test_to_dlpack(ext_name, numpy_type, torch_type, set_dtype, set_ctx) without return types