def update_infer_params(
        model_configs,
        beam_size=None,
        maximum_labels_length=None,
        length_penalty=None):
    """ Resets inference-specific parameters.

    Args:
        model_configs: A dictionary of all model configurations.
        beam_size: The beam width, if provided, pass it to `model_configs`'s
           "model_params".
        maximum_labels_length: The maximum length of sequence that model generates,
          if provided, pass it to `model_configs`'s "model_params".
        length_penalty: The length penalty, if provided, pass it to
          `model_configs`'s "model_params".

    Returns: An updated dict.
    """
    if beam_size is not None:
        model_configs["model_params"]["inference.beam_size"] = beam_size
    if maximum_labels_length is not None:
        model_configs["model_params"]["inference.maximum_labels_length"] = maximum_labels_length
    if length_penalty is not None:
        model_configs["model_params"]["inference.length_penalty"] = length_penalty
    return model_configs