code: def random_shard_dataset(dataset_size, shard_size, seed=None):
      """Returns a dataset transformation function that randomly shards a
      dataset.
      """
      num_shards = utils.ceildiv(dataset_size, shard_size)
      boundaries = np.linspace(
          0,
          dataset_size,
          num=num_shards,
          endpoint=False,
          dtype=np.int64,
      )  # pylint: disable=no-member
  
      def _shard_fn(dataset):
          sharded_dataset = (
              tf.data.Dataset.from_tensor_slices(boundaries)
              .shuffle(num_shards, seed=seed)
              .flat_map(lambda lb: dataset.skip(lb).take(shard_size))
          )
          return sharded_dataset
  
      return _shard_fn
  
imports: import six
  import tensorflow
  import numpy
  from texar.tf.utils import utils
label_desc: Use image node_id 10 for calling a global function with example usage: random_shard_dataset(dataset_size, shard_size, seed) and returns: _shard_fn, sharded_dataset