code: def _try_proceed_with_timeout(
      fn: Callable, timeout: int = _DOCTEST_DOWNLOAD_TIMEOUT
  ) -> bool:
      """Check if a certain function is taking too long to execute.
  
      Function will only be executed if running inside a doctest context. Currently does not support Windows.
  
      Args:
          fn: function to check
          timeout: timeout for function
  
      Returns:
          Bool indicating if the function finished within the specified timeout
  
      """
      # source: https://stackoverflow.com/a/14924210/4521646
      proc = multiprocessing.Process(target=fn)
      logging.debug(f"try to run `{fn.__name__}` for {timeout}s...")
      proc.start()
      # Wait for N seconds or until process finishes
      proc.join(timeout)
      # If thread is still active
      if not proc.is_alive():
          return True
  
      logging.warning(f"running `{fn.__name__}`... let's kill it...")
      # Terminate - may not work if process is stuck for good
      proc.terminate()
      # OR Kill - will work for sure, no chance for process to finish nicely however
      # p.kill()
      proc.join()
      return False
  
imports: import logging
  import multiprocessing
  import os
  from functools import partial
  from time import perf_counter
  from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple, no_type_check
  from unittest.mock import Mock
  import torch
  from torch import Tensor
  from torchmetrics.metric import Metric
  from torchmetrics.utilities.data import select_topk, to_onehot
  from torchmetrics.utilities.enums import DataType
label_desc: Use image node_id 19 for calling a global function with example usage: _try_proceed_with_timeout(fn, timeout) and returns: False, True