code: def _threshold_mask(metric: torch.Tensor, sparse_threshold: float):
      return (metric >= sparse_threshold).float().to(metric.device)
  
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 9 for calling a global function with example usage: _threshold_mask(metric, sparse_threshold) and returns: unknown