code: def test_rasterize(self):
      max_depth = 10
      min_depth = 2
      height = 480
      width = 640
      camera_origin = (0.0, 0.0, 0.0)
      camera_up = (0.0, 1.0, 0.0)
      look_at_point = (0.0, 0.0, 1.0)
      fov = (60.0 * np.math.pi / 180,)
      near_plane = (1.0,)
      far_plane = (10.0,)
      batch_shape = tf.convert_to_tensor(
          value=(2, (max_depth - min_depth) // 2), dtype=tf.int32
      )
  
      world_to_camera = look_at.right_handed(
          camera_origin, look_at_point, camera_up
      )
      perspective_matrix = perspective.right_handed(
          fov, (float(width) / float(height),), near_plane, far_plane
      )
      view_projection_matrix = tf.matmul(
          perspective_matrix, world_to_camera
      )
      view_projection_matrix = tf.squeeze(view_projection_matrix)
  
      # Generate triangles at different depths and associated ground truth.
      tris = np.zeros((max_depth - min_depth, 9), dtype=np.float32)
      gt = np.zeros(
          (max_depth - min_depth, height, width, 2), dtype=np.float32
      )
      for idx in range(max_depth - min_depth):
          tris[idx, :] = (
              -100.0,
              100.0,
              idx + min_depth,
              100.0,
              100.0,
              idx + min_depth,
              0.0,
              -100.0,
              idx + min_depth,
          )
          gt[idx, :, :, :] = (0, idx + min_depth)
  
      # Broadcast the variables.
      render_parameters = {
          "view_projection_matrix": (
              "mat",
              tf.broadcast_to(
                  input=view_projection_matrix,
                  shape=tf.concat(
                      values=(
                          batch_shape,
                          tf.shape(input=view_projection_matrix)[-2:],
                      ),
                      axis=0,
                  ),
              ),
          ),
          "triangular_mesh": (
              "buffer",
              tf.reshape(
                  tris,
                  shape=tf.concat(values=(batch_shape, (9,)), axis=0),
              ),
          ),
      }
      # Reshape the ground truth.
      gt = tf.reshape(
          gt,
          shape=tf.concat(
              values=(batch_shape, (height, width, 2)), axis=0
          ),
      )
  
      render_parameters = list(six.iteritems(render_parameters))
      variable_names = [v[0] for v in render_parameters]
      variable_kinds = [v[1][0] for v in render_parameters]
      variable_values = [v[1][1] for v in render_parameters]
  
      def rasterize():
          return rasterization_backend.render_ops.rasterize(
              num_points=3,
              variable_names=variable_names,
              variable_kinds=variable_kinds,
              variable_values=variable_values,
              output_resolution=(width, height),
              vertex_shader=test_vertex_shader,
              geometry_shader=test_geometry_shader,
              fragment_shader=test_fragment_shader,
          )
  
      result = rasterize()
      self.assertAllClose(result[..., 2:4], gt)
  
      @tf.function
      def check_lazy_shape():
          # Within @tf.function, the tensor shape is determined by SetShapeFn
          # callback. Ensure that the shape of non-batch axes matches that of of
          # the actual tensor evaluated in eager mode above.
          lazy_shape = rasterize().shape
          self.assertEqual(lazy_shape[-3:], list(result.shape)[-3:])
  
      check_lazy_shape()
  
file_path: graphics/tensorflow_graphics/rendering/opengl/tests/rasterizer_op_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import parameterized
  import numpy
  import six
  from six.moves import range
  import tensorflow
  from tensorflow_graphics.geometry.transformation import look_at
  from tensorflow_graphics.rendering.camera import perspective
  from tensorflow_graphics.rendering.opengl import rasterization_backend
  from tensorflow_graphics.util import test_case
label_desc: Use image node_id 1 for calling the RasterizerOPTest obj's underlying member method code with example usage: obj.test_rasterize() and returns: rasterization_backend