code: def _grouped_backends(cls, options, backend):
          "Group options by backend and filter out output group appropriately"
  
          if options is None:
              return [(backend or Store.current_backend, options)]
          dfltdict = defaultdict(dict)
          for spec, groups in options.items():
              if 'output' not in groups.keys() or len(groups['output'])==0:
                  dfltdict[backend or Store.current_backend][spec.strip()] = groups
              elif set(groups['output'].keys()) - set(['backend']):
                  dfltdict[groups['output']['backend']][spec.strip()] = groups
              elif ['backend'] == list(groups['output'].keys()):
                  filtered = {k:v for k,v in groups.items() if k != 'output'}
                  dfltdict[groups['output']['backend']][spec.strip()] = filtered
              else:
                  raise Exception('The output options group must have the backend keyword')
  
          return [(bk, bk_opts) for (bk, bk_opts) in dfltdict.items()f _grouped_backends(cls, options, backend):
          "Group options by backend and filter out output group appropriately"
  
          if options is None:
              return [(backend or Store.current_backend, options)]
          dfltdict = defaultdict(dict)
          for spec, groups in options.items():
              if 'output' not in groups.keys() or len(groups['output'])==0:
                  dfltdict[backend or Store.current_backend][spec.strip()] = groups
              elif set(groups['output'].keys()) - set(['backend']):
                  dfltdict[groups['output']['backend']][spec.strip()] = groups
              elif ['backend'] == list(groups['output'].keys()):
                  filtered = {k:v for k,v in groups.items() if k != 'output'}
                  dfltdict[groups['output']['backend']][spec.strip()] = filtered
              else:
                  raise Exception('The output options group must have the backend keyword')
  
          return [(bk, bk_opts) for (bk, bk_opts) in dfltdict.items()]
docs: Group options by backend and filter out output group appropriately