code: def rotate_affine_mat(angle, axis=None, center=None):
      assert axis is None or len(axis) == 3
      ndim = 3 if axis is not None else 2
      assert center is None or len(center) == ndim
  
      angle_rad = angle * np.pi / 180.0
      if ndim == 2:
          c = np.cos(angle_rad)
          s = np.sin(angle_rad)
          r_mat = np.array([[c, -s, 0.0], [s, c, 0.0], [0.0, 0.0, 1.0]])
      else:  # ndim == 3
          norm_axis = axis / np.linalg.norm(axis)
          r_mat = np.identity(ndim + 1)
          r_mat[:ndim, :ndim] = scipy_rotate.from_rotvec(
              angle_rad * norm_axis
          ).as_matrix()
      if center is not None:
          neg_offset = [-x for x in center]
          t1_mat = translate_affine_mat(neg_offset)
          t2_mat = translate_affine_mat(center)
          affine_mat = np.dot(t2_mat, np.dot(r_mat, t1_mat))
      else:
          affine_mat = r_mat
  
      return affine_mat
  
imports: import random
  import warnings
  import numpy
  from scipy.spatial.transform import Rotation
  from nvidia.dali.pipeline import Pipeline
  import nvidia.dali.ops.transforms
  import nvidia.dali.ops
  import nvidia.dali.fn
  from nvidia.dali import pipeline_def
  from sequences_test_utils import ArgData, ArgDesc, sequence_suite_helper, ArgCb, ParamsProvider
  from nose_utils import assert_raises
label_desc: Use image node_id 9 for calling a global function with example usage: rotate_affine_mat(angle, axis, center) and returns: affine_mat