code: def _render_href(x, format):
      """uses regex to detect a common URL pattern and converts to href tag in format."""
      if isinstance(x, str):
          if format == "html":
              href = '<a href="{0}" target="_blank">{0}</a>'
          elif format == "latex":
              href = r"\href{{{0}}}{{{0}}}"
          else:
              raise ValueError(
                  "``hyperlinks`` format can only be 'html' or 'latex'"
              )
          pat = r"((http|ftp)s?:\/\/|www.)[\w/\-?=%.:@]+\.[\w/\-&?=%.,':;~!@#$*()\[\]]+"
          return re.sub(pat, lambda m: href.format(m.group(0)), x)
      return x
  
imports: from __future__ import annotations
  from collections import defaultdict
  from collections.abc import Sequence
  from functools import partial
  import re
  from typing import TYPE_CHECKING, Any, Callable, DefaultDict, Optional, TypedDict, Union
  from uuid import uuid4
  import numpy
  from pandas._config import get_option
  from pandas._libs import lib
  from pandas.compat._optional import import_optional_dependency
  from pandas.core.dtypes.common import is_complex, is_float, is_integer
  from pandas.core.dtypes.generic import ABCSeries
  from pandas import DataFrame, Index, IndexSlice, MultiIndex, Series, isna
  from pandas.api.types import is_list_like
  import pandas.core.common
  from markupsafe import escape
label_desc: Use image node_id 9 for calling a global function with example usage: _render_href(x, format) and returns: x, re