code: def _get_user(self, user: Union[User, str]) -> User:
          
          user_id: str = getattr(user, 'user_id', user)
          discovery_room = self._global_rooms.get(
              make_room_alias(self.network_id, DISCOVERY_DEFAULT_ROOM),
          )
          if discovery_room and user_id in discovery_room._members:
              duser = discovery_room._members[user_id]
              # if handed a User instance with displayname set, update the discovery room cache
              if getattr(user, 'displayname', None):
                  assert isinstance(user, User)
                  duser.displayname = user.displayname
              user = duser
          elif not isinstance(user, User):
              user = self._client.get_user(user_id)
          return user
docs: Creates an User from an user_id, if none, or fetch a cached User
  
          As all users are supposed to be in discovery room, its members dict is used for caching