code: def _base64_encode(decoded: bytes | str) -> str:
      # base64 encode both takes and returns bytes, we want to work with strings.
      # If 'decoded' isn't bytes already, assume it's utf-8
      decoded_as_bytes = _ensure_bytes(decoded)
      # TODO: urlsafe_b64encode only accepts bytes input, not bytes | None.
      # Perhaps we can change _ensure_bytes change return type from bytes | None to bytes
      encoded = codecs.decode(base64.urlsafe_b64encode(decoded_as_bytes), "ascii")  # type: ignore
      # remove padding '=' chars that cause trouble
      return str(encoded.rstrip("="))
  
imports: from __future__ import annotations
  import logging
  import base64
  import calendar
  import codecs
  import datetime
  import hashlib
  import hmac
  import json
  import time
  import zlib
  from typing import TYPE_CHECKING, Any
  from ..core.types import ID
  from ..settings import settings
  from .warnings import warn
label_desc: Use image node_id 11 for calling a global function with example usage: _base64_encode(decoded) and returns: str