docstr: s
docstr_tok: ["s"]
code: def test_affine_resize(self, s):
      """s"""
      im = np.arange(4).reshape(1, 2, 2).astype(float)
      mat = np.array([[1 / s, 0, 0], [0, 1 / s, 0], [0, 0, 1]])
      sp_size = 2 * s
  
      def method_0(im, ac):
          xform = Affine(
              align_corners=ac,
              affine=mat,
              image_only=True,
              spatial_size=sp_size,
          )
          xform.lazy = True
          out = xform(im)
          overrides = {"padding_mode": "border", "align_corners": ac}
          out = apply_pending(out, overrides=overrides)[0]
          return out
  
      def method_1(im, ac):
          xform = Affine(
              align_corners=ac,
              affine=mat,
              image_only=True,
              spatial_size=sp_size,
          )
          xform.lazy = True
          out = xform(im)
          overrides = {
              "mode": 1,
              "padding_mode": "nearest",
              "align_corners": ac,
          }
          out = apply_pending(out, overrides=overrides)[0]
          return out
  
      def method_2(im, ac):
          xform = Affine(
              align_corners=ac,
              affine=mat,
              padding_mode="border",
              image_only=True,
              spatial_size=sp_size,
          )
          out = xform(im)
          return out
  
      def method_3(im, ac):
          xform = Affine(
              align_corners=ac,
              affine=mat,
              mode=1,
              padding_mode="nearest",
              image_only=True,
              spatial_size=sp_size,
          )
          out = xform(im)
          return out
  
      for call in (method_0, method_1, method_2, method_3):
          for ac in (False, True):
              out = call(im, ac)
              ref = Resize(
                  align_corners=ac,
                  spatial_size=(sp_size, sp_size),
                  mode="bilinear",
              )(im)
              assert_allclose(
                  out, ref, rtol=1e-4, atol=1e-4, type_test=False
              )
  
file_path: MONAI/tests/test_affine.py
imports: from __future__ import annotations
  import unittest
  from copy import deepcopy
  import numpy
  import torch
  from parameterized import parameterized
  from monai.data import MetaTensor, set_track_meta
  from monai.transforms import Affine, Resize
  from monai.transforms.lazy.functional import apply_pending
  from monai.utils import optional_import
  from tests.lazy_transforms_utils import test_resampler_lazy
  from tests.utils import TEST_NDARRAYS_ALL, assert_allclose, test_local_inversion
label_desc: Use image node_id 1 for calling the TestAffineConsistency obj's underlying member method code with example usage: obj.test_affine_resize(s) and returns: out, out, out, out