code: def generate_random_face_indices(
      num_samples: int,
      face_weights: type_alias.TensorLike,
      seed: Optional[type_alias.TensorLike] = None,
      stateless: bool = False,
      name: str = "generate_random_face_indices",
  ) -> type_alias.TensorLike:
      """Generate a sample of face ids given per face probability.
  
      Note:
        In the following, A1 to An are optional batch dimensions.
  
      Args:
        num_samples: An `int32` scalar denoting the number of samples to generate
          per mesh.
        face_weights: A `float` tensor of shape `[A1, ..., An, F]` where F is
          number of faces. All weights must be > 0.
        seed: Optional seed for the random number generator.
        stateless: Optional flag to use stateless random sampler. If stateless=True,
          then `seed` must be provided as shape `[2]` int tensor. Stateless random
          sampling is useful for testing to generate the same reproducible sequence
          across calls. If stateless=False, then a stateful random number generator
          is used (default behavior).
        name: Name for op. Defaults to "generate_random_face_indices".
  
      Returns:
        An `int32` tensor of shape `[A1, ..., An, num_samples]` denoting sampled
          face indices.
      """
      with tf.name_scope(name):
          num_samples = tf.convert_to_tensor(value=num_samples)
          face_weights = tf.convert_to_tensor(value=face_weights)
          shape.check_static(
              tensor=face_weights,
              tensor_name="face_weights",
              has_rank_greater_than=0,
          )
          shape.check_static(
              tensor=num_samples, tensor_name="num_samples", has_rank=0
          )
  
          face_weights = asserts.assert_all_above(
              face_weights, minval=0.0
          )
          eps = asserts.select_eps_for_division(face_weights.dtype)
          face_weights = face_weights + eps
          sampled_face_indices = _random_categorical_sample(
              num_samples=num_samples,
              weights=face_weights,
              seed=seed,
              stateless=stateless,
          )
          return sampled_face_indices
  
file_path: graphics/tensorflow_graphics/geometry/representation/mesh/sampler.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Optional, Tuple
  import tensorflow
  from tensorflow_graphics.geometry.representation import triangle
  from tensorflow_graphics.geometry.representation.mesh import normals
  from tensorflow_graphics.util import asserts
  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 3 for calling a global function with example usage: generate_random_face_indices(num_samples, face_weights, seed, stateless, name) and returns: sampled_face_indices