<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create_mask(N, method='all', nmissing=0):
 """ Create weight mask according to method. :param N: Dimension of square weight matrix. :param method: Method to use (default: 'all'). - none: no missing entries (only diagonal is set to 0 for dwMDS) - first: only randomly delete measurements to first point (zeros in first row/column of matrix) - all: randomly delete measurements in whole matrix :param nmissing: Number of deleted measurements, used by methods 'first' and 'all' :return: Binary weight mask. :rtype: numpy.ndarray """


    weights = np.ones((N, N))
    weights[range(N), range(N)] = 0

    if method == 'none':
        return weights

    # create indices object to choose from
    elif method == 'all':
        all_indices = np.triu_indices(N, 1)
    elif method == 'first':
        all_indices = [np.zeros(N - 1).astype(np.int),
                       np.arange(1, N).astype(np.int)]
    ntotal = len(all_indices[0])
    # randomly choose from indices and set to 0
    choice = np.random.choice(ntotal, nmissing, replace=False)
    chosen = [all_indices[0][choice], all_indices[1][choice]]
    weights[chosen] = 0
    weights[chosen[1], chosen[0]] = 0
    return weights