code: def scale_affine_mat(scale, center=None, ndim=None):
      if ndim is None:
          ndim = len(scale)
      else:
          assert ndim == len(scale) or 1 == len(scale)
      assert center is None or len(center) == ndim
  
      s_mat = np.identity(ndim + 1)
      for d in range(ndim):
          s_mat[d, d] = scale[0] if len(scale) == 1 else scale[d]
  
      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(s_mat, t1_mat))
      else:
          affine_mat = s_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 6 for calling a global function with example usage: scale_affine_mat(scale, center, ndim) and returns: affine_mat