human
Complete the below
def attention_1d_v0(source, target, attention_size, output_size, num_heads, mask=None, transform_source=True, transform_target=True, transform_output=True, name=None):

    ''''multi-headed attention.
    TODO(noam): this could probably be extended to 2d.
    Args:
    source: a Tensor of shape [batch, source_length, source_depth]
    target: a Tensor of shape [batch, target_length, target_depth]
    attention_size: an integer
    output_size: an integer
    num_heads: an integer divisor of attention_size
    mask: a float32 Tensor of shape [batch, target_length, source_length]
    1.0 means can-see.
0.0 means can\'t-see.
    Any dimension can be 1 (supports broadcasting).
    transform_source: a boolean
    transform_target: a boolean
    transform_output: a boolean
    name: an optional string
    Returns:
    a Tensor of shape [batch, length, output_size]'
    '''

Can you provide a the Python program you requested?
assistant
#Here is the Python program you requested.
    with tf.variable_scope(name, default_name='attention', values=[target]):
        source_length = tf.shape(source)[1]
        target_length = tf.shape(target)[1]
        batch = tf.shape(source)[0]
        def _maybe_transform(t, size, should_transform, name):
            if should_transform:
                return conv1d(t, size, 1, name=name)
            else:
                assert (t.get_shape()[(-1)] == size)
                return t
        source_attention = _maybe_transform(source, attention_size, transform_source, 'source_attention')
        target_attention = _maybe_transform(target, attention_size, transform_target, 'target_attention')
        assert ((attention_size % num_heads) == 0)
        size_per_head = (attention_size // num_heads)
        source_attention = tf.reshape(source_attention, [batch, source_length, num_heads, size_per_head])
        target_attention = tf.reshape(target_attention, [batch, target_length, num_heads, size_per_head])
        source_attention = tf.transpose(source_attention, [0, 2, 1, 3])
        target_attention = tf.transpose(target_attention, [0, 2, 1, 3])
        attention = tf.matmul(target_attention, source_attention, transpose_b=True)
        attention *= (size_per_head ** (-0.5))
        if (mask is not None):
            mask = tf.expand_dims(mask, 1)
            mask = ((1.0 - mask) * (-1000000000.0))
            attention += mask
        attention = tf.nn.softmax(attention)
        if (not tf.get_variable_scope().reuse):
            image = tf.reshape(attention, [batch, num_heads, target_length, source_length])
            image = tf.transpose(image, [0, 2, 3, 1])
            image = tf.pow(image, 0.2)
            extra_heads = ((- num_heads) % 3)
            image = tf.pad(image, [[0, 0], [0, 0], [0, 0], [0, ((- num_heads) % 3)]])
            image = tf.reshape(image, [batch, target_length, source_length, 3, ((num_heads + extra_heads) // 3)])
            image = tf.reduce_max(image, 4)
            tf.summary.image('local_attention', image, max_outputs=1)
...