code: def make_global_and_nonlocal_decls(code_instrs):
      
      globals_ = sorted(set(
          i.arg for i in code_instrs if isinstance(i, instrs.STORE_GLOBAL)
      ))
      nonlocals = sorted(set(
          i.arg for i in code_instrs
          if isinstance(i, instrs.STORE_DEREF) and i.vartype == 'free'
      ))
  
      out = []
      if globals_:
          out.append(ast.Global(names=globals_))
      if nonlocals:
          out.append(ast.Nonlocal(names=nonlocals))
      return out
docs: Find all STORE_GLOBAL and STORE_DEREF instructions in `instrs` and convert
      them into a canonical list of `ast.Global` and `ast.Nonlocal` declarations.