code: def _get_random_bucketed_data(
      buckets: List[Tuple[int, int]],
      min_count: int,
      max_count: int,
      bucket_counts: Optional[List[Optional[int]]] = None,
      include_prepended_source_length: bool = False,
  ) -> Tuple[
      List[torch.Tensor], List[torch.Tensor], List[torch.Tensor]
  ]:
      """
      Get random bucket data.
  
      :param buckets: The list of buckets.
      :param min_count: The minimum number of samples that will be sampled if no exact count is given.
      :param max_count: The maximum number of samples that will be sampled if no exact count is given.
      :param bucket_counts: For each bucket an optional exact example count can be given. If it is not given it will be
                           sampled.
      :param include_prepended_source_length: Generate random length of prepended source tokens (otherwise return None).
      :return: The random source, target and optional prepended_source_length tensors.
      """
      if bucket_counts is None:
          bucket_counts = [None for _ in buckets]
      bucket_counts = [
          random.randint(min_count, max_count)
          if given_count is None
          else given_count
          for given_count in bucket_counts
      ]
      source = [
          torch.randint(0, 10, (count, random.randint(1, bucket[0]), 1))
          for count, bucket in zip(bucket_counts, buckets)
      ]
      target = [
          torch.randint(0, 10, (count, random.randint(2, bucket[1]), 1))
          for count, bucket in zip(bucket_counts, buckets)
      ]
      prepended_source_length = (
          [torch.randint(0, 10, (count, 1)) for count in bucket_counts]
          if include_prepended_source_length
          else None
      )
      return source, target, prepended_source_length
  
imports: import os
  import random
  from tempfile import TemporaryDirectory
  from typing import Optional, List, Tuple
  import numpy
  import pytest
  import torch
  from sockeye import constants
  from sockeye import data_io
  from sockeye import utils
  from sockeye import vocab
  from sockeye.test_utils import tmp_digits_dataset
  from sockeye.utils import SockeyeError, get_tokens, seed_rngs
label_desc: Use image node_id 14 for calling a global function with example usage: _get_random_bucketed_data(buckets, min_count, max_count, bucket_counts, include_prepended_source_length) and returns: source,  target,  prepended_source_length