class_docstr: An `ItemSelector` implementation that randomly selects items in a batch.
  
  `RandomItemSelector` randomly selects items in a batch subject to
  restrictions given (max_selections_per_batch, selection_rate and
  unselectable_ids).
  
  Example:
  >>> vocab = ["[UNK]", "[MASK]", "[RANDOM]", "[CLS]", "[SEP]",
  ...          "abc", "def", "ghi"]
  >>> # Note that commonly in masked language model work, there are
  >>> # special tokens we don't want to mask, like CLS, SEP, and probably
  >>> # any OOV (out-of-vocab) tokens here called UNK.
  >>> # Note that if e.g. there are bucketed OOV tokens in the code,
  >>> # that might be a use case for overriding `get_selectable()` to
  >>> # exclude a range of IDs rather than enumerating them.
  >>> tf.random.set_seed(1234)
  >>> selector = tf_text.RandomItemSelector(
  ...     max_selections_per_batch=2,
  ...     selection_rate=0.2,
  ...     unselectable_ids=[0, 3, 4])  # indices of UNK, CLS, SEP
  >>> selection = selector.get_selection_mask(
  ...     tf.ragged.constant([[3, 5, 7, 7], [4, 6, 7, 5]]), axis=1)
  >>> print(selection)
  <tf.RaggedTensor [[False, False, False, True], [False, False, True, False]]>
  
  The selection has skipped the first elements (the CLS and SEP token codings)
  and picked random elements from the other elements of the segments -- if
  run with a different random seed the selections might be different.
code: def get_selection_mask(self, input_ids, axis):
      selectable = self.get_selectable(input_ids, axis)
  
      # Run the selection algorithm on positions RT
      positions_flat = math_ops.range(
          array_ops.size(input_ids.flat_values)
      )
      positions = input_ids.with_flat_values(positions_flat)
      # Mask out positions that are not selectable
      positions = ragged_array_ops.boolean_mask(positions, selectable)
  
      # merge to the desired axis
      positions = (
          positions.merge_dims(1, axis) if axis > 1 else positions
      )
  
      # Figure out how many we are going to select
      num_to_select = math_ops.ceil(
          math_ops.cast(positions.row_lengths(), dtypes.float32)
          * self.selection_rate
      )
      num_to_select = math_ops.minimum(
          num_to_select, self.max_selections_per_batch
      )
      num_to_select = math_ops.cast(num_to_select, dtypes.int64)
  
      # Shuffle and trim to items that are going to be selected
      def _shuffle_and_trim(x):
          positions, top_n = x
          if isinstance(positions, ragged_tensor.RaggedTensor):
              positions_at_axis = math_ops.range(positions.nrows())
              chosen_positions_at_axis = self._shuffle_fn(
                  positions_at_axis
              )[:top_n]
              return array_ops.gather(
                  positions, chosen_positions_at_axis
              )
          else:
              shuffled = self._shuffle_fn(positions)
              return shuffled[:top_n]
  
      selected_for_mask = map_fn.map_fn(
          _shuffle_and_trim,
          (positions, num_to_select),
          fn_output_signature=ragged_tensor.RaggedTensorSpec(
              ragged_rank=positions.ragged_rank - 1,
              dtype=positions.dtype,
          ),
      )
      selected_for_mask.flat_values.set_shape([None])
  
      # Construct the result which is a boolean RT
      # Scatter 1's to positions that have been selected_for_mask
      update_values = array_ops.ones_like(selected_for_mask.flat_values)
      update_values = math_ops.cast(update_values, input_ids.dtype)
      update_indices = selected_for_mask.flat_values
      update_indices = array_ops.expand_dims(update_indices, -1)
      update_indices = math_ops.cast(update_indices, input_ids.dtype)
  
      results_flat = array_ops.zeros_like(input_ids.flat_values)
      results_flat = gen_array_ops.tensor_scatter_update(
          results_flat, update_indices, update_values
      )
      results = math_ops.cast(
          input_ids.with_flat_values(results_flat), dtypes.bool
      )
  
      if axis < results.ragged_rank:
          reduce_axis = list(range(results.ragged_rank, axis, -1))
          results = math_ops.reduce_all(results, reduce_axis)
      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 5 for calling the RandomItemSelector obj's underlying member method code with example usage: obj.get_selection_mask(input_ids, axis) and returns: results, array_ops, shuffled