This took me a bit to debug just now, due to an error in the ndb docs, so I figured I'd file this to hopefully prevent that for others in the future. The docs currently say that the context global_cache_timeout_policy and (I think?) global_cache_policy callables get passed a google.cloud.ndb.key.Key, but that's not true. Evidently they actually get passed a google.cloud.datastore.key.Key instead.
Interestingly cache_policy gets passed a google.cloud.ndb.key.Key, which is documented correctly, but only adds to the confusion.
Hope this helps!