def so3_hat(v):
    """
    Map a point in R^N to the tangent space at the identity, i.e.
    to the Lie Algebra. Inverse of so3_vee.

    :param v: Lie algebra in vector rep of shape (..., 3
    :return: Lie algebar in matrix rep of shape (..., 3, 3)
    """
    assert v.shape[-1] == 3

    e_x = v.new_tensor([[0.0, 0.0, 0.0], [0.0, 0.0, -1.0], [0.0, 1.0, 0.0]])

    e_y = v.new_tensor([[0.0, 0.0, 1.0], [0.0, 0.0, 0.0], [-1.0, 0.0, 0.0]])

    e_z = v.new_tensor([[0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0]])

    x = (
        e_x * v[..., 0, None, None]
        + e_y * v[..., 1, None, None]
        + e_z * v[..., 2, None, None]
    )
    return x