code: def compose_matrix(
      scale=None,
      shear=None,
      angles=None,
      translate=None,
      perspective=None,
  ):
      """Return 4x4 transformation matrix from sequence of
      transformations.
  
      Code modified from the work of Christoph Gohlke, link provided here
      https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py
  
      This is the inverse of the ``decompose_matrix`` function.
  
      Parameters
      ----------
      scale : (3,) array_like
          Scaling factors.
      shear : array_like
          Shear factors for x-y, x-z, y-z axes.
      angles : array_like
          Euler angles about static x, y, z axes.
      translate : array_like
          Translation vector along x, y, z axes.
      perspective : array_like
          Perspective partition of matrix.
  
      Returns
      -------
      matrix : 4x4 array
  
  
      Examples
      --------
      >>> import math
      >>> import numpy as np
      >>> import dipy.core.geometry as gm
      >>> scale = np.random.random(3) - 0.5
      >>> shear = np.random.random(3) - 0.5
      >>> angles = (np.random.random(3) - 0.5) * (2*math.pi)
      >>> trans = np.random.random(3) - 0.5
      >>> persp = np.random.random(4) - 0.5
      >>> M0 = gm.compose_matrix(scale, shear, angles, trans, persp)
  
      """
      M = np.identity(4)
      if perspective is not None:
          P = np.identity(4)
          P[3, :] = perspective[:4]
          M = np.dot(M, P)
      if translate is not None:
          T = np.identity(4)
          T[:3, 3] = translate[:3]
          M = np.dot(M, T)
      if angles is not None:
          R = euler_matrix(angles[0], angles[1], angles[2], "sxyz")
          M = np.dot(M, R)
      if shear is not None:
          Z = np.identity(4)
          Z[1, 2] = shear[2]
          Z[0, 2] = shear[1]
          Z[0, 1] = shear[0]
          M = np.dot(M, Z)
      if scale is not None:
          S = np.identity(4)
          S[0, 0] = scale[0]
          S[1, 1] = scale[1]
          S[2, 2] = scale[2]
          M = np.dot(M, S)
      M /= M[3, 3]
      return M
  
imports: import itertools
  import math
  import numpy
  import numpy.linalg
label_desc: Use image node_id 14 for calling a global function with example usage: compose_matrix(scale, shear, angles, translate, perspective) and returns: M