code: def compute_barycentric_coordinates(
      triangle_ids: type_alias.TensorLike,
      triangle_matrices: type_alias.TensorLike,
      px: type_alias.TensorLike,
      py: type_alias.TensorLike,
  ) -> tf.Tensor:
      """Computes per-pixel barycentric coordinates.
  
      Args:
        triangle_ids: 2-D int tensor with shape [image_height, image_width]
          containing per-pixel triangle ids, as computed by rasterize_triangles.
        triangle_matrices: 3-D float32 tensor with shape [3, 3, triangle_count]
          containing per-triangle matrices computed by compute_triangle_matrices.
        px: 2-D float32 tensor with shape [image_height, image_width] containing
          per-pixel x-coordinates, as computed by normalized_pixel_coordinates.
        py: 2-D float32 tensor with shape [image_height, image_width] containing
          per-pixel y-coordinates, as computed by normalized_pixel_coordinates.
  
      Returns:
        3-D float32 tensor with shape [height, width, 3] containing the barycentric
        coordinates of the point at each pixel within the triangle specified by
        triangle_ids.
      """
      # Gather per-pixel triangle matrices into m.
      pixel_triangle_matrices = tf.gather(
          triangle_matrices, triangle_ids, axis=-1
      )
      # Compute barycentric coordinates by evaluating edge equations.
      barycentric_coords = (
          pixel_triangle_matrices[:, 0] * px
          + pixel_triangle_matrices[:, 1] * py
          + pixel_triangle_matrices[:, 2]
      )
      # Normalize so the barycentric coordinates sum to 1. Guard against division
      # by zero in the case that the barycentrics sum to zero, which can happen for
      # background pixels when the 0th triangle in the list is degenerate, due to
      # the way we use triangle id 0 for both background and the first triangle.
      barycentric_coords = tf.math.divide_no_nan(
          barycentric_coords, tf.reduce_sum(barycentric_coords, axis=0)
      )
      return barycentric_coords
  
file_path: graphics/tensorflow_graphics/rendering/barycentrics.py
imports: from typing import Tuple
  import tensorflow
  from tensorflow_graphics.rendering import framebuffer
  from tensorflow_graphics.util import shape
  from tensorflow_graphics.util import type_alias
label_desc: Use image node_id 4 for calling a global function with example usage: compute_barycentric_coordinates(triangle_ids, triangle_matrices, px, py) and returns: barycentric_coords