def nvmlDeviceGetTopologyNearestGpus(device, level):
    r"""
    /**
     * Retrieve the set of GPUs that are nearest to a given device at a specific interconnectivity level
     * For all products.
     * Supported on Linux only.
     *
     * @param device                               The identifier of the first device
     * @param level                                The \ref nvmlGpuTopologyLevel_t level to search for other GPUs
     * @param count                                When zero, is set to the number of matching GPUs such that \a deviceArray
     *                                             can be malloc'd.  When non-zero, \a deviceArray will be filled with \a count
     *                                             number of device handles.
     * @param deviceArray                          An array of device handles for GPUs found at \a level
     *
     * @return
     *         - \ref NVML_SUCCESS                 if \a deviceArray or \a count (if initially zero) has been set
     *         - \ref NVML_ERROR_INVALID_ARGUMENT  if \a device, \a level, or \a count is invalid, or \a deviceArray is NULL with a non-zero \a count
     *         - \ref NVML_ERROR_NOT_SUPPORTED     if the device or OS does not support this feature
     *         - \ref NVML_ERROR_UNKNOWN           an error has occurred in underlying topology discovery
     */
    nvmlReturn_t DECLDIR nvmlDeviceGetTopologyNearestGpus
    """
    c_count = c_uint(0)
    fn = _nvmlGetFunctionPointer("nvmlDeviceGetTopologyNearestGpus")

    # First call will get the size
    ret = fn(device, level, byref(c_count), None)

    if ret != NVML_SUCCESS:
        raise NVMLError(ret)

    # call again with a buffer
    device_array = c_nvmlDevice_t * c_count.value
    c_devices = device_array()
    ret = fn(device, level, byref(c_count), c_devices)
    _nvmlCheckReturn(ret)
    return list(c_devices[0:c_count.value])