<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def inventory(self, all=False, ssid=None):
 """ Returns a node inventory. If an API key is specified, only the nodes provisioned by this key will be returned. :return: { inventory } """

        if all or self.api_key is None:
            if ssid is not None:
                return self._ssid_inventory(self.full_inventory, ssid)
            else:
                return self.full_inventory
        else:
            if ssid is not None:
                return self._ssid_inventory(self.self_inventory, ssid)
            else:
                return self.self_inventory