code: def _dataset_size_upperbound(dataset: tf.data.Dataset) -> int:
      if (
          dataset.cardinality()
          != tf.data.experimental.UNKNOWN_CARDINALITY
      ):
          return dataset.cardinality()
      return tf.cast(
          dataset.batch(1000).reduce(0, lambda x, step: x + 1000),
          tf.int64,
      )
  
imports: import logging
  from typing import Any, Iterator, Optional, Tuple, Sequence
  from acme import specs
  from acme import types
  from flax import jax_utils
  import jax
  import jax.numpy
  import numpy
  import rlds
  import tensorflow
  import tensorflow_datasets
label_desc: Use image node_id 3 for calling a global function with example usage: _dataset_size_upperbound(dataset) and returns: tf, dataset