code: def test_get_training_data_iters(end_of_prepending_tag):
      if end_of_prepending_tag:
          source_text_prefix_token = end_of_prepending_tag
          expected_mean = 0.9208152692746332
          expected_std = 0.0698611911724421
      else:
          source_text_prefix_token = ""
          expected_mean = 1.0
          expected_std = 0.0
  
      train_line_count = 100
      train_line_count_empty = 0
      train_max_length = 30
      dev_line_count = 20
      dev_max_length = 30
      test_line_count = 20
      test_line_count_empty = 0
      test_max_length = 30
      batch_size = 5
      num_source_factors = num_target_factors = 1
      with tmp_digits_dataset(
          "tmp_corpus",
          train_line_count,
          train_line_count_empty,
          train_max_length - C.SPACE_FOR_XOS,
          dev_line_count,
          dev_max_length - C.SPACE_FOR_XOS,
          test_line_count,
          test_line_count_empty,
          test_max_length - C.SPACE_FOR_XOS,
          source_text_prefix_token=source_text_prefix_token,
      ) as data:
          # tmp common vocab
          vcb = vocab.build_from_paths(
              [data["train_source"], data["train_target"]]
          )
  
          (
              train_iter,
              val_iter,
              config_data,
              data_info,
          ) = data_io.get_training_data_iters(
              sources=[data["train_source"]],
              targets=[data["train_target"]],
              validation_sources=[data["dev_source"]],
              validation_targets=[data["dev_target"]],
              source_vocabs=[vcb],
              target_vocabs=[vcb],
              source_vocab_paths=[None],
              target_vocab_paths=[None],
              shared_vocab=True,
              batch_size=batch_size,
              batch_type=C.BATCH_TYPE_SENTENCE,
              max_seq_len_source=train_max_length,
              max_seq_len_target=train_max_length,
              bucketing=True,
              bucket_width=10,
              end_of_prepending_tag=end_of_prepending_tag,
          )
          assert isinstance(train_iter, data_io.ParallelSampleIter)
          assert isinstance(val_iter, data_io.ParallelSampleIter)
          assert isinstance(config_data, data_io.DataConfig)
          assert data_info.sources == [data["train_source"]]
          assert data_info.targets == [data["train_target"]]
          assert data_info.source_vocabs == [None]
          assert data_info.target_vocabs == [None]
          assert (
              config_data.data_statistics.max_observed_len_source
              == train_max_length
          )
          assert (
              config_data.data_statistics.max_observed_len_target
              == train_max_length - 1
              if end_of_prepending_tag
              else train_max_length
          )  # The EOP tag occupies one in the source but not target.
          assert np.isclose(
              config_data.data_statistics.length_ratio_mean,
              expected_mean,
          )
          assert np.isclose(
              config_data.data_statistics.length_ratio_std, expected_std
          )
  
          assert train_iter.batch_size == batch_size
          assert val_iter.batch_size == batch_size
  
          # test some batches
          bos_id = vcb[C.BOS_SYMBOL]
          eos_id = vcb[C.EOS_SYMBOL]
          expected_first_target_symbols = torch.full(
              (batch_size, 1), bos_id, dtype=torch.int32
          )
          for epoch in range(2):
              while train_iter.iter_next():
                  batch = train_iter.next()
                  assert isinstance(batch, data_io.Batch)
                  source = batch.source
                  target = batch.target
                  label = batch.labels[
                      C.TARGET_LABEL_NAME
                  ]  # TODO: still 2-shape: (batch, length)
                  length_ratio_label = batch.labels[
                      C.LENRATIO_LABEL_NAME
                  ]
                  assert (
                      source.shape[0]
                      == target.shape[0]
                      == label.shape[0]
                      == batch_size
                  )
                  assert (
                      source.shape[2]
                      == target.shape[2]
                      == num_source_factors
                      == num_target_factors
                  )
                  # target first symbol should be BOS
                  # each source sequence contains one EOS symbol
                  assert torch.sum(source == eos_id) == batch_size
                  assert torch.equal(
                      target[:, 0], expected_first_target_symbols
                  )
                  # label first symbol should be 2nd target symbol
                  assert torch.equal(label[:, 0], target[:, 1, 0])
                  # each label sequence contains one EOS symbol
                  assert torch.sum(label == eos_id) == batch_size
              train_iter.reset()
  
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 23 for calling a global function with example usage: test_get_training_data_iters(end_of_prepending_tag) without return types