nodes: 0, module; 1, function_definition; 2, function_name:suggestion_list; 3, parameters; 4, block; 5, typed_parameter; 6, typed_parameter; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, identifier:input_; 13, type; 14, identifier:options; 15, type; 16, comment:"""Get list with suggestions for a given input.
  
      Given an invalid input string and list of valid options, returns a filtered list
      of valid options sorted based on their similarity with the input.
      """; 17, assignment; 18, assignment; 19, identifier:option; 20, identifier:options; 21, block; 22, call; 23, identifier:str; 24, generic_type; 25, identifier:options_by_distance; 26, dictionary; 27, identifier:input_threshold; 28, binary_operator:len(input_) // 2; 29, expression_statement; 30, expression_statement; 31, if_statement; 32, identifier:sorted; 33, argument_list; 34, identifier:Collection; 35, type_parameter; 36, call; 37, integer:2; 38, assignment; 39, assignment; 40, comparison_operator:distance <= threshold; 41, block; 42, identifier:options_by_distance; 43, keyword_argument; 44, type; 45, identifier:len; 46, argument_list; 47, identifier:distance; 48, call; 49, identifier:threshold; 50, call; 51, identifier:distance; 52, identifier:threshold; 53, expression_statement; 54, identifier:key; 55, attribute; 56, identifier:str; 57, identifier:input_; 58, identifier:lexical_distance; 59, argument_list; 60, identifier:max; 61, argument_list; 62, assignment; 63, identifier:options_by_distance; 64, identifier:get; 65, identifier:input_; 66, identifier:option; 67, identifier:input_threshold; 68, binary_operator:len(option) // 2; 69, integer:1; 70, subscript; 71, identifier:distance; 72, call; 73, integer:2; 74, identifier:options_by_distance; 75, identifier:option; 76, identifier:len; 77, argument_list; 78, identifier:option
code: def suggestion_list(input_: str, options: Collection[str]):
      """Get list with suggestions for a given input.
  
      Given an invalid input string and list of valid options, returns a filtered list
      of valid options sorted based on their similarity with the input.
      """
      options_by_distance = {}
      input_threshold = len(input_) // 2
  
      for option in options:
          distance = lexical_distance(input_, option)
          threshold = max(input_threshold, len(option) // 2, 1)
          if distance <= threshold:
              options_by_distance[option] = distance
  
      return sorted(options_by_distance, key=options_by_distance.get)