def _replace_custom_layer_name(spec, oldname, newname):
    """

    Substitutes ``newname`` for ``oldname`` in the ``className`` field of custom layers. If there are no custom layers, or no
    layers with ``className`` = ``oldname``, then the spec is unchanged.

    Parameters
    ----------
    spec: mlmodel spec

    oldname: str
        The custom layer ``className`` to be replaced.

    newname: str
        The new ``className`` value to replace ``oldname``.

    Returns
    -------
    An mlmodel spec.

    """
    layers = _get_custom_layers(spec)
    for layer in layers:
        if layer.custom.className == oldname:
            layer.custom.className = newname


    Substitutes ``newname`` for ``oldname`` in the ``className`` field of custom layers. If there are no custom layers, or no
    layers with ``className`` = ``oldname``, then the spec is unchanged.

    Parameters
    ----------
    spec: mlmodel spec

    oldname: str
        The custom layer ``className`` to be replaced.

    newname: str
        The new ``className`` value to replace ``oldname``.

    Returns
    -------
    An mlmodel spec.

    
coremltools/models/utils.py