code: def worktree_view_by_remotes(
      index: "Index",
      targets: Optional["TargetType"] = None,
      push: bool = False,
      **kwargs: Any,
  ) -> Iterable[Tuple[Optional[str], "IndexView"]]:
      from dvc.repo.index import IndexView
  
      def outs_filter(view: "IndexView", remote: Optional[str]):
          def _filter(out: "Output") -> bool:
              if out.remote != remote:
                  return False
              if view._outs_filter:
                  return view._outs_filter(out)
              return True
  
          return _filter
  
      view = worktree_view(index, targets=targets, push=push, **kwargs)
      remotes = {out.remote for out in view.outs}
  
      if len(remotes) <= 1:
          yield first(remotes), view
          return
  
      for remote in remotes:
          yield remote, IndexView(
              index, view._stage_infos, outs_filter(view, remote)
          )
  
file_path: dvc/dvc/repo/worktree.py
imports: from functools import partial
  from typing import TYPE_CHECKING, Any, Dict, Iterable, Optional, Tuple, Union
  from funcy import first
  from dvc.log import logger
  from dvc.stage.exceptions import StageUpdateError
label_desc: Use image node_id 2 for calling a global function with example usage: worktree_view_by_remotes(index, targets, push) and returns: _filter, True, False, view