Move `BuildAttributesMap()` to a common place
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this [failed invocation](https://github.com/tensorflow/tensorflow/pull/67168/checks?check_run_id=24733806830) of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.
Move `BuildAttributesMap()` to a common place

So that both CPU and GPU code can reuse the same implementation. At the moment each uses its own version that are identical.
