Authors, artists and poets from 40 countries are defying security threats to take part in a literary festival in Pakistan.