human
Complete this python program:
def conv_internal(conv_fn, inputs, filters, kernel_size, **kwargs):
assistant
#Here is the Python code you requested.

    """Conditional conv_fn making kernel 1d or 2d depending on inputs shape.
    """
    static_shape = inputs.get_shape()
    if ((not static_shape) or (len(static_shape) != 4)):
        raise ValueError(('Inputs    to    conv    must    have    statically    known    rank    4.    Shape:    ' + str(static_shape)))
    if (('padding' in kwargs) and (kwargs['padding'] == 'LEFT')):
        dilation_rate = (1, 1)
        if ('dilation_rate' in kwargs):
            dilation_rate = kwargs['dilation_rate']
        assert (((kernel_size[0] % 2) == 1) and ((kernel_size[1] % 2) == 1))
        height_padding = ((2 * (kernel_size[0] // 2)) * dilation_rate[0])
        cond_padding = tf.cond(tf.equal(tf.shape(inputs)[2], 1), (lambda : tf.constant(0)), (lambda : tf.constant(((2 * (kernel_size[1] // 2)) * dilation_rate[1]))))
        width_padding = (0 if (static_shape[2] == 1) else cond_padding)
        padding = [[0, 0], [height_padding, 0], [width_padding, 0], [0, 0]]
        inputs = tf.pad(inputs, padding)
        inputs.set_shape([static_shape[0], None, None, static_shape[3]])
        kwargs['padding'] = 'VALID'
    def conv2d_kernel(kernel_size_arg, name_suffix):
        'Call    conv2d    but    add    suffix    to    name.'
        if ('name' in kwargs):
            original_name = kwargs['name']
            name = ((kwargs.pop('name') + '_') + name_suffix)
        else:
            original_name = None
            name = ('conv_' + name_suffix)
        original_force2d = None
        if ('force2d' in kwargs):
            original_force2d = kwargs.pop('force2d')
        result = conv_fn(inputs, filters, kernel_size_arg, name=name, **kwargs)
        if (original_name is not None):
            kwargs['name'] = original_name
        if (original_force2d is not None):
            kwargs['force2d'] = original_force2d
        return result
    return conv2d_kernel(kernel_size, 'single')