code: def compute_radiance(
      rgba_values: type_alias.TensorLike,
      distances: type_alias.TensorLike,
      name: str = "ray_radiance",
  ) -> Tuple[tf.Tensor, tf.Tensor, tf.Tensor]:
      """Renders the rgba values for points along a ray, as described in ["NeRF Representing Scenes as Neural Radiance Fields for View Synthesis"](https://github.com/bmild/nerf).
  
      Note:
        In the following, A1 to An are optional batch dimensions.
  
      Args:
        rgba_values: A tensor of shape `[A1, ..., An, N, 4]`, where N are the
          samples on the ray.
        distances: A tensor of shape `[A1, ..., An, N]` containing the distances
          between the samples, where N are the samples on the ray.
        name: A name for this op. Defaults to "ray_radiance".
  
      Returns:
        A tensor of shape `[A1, ..., An, 3]` for the estimated rgb values,
        a tensor of shape `[A1, ..., An, 1]` for the estimated density values,
        and a tensor of shape `[A1, ..., An, N]` for the sample weights.
      """
  
      with tf.name_scope(name):
          rgba_values = tf.convert_to_tensor(value=rgba_values)
          distances = tf.convert_to_tensor(value=distances)
          distances = tf.expand_dims(distances, -1)
  
          shape.check_static(
              tensor=rgba_values,
              tensor_name="rgba_values",
              has_dim_equals=(-1, 4),
          )
          shape.check_static(
              tensor=rgba_values,
              tensor_name="rgba_values",
              has_rank_greater_than=1,
          )
          shape.check_static(
              tensor=distances,
              tensor_name="distances",
              has_rank_greater_than=1,
          )
          shape.compare_batch_dimensions(
              tensors=(rgba_values, distances),
              tensor_names=("ray_values", "dists"),
              last_axes=-3,
              broadcast_compatible=True,
          )
          shape.compare_dimensions(
              tensors=(rgba_values, distances),
              tensor_names=("ray_values", "dists"),
              axes=-2,
          )
  
          rgb, density = tf.split(rgba_values, [3, 1], axis=-1)
          alpha = 1.0 - tf.exp(-density * distances)
          alpha = tf.squeeze(alpha, -1)
          ray_sample_weights = alpha * tf.math.cumprod(
              1.0 - alpha + 1e-10, -1, exclusive=True
          )
          ray_rgb = tf.reduce_sum(
              input_tensor=tf.expand_dims(ray_sample_weights, -1) * rgb,
              axis=-2,
          )
          ray_alpha = tf.expand_dims(
              tf.reduce_sum(input_tensor=ray_sample_weights, axis=-1),
              axis=-1,
          )
          return ray_rgb, ray_alpha, ray_sample_weights
  
file_path: graphics/tensorflow_graphics/rendering/volumetric/ray_radiance.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Tuple
  import tensorflow
  from tensorflow_graphics.util import export_api
  from tensorflow_graphics.util import shape
  from tensorflow_graphics.util import type_alias
label_desc: Use image node_id 1 for calling a global function with example usage: compute_radiance(rgba_values, distances, name) and returns: ray_rgb,  ray_alpha,  ray_sample_weights