code: def projective_transform(
      image,
      label,
      reso,
      image_translate_ratio,
      image_transform_ratio,
      sampled_2d_slices=False,
  ):
      """Apply projective transformation on image and label."""
  
      if image_translate_ratio < 0.000001 and (
          image_transform_ratio < 0.000001
      ):
          return image, label
  
      def _projective_transform(
          data, proj_matrix, static_axis, interpolation
      ):
          """Apply projective transformation."""
          if static_axis == 2:
              data = contrib_image.transform(
                  data, proj_matrix, interpolation
              )
          elif static_axis == 1:
              data = tf.transpose(data, [0, 2, 1])
              data = contrib_image.transform(
                  data, proj_matrix, interpolation
              )
              data = tf.transpose(data, [0, 2, 1])
          else:
              data = tf.transpose(data, [2, 1, 0])
              data = contrib_image.transform(
                  data, proj_matrix, interpolation
              )
              data = tf.transpose(data, [2, 1, 0])
          return data
  
      for static_axis in [0, 1, 2]:
          if sampled_2d_slices and static_axis != 2:
              continue
          a0 = _truncated_normal(1.0, image_transform_ratio)
          a1 = _truncated_normal(0.0, image_transform_ratio)
          a2 = _truncated_normal(0.0, image_translate_ratio * reso)
          b0 = _truncated_normal(0.0, image_transform_ratio)
          b1 = _truncated_normal(1.0, image_transform_ratio)
          b2 = _truncated_normal(0.0, image_translate_ratio * reso)
          c0 = _truncated_normal(0.0, image_transform_ratio)
          c1 = _truncated_normal(0.0, image_transform_ratio)
          proj_matrix = [a0, a1, a2, b0, b1, b2, c0, c1]
  
          image = _projective_transform(
              image, proj_matrix, static_axis, "BILINEAR"
          )
          label = _projective_transform(
              label, proj_matrix, static_axis, "NEAREST"
          )
  
      return image, label
  
file_path: mesh/mesh_tensorflow/experimental/data_aug_lib.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow.compat.v1
  import tensorflow_probability
  from tensorflow.contrib import image
label_desc: Use image node_id 3 for calling a global function with example usage: projective_transform(image, label, reso, image_translate_ratio, image_transform_ratio, sampled_2d_slices) and returns: image,  label, image,  label, data