<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _copy_if_necessary(self, local_path, overwrite):
 """ Return cached path to local file, copying it to the cache if necessary. """

        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