def METHOD_NAME(array, copy, nan, posinf, neginf, highlevel, behavior):
    behavior = behavior_of(array, behavior=behavior)
    broadcasting_ids = {}
    broadcasting = []
    layout = ak.operations.to_layout(array)
    broadcasting.append(layout)
    nan_layout = ak.operations.to_layout(nan, allow_other=True)
    if isinstance(nan_layout, ak.contents.Content):
        broadcasting_ids[id(nan)] = len(broadcasting)
        broadcasting.append(nan_layout)
    posinf_layout = ak.operations.to_layout(posinf, allow_other=True)
    if isinstance(posinf_layout, ak.contents.Content):
        broadcasting_ids[id(posinf)] = len(broadcasting)
        broadcasting.append(posinf_layout)
    neginf_layout = ak.operations.to_layout(neginf, allow_other=True)
    if isinstance(neginf_layout, ak.contents.Content):
        broadcasting_ids[id(neginf)] = len(broadcasting)
        broadcasting.append(neginf_layout)
    if len(broadcasting) == 1:
        def action(layout, backend, **kwargs):
            if isinstance(layout, ak.contents.NumpyArray):
                return ak.contents.NumpyArray(
                    backend.nplike.nan_to_num(
                        layout.data,
                        nan=nan,
                        posinf=posinf,
                        neginf=neginf,
                    )
                )
            else:
                return None
        out = ak._do.recursively_apply(layout, action, behavior)
    else:
        def action(inputs, backend, **kwargs):
            if all(isinstance(x, ak.contents.NumpyArray) for x in inputs):
                tmp_layout = inputs[0].data
                if id(nan) in broadcasting_ids:
                    tmp_nan = inputs[broadcasting_ids[id(nan)]].to_backend_array()
                else:
                    tmp_nan = nan
                if id(posinf) in broadcasting_ids:
                    tmp_posinf = inputs[broadcasting_ids[id(posinf)]].to_backend_array()
                else:
                    tmp_posinf = posinf
                if id(neginf) in broadcasting_ids:
                    tmp_neginf = inputs[broadcasting_ids[id(neginf)]].to_backend_array()
                else:
                    tmp_neginf = neginf
                return (
                    ak.contents.NumpyArray(
                        backend.nplike.nan_to_num(
                            tmp_layout,
                            nan=tmp_nan,
                            posinf=tmp_posinf,
                            neginf=tmp_neginf,
                        )
                    ),
                )
            else:
                return None
        out = ak._broadcasting.broadcast_and_apply(broadcasting, action, behavior)
        assert isinstance(out, tuple) and len(out) == 1
        out = out[0]
    return wrap_layout(out, behavior, highlevel)