code: def extract_indices_tf(X, idx, allow_shuffle) -> DatasetLike:
      """Extracts subset of tensorflow dataset corresponding to examples at particular indices.
  
      Args:
        X : ``tensorflow.data.Dataset``
  
        idx : array_like of integer indices corresponding to examples to keep in the dataset.
          Returns subset of examples in the dataset X that correspond to these indices.
  
        allow_shuffle : bool
          Whether or not shuffling of this data is allowed (eg. must turn off shuffling for validation data).
  
      Note: this code only works on Datasets in which:
      * ``shuffle()`` has been called before ``batch()``,
      * no other order-destroying operation (eg. ``repeat()``) has been applied.
  
      Indices are extracted from the original version of Dataset (before shuffle was called rather than in shuffled order).
      """
      import tensorflow
  
      idx = np.asarray(idx)
      idx = np.int64(
          idx
      )  # needed for Windows (reconsider if necessary in the future)
  
      og_batch_size = None
      if hasattr(X, "_batch_size"):
          og_batch_size = int(X._batch_size)
          X = X.unbatch()
  
      unshuffled_X, buffer_size = unshuffle_tensorflow_dataset(X)
      if unshuffled_X is not None:
          X = unshuffled_X
  
      # Create index,value pairs in the dataset (adds extra indices that werent there before)
      X = X.enumerate()
      keys_tensor = tensorflow.constant(idx)
      vals_tensor = tensorflow.ones_like(
          keys_tensor
      )  # Ones will be casted to True
      table = tensorflow.lookup.StaticHashTable(
          tensorflow.lookup.KeyValueTensorInitializer(
              keys_tensor, vals_tensor
          ),
          default_value=0,
      )  # If index not in table, return 0
  
      def hash_table_filter(index, value):
          table_value = table.lookup(index)  # 1 if index in arr, else 0
          index_in_arr = tensorflow.cast(
              table_value, tensorflow.bool
          )  # 1 -> True, 0 -> False
          return index_in_arr
  
      # Filter the dataset, then drop the added indices
      X_subset = X.filter(hash_table_filter).map(
          lambda idx, value: value
      )
  
      if (unshuffled_X is not None) and allow_shuffle:
          X_subset = X_subset.shuffle(buffer_size=buffer_size)
  
      if (
          og_batch_size is not None
      ):  # reset batch size to original value
          X_subset = X_subset.batch(og_batch_size)
  
      return X_subset
  
imports: import warnings
  import numpy
  import pandas
  from typing import Union, Tuple
  from cleanlab.typing import DatasetLike, LabelLike
  from cleanlab.internal.validation import labels_to_array
  from cleanlab.internal.constants import FLOATING_POINT_COMPARISON, TINY_VALUE
label_desc: Use image node_id 20 for calling a global function with example usage: extract_indices_tf(X, idx, allow_shuffle) and returns: X_subset, index_in_arr