code: def _circular_indices(size, num_valid_entries):
      """Creates circular indices with padding and mask for non-padded ones.
  
      This returns a indices and a mask Tensor, where the mask is True for valid
      entries and False for padded entries.
  
      The returned indices have the shape of [batch_size, size], where the
      batch_size is obtained from the 1st dim of `num_valid_entries`. For a
      batch_size = 1, when size = 3, returns [[0, 1, 2]], when num_valid_entries =
      2, returns [[0, 1, 0]]. The first 2 are valid and the returned mask is [True,
      True, False].
  
      Args:
        size: A scalar int `Tensor` for the size.
        num_valid_entries: A 1-D `Tensor` with shape [batch_size] representing the
          number of valid entries for each instance in a batch.
  
      Returns:
        A tuple of Tensors (batch_indices, batch_indices_mask). The first has
        shape [batch_size, size] and the second has shape [batch_size, size].
      """
      with tf.compat.v1.name_scope(name="circular_indices"):
          # shape = [batch_size, size] with value [[0, 1, ...], [0, 1, ...], ...].
          batch_indices = tf.tile(
              tf.expand_dims(tf.range(size), 0),
              [tf.shape(input=num_valid_entries)[0], 1],
          )
          num_valid_entries = tf.reshape(num_valid_entries, [-1, 1])
          batch_indices_mask = tf.less(batch_indices, num_valid_entries)
          # Use mod to make the indices to the ranges of valid entries.
          num_valid_entries = tf.where(
              tf.less(num_valid_entries, 1),
              tf.ones_like(num_valid_entries),
              num_valid_entries,
          )
          batch_indices = tf.math.mod(batch_indices, num_valid_entries)
          return batch_indices, batch_indices_mask
  
file_path: ranking/tensorflow_ranking/python/utils.py
imports: from typing import Callable, Dict, Tuple
  import tensorflow
label_desc: Use image node_id 11 for calling a global function with example usage: _circular_indices(size, num_valid_entries) and returns: batch_indices,  batch_indices_mask