code: def test_select_specified_number_of_samples_per_category():
      (
          labels,
          num_samples_per_class,
          min_num_samples_per_class,
          num_classes,
          _,
      ) = _test_data()
      random_seed = 0
      for num_samples_to_select_per_class in range(
          min_num_samples_per_class + 1
      ):
          if num_samples_to_select_per_class > 0:
              selected_sample_indices = common.select_samples_by_category(
                  sample_category_labels=labels,
                  random_seed=random_seed,
                  num_samples_per_category=num_samples_to_select_per_class,
              )
              assert (
                  len(selected_sample_indices)
                  == num_samples_to_select_per_class * num_classes
              )
  
              for c in num_samples_per_class:
                  num_selected_samples_in_class_c = len(
                      [
                          ind
                          for ind in selected_sample_indices
                          if labels[ind] == c
                      ]
                  )
                  assert (
                      num_selected_samples_in_class_c
                      == num_samples_to_select_per_class
                  )
          else:
              with pytest.raises(ValueError):
                  common.select_samples_by_category(
                      sample_category_labels=labels,
                      random_seed=random_seed,
                      num_samples_per_category=num_samples_to_select_per_class,
                  )
  
file_path: ml-cvnets/tests/data/datasets/utils/test_common.py
imports: import numpy
  import pytest
  from data.datasets.utils import common
label_desc: Use image node_id 2 for calling a global function with example usage: test_select_specified_number_of_samples_per_category() without return types