code: def prepare_new_layer(self, input_layer):
          
          # create memory layer
          output_layer_name = os.path.splitext(input_layer.name())[0]
          output_layer_name = unique_filename(
              prefix=('%s_minimum_needs_' % output_layer_name),
              dir='minimum_needs_calculator')
          output_layer = create_memory_layer(
              output_layer_name,
              input_layer.geometryType(),
              input_layer.crs(),
              input_layer.fields())
  
          # monkey patching input layer to make it work with
          # prepare vector layer function
          temp_layer = input_layer
          temp_layer.keywords = {
              'layer_purpose': layer_purpose_aggregation['key']}
  
          # copy features to output layer
          copy_layer(temp_layer, output_layer)
  
          # Monkey patching output layer to make it work with
          # minimum needs calculator
          output_layer.keywords['layer_purpose'] = (
              layer_purpose_aggregation['key'])
          output_layer.keywords['inasafe_fields'] = {
              displaced_field['key']: self.displaced.currentField()
          }
          if self.aggregation_name.currentField():
              output_layer.keywords['inasafe_fields'][
                  aggregation_name_field['key']] = (
                      self.aggregation_name.currentField())
  
          # remove unnecessary fields & rename inasafe fields
          clean_inasafe_fields(output_layer)
  
          return output_layer
docs: Prepare new layer for the output layer.
  
          :param input_layer: Vector layer.
          :type input_layer: QgsVectorLayer
  
          :return: New memory layer duplicated from input_layer.
          :rtype: QgsVectorLayer