<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generate_random_schema(valid):
 """ Generate a random plain schema, and a sample generation function. :param valid: Generate valid samples? :type valid: bool :returns: schema, sample-generator :rtype: *, generator """

    schema_type = choice(['literal', 'type'])

    if schema_type == 'literal':
        type, gen = generate_random_type(valid)
        value = next(gen)
        return value, (value if valid else None for i in itertools.count())
    elif schema_type == 'type':
        return generate_random_type(valid)
    else:
        raise AssertionError('!')