# Desired dimension (mermaid supports 1D, 2D, and 3D registration)
dim = 2

# If we want to add some noise to the background (for synthetic examples)
add_noise_to_bg = True

# and now create it
if use_synthetic_test_case:
    length = 64
    # size of the desired images: (sz)^dim
    szEx = np.tile(length, dim )
    # create a default image size with two sample squares
    I0, I1, spacing = EG.CreateSquares(dim,add_noise_to_bg).create_image_pair(szEx, params)
else:
    # return a real image example
    I0, I1, spacing = EG.CreateRealExampleImages(dim).create_image_pair() # create a default image size with two sample squares

##################################
# Creating the registration algorithm
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#
# We simply instantiate a simple interface object for the registration of image pairs.
# We can then query it as to what models registration models are currently supported.
#

# create a simple interface object for pair-wise image registration
si = SI.RegisterImagePair()

# print possible model names
si.print_available_models()
        var_inputs = list([i for i in inputs if isinstance(i, Variable)])
        if not var_inputs:
            raise RuntimeError("no Variables found in input")
        for i in var_inputs:
            if i.grad is None:
                continue
            if not i.grad.data.eq(0).all():
                return fail_test('backward not multiplied by grad_output')

    return True


torch.set_num_threads(8)

dim = 2
I0, I1, spacing = eg.CreateRealExampleImages(dim).create_image_pair()
I0 = I0[:, :, 64:64 + 16, 64:64 + 32]
spacing[1] *= 0.7

I0v = torch.from_numpy(I0)
I0v.requires_grad = True

stn = STN_ND_BCXYZ(spacing)
sz = I0.shape

id = utils.identity_map_multiN(sz, spacing)
idp = id + np.random.random(id.shape).astype('float32') * 0.025

phi = torch.from_numpy(idp)
phi.requires_grad = True