code: def _update_worktree_out(
      repo: "Repo",
      out: "Output",
      local_index: Union["DataIndex", "DataIndexView"],
      remote_indexes: Dict[str, Tuple["Remote", "DataIndex"]],
  ):
      from dvc_data.index import build
  
      remote_name = out.remote or out.meta.remote
      if not remote_name:
          logger.warning(
              "Could not update '%s', it was never pushed to a remote",
              out,
          )
          return
  
      if remote_name in remote_indexes:
          remote, remote_index = remote_indexes[remote_name]
      else:
          remote = repo.cloud.get_remote(remote_name, "update")
          if not remote.worktree:
              raise StageUpdateError(out.stage.relpath)
          logger.debug("indexing latest worktree for '%s'", remote.path)
          remote_index = build(remote.path, remote.fs)
          remote_indexes[remote_name] = remote, remote_index
      _workspace, key = out.index_key
      if key not in remote_index:
          logger.warning(
              "Could not update '%s', it does not exist in the remote",
              out,
          )
          return
  
      entry = remote_index[key]
      if (
          entry.meta
          and entry.meta.isdir
          and not any(
              subkey != key
              and subentry.meta
              and not subentry.meta.isdir
              for subkey, subentry in remote_index.iteritems(key)
          )
      ):
          logger.warning(
              "Could not update '%s', directory is empty in the remote",
              out,
          )
          return
  
      _fetch_out_changes(out, local_index, remote_index, remote)
      _update_out_meta(
          repo,
          out,
          local_index,
          remote_index,
          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 7 for calling a global function with example usage: _update_worktree_out(repo, out, local_index, remote_indexes) without return types