Returns a TensorFluent for the transpose operation with given `permutation`.

        Args:
            permutation: The output's shape permutation.

        Returns:
            A TensorFluent wrapping the transpose operation.
341544
def transpose(self, permutation: Optional[List[int]] = None) -> 'TensorFluent':
        '''
        '''
        if permutation == []:
            return self
        t = tf.transpose(self.tensor, permutation) if permutation != [] else self.tensor
        scope = self.scope.as_list()
        batch = self.batch
        return TensorFluent(t, scope, batch=batch)
592846
def permute(self, qubits: Qubits) -> 'Channel':
        """"""
        vec = self.vec.permute(qubits)
        return Channel(vec.tensor, qubits=vec.qubits)
446279
public TernaryVector permute(TernaryVector v, 
                                 int numPermutations) {
        int[] oldPos = v.positiveDimensions();
        int[] oldNeg = v.negativeDimensions();

        // create new arrays to hold the permuted locations of the vectors's
        // positive and negative values.
        //
        // NB: we use a copy here to ensure that the function works for the 0
        // permutation (i.e. effectively a no-op);
        int[] positive = Arrays.copyOf(oldPos, oldPos.length);
        int[] negative = Arrays.copyOf(oldNeg, oldNeg.length);

        boolean isInverse = numPermutations < 0;
        
        // NB: because we use the signum and !=, this loop will work for both
        // positive and negative numbers of permutations
        int totalPermutations = Math.abs(numPermutations);

        for (int count = 1; count <= totalPermutations; ++count) {            

            // load the reordering funcion for this iteration of the permutation
            Function function = getFunction(count, v.length());

            // based on whether this is an inverse permutation, select whether
            // to use the forward or backwards mapping.
            int[] reordering = (isInverse) 
                ? function.backward : function.forward;
            
            // create a copy of the previous permuted values for positive and
            // negative.  We need this array because the permutation cannot be
            // done in place
            oldPos = Arrays.copyOf(positive, positive.length);
            oldNeg = Arrays.copyOf(negative, negative.length);
            
            // The reordering array specifies for index i the positive of i in
            // the permuted array.  Since the positive and negative indices are
            // the only non-zero indicies, we can simply create new arrays for
            // them of the same length and then set their new positions based on
            // the values in the reordering array.
            for (int i = 0; i < oldPos.length; ++i) {
                positive[i] = reordering[oldPos[i]];
            }

            for (int i = 0; i < oldNeg.length; ++i) {
                negative[i] = reordering[oldNeg[i]];
            }
        }

        return new TernaryVector(v.length(), positive, negative);
    }
1054469
def transpose(self) -> 'AnnData':
        
        if not self.isbacked: X = self._X
        else: X = self.file['X']
        if self.isview:
            raise ValueError(
                'You\'re trying to transpose a view of an `AnnData`, which is currently not implemented. '
                'Call `.copy()` before transposing.')
        layers = {k:(v.T.tocsr() if sparse.isspmatrix_csr(v) else v.T) for (k, v) in self.layers.items(copy=False)}
        if sparse.isspmatrix_csr(X):
            return AnnData(X.T.tocsr(), self._var, self._obs, self._uns,
                           self._varm.flipped(), self._obsm.flipped(),
                           filename=self.filename, layers=layers, dtype=self.X.dtype.name)
        return AnnData(X.T, self._var, self._obs, self._uns,
                       self._varm.flipped(), self._obsm.flipped(),
                       filename=self.filename, layers=layers, dtype=self.X.dtype.name)
294284
public static void permute( int[] perm , double []input , double[]output , int N ) {
        for (int k = 0; k < N; k++) {
            output[k] = input[perm[k]];
        }
    }
703706
def tan(cls, x: 'TensorFluent') -> 'TensorFluent':
        '''
        '''
        return cls._unary_op(x, tf.tan, tf.float32)
93348
def next_permutation(tab):
    
    n = len(tab)
    pivot = None                         # find pivot
    for i in range(n - 1):
        if tab[i] < tab[i + 1]:
            pivot = i
    if pivot is None:                    # tab is already the last perm.
        return False
    for i in range(pivot + 1, n):        # find the element to swap
        if tab[i] > tab[pivot]:
            swap = i
    tab[swap], tab[pivot] = tab[pivot], tab[swap]
    i = pivot + 1
    j = n - 1                            # invert suffix
    while i < j:
        tab[i], tab[j] = tab[j], tab[i]
        i += 1
        j -= 1
    return True
981850
public Matrix4f transpose(Matrix4f dest) {
        if ((properties & PROPERTY_IDENTITY) != 0)
            return dest.identity();
        return transposeGeneric(dest);
    }
1281677
def _tensors(cls, fluents: Sequence[FluentPair]) -> Iterable[tf.Tensor]:
        ''''''
        for _, fluent in fluents:
            tensor = cls._output_size(fluent.tensor)
            yield tensor
27993
def convert_flatten(builder, layer, input_names, output_names, keras_layer):
    
    input_name, output_name = (input_names[0], output_names[0])

    # blob_order == 0 if the input blob needs not be rearranged
    # blob_order == 1 if the input blob needs to be rearranged
    blob_order = 0

    # using keras_layer.input.shape have a "?" (Dimension[None] at the front),
    # making a 3D tensor with unknown batch size 4D

    try:
        in_shape = keras_layer.input_shape
        if len(in_shape) == 4:
            blob_order = 1
        if len(in_shape) == 3 and in_shape[0] is None:
            # handling Keras rank-3 tensor (Batch, Sequence, Channels)
            permute_output_name = output_name + '__permute__'
            builder.add_permute(name=layer+'__permute__', dim=(2,1,0,3),
                input_name=input_name, output_name=permute_output_name)
            builder.add_flatten(name=layer, mode=1,
                input_name=permute_output_name, output_name=output_name)
        else:
            builder.add_flatten(name=layer, mode=blob_order, input_name=input_name,
                    output_name=output_name)
    except:
        builder.add_flatten(name=layer, mode=1, input_name=input_name, output_name=output_name)
658174
def _generate_permutation(self, npoints):
        
        i = np.arange(0, npoints)
        # permutation
        p = np.random.permutation(npoints)
        ip = np.empty_like(p)
        # inverse permutation
        ip[p[i]] = i
        return p, ip
1010047
def full(self):
        
        N = self.n.prod()
        M = self.m.prod()
        a = self.tt.full()
        d = self.tt.d
        sz = _np.vstack((self.n, self.m)).flatten('F')
        a = a.reshape(sz, order='F')
        # Design a permutation
        prm = _np.arange(2 * d)
        prm = prm.reshape((d, 2), order='F')
        prm = prm.transpose()
        prm = prm.flatten('F')
        # Get the inverse permutation
        iprm = [0] * (2 * d)
        for i in xrange(2 * d):
            iprm[prm[i]] = i
        a = a.transpose(iprm).reshape(N, M, order='F')
        a = a.reshape(N, M)
        return a
32686
def optimizer_tensor(self) -> Union[tf.Tensor, tf.Operation]:
        
        return _get_attr(self, _optimizer_tensor=None)
446617
def number_of_permutations(self):
        
        if self.permutations_safe_override:
            return factorial(self.coordination)
        elif self.permutations is None:
            return factorial(self.coordination)
        return len(self.permutations)
894369
def log(cls, x: 'TensorFluent') -> 'TensorFluent':
        '''
        '''
        return cls._unary_op(x, tf.log, tf.float32)
277707
def _output(cls, fluents: Sequence[FluentPair]) -> Sequence[tf.Tensor]:
        ''''''
        return tuple(cls._dtype(t) for t in cls._tensors(fluents))
583161
def permute(self, ba):
        
        c = ba.copy()
        for i in xrange(len(self.mapping)):
            ba[i] = c[self.mapping[i]]
        return ba