The tensor virial theorem for subsystems