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.
docstr: Creates instance of `RandomItemSelector`.
  
  By default the source of randomness will be the one set by
  tf.random.set_seed. Users can adjust this independently by providing
  a separate `shuffle_fn` to the selector.
  
  Args:
    max_selections_per_batch: An int of the max number of items to mask out.
    selection_rate: The rate at which items are randomly selected.
    unselectable_ids: (optional) A list of python ints or 1D `Tensor` of ints
      which are ids that will be not be masked.
    shuffle_fn: (optional) A function that shuffles a 1D `Tensor`. Default
      uses `tf.random.shuffle`.
docstr_tok: ["Creates","instance","of","`","RandomItemSelector","`",".","By","default","the","source","of","randomness","will","be","the","one","set","by","tf.random.set_seed",".","Users","can","adjust","this","independently","by","providing","a","separate","`","shuffle_fn","`","to","the","selector",".","Args",":","max_selections_per_batch",":","An","int","of","the","max","number","of","items","to","mask","out",".","selection_rate",":","The","rate","at","which","items","are","randomly","selected",".","unselectable_ids",":","(","optional",")","A","list","of","python","ints","or","1D","`","Tensor","`","of","ints","which","are","ids","that","will","be","not","be","masked",".","shuffle_fn",":","(","optional",")","A","function","that","shuffles","a","1D","`","Tensor","`",".","Default","uses","`","tf.random.shuffle","`","."]
code: def __init__(
      self,
      max_selections_per_batch,
      selection_rate,
      unselectable_ids=None,
      shuffle_fn=None,
  ):
      """Creates instance of `RandomItemSelector`.
  
      By default the source of randomness will be the one set by
      tf.random.set_seed. Users can adjust this independently by providing
      a separate `shuffle_fn` to the selector.
  
      Args:
        max_selections_per_batch: An int of the max number of items to mask out.
        selection_rate: The rate at which items are randomly selected.
        unselectable_ids: (optional) A list of python ints or 1D `Tensor` of ints
          which are ids that will be not be masked.
        shuffle_fn: (optional) A function that shuffles a 1D `Tensor`. Default
          uses `tf.random.shuffle`.
      """
      if selection_rate is None:
          raise ValueError("`selection_rate` cannot be None")
      if shuffle_fn is None:
          self._shuffle_fn = random_ops.random_shuffle
      else:
          self._shuffle_fn = shuffle_fn
  
      self._max_selections_per_batch = max_selections_per_batch
      self._selection_rate = selection_rate
      super().__init__(unselectable_ids)
  
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 1 to create a new RandomItemSelector object from inherited base classes: ItemSelector with example: obj = RandomItemSelector(max_selections_per_batch, selection_rate, unselectable_ids, shuffle_fn)