code: def target_spaces_filter(
      target_spaces: _PRUNING_TARGET_SPACES,
      condition: Callable[[PruningTargetSpace], bool],
  ) -> Tuple[_PRUNING_TARGET_SPACES, _PRUNING_TARGET_SPACES]:
      filtered_target_spaces = defaultdict(dict)
      remained_target_spaces = defaultdict(dict)
  
      for module_name, ts in target_spaces.items():
          for target_name, target_space in ts.items():
              if (
                  target_space.type is TargetType.PARAMETER
                  and target_space.target is None
              ) or not condition(target_space):
                  remained_target_spaces[module_name][
                      target_name
                  ] = target_space
              else:
                  filtered_target_spaces[module_name][
                      target_name
                  ] = target_space
  
      return filtered_target_spaces, remained_target_spaces
  
imports: from __future__ import annotations
  from collections import defaultdict
  from functools import reduce
  import heapq
  from typing import Callable, Dict, List, Tuple
  import numpy
  import torch
  from .calculate_metrics import _METRICS
  from ...base.compressor import _PRUNING_TARGET_SPACES
  from ...base.target_space import PruningTargetSpace, TargetType
label_desc: Use image node_id 2 for calling a global function with example usage: target_spaces_filter(target_spaces, condition) and returns: filtered_target_spaces,  remained_target_spaces