Speaking as neither;lawyer,doctor or dentist...[Animal, vegetable or mineral?]
Far better if such assessments were made at conviction and the sentence served in their home country. Though the extreme of refusing entry to all who's home nation did not allow for this is to be avoided too.
There will be cases where the person convicted and deemed dangerous came here to escape from their home country with valid reasons (as assessed at point of entry) and it makes more sense to attempt rehabilitation with the carrot of release and the stick of life imprisonment.
The point that any of this is done at public expense is lost in the fact that ALL of this is done that way.
[I had a lawyer in the back of my cab once...turns out that 'Habeas Corpus' to him meant, "Take me home, James.

]