Answering my own question.I have written the python script that writes the global rotation of the bones for each frame, and i just applied the rotations to other armature (with different rest pose)and now the animation can be easily copied independent of rest pose.
pose.bone[boneIndex].matrix.decompose()[1] //global rotation of bone in Quaternion
if we apply the global rotation of one armature to another , then the rest poses of both the armatures are not necessary to be same.But if we try to apply the local (relative )rotations of the bones to other armature , then the both armatures should have same rest pose.