@gen.coroutine
  def _ResolveContactIds(self, contact_dicts):
    # Get identity objects for all contacts for which no user_id is given.
    identity_keys = [DBKey(contact_dict['identity'], None)
                     for contact_dict in contact_dicts if 'user_id' not in contact_dict]

    identities = yield gen.Task(Identity.BatchQuery, self._client, identity_keys, None, must_exist=False)

    # Get user objects for all contacts with a user_id given, or if identity is already bound.
    user_keys = []
    ident_iter = iter(identities)
    for contact_dict in contact_dicts:
      if 'user_id' in contact_dict:
        user_keys.append(DBKey(contact_dict['user_id'], None))
      else:
        identity = next(ident_iter)
        if identity is not None and identity.user_id is not None:
          user_keys.append(DBKey(identity.user_id, None))

    users = yield gen.Task(User.BatchQuery, self._client, user_keys, None, must_exist=False)

    # Construct result tuples; if a user does not exist, allocate a user_id and webapp_dev_id.
    results = []
    ident_iter = iter(identities)
    user_iter = iter(users)
    for contact_dict in contact_dicts:
      if 'user_id' not in contact_dict:
        identity = next(ident_iter)
        if identity is None or identity.user_id is None:
          # User doesn't yet exist, so allocate new user and web device ids.
          user_id, webapp_dev_id = yield User.AllocateUserAndWebDeviceIds(self._client)
          results.append((False, user_id, webapp_dev_id))
          continue

      user = next(user_iter)
      if user is None:
        assert 'user_id' in contact_dict, contact_dict
        raise InvalidRequestError('A user with id %d cannot be found.' % contact_dict['user_id'])

      # User already exists.
      results.append((True, user.user_id, user.webapp_dev_id))

    raise gen.Return(results)
Examines each contact in "contact_dicts" (in the CONTACT_METADATA format). Returns a
dataset/ETHPy150Open viewfinderco/viewfinder/backend/op/viewfinder_op.py/ViewfinderOperation._ResolveContactIds