def convolved(iterable, kernel_size=<NUM_LIT:1>, stride=<NUM_LIT:1>, padding=<NUM_LIT:0>, default_value=None):
<EOL>if not hasattr(iterable, '<STR_LIT>'):<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>".format(<EOL>iterable))<EOL><DEDENT>if stride < <NUM_LIT:1>:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>".format(<EOL>stride))<EOL><DEDENT>if not (padding in ['<STR_LIT>', '<STR_LIT>'] or type(padding) in [int]):<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>")<EOL><DEDENT>if not isinstance(padding, str):<EOL><INDENT>if padding < <NUM_LIT:0>:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>".format(<EOL>padding))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if padding == '<STR_LIT>':<EOL><INDENT>padding = kernel_size // <NUM_LIT:2><EOL><DEDENT>elif padding == '<STR_LIT>':<EOL><INDENT>padding = <NUM_LIT:0><EOL><DEDENT><DEDENT>if not type(iterable) == list:<EOL><INDENT>iterable = list(iterable)<EOL><DEDENT>if padding > <NUM_LIT:0>:<EOL><INDENT>pad = [default_value] * padding<EOL>iterable = pad + list(iterable) + pad<EOL><DEDENT>remainder = (kernel_size - len(iterable)) % stride<EOL>extra_pad = [default_value] * remainder<EOL>iterable = iterable + extra_pad<EOL>i = <NUM_LIT:0><EOL>while True:<EOL><INDENT>if i > len(iterable) - kernel_size:<EOL><INDENT>break<EOL><DEDENT>yield iterable[i:i + kernel_size]<EOL>i += stride<EOL><DEDENT>
Iterable to get every convolution window per loop iteration.

    For example:
        `convolved([1, 2, 3, 4], kernel_size=2)`
            will produce the following result:
            `[[1, 2], [2, 3], [3, 4]]`.
        `convolved([1, 2, 3], kernel_size=2, stride=1, padding=2, default_value=42)`
            will produce the following result:
            `[[42, 42], [42, 1], [1, 2], [2, 3], [3, 42], [42, 42]]`

    Arguments:
        iterable: An object to iterate on. It should support slice indexing if `padding == 0`.
        kernel_size: The number of items yielded at every iteration.
        stride: The step size between each iteration.
        padding: Padding must be an integer or a string with value `SAME` or `VALID`. If it is an integer, it represents
            how many values we add with `default_value` on the borders. If it is a string, `SAME` means that the
            convolution will add some padding according to the kernel_size, and `VALID` is the same as
            specifying `padding=0`.
        default_value: Default fill value for padding and values outside iteration range.

    For more information, refer to: 
    - https://github.com/guillaume-chevalier/python-conv-lib/blob/master/conv/conv.py
    - https://github.com/guillaume-chevalier/python-conv-lib
    - MIT License, Copyright (c) 2018 Guillaume Chevalier