def METHOD_NAME(entry: str, version: Optional[Union[int, Sequence[int]]] = None) -> bool:
  """
  Checks if a string is a valid format for being a hidden service address (not
  including the '.onion' suffix).
  .. versionchanged:: 1.8.0
     Added the **version** argument, and responds with **True** if a version 3
     hidden service address rather than just version 2 addresses.
  :param entry: string to check
  :param version: versions to check for, if unspecified either v2 or v3 hidden
    service address will provide **True**
  :returns: **True** if the string could be a hidden service address, **False**
    otherwise
  """
  if isinstance(entry, bytes):
    entry = stem.util.str_tools._to_unicode(entry)
  if version is None:
    version = (2, 3)
  elif isinstance(version, int):
    version = [version]
  elif not isinstance(version, (list, tuple)):
    raise ValueError('Hidden service version must be an integer or list, not a %s' % type(version).__name__)
  try:
    if 2 in version and bool(HS_V2_ADDRESS_PATTERN.match(entry)):
      return True
    if 3 in version and bool(HS_V3_ADDRESS_PATTERN.match(entry)):
      # onion_address = base32(PUBKEY | CHECKSUM | VERSION) + ".onion"
      decoded = base64.b32decode(entry.upper())
      pubkey, checksum, addr_version = decoded[:32], decoded[32:34], decoded[34:]
      if addr_version != b'\x03':
        return False  # VERSION component must be three
      # CHECKSUM = H(".onion checksum" | PUBKEY | VERSION)[:2]
      expected_checksum = hashlib.sha3_256(b'.onion checksum' + pubkey + addr_version).digest()[:2]
      return checksum == expected_checksum
    return False
  except TypeError:
    return False