code: def test_cardinality(self, batch_size, device, dtype):
      inp = torch.zeros(batch_size, 3, 4, 4, device=device, dtype=dtype)
      assert SpatialGradient()(inp).shape == (batch_size, 3, 2, 4, 4)
  
imports: import pytest
  import torch
  from kornia.filters import Sobel, SpatialGradient, SpatialGradient3d, sobel, spatial_gradient, spatial_gradient3d
  from kornia.testing import BaseTester, tensor_to_gradcheck_var
label_desc: Use image node_id 2 for calling the TestSpatialGradient obj's underlying member method code with example usage: obj.test_cardinality(batch_size, device, dtype) without return types