def create_calc_dh_d_shape(estimator):
    """
    Return the function that can be used in the various gradient and hessian
    calculations to calculate the derivative of the transformation with respect
    to the shape parameters.

    Parameters
    ----------
    estimator : an instance of the estimation.LogitTypeEstimator class.
        Should contain a `rows_to_alts` attribute that is a 2D scipy sparse
        matrix that maps the rows of the `design` matrix to the alternatives
        available in this dataset.

    Returns
    -------
    Callable.
        Will accept a 1D array of systematic utility values, a 1D array of
        alternative IDs, (shape parameters if there are any) and miscellaneous
        args and kwargs. Should return a 2D array whose elements contain the
        derivative of the tranformed utility vector with respect to the vector
        of shape parameters. The dimensions of the returned vector should
        be `(design.shape[0], num_alternatives)`.
    """
    num_alts = estimator.rows_to_alts.shape[1]
    pre_dc_d_eta = np.zeros((num_alts, num_alts - 1), dtype=float)

    pre_dh_dc = estimator.rows_to_alts.copy()

    pre_dh_d_eta = np.matrix(np.zeros((estimator.design.shape[0],
                                       num_alts - 1), dtype=float))

    easy_calc_dc_d_eta = partial(_calc_deriv_c_with_respect_to_eta,
                                 output_array=pre_dc_d_eta)

    # Create a function that will take in the pre-formed matrix, replace its
    # data in-place with the new data, and return the correct dh_dshape on each
    # iteration of the minimizer
    calc_dh_d_eta = partial(_asym_transform_deriv_shape,
                            ref_position=estimator.shape_ref_pos,
                            dh_dc_array=pre_dh_dc,
                            fill_dc_d_eta=easy_calc_dc_d_eta,
                            output_array=pre_dh_d_eta)
    return calc_dh_d_eta