import inspect


def _instantiate_schema(schema, **kwargs):
    """
    Returns an object of the given marshmallow schema.

    :param schema: The marshmallow schema class with which the request should
        be validated
    :param kwargs: The keyword arguments that will be provided to the
        marshmallow schema's constructor
    :return: The object of the marshmallow schema
    """
    if not inspect.isclass(schema):
        raise ValueError('You need to pass Marshmallow class instead '
                         'of schema instance')
    return schema(**kwargs)