def prepare_head(tensor):
    (bsz, seq_len, _) = tensor.size()
    tensor = tensor.view(batch_size, tensor.size(1), n_heads, dim_per_head)
    tensor = tensor.transpose(1, 2).contiguous().view((batch_size * n_heads), seq_len, dim_per_head)
    return tensor
def prepare_head(tensor):
    (bsz, seq_len, _) = tensor.size()
    tensor = tensor.view(batch_size, tensor.size(1), n_heads, dim_per_head)
    tensor = tensor.transpose(1, 2).contiguous().view((batch_size * n_heads), seq_len, dim_per_head)
    return tensor