code: def shear_affine_mat(shear=None, angles=None, center=None):
      assert shear is not None or angles is not None
  
      if isinstance(shear, (list, tuple)):
          shear = np.float32(shear)
      if isinstance(angles, (list, tuple)):
          angles = np.float32(angles)
  
      if shear is None:
          shear = np.tan(angles * np.pi / 180.0)
      assert shear.size == 2 or shear.size == 6
      ndim = 3 if shear.size == 6 else 2
      assert center is None or len(center) == ndim
  
      if ndim == 2:
          sxy, syx = np.float32(shear).flatten()
          s_mat = np.array(
              [[1.0, sxy, 0.0], [syx, 1.0, 0.0], [0.0, 0.0, 1.0]]
          )
      else:  # ndim == 3
          sxy, sxz, syx, syz, szx, szy = np.float32(shear).flatten()
          s_mat = np.array(
              [
                  [1, sxy, sxz, 0],
                  [syx, 1, syz, 0],
                  [szx, szy, 1, 0],
                  [0, 0, 0, 1],
              ]
          )
  
      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 12 for calling a global function with example usage: shear_affine_mat(shear, angles, center) and returns: affine_mat