def print_msg(message, line_break=True):
    """Print the message to absl logging or stdout."""
    message = str(message)
    if is_interactive_logging_enabled():
        message = message + "\n" if line_break else message
        try:
            sys.stdout.write(message)
        except UnicodeEncodeError:
            # If the encoding differs from UTF-8, `sys.stdout.write` may fail.
            # To address this, replace special unicode characters in the
            # message, and then encode and decode using the target encoding.
            message = _replace_special_unicode_character(message)
            message_bytes = message.encode(sys.stdout.encoding, errors="ignore")
            message = message_bytes.decode(sys.stdout.encoding)
            sys.stdout.write(message)
        sys.stdout.flush()
    else:
        logging.info(message)
Print the message to absl logging or stdout.
keras/src/utils/io_utils.py