code: def prepare_resampler(source_area, destination_area, resampler=None, **resample_kwargs):
      
      if resampler is None:
          LOG.info("Using default KDTree resampler")
          resampler = 'kd_tree'
  
      if isinstance(resampler, BaseResampler):
          raise ValueError("Trying to create a resampler when one already "
                           "exists.")
      elif isinstance(resampler, str):
          resampler_class = RESAMPLERS[resampler]
      else:
          resampler_class = resampler
  
      key = (resampler_class,
             source_area, destination_area,
             hash_dict(resample_kwargs))
      try:
          resampler_instance = resamplers_cache[key]
      except KeyError:
          resampler_instance = resampler_class(source_area, destination_area)
          resamplers_cache[key] = resampler_instance
      return key, resampler_instance
docs: Instantiate and return a resampler.