<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_penalty_model(specification):
 """Factory function for penaltymodel_maxgap. Args: specification (penaltymodel.Specification):
 The specification for the desired penalty model. Returns: :class:`penaltymodel.PenaltyModel`: Penalty model with the given specification. Raises: :class:`penaltymodel.ImpossiblePenaltyModel`: If the penalty cannot be built. Parameters: priority (int):
 -100 """


    # check that the feasible_configurations are spin
    feasible_configurations = specification.feasible_configurations
    if specification.vartype is dimod.BINARY:
        feasible_configurations = {tuple(2 * v - 1 for v in config): en
                                   for config, en in feasible_configurations.items()}

    # convert ising_quadratic_ranges to the form we expect
    ising_quadratic_ranges = specification.ising_quadratic_ranges
    quadratic_ranges = {(u, v): ising_quadratic_ranges[u][v] for u, v in specification.graph.edges}

    bqm, gap = generate(specification.graph,
                        feasible_configurations,
                        specification.decision_variables,
                        specification.ising_linear_ranges,
                        quadratic_ranges,
                        specification.min_classical_gap,
                        None)  # unspecified smt solver

    try:
        ground = max(feasible_configurations.values())
    except ValueError:
        ground = 0.0  # if empty

    return pm.PenaltyModel.from_specification(specification, bqm, gap, ground)