code: def resolve_paths(repo, out, always_local=False):
      from urllib.parse import urlparse
  
      from dvc.dvcfile import DVC_FILE_SUFFIX
      from dvc.exceptions import DvcException
      from dvc.fs import localfs
  
      from .fs import contains_symlink_up_to
  
      abspath = os.path.abspath(out)
      dirname = os.path.dirname(abspath)
      base = os.path.basename(os.path.normpath(out))
  
      scheme = urlparse(out).scheme
  
      if (
          os.name == "nt"
          and scheme == os.path.splitdrive(abspath)[0][0].lower()
      ):
          # urlparse interprets windows drive letters as URL scheme
          scheme = ""
  
      if scheme or not localfs.isin_or_eq(abspath, repo.root_dir):
          wdir = os.getcwd()
      elif contains_symlink_up_to(dirname, repo.root_dir) or (
          os.path.isdir(abspath) and localfs.is_symlink(abspath)
      ):
          msg = (
              "Cannot add files inside symlinked directories to DVC. "
              "See {} for more information."
          ).format(
              format_link(
                  "https://dvc.org/doc/user-guide/troubleshooting#add-symlink"
              )
          )
          raise DvcException(msg)
      else:
          wdir = dirname
          out = base
  
      if always_local:
          out = base
  
      path = os.path.join(wdir, base + DVC_FILE_SUFFIX)
  
      return (path, wdir, out)
  
imports: import hashlib
  import json
  import os
  import re
  import sys
  from typing import TYPE_CHECKING, Dict, Iterable, Iterator, List, Optional, Tuple
  import colorama
label_desc: Use image node_id 17 for calling a global function with example usage: resolve_paths(repo, out, always_local) and returns: path,  wdir,  out