code: def test_sampling_mode(
      tasks: List[str],
      config_file: str,
      batch_size: int,
      n_samples: int,
      n_repeats: int,
      truncated_rep: bool,
  ) -> None:
      batch_size = 2
  
      sampler_list = []
      n_data_samples = {}
      total_expected_samples = 0
      for task_name in tasks:
          sampler_dict = {
              "task_name": task_name,
              "train_batch_size0": batch_size,
              "sampler_config": {
                  "name": "batch_sampler",
                  "bs": {
                      "crop_size_width": 512,
                      "crop_size_height": 512,
                  },
              },
          }
          total_expected_samples += n_samples
          n_data_samples[task_name] = n_samples
          sampler_list.append(sampler_dict)
  
      n_repeats_ = n_repeats
      if truncated_rep:
          # when truncated repetition is enabled, then total samples in the dataset
          # are the same as before repetition
          n_repeats_ = 1
  
      expected_seq_out = [
          t
          for t in tasks
          for i in range(n_samples)
          for j in range(n_repeats_)
      ]
      expected_interleave_order = [
          t
          for _ in range(n_samples // batch_size)
          for _ in range(n_repeats_)
          for t in tasks
          for _ in range(batch_size)
      ]
  
      for mode in ["sequential", "interleave"]:
          opts = get_config(config_file=config_file)
  
          setattr(
              opts, "sampler.chain_sampler", copy.deepcopy(sampler_list)
          )
  
          setattr(opts, "sampler.chain_sampler_mode", mode)
          setattr(
              opts,
              "sampler.truncated_repeat_aug_sampler",
              truncated_rep,
          )
          setattr(opts, "sampler.num_repeats", n_repeats)
  
          sampler = build_sampler(
              opts, n_data_samples=n_data_samples, is_training=True
          )
  
          sampler_order = [
              b[len(b) - 1] for batch in sampler for b in batch
          ]
          if mode == "sequential":
              np.testing.assert_equal(expected_seq_out, sampler_order)
          else:
              np.testing.assert_equal(
                  expected_interleave_order, sampler_order
              )
  
file_path: ml-cvnets/tests/data/samplers/test_chain_sampler.py
imports: import copy
  import random
  from typing import List
  import numpy
  import pytest
  from data.sampler import build_sampler
  from tests.configs import get_config
label_desc: Use image node_id 2 for calling a global function with example usage: test_sampling_mode(tasks, config_file, batch_size, n_samples, n_repeats, truncated_rep) without return types