<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_inventory(self, keys=None):
 """ Create an Ansible inventory based on python dicts and lists. The returned value is a dict in which every key represents a group and every value is a list of entries for that group. Args: keys (list of str):
 Path to the keys that will be used to create groups. Returns: dict: dict based Ansible inventory """

        inventory = defaultdict(list)
        keys = keys or ['vm-type', 'groups', 'vm-provider']
        vms = self.prefix.get_vms().values()

        for vm in vms:
            entry = self._generate_entry(vm)
            vm_spec = vm.spec
            for key in keys:
                value = self.get_key(key, vm_spec)
                if value is None:
                    continue
                if isinstance(value, list):
                    for sub_value in value:
                        inventory['{}={}'.format(key, sub_value)].append(entry)
                else:
                    inventory['{}={}'.format(key, value)].append(entry)

            # Adding a special case for the group key.
            # Most of the times the user wants that the host
            # will be a part of the group "group", and not a part of
            # "group=something"
            for group in vm_spec.get('groups', []):
                inventory[group].append(entry)

        return inventory