def writeweight(alloc, content_w, g_w, g_a):
    """Return write weighting `ww`

    Parameters
    ----------
    alloc : `[batch_size, mem_size]`.
    content_w : `[batch_size, mem_size]`.
    g_w : `[batch_size, 1]`.
    g_a : `[batch_size, 1]`.

    Returns
    -------
    ww : `[batch_size, mem_size]`.
    """
    return g_w * (g_a * alloc + (1 - g_a) * content_w)