code: def test_chain_sampler(
      tasks: List[str],
      config_file: str,
      batch_size: int,
      num_repeats: int,
      trunc_ra_sampler: bool,
  ) -> None:
      opts = get_config(config_file=config_file)
  
      sampler_list = []
      n_data_samples = {}
      samples = 1000
      total_expected_samples = 0
      for task_name in tasks:
          # we randomly decide number of repeats so that number of repeats for each task is different
          # Expected result is deterministic, despite this randomness.
          reps = random.choice([1, num_repeats])
  
          sampler_dict = {
              "task_name": task_name,
              "train_batch_size0": batch_size,
              "sampler_config": {
                  "name": "variable_batch_sampler",
                  "truncated_repeat_aug_sampler": trunc_ra_sampler,
                  "num_repeats": reps,
                  "vbs": {
                      "crop_size_width": 512,
                      "crop_size_height": 512,
                      "max_n_scales": 10,
                      "min_crop_size_width": 256,
                      "max_crop_size_width": 768,
                      "min_crop_size_height": 256,
                      "max_crop_size_height": 768,
                      "check_scale": 16,
                  },
              },
          }
          total_expected_samples += samples * (
              1 if trunc_ra_sampler else reps
          )
          n_data_samples[task_name] = samples
          sampler_list.append(sampler_dict)
  
      setattr(opts, "sampler.chain_sampler", sampler_list)
  
      sampler = build_sampler(
          opts, n_data_samples=n_data_samples, is_training=True
      )
  
      np.testing.assert_equal(len(sampler), total_expected_samples)
  
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 1 for calling a global function with example usage: test_chain_sampler(tasks, config_file, batch_size, num_repeats, trunc_ra_sampler) without return types