def _get_context(argspec, kwargs):
    """Prepare a context for the serialization.

    :param argspec: The argspec of the serialization function.
    :param kwargs: Dict with context
    :return: Keywords arguments that function can accept.
    """
    if argspec.keywords is not None:
        return kwargs
    return dict((arg, kwargs[arg]) for arg in argspec.args if arg in kwargs)