Imported from https://github.com/sid7954/beam-joint-attention
