code: def _get_selection_mask(
      original, num_to_select, axis=-1, reverse=False
  ):
      """Computes a selection mask given how many items to select."""
      num_to_select = ops.convert_to_tensor(num_to_select)
      num_to_select = array_ops.reshape(num_to_select, [-1])
      row_lengths = _get_row_lengths_merged_to_axis(original, axis)
      num_to_select = array_ops.broadcast_to(
          num_to_select, array_ops.shape(row_lengths)
      )
      num_to_select = math_ops.cast(num_to_select, row_lengths.dtype)
      num_to_select = math_ops.minimum(num_to_select, row_lengths)
      ones = array_ops.ones_like(ragged_math_ops.range(num_to_select))
      ones = math_ops.cast(ones, dtypes.int32)
      zeros_row_length = row_lengths - num_to_select
      zeros = math_ops.cast(
          array_ops.zeros_like(ragged_math_ops.range(zeros_row_length)),
          dtypes.int32,
      )
      if reverse:
          results = array_ops.concat([zeros, ones], 1)
      else:
          results = array_ops.concat([ones, zeros], 1)
      results = math_ops.cast(results, dtypes.bool)
      return results
  
imports: from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import array_ops_stack
  from tensorflow.python.ops import gen_array_ops
  from tensorflow.python.ops import map_fn
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.ops.ragged import ragged_array_ops
  from tensorflow.python.ops.ragged import ragged_functional_ops
  from tensorflow.python.ops.ragged import ragged_math_ops
  from tensorflow.python.ops.ragged import ragged_tensor
label_desc: Use image node_id 2 for calling a global function with example usage: _get_selection_mask(original, num_to_select, axis, reverse) and returns: results