code: def _copy_if_necessary(self, local_path, overwrite):
          
          local_path = abspath(local_path)
          if not exists(local_path):
              raise MissingLocalFile(local_path)
          elif not self.copy_local_files_to_cache:
              return local_path
          else:
              cached_path = self.cached_path(local_path)
              if exists(cached_path) and not overwrite:
                  return cached_path
              copy2(local_path, cached_path)
              return cached_path
docs: Return cached path to local file, copying it to the cache if necessary.