code: def create_affine_transforms(
      dim, translations, rotations, scales, rot_axis=None
  ):
      r"""Creates a list of affine transforms with all combinations of params
  
      This function is intended to be used for testing only. It generates
      affine transforms for all combinations of the input parameters in the
      following order: let T be a translation, R a rotation and S a scale. The
      generated affine will be:
  
      A = T.dot(S).dot(R).dot(T^{-1})
  
      Translation is handled this way because it is convenient to provide
      the translation parameters in terms of the center of rotation we wish
      to generate.
  
      Parameters
      ----------
      dim: int (either dim=2 or dim=3)
          dimension of the affine transforms
      translations: sequence of dim-tuples
          each dim-tuple represents a translation parameter
      rotations: sequence of floats
          each number represents a rotation angle in radians
      scales: sequence of floats
          each number represents a scale
      rot_axis: rotation axis (used for dim=3 only)
  
      Returns
      -------
      transforms: sequence of (dim + 1)x(dim + 1) matrices
          each matrix correspond to an affine transform with a combination
          of the input parameters
      """
      transforms = []
      for t in translations:
          trans_inv = np.eye(dim + 1)
          trans_inv[:dim, dim] = -t[:dim]
          trans = npl.inv(trans_inv)
          for theta in rotations:  # rotation angle
              if dim == 2:
                  ct = np.cos(theta)
                  st = np.sin(theta)
                  rot = np.array([[ct, -st, 0], [st, ct, 0], [0, 0, 1]])
              else:
                  rot = np.eye(dim + 1)
                  rot[:3, :3] = geometry.rodrigues_axis_rotation(
                      rot_axis, theta
                  )
  
              for s in scales:  # scale
                  scale = np.eye(dim + 1) * s
                  scale[dim, dim] = 1
  
              affine = trans.dot(scale.dot(rot.dot(trans_inv)))
              transforms.append(affine)
      return transforms
  
file_path: dipy/dipy/align/tests/test_imaffine.py
imports: import numpy
  import numpy.linalg
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_equal, assert_raises, assert_warns
  from dipy.core import geometry
  from dipy.align import vector_fields
  from dipy.align import imaffine
  from dipy.align.imaffine import AffineInversionError, AffineInvalidValuesError, AffineMap, _number_dim_affine_matrix
  from dipy.align.transforms import regtransforms
  from dipy.align.tests.test_parzenhist import setup_random_transform
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 7 for calling a global function with example usage: create_affine_transforms(dim, translations, rotations, scales, rot_axis) and returns: transforms