I have had the same question myself in French. There are a range of opinions on this. My personal preference is for the hyper-local accent always, i.e., try to imitate the people who are around you, whatever they may speak. The fact is, though, that this will get you into trouble sometimes.
I think the safest bet (although it is not what I would always do myself) is: whatever country you go to, adopt the most standard pronunciation of that country. Certainly in the US it will make you more understandable if you pronounce word-final r, for instance. That's true even if you land in one of the (diminishing) areas of the country where it's not pronounced, because everyone is used to hearing the standard dialect in broadcast media.
It is interesting, because there are a lot of folk theories about linguistics and dialect. In the US, for instance, the general folk theory is that standard American (like you hear in most movies, as you would hear in, say, the rich suburban areas of most northern cities) is "English without an accent." Interestingly, most people who speak "with an accent" i.e. not with the standard accent (e.g. especially the south, also the rural midwest), talk about the language in this way too, even though it is linguistically nonsense.
In particular, I imagine that if you adopt a regional accent in America, some folks would think you were making fun of them for trying to speak "with an accent" or that you were pretentious, trying to be something you were not (which is a little silly given that anyone learning a foreign language is trying to pronounce it as well as possible). This is a very unfortunate attitude, but you should at least be aware that it exists before trying to pick up a regional accent.
I'd specifically caution against trying to imitate African-American Vernacular English, because there is a lot of nasty and ignorant stigma surrounding that dialect, and people may mistake you for someone who is racist and making fun of the dialect (also, because the dialect is so stigmatized, many of its native speakers don't use it for official business, so it would seem very out of place for a foreigner to attempt that).