code: def punctuation(
      text: str,
      *,
      only: Optional[str | Collection[str]] = None,
  ) -> str:
      """
      Remove punctuation from ``text`` by replacing all instances of punctuation
      (or a subset thereof specified by ``only``) with whitespace.
  
      Args:
          text
          only: Remove only those punctuation marks specified here. For example,
              ``"."`` removes only periods, while ``[",", ";", ":"]`` removes commas,
              semicolons, and colons; if None, all unicode punctuation marks are removed.
  
      Returns:
          str
  
      Note:
          When ``only=None``, Python's built-in :meth:`str.translate()` is
          used to remove punctuation; otherwise, a regular expression is used.
          The former's performance can be up to an order of magnitude faster.
      """
      only = utils.to_set(only) if only is not None else None
      if only is not None:
          return re.sub(
              "[{}]+".format(re.escape("".join(only))), " ", text
          )
      else:
          return text.translate(resources.PUNCT_TRANSLATION_TABLE)
  
file_path: textacy/src/textacy/preprocessing/remove.py
imports: from __future__ import annotations
  import re
  import unicodedata
  from typing import Collection, Optional
  from ..None import utils
  from .None import resources
label_desc: Use image node_id 4 for calling a global function with example usage: punctuation(text) and returns: re, text