code: def test_speed(case):
      repeats = int(
          1e5 / len(case.target)
      )  # Approx. a hundred thousand targets
  
      if torch.is_tensor(case.target):
          targets = case.target.repeat(
              repeats, *(1 for _ in range(case.target.ndim - 1))
          )
      elif isinstance(case.target, np.ndarray):
          targets = np.repeat(case.target, repeats)
      else:
          targets = case.target * repeats
  
      start = time.perf_counter()
      formatter = get_target_formatter(targets)
      end = time.perf_counter()
  
      assert (end - start) / len(targets) < 5e-4  # 0.1ms per target
  
      start = time.perf_counter()
      _ = [formatter(t) for t in targets]
      end = time.perf_counter()
  
      assert (end - start) / len(targets) < 5e-4
  
file_path: lightning-flash/tests/core/data/utilities/test_classification.py
imports: import time
  from collections import namedtuple
  import numpy
  import pytest
  import torch
  from flash.core.data.utilities.classification import CommaDelimitedMultiLabelTargetFormatter, MultiBinaryTargetFormatter, MultiLabelTargetFormatter, MultiNumericTargetFormatter, MultiSoftTargetFormatter, SingleBinaryTargetFormatter, SingleLabelTargetFormatter, SingleNumericTargetFormatter, SpaceDelimitedTargetFormatter, get_target_formatter
  from flash.core.utilities.imports import _TOPIC_CORE_AVAILABLE
label_desc: Use image node_id 2 for calling a global function with example usage: test_speed(case) without return types