def get_extension_context(ext_name, **kw):
    """Get the context of the specified extension.

    All extension's module must provide `context(**kw)` function.

    Args:
        ext_name (str) : Module path relative to `nnabla_ext`.
        kw (dict) : Additional keyword arguments for context function in a extension module.

    Returns:
        :class:`nnabla.Context`: The current extension context.

    Example:

        .. code-block:: python

            ctx = get_extension_context('cudnn', device_id='0', type_config='half')
            nn.set_default_context(ctx)

    """
    if ext_name == 'cuda.cudnn':
        from nnabla import logger
        logger.warn(
            'Deprecated extension name "cuda.cudnn" passed. Use "cudnn" instead.')
        ext_name = 'cudnn'
    mod = import_extension_module(ext_name)
    return mod.context(**kw)