code: def _get_shuffle_indices(
      shape, mask=None, shuffle_ties=True, seed=None
  ):
      """Gets indices which would shuffle a tensor.
  
      Args:
        shape: The shape of the indices to generate.
        mask: An optional mask that indicates which entries to place first. Its
          shape should be equal to given shape.
        shuffle_ties: Whether to randomly shuffle ties.
        seed: The ops-level random seed.
  
      Returns:
        An int32 `Tensor` with given `shape`. Its entries are indices that would
        (randomly) shuffle the values of a `Tensor` of given `shape` along the last
        axis while placing masked items first.
      """
      # Generate random values when shuffling ties or all zeros when not.
      if shuffle_ties:
          shuffle_values = tf.random.uniform(shape, seed=seed)
      else:
          shuffle_values = tf.zeros(shape, dtype=tf.float32)
  
      # Since shuffle_values is always in [0, 1), we can safely increase entries
      # where mask=False with 2.0 to make sure those are placed last during the
      # argsort op.
      if mask is not None:
          shuffle_values = tf.where(
              mask, shuffle_values, shuffle_values + 2.0
          )
  
      # Generate indices by sorting the shuffle values.
      return tf.argsort(shuffle_values, stable=True)
  
file_path: ranking/tensorflow_ranking/python/utils.py
imports: from typing import Callable, Dict, Tuple
  import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: _get_shuffle_indices(shape, mask, shuffle_ties, seed) and returns: tf