The ultimate answer to this is that the frame_id of the imu must be the frame in which it is mounted.
The followup is, of course, the problem and that is that IMUs have much more variety than say laser scanners. An example would be if a laser scanner did not scan in a regular angular increment, but instead varied the angle between beams. However, almost every laser scanner fits the LaserScan message. Every IMU fits the IMU message, but there are a few cases that are not made clear:
1) Orientation not provided. This is just some gyros and accelerometers, no fusion yet. Setting msg.orientation_covariance[0] = -1, will tell other software to not use the orientation.
2) Orientation integrated with drift from where the IMU started. This IMU doesn't even guarantee a known reference position. It's possible for the ROS software to startup after the IMU calibrated, so the reference position is completely unknown due to drift. These IMUs are uncommon, but essentially only integrate the gyros for orientation and do not use a gravity reference. This a purely inertial output and the best you could do in empty space. The issue using this type in ROS is that the message itself does not let you know that the orientation is relative rather than absolute.
This is the case that ROS handles today and is a form of dead reckoning/Odometry. Turtlebot and robot_pose_ekf all use the IMU only for the change in orientation, not the absolute orientation. This is ultimately safest, as any orientation can be fused in this manner. Unfortunately you lose the ability to remove drift, so more complicated approaches exist.
3) Orientation integrated with drift but pitch and roll referenced to gravity. This IMU is the most common. It uses the gyros to determine angle from startup, but references pitch and roll to gravity. The assumption here is that you will have to re-reference before you travel far enough for the Earth's gravity vector to not aligned down in your Cartesian frame. In this case, 'yaw' or 'heading' still drifts since the gravity component for yaw is 0, so you cannot determine absolute heading with only those 6 measurements.
This is shown in the following image. Initially (x, y, z), the cartesian coordinate frame is tangential to the Earth's surface. As the IMU travels very, very far (x', y', z'), the gravity reference drifts and no longer aligns with the z-axis. Where this becomes a problem depends on the specific application.
4) Orientation reference to gravity and magnetic north. This is another very common sensor and typically adds two or more magnetometers to reference the heading to magnetic north. The problem using this method is that the frame must still be tangential to the Earth's surface and that the magnetic field has 'declination' that varies based on where the IMU is located on the Earth's surface. The message has no indicator of this at all.
5) Orientation fused ... (more)