code: def select_random_subset(
      random_seed: int,
      num_total_samples: int,
      num_samples_to_select: Optional[int] = None,
      percentage_of_samples_to_select: Optional[float] = None,
  ) -> List[int]:
      """
      Randomly selects a subset of samples.
  
      Only one of `num_samples_to_select` and `percentage_of_samples_to_select` should be provided.
      Selects all the samples if neither of them are provided.
  
      Args:
          random_seed: An integer seed to use for random selection.
          num_total_samples: Total number of samples in the set that is being subsampled.
          num_samples_to_select: An optional integer indicating the number of samples to select.
          percentage_of_samples_to_select: An optional float in the range (0,100] indicating the percentage of
              samples to select.
  
      Returns:
          A list of (integer) indices of the selected samples.
  
       Raises:
          ValueError if both `num_samples_to_select` and `percentage_of_samples_to_select` are provided.
      """
      if (
          num_samples_to_select is not None
          and percentage_of_samples_to_select is not None
      ):
          raise ValueError(
              "Only one of `num_samples_to_select` and `percentage_of_samples_to_select` should be provided."
          )
  
      if (
          num_samples_to_select is not None
          and num_samples_to_select < 1
      ):
          raise ValueError(
              "`num_samples_to_select` should be greater than 0."
          )
  
      if percentage_of_samples_to_select is not None:
          if not 0 < percentage_of_samples_to_select <= 100:
              raise ValueError(
                  "`percentage_of_samples_to_select` should be in the range (0, 100]."
              )
  
      sample_indices = list(range(num_total_samples))
      rng = random.Random(random_seed)
      rng.shuffle(sample_indices)
  
      if (
          num_samples_to_select is None
          and percentage_of_samples_to_select is None
      ):
          return sample_indices
  
      if num_samples_to_select is None:
          num_samples_to_select = int(
              percentage_of_samples_to_select * num_total_samples / 100
          )
  
      num_samples_to_select = min(
          num_samples_to_select, num_total_samples
      )
      return sample_indices[:num_samples_to_select]
  
file_path: ml-cvnets/data/datasets/utils/common.py
imports: import collections
  import os
  import random
  from typing import Any, List, Optional, Tuple, Union
label_desc: Use image node_id 4 for calling a global function with example usage: select_random_subset(random_seed, num_total_samples, num_samples_to_select, percentage_of_samples_to_select) and returns: sample_indices, sample_indices