class_docstr: A class encapsulating the logic for selecting items.
  
  `ItemSelector` implementations contain algorithms for selecting items in a
  `RaggedTensor`. Users of `ItemSelector` implementations can call
  `get_selection_mask()` to retrieve a bool `RaggedTensor` mask indicating the
  items that have been selected. For example:
  
  >>> inputs = tf.ragged.constant([
  ...     [1, 2, 3, 4],
  ...     [100, 200]
  ...   ])
  >>> tf.random.set_seed(1234)
  >>> selector = RandomItemSelector(3, .5)
  >>> selected = selector.get_selection_mask(inputs, axis=1)
  >>> print(selected)
  <tf.RaggedTensor [[False, True, True, False],
                    [False, True]]>
  
  
  An important use case for these classes is in creating inputs for masked
  language model training dataset preparation. See `masked_language_model` for
  an example of using the selectors in such a context.
  
  Subclass writers will typically implement a selection algorithm by overriding
  `get_selection_mask()`.
  
  A helper function `get_selectable()` is provided to help subclass writers
  filter out excluded items from selection (e.g. CLS and SEP for bert style
  models). This will frequently serve as a prefilter for subclass item
  selection (see e.g. the implementation of `RandomItemSelector`. The base class
  behavior is to simply return the mask obtained by filtering out items listed
  in `unselectable_ids`.
docstr: Creates an instance of a `ItemSelector`.
  
  Args:
    unselectable_ids: a list, or `Tensor` of ids that are not selectable.
docstr_tok: ["Creates","an","instance","of","a","`","ItemSelector","`",".","Args",":","unselectable_ids",":","a","list",",","or","`","Tensor","`","of","ids","that","are","not","selectable","."]
code: def __init__(self, unselectable_ids=None):
      """Creates an instance of a `ItemSelector`.
  
      Args:
        unselectable_ids: a list, or `Tensor` of ids that are not selectable.
      """
      if unselectable_ids is None:
          unselectable_ids = []
      if isinstance(unselectable_ids, list):
          self._unselectable_ids = unselectable_ids
      elif isinstance(unselectable_ids, tensor.Tensor):
          if unselectable_ids.shape.rank not in (1, None):
              raise ValueError(
                  f"`unselectable_ids` must have a rank of 1 or None, "
                  f"but was: {unselectable_ids.shape.rank}"
              )
          self._unselectable_ids = array_ops_stack.unstack(
              unselectable_ids
          )
      else:
          raise ValueError(
              "`unselectable_ids` must be either a list or "
              + "`1 dimensional Tensor`, instead it is a "
              + str(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 ItemSelector object from inherited base classes: object with example: obj = ItemSelector(unselectable_ids)