text: import base64
  import binascii
  from typing import Any
  
  
  def validate_base64(value: Any) -> bytes:
      if isinstance(value, bytes):
          return value
      if isinstance(value, str):
          try:
              return base64.b64decode(value)
          except binascii.Error as exc:
              raise ValueError("Failed to parse base64 string")
      else:
          raise TypeError("Invalid type for base64 field; must be string or bytes")
  