code: def filter_invalid_beams(beam: List[List[str]]) -> List[List[str]]:
      return list(filter(lambda pred: is_valid_tree(pred), beam))
  
imports: from typing import List, Optional, Tuple
label_desc: Use image node_id 2 for calling a global function with example usage: filter_invalid_beams(beam) and returns: list