def execute_operator(operator_uri, ctx=None, **kwargs):
    """Executes the operator with the given name.

    Args:
        operator_uri: the URI of the operator
        ctx (None): a dictionary of parameters defining the execution context.
            The supported keys are:

            -   ``dataset``: a :class:`fiftyone.core.dataset.Dataset` or the
                name of a dataset to process. This is required unless a
                ``view`` is provided
            -   ``view`` (None): an optional
                :class:`fiftyone.core.view.DatasetView` to process
            -   ``selected`` ([]): an optional list of selected sample IDs
            -   ``selected_labels`` ([]): an optional list of selected labels
                in the format returned by
                :attr:`fiftyone.core.session.Session.selected_labels`
            -   ``current_sample`` (None): an optional ID of the current sample
                being processed
            -   ``params``: a dictionary of parameters for the operator.
                Consult the operator's documentation for details
            -   ``request_delegation`` (False): whether to request delegated
                execution, if supported by the operator
            -   ``delegation_target`` (None): an optional orchestrator on which
                to schedule the operation, if it is delegated
        **kwargs: you can optionally provide any of the supported ``ctx`` keys
            as keyword arguments rather than including them in ``ctx``

    Returns:
        an :class:`ExecutionResult`, or an ``asyncio.Task`` if you run this
        method in a notebook context

    Raises:
        ExecutionError: if an error occurred while immediately executing an
            operation or scheduling a delegated operation
    """
    request_params = _parse_ctx(ctx=ctx, **kwargs)
    coroutine = execute_or_delegate_operator(
        operator_uri, request_params, exhaust=True
    )

    try:
        # Some contexts like notebooks already have event loops running, so we
        # must use the existing loop
        loop = asyncio.get_running_loop()
    except:
        loop = None

    if loop is not None:
        # @todo is it possible to await result here?
        # Sadly, run_until_complete() is not allowed in Jupyter notebooks
        # https://nocomplexity.com/documents/jupyterlab/tip-asyncio.html
        result = loop.create_task(coroutine)
    else:
        result = asyncio.run(coroutine)
        result.raise_exceptions()

    return result
Executes the operator with the given name.

    Args:
        operator_uri: the URI of the operator
        ctx (None): a dictionary of parameters defining the execution context.
            The supported keys are:

            -   ``dataset``: a :class:`fiftyone.core.dataset.Dataset` or the
                name of a dataset to process. This is required unless a
                ``view`` is provided
            -   ``view`` (None): an optional
                :class:`fiftyone.core.view.DatasetView` to process
            -   ``selected`` ([]): an optional list of selected sample IDs
            -   ``selected_labels`` ([]): an optional list of selected labels
                in the format returned by
                :attr:`fiftyone.core.session.Session.selected_labels`
            -   ``current_sample`` (None): an optional ID of the current sample
                being processed
            -   ``params``: a dictionary of parameters for the operator.
                Consult the operator's documentation for details
            -   ``request_delegation`` (False): whether to request delegated
                execution, if supported by the operator
            -   ``delegation_target`` (None): an optional orchestrator on which
                to schedule the operation, if it is delegated
        **kwargs: you can optionally provide any of the supported ``ctx`` keys
            as keyword arguments rather than including them in ``ctx``

    Returns:
        an :class:`ExecutionResult`, or an ``asyncio.Task`` if you run this
        method in a notebook context

    Raises:
        ExecutionError: if an error occurred while immediately executing an
            operation or scheduling a delegated operation
    
fiftyone/operators/executor.py