code: def test_create_grid(self):
      with self.assertRaisesRegex(TypeError, ""):
          create_grid(None)
      with self.assertRaisesRegex(TypeError, ""):
          create_grid((1, 1), spacing=2.0)
      with self.assertRaisesRegex(TypeError, ""):
          create_grid((1, 1), spacing=2.0)
  
      test_assert(
          create_grid, ((1, 1),), np.array([[[0.0]], [[0.0]], [[1.0]]])
      )
  
      test_assert(
          create_grid,
          ((1, 1), None, False),
          np.array([[[0.0]], [[0.0]]]),
      )
  
      test_assert(
          create_grid,
          ((1, 1), (1.2, 1.3)),
          np.array([[[0.0]], [[0.0]], [[1.0]]]),
      )
  
      test_assert(
          create_grid,
          ((1, 1, 1), (1.2, 1.3, 1.0)),
          np.array([[[[0.0]]], [[[0.0]]], [[[0.0]]], [[[1.0]]]]),
      )
  
      test_assert(
          create_grid,
          ((1, 1, 1), (1.2, 1.3, 1.0), False),
          np.array([[[[0.0]]], [[[0.0]]], [[[0.0]]]]),
      )
  
      g = create_grid(
          (1, 1, 1), spacing=(1.2, 1.3, 1.0), dtype=np.int32
      )
      np.testing.assert_equal(g.dtype, np.int32)
  
      g = create_grid(
          (1, 1, 1),
          spacing=(1.2, 1.3, 1.0),
          dtype=torch.float64,
          backend="torch",
      )
      np.testing.assert_equal(g.dtype, torch.float64)
  
      test_assert(
          create_grid,
          ((2, 2, 2),),
          np.array(
              [
                  [
                      [[-0.5, -0.5], [-0.5, -0.5]],
                      [[0.5, 0.5], [0.5, 0.5]],
                  ],
                  [
                      [[-0.5, -0.5], [0.5, 0.5]],
                      [[-0.5, -0.5], [0.5, 0.5]],
                  ],
                  [
                      [[-0.5, 0.5], [-0.5, 0.5]],
                      [[-0.5, 0.5], [-0.5, 0.5]],
                  ],
                  [[[1.0, 1.0], [1.0, 1.0]], [[1.0, 1.0], [1.0, 1.0]]],
              ]
          ),
      )
  
      test_assert(
          create_grid,
          ((2, 2, 2), (1.2, 1.3, 1.0)),
          np.array(
              [
                  [
                      [[-0.6, -0.6], [-0.6, -0.6]],
                      [[0.6, 0.6], [0.6, 0.6]],
                  ],
                  [
                      [[-0.65, -0.65], [0.65, 0.65]],
                      [[-0.65, -0.65], [0.65, 0.65]],
                  ],
                  [
                      [[-0.5, 0.5], [-0.5, 0.5]],
                      [[-0.5, 0.5], [-0.5, 0.5]],
                  ],
                  [[[1.0, 1.0], [1.0, 1.0]], [[1.0, 1.0], [1.0, 1.0]]],
              ]
          ),
      )
  
file_path: MONAI/tests/test_create_grid_and_affine.py
imports: from __future__ import annotations
  import unittest
  import numpy
  import torch
  from monai.transforms import create_control_grid, create_grid, create_rotate, create_scale, create_shear, create_translate
  from tests.utils import assert_allclose, is_tf32_env
label_desc: Use image node_id 1 for calling the TestCreateGrid obj's underlying member method code with example usage: obj.test_create_grid() without return types