code: def create_task_sampler(
      sampler_config: dict,
      task_dict: dict,
      task_to_num_examples_dict: dict,
      rng=None,
  ) -> BaseMultiTaskSampler:
      """Perform basic config validation, then instantiate and return the specified multitask sampler.
  
      Args:
          sampler_config (Dict): map containing sample config options.
          task_dict (Dict[str, Task]): map from task name to task instance.
          task_to_num_examples_dict (Dict[str, int]): map task names to counts of training examples.
          rng (Union[int, np.random.RandomState, None]): random state to seed sampler.
  
      Raises:
          KeyError if invalid sampler type argument is provided in the sampler config.
  
      Returns:
          Subclass of BaseMultiTaskSampler.
  
      """
      sampler_type = sampler_config["sampler_type"]
      if sampler_type == "UniformMultiTaskSampler":
          assert len(sampler_config) == 1
          return UniformMultiTaskSampler(task_dict=task_dict, rng=rng)
      elif sampler_type == "ProportionalMultiTaskSampler":
          assert len(sampler_config) == 1
          return ProportionalMultiTaskSampler(
              task_dict=task_dict,
              rng=rng,
              task_to_num_examples_dict=task_to_num_examples_dict,
          )
      elif sampler_type == "SpecifiedProbMultiTaskSampler":
          assert len(sampler_config) == 2
          return SpecifiedProbMultiTaskSampler(
              task_dict=task_dict,
              rng=rng,
              task_to_unweighted_probs=sampler_config[
                  "task_to_unweighted_probs"
              ],
          )
      elif sampler_type == "TemperatureMultiTaskSampler":
          assert len(sampler_config) == 3
          return TemperatureMultiTaskSampler(
              task_dict=task_dict,
              rng=rng,
              task_to_num_examples_dict=task_to_num_examples_dict,
              temperature=sampler_config["temperature"],
              examples_cap=sampler_config["examples_cap"],
          )
      elif sampler_type == "TimeDependentProbMultiTaskSampler":
          assert len(sampler_config) == 3
          return TimeDependentProbMultiTaskSampler(
              task_dict=task_dict,
              rng=rng,
              task_to_unnormalized_prob_funcs_dict=sampler_config[
                  "task_to_unnormalized_prob_funcs_dict"
              ],
              max_steps=sampler_config["max_steps"],
          )
      else:
          raise KeyError(sampler_type)
  
imports: import abc
  import numexpr
  import numpy
  from typing import Union, Optional, Dict
label_desc: Use image node_id 1 for calling a global function with example usage: create_task_sampler(sampler_config, task_dict, task_to_num_examples_dict, rng) and returns: UniformMultiTaskSampler, ProportionalMultiTaskSampler, SpecifiedProbMultiTaskSampler, TemperatureMultiTaskSampler, TimeDependentProbMultiTaskSampler