<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_recipe_instances(self, badges=None, excluded=None):
 """ Returns all recipe instances or just those for the given badges. """

        if badges:
            if not isinstance(badges, (list, tuple)):
                badges = [badges]

        if excluded:
            if not isinstance(excluded, (list, tuple)):
                excluded = [excluded]
            badges = list(set(self.registered) - set(excluded))

        if badges:
            valid, invalid = self.get_recipe_instances_for_badges(badges=badges)
            return valid

        return self.recipes.values()