code: def is_dataset(ds):
    
    import tensorflow as tf
    from tensorflow_datasets.core.utils import py_utils
    dataset_types = [tf.data.Dataset]
    v1_ds = py_utils.rgetattr(tf, "compat.v1.data.Dataset", None)
    v2_ds = py_utils.rgetattr(tf, "compat.v2.data.Dataset", None)
    if v1_ds is not None:
      dataset_types.append(v1_ds)
    if v2_ds is not None:
      dataset_types.append(v2_ds)
    return isinstance(ds, tuple(dataset_types))
docs: Whether ds is a Dataset. Compatible across TF versions.