code: def hardlink_or_copy(src, lnk):
      def should_fallback_to_copy(exc):
          if (
              WindowsError is not None
              and isinstance(exc, WindowsError)
              and exc.winerror == 1142
          ):  # too many hardlinks
              return True
          # cross-device hardlink or too many hardlinks, or some known WSL error
          if isinstance(exc, OSError) and exc.errno in (
              errno.EXDEV,
              errno.EMLINK,
              errno.EINVAL,
              errno.EACCES,
              errno.EPERM,
          ):
              return True
          return False
  
      try:
          hardlink(src, lnk)
      except Exception as e:
          logger.debug(
              "Failed to hardlink %s to %s with error %s, will copy it",
              src,
              lnk,
              repr(e),
          )
          if should_fallback_to_copy(e):
              copy2(src, lnk, follow_symlinks=False)
          else:
              raise
  
imports: import codecs
  import errno
  import logging
  import os
  import random
  import shutil
  import six
  import stat
  import sys
  import library.python.func
  import library.python.strings
  import library.python.windows
label_desc: Use image node_id 13 for calling a global function with example usage: hardlink_or_copy(src, lnk) and returns: False, True, True