code: def _sample_indices(n_to_sample, n_available_tasks, with_replacement):
      """Select indices of tasks to sample.
  
      Args:
          n_to_sample (int): Number of environments to sample. May be greater
              than n_available_tasks.
          n_available_tasks (int): Number of available tasks. Task indices will
              be selected in the range [0, n_available_tasks).
          with_replacement (bool): Whether tasks can repeat when sampled.
              Note that if more tasks are sampled than exist, then tasks may
              repeat, but only after every environment has been included at
              least once in this batch. Ignored for continuous task spaces.
  
      Returns:
          np.ndarray[int]: Array of task indices.
  
      """
      if with_replacement:
          return np.random.randint(n_available_tasks, size=n_to_sample)
      else:
          blocks = []
          for _ in range(math.ceil(n_to_sample / n_available_tasks)):
              s = np.arange(n_available_tasks)
              np.random.shuffle(s)
              blocks.append(s)
          return np.concatenate(blocks)[:n_to_sample]
  
imports: import abc
  import copy
  import math
  import numpy
  from garage.envs import GymEnv, TaskNameWrapper, TaskOnehotWrapper
  from garage.sampler.env_update import ExistingEnvUpdate, NewEnvUpdate, SetTaskUpdate
label_desc: Use image node_id 1 for calling a global function with example usage: _sample_indices(n_to_sample, n_available_tasks, with_replacement) and returns: np, np