nodes: 0, module; 1, function_definition; 2, function_name:selector; 3, parameters; 4, block; 5, identifier:keys; 6, identifier:dictionary; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, if_statement; 12, if_statement; 13, comment:# Select as dict.; 14, return_statement; 15, identifier:copy; 16, False; 17, identifier:output_type; 18, string; 19, identifier:allow_miss; 20, False; 21, comment:"""
      Selects the chosen dictionary keys from the given dictionary.
  
      :param keys:
          Keys to select.
      :type keys: list, tuple, set
  
      :param dictionary:
          A dictionary.
      :type dictionary: dict
  
      :param copy:
          If True the output contains deep-copies of the values.
      :type copy: bool
  
      :param output_type:
          Type of function output:
  
              + 'list': a list with all values listed in `keys`.
              + 'dict': a dictionary with any outputs listed in `keys`.
              + 'values': if output length == 1 return a single value otherwise a
                          tuple with all values listed in `keys`.
  
          :type output_type: str, optional
  
      :param allow_miss:
          If True it does not raise when some key is missing in the dictionary.
      :type allow_miss: bool
  
      :return:
          A dictionary with chosen dictionary keys if present in the sequence of
          dictionaries. These are combined with :func:`combine_dicts`.
      :rtype: dict
  
      Example::
  
          >>> from functools import partial
          >>> fun = partial(selector, ['a', 'b'])
          >>> sorted(fun({'a': 1, 'b': 2, 'c': 3}).items())
          [('a', 1), ('b', 2)]
      """; 22, not_operator; 23, comment:# noinspection PyUnusedLocal; 24, block; 25, else_clause; 26, comparison_operator:output_type == 'list'; 27, comment:# Select as list.; 28, block; 29, elif_clause; 30, call; 31, string_content:dict; 32, identifier:allow_miss; 33, function_definition; 34, block; 35, identifier:output_type; 36, string; 37, expression_statement; 38, return_statement; 39, comparison_operator:output_type == 'values'; 40, block; 41, identifier:bypass; 42, argument_list; 43, function_name:check; 44, parameters; 45, block; 46, function_definition; 47, string_content:list; 48, assignment; 49, conditional_expression:_copy.deepcopy(res) if copy else res; 50, identifier:output_type; 51, string; 52, return_statement; 53, dictionary_comprehension; 54, keyword_argument; 55, identifier:key; 56, return_statement; 57, function_name:check; 58, parameters; 59, block; 60, identifier:res; 61, list_comprehension; 62, call; 63, identifier:copy; 64, identifier:res; 65, string_content:values; 66, call; 67, pair; 68, for_in_clause; 69, if_clause; 70, identifier:copy; 71, identifier:copy; 72, True; 73, identifier:key; 74, return_statement; 75, subscript; 76, for_in_clause; 77, if_clause; 78, attribute; 79, argument_list; 80, identifier:bypass; 81, argument_list; 82, identifier:k; 83, subscript; 84, identifier:k; 85, identifier:keys; 86, call; 87, comparison_operator:key in dictionary; 88, identifier:dictionary; 89, identifier:k; 90, identifier:k; 91, identifier:keys; 92, call; 93, identifier:_copy; 94, identifier:deepcopy; 95, identifier:res; 96, list_splat; 97, keyword_argument; 98, identifier:dictionary; 99, identifier:k; 100, identifier:check; 101, argument_list; 102, identifier:key; 103, identifier:dictionary; 104, identifier:check; 105, argument_list; 106, list_comprehension; 107, identifier:copy; 108, identifier:copy; 109, identifier:k; 110, identifier:k; 111, subscript; 112, for_in_clause; 113, if_clause; 114, identifier:dictionary; 115, identifier:k; 116, identifier:k; 117, identifier:keys; 118, call; 119, identifier:check; 120, argument_list; 121, identifier:k
code: def selector(keys, dictionary, copy=False, output_type='dict',
               allow_miss=False):
      """
      Selects the chosen dictionary keys from the given dictionary.
  
      :param keys:
          Keys to select.
      :type keys: list, tuple, set
  
      :param dictionary:
          A dictionary.
      :type dictionary: dict
  
      :param copy:
          If True the output contains deep-copies of the values.
      :type copy: bool
  
      :param output_type:
          Type of function output:
  
              + 'list': a list with all values listed in `keys`.
              + 'dict': a dictionary with any outputs listed in `keys`.
              + 'values': if output length == 1 return a single value otherwise a
                          tuple with all values listed in `keys`.
  
          :type output_type: str, optional
  
      :param allow_miss:
          If True it does not raise when some key is missing in the dictionary.
      :type allow_miss: bool
  
      :return:
          A dictionary with chosen dictionary keys if present in the sequence of
          dictionaries. These are combined with :func:`combine_dicts`.
      :rtype: dict
  
      Example::
  
          >>> from functools import partial
          >>> fun = partial(selector, ['a', 'b'])
          >>> sorted(fun({'a': 1, 'b': 2, 'c': 3}).items())
          [('a', 1), ('b', 2)]
      """
  
      if not allow_miss:
          # noinspection PyUnusedLocal
          def check(key):
              return True
      else:
          def check(key):
              return key in dictionary
  
      if output_type == 'list':  # Select as list.
          res = [dictionary[k] for k in keys if check(k)]
          return _copy.deepcopy(res) if copy else res
      elif output_type == 'values':
          return bypass(*[dictionary[k] for k in keys if check(k)], copy=copy)
  
      # Select as dict.
      return bypass({k: dictionary[k] for k in keys if check(k)}, copy=copy)