Best JavaScript code snippet using storybook-root
checker2.js
Source:checker2.js
1const TWENTY_FOUR = 24;2function checker(allProbability, allResult) {3 for (let index = 0; index < allProbability.length; index++) {4 if (allProbability[index][0] + allProbability[index][1] + allProbability[index][2] + allProbability[index][3] == TWENTY_FOUR) {5 allResult.push(`${allProbability[index][0]} + ${allProbability[index][1]} + ${allProbability[index][2]} + ${allProbability[index][3]} = 24`)6 }7 if (allProbability[index][0] + allProbability[index][1] + allProbability[index][2] - allProbability[index][3] == TWENTY_FOUR) {8 allResult.push(`${allProbability[index][0]} + ${allProbability[index][1]} + ${allProbability[index][2]} - ${allProbability[index][3]} = 24`)9 }10 if (allProbability[index][0] + allProbability[index][1] + allProbability[index][2] * allProbability[index][3] == TWENTY_FOUR) {11 allResult.push(`${allProbability[index][0]} + ${allProbability[index][1]} + ${allProbability[index][2]} * ${allProbability[index][3]} = 24`)12 }13 if (allProbability[index][0] + allProbability[index][1] + allProbability[index][2] / allProbability[index][3] == TWENTY_FOUR) {14 allResult.push(`${allProbability[index][0]} + ${allProbability[index][1]} + ${allProbability[index][2]} / ${allProbability[index][3]} = 24`)15 }16 if (allProbability[index][0] + allProbability[index][1] - allProbability[index][2] + allProbability[index][3] == TWENTY_FOUR) {17 allResult.push(`${allProbability[index][0]} + ${allProbability[index][1]} - ${allProbability[index][2]} + ${allProbability[index][3]} = 24`)18 }19 if (allProbability[index][0] + allProbability[index][1] - allProbability[index][2] - allProbability[index][3] == TWENTY_FOUR) {20 allResult.push(`${allProbability[index][0]} + ${allProbability[index][1]} - ${allProbability[index][2]} - ${allProbability[index][3]} = 24`)21 }22 if (allProbability[index][0] + allProbability[index][1] - allProbability[index][2] * allProbability[index][3] == TWENTY_FOUR) {23 allResult.push(`${allProbability[index][0]} + ${allProbability[index][1]} - ${allProbability[index][2]} * ${allProbability[index][3]} = 24`)24 }25 if (allProbability[index][0] + allProbability[index][1] - allProbability[index][2] / allProbability[index][3] == TWENTY_FOUR) {26 allResult.push(`${allProbability[index][0]} + ${allProbability[index][1]} - ${allProbability[index][2]} / ${allProbability[index][3]} = 24`)27 }28 if (allProbability[index][0] + allProbability[index][1] * allProbability[index][2] + allProbability[index][3] == TWENTY_FOUR) {29 allResult.push(`${allProbability[index][0]} + ${allProbability[index][1]} * ${allProbability[index][2]} + ${allProbability[index][3]} = 24`)30 }31 if (allProbability[index][0] + allProbability[index][1] * allProbability[index][2] - allProbability[index][3] == TWENTY_FOUR) {32 allResult.push(`${allProbability[index][0]} + ${allProbability[index][1]} * ${allProbability[index][2]} - ${allProbability[index][3]} = 24`)33 }34 if (allProbability[index][0] + allProbability[index][1] * allProbability[index][2] * allProbability[index][3] == TWENTY_FOUR) {35 allResult.push(`${allProbability[index][0]} + ${allProbability[index][1]} * ${allProbability[index][2]} * ${allProbability[index][3]} = 24`)36 }37 if (allProbability[index][0] + allProbability[index][1] * allProbability[index][2] / allProbability[index][3] == TWENTY_FOUR) {38 allResult.push(`${allProbability[index][0]} + ${allProbability[index][1]} * ${allProbability[index][2]} / ${allProbability[index][3]} = 24`)39 }40 if (allProbability[index][0] + allProbability[index][1] / allProbability[index][2] + allProbability[index][3] == TWENTY_FOUR) {41 allResult.push(`${allProbability[index][0]} + ${allProbability[index][1]} / ${allProbability[index][2]} + ${allProbability[index][3]} = 24`)42 }43 if (allProbability[index][0] + allProbability[index][1] / allProbability[index][2] - allProbability[index][3] == TWENTY_FOUR) {44 allResult.push(`${allProbability[index][0]} + ${allProbability[index][1]} / ${allProbability[index][2]} - ${allProbability[index][3]} = 24`)45 }46 if (allProbability[index][0] + allProbability[index][1] / allProbability[index][2] * allProbability[index][3] == TWENTY_FOUR) {47 allResult.push(`${allProbability[index][0]} + ${allProbability[index][1]} / ${allProbability[index][2]} * ${allProbability[index][3]} = 24`)48 }49 if (allProbability[index][0] + allProbability[index][1] / allProbability[index][2] / allProbability[index][3] == TWENTY_FOUR) {50 allResult.push(`${allProbability[index][0]} + ${allProbability[index][1]} / ${allProbability[index][2]} / ${allProbability[index][3]} = 24`)51 }52 if (allProbability[index][0] - allProbability[index][1] + allProbability[index][2] + allProbability[index][3] == TWENTY_FOUR) {53 allResult.push(`${allProbability[index][0]} - ${allProbability[index][1]} + ${allProbability[index][2]} + ${allProbability[index][3]} = 24`)54 }55 if (allProbability[index][0] - allProbability[index][1] + allProbability[index][2] - allProbability[index][3] == TWENTY_FOUR) {56 allResult.push(`${allProbability[index][0]} - ${allProbability[index][1]} + ${allProbability[index][2]} - ${allProbability[index][3]} = 24`)57 }58 if (allProbability[index][0] - allProbability[index][1] + allProbability[index][2] * allProbability[index][3] == TWENTY_FOUR) {59 allResult.push(`${allProbability[index][0]} - ${allProbability[index][1]} + ${allProbability[index][2]} * ${allProbability[index][3]} = 24`)60 }61 if (allProbability[index][0] - allProbability[index][1] + allProbability[index][2] / allProbability[index][3] == TWENTY_FOUR) {62 allResult.push(`${allProbability[index][0]} - ${allProbability[index][1]} + ${allProbability[index][2]} / ${allProbability[index][3]} = 24`)63 }64 if (allProbability[index][0] - allProbability[index][1] - allProbability[index][2] + allProbability[index][3] == TWENTY_FOUR) {65 allResult.push(`${allProbability[index][0]} - ${allProbability[index][1]} - ${allProbability[index][2]} + ${allProbability[index][3]} = 24`)66 }67 if (allProbability[index][0] - allProbability[index][1] - allProbability[index][2] - allProbability[index][3] == TWENTY_FOUR) {68 allResult.push(`${allProbability[index][0]} - ${allProbability[index][1]} - ${allProbability[index][2]} - ${allProbability[index][3]} = 24`)69 }70 if (allProbability[index][0] - allProbability[index][1] - allProbability[index][2] * allProbability[index][3] == TWENTY_FOUR) {71 allResult.push(`${allProbability[index][0]} - ${allProbability[index][1]} - ${allProbability[index][2]} * ${allProbability[index][3]} = 24`)72 }73 if (allProbability[index][0] - allProbability[index][1] - allProbability[index][2] / allProbability[index][3] == TWENTY_FOUR) {74 allResult.push(`${allProbability[index][0]} - ${allProbability[index][1]} - ${allProbability[index][2]} / ${allProbability[index][3]} = 24`)75 }76 if (allProbability[index][0] - allProbability[index][1] * allProbability[index][2] + allProbability[index][3] == TWENTY_FOUR) {77 allResult.push(`${allProbability[index][0]} - ${allProbability[index][1]} * ${allProbability[index][2]} + ${allProbability[index][3]} = 24`)78 }79 if (allProbability[index][0] - allProbability[index][1] * allProbability[index][2] - allProbability[index][3] == TWENTY_FOUR) {80 allResult.push(`${allProbability[index][0]} - ${allProbability[index][1]} * ${allProbability[index][2]} - ${allProbability[index][3]} = 24`)81 }82 if (allProbability[index][0] - allProbability[index][1] * allProbability[index][2] * allProbability[index][3] == TWENTY_FOUR) {83 allResult.push(`${allProbability[index][0]} - ${allProbability[index][1]} * ${allProbability[index][2]} * ${allProbability[index][3]} = 24`)84 }85 if (allProbability[index][0] - allProbability[index][1] * allProbability[index][2] / allProbability[index][3] == TWENTY_FOUR) {86 allResult.push(`${allProbability[index][0]} - ${allProbability[index][1]} * ${allProbability[index][2]} / ${allProbability[index][3]} = 24`)87 }88 if (allProbability[index][0] - allProbability[index][1] / allProbability[index][2] + allProbability[index][3] == TWENTY_FOUR) {89 allResult.push(`${allProbability[index][0]} - ${allProbability[index][1]} / ${allProbability[index][2]} + ${allProbability[index][3]} = 24`)90 }91 if (allProbability[index][0] - allProbability[index][1] / allProbability[index][2] - allProbability[index][3] == TWENTY_FOUR) {92 allResult.push(`${allProbability[index][0]} - ${allProbability[index][1]} / ${allProbability[index][2]} - ${allProbability[index][3]} = 24`)93 }94 if (allProbability[index][0] - allProbability[index][1] / allProbability[index][2] * allProbability[index][3] == TWENTY_FOUR) {95 allResult.push(`${allProbability[index][0]} - ${allProbability[index][1]} / ${allProbability[index][2]} * ${allProbability[index][3]} = 24`)96 }97 if (allProbability[index][0] - allProbability[index][1] / allProbability[index][2] / allProbability[index][3] == TWENTY_FOUR) {98 allResult.push(`${allProbability[index][0]} - ${allProbability[index][1]} / ${allProbability[index][2]} / ${allProbability[index][3]} = 24`)99 }100 if (allProbability[index][0] * allProbability[index][1] + allProbability[index][2] + allProbability[index][3] == TWENTY_FOUR) {101 allResult.push(`${allProbability[index][0]} * ${allProbability[index][1]} + ${allProbability[index][2]} + ${allProbability[index][3]} = 24`)102 }103 if (allProbability[index][0] * allProbability[index][1] + allProbability[index][2] - allProbability[index][3] == TWENTY_FOUR) {104 allResult.push(`${allProbability[index][0]} * ${allProbability[index][1]} + ${allProbability[index][2]} - ${allProbability[index][3]} = 24`)105 }106 if (allProbability[index][0] * allProbability[index][1] + allProbability[index][2] * allProbability[index][3] == TWENTY_FOUR) {107 allResult.push(`${allProbability[index][0]} * ${allProbability[index][1]} + ${allProbability[index][2]} * ${allProbability[index][3]} = 24`)108 }109 if (allProbability[index][0] * allProbability[index][1] + allProbability[index][2] / allProbability[index][3] == TWENTY_FOUR) {110 allResult.push(`${allProbability[index][0]} * ${allProbability[index][1]} + ${allProbability[index][2]} / ${allProbability[index][3]} = 24`)111 }112 if (allProbability[index][0] * allProbability[index][1] - allProbability[index][2] + allProbability[index][3] == TWENTY_FOUR) {113 allResult.push(`${allProbability[index][0]} * ${allProbability[index][1]} - ${allProbability[index][2]} + ${allProbability[index][3]} = 24`)114 }115 if (allProbability[index][0] * allProbability[index][1] - allProbability[index][2] - allProbability[index][3] == TWENTY_FOUR) {116 allResult.push(`${allProbability[index][0]} * ${allProbability[index][1]} - ${allProbability[index][2]} - ${allProbability[index][3]} = 24`)117 }118 if (allProbability[index][0] * allProbability[index][1] - allProbability[index][2] * allProbability[index][3] == TWENTY_FOUR) {119 allResult.push(`${allProbability[index][0]} * ${allProbability[index][1]} - ${allProbability[index][2]} * ${allProbability[index][3]} = 24`)120 }121 if (allProbability[index][0] * allProbability[index][1] - allProbability[index][2] / allProbability[index][3] == TWENTY_FOUR) {122 allResult.push(`${allProbability[index][0]} * ${allProbability[index][1]} - ${allProbability[index][2]} / ${allProbability[index][3]} = 24`)123 }124 if (allProbability[index][0] * allProbability[index][1] * allProbability[index][2] + allProbability[index][3] == TWENTY_FOUR) {125 allResult.push(`${allProbability[index][0]} * ${allProbability[index][1]} * ${allProbability[index][2]} + ${allProbability[index][3]} = 24`)126 }127 if (allProbability[index][0] * allProbability[index][1] * allProbability[index][2] - allProbability[index][3] == TWENTY_FOUR) {128 allResult.push(`${allProbability[index][0]} * ${allProbability[index][1]} * ${allProbability[index][2]} - ${allProbability[index][3]} = 24`)129 }130 if (allProbability[index][0] * allProbability[index][1] * allProbability[index][2] * allProbability[index][3] == TWENTY_FOUR) {131 allResult.push(`${allProbability[index][0]} * ${allProbability[index][1]} * ${allProbability[index][2]} * ${allProbability[index][3]} = 24`)132 }133 if (allProbability[index][0] * allProbability[index][1] * allProbability[index][2] / allProbability[index][3] == TWENTY_FOUR) {134 allResult.push(`${allProbability[index][0]} * ${allProbability[index][1]} * ${allProbability[index][2]} / ${allProbability[index][3]} = 24`)135 }136 if (allProbability[index][0] * allProbability[index][1] / allProbability[index][2] + allProbability[index][3] == TWENTY_FOUR) {137 allResult.push(`${allProbability[index][0]} * ${allProbability[index][1]} / ${allProbability[index][2]} + ${allProbability[index][3]} = 24`)138 }139 if (allProbability[index][0] * allProbability[index][1] / allProbability[index][2] - allProbability[index][3] == TWENTY_FOUR) {140 allResult.push(`${allProbability[index][0]} * ${allProbability[index][1]} / ${allProbability[index][2]} - ${allProbability[index][3]} = 24`)141 }142 if (allProbability[index][0] * allProbability[index][1] / allProbability[index][2] * allProbability[index][3] == TWENTY_FOUR) {143 allResult.push(`${allProbability[index][0]} * ${allProbability[index][1]} / ${allProbability[index][2]} * ${allProbability[index][3]} = 24`)144 }145 if (allProbability[index][0] * allProbability[index][1] / allProbability[index][2] / allProbability[index][3] == TWENTY_FOUR) {146 allResult.push(`${allProbability[index][0]} * ${allProbability[index][1]} / ${allProbability[index][2]} / ${allProbability[index][3]} = 24`)147 }148 if (allProbability[index][0] / allProbability[index][1] + allProbability[index][2] + allProbability[index][3] == TWENTY_FOUR) {149 allResult.push(`${allProbability[index][0]} / ${allProbability[index][1]} + ${allProbability[index][2]} + ${allProbability[index][3]} = 24`)150 }151 if (allProbability[index][0] / allProbability[index][1] + allProbability[index][2] - allProbability[index][3] == TWENTY_FOUR) {152 allResult.push(`${allProbability[index][0]} / ${allProbability[index][1]} + ${allProbability[index][2]} - ${allProbability[index][3]} = 24`)153 }154 if (allProbability[index][0] / allProbability[index][1] + allProbability[index][2] * allProbability[index][3] == TWENTY_FOUR) {155 allResult.push(`${allProbability[index][0]} / ${allProbability[index][1]} + ${allProbability[index][2]} * ${allProbability[index][3]} = 24`)156 }157 if (allProbability[index][0] / allProbability[index][1] + allProbability[index][2] / allProbability[index][3] == TWENTY_FOUR) {158 allResult.push(`${allProbability[index][0]} / ${allProbability[index][1]} + ${allProbability[index][2]} / ${allProbability[index][3]} = 24`)159 }160 if (allProbability[index][0] / allProbability[index][1] - allProbability[index][2] + allProbability[index][3] == TWENTY_FOUR) {161 allResult.push(`${allProbability[index][0]} / ${allProbability[index][1]} - ${allProbability[index][2]} + ${allProbability[index][3]} = 24`)162 }163 if (allProbability[index][0] / allProbability[index][1] - allProbability[index][2] - allProbability[index][3] == TWENTY_FOUR) {164 allResult.push(`${allProbability[index][0]} / ${allProbability[index][1]} - ${allProbability[index][2]} - ${allProbability[index][3]} = 24`)165 }166 if (allProbability[index][0] / allProbability[index][1] - allProbability[index][2] * allProbability[index][3] == TWENTY_FOUR) {167 allResult.push(`${allProbability[index][0]} / ${allProbability[index][1]} - ${allProbability[index][2]} * ${allProbability[index][3]} = 24`)168 }169 if (allProbability[index][0] / allProbability[index][1] - allProbability[index][2] / allProbability[index][3] == TWENTY_FOUR) {170 allResult.push(`${allProbability[index][0]} / ${allProbability[index][1]} - ${allProbability[index][2]} / ${allProbability[index][3]} = 24`)171 }172 if (allProbability[index][0] / allProbability[index][1] * allProbability[index][2] + allProbability[index][3] == TWENTY_FOUR) {173 allResult.push(`${allProbability[index][0]} / ${allProbability[index][1]} * ${allProbability[index][2]} + ${allProbability[index][3]} = 24`)174 }175 if (allProbability[index][0] / allProbability[index][1] * allProbability[index][2] - allProbability[index][3] == TWENTY_FOUR) {176 allResult.push(`${allProbability[index][0]} / ${allProbability[index][1]} * ${allProbability[index][2]} - ${allProbability[index][3]} = 24`)177 }178 if (allProbability[index][0] / allProbability[index][1] * allProbability[index][2] * allProbability[index][3] == TWENTY_FOUR) {179 allResult.push(`${allProbability[index][0]} / ${allProbability[index][1]} * ${allProbability[index][2]} * ${allProbability[index][3]} = 24`)180 }181 if (allProbability[index][0] / allProbability[index][1] * allProbability[index][2] / allProbability[index][3] == TWENTY_FOUR) {182 allResult.push(`${allProbability[index][0]} / ${allProbability[index][1]} * ${allProbability[index][2]} / ${allProbability[index][3]} = 24`)183 }184 if (allProbability[index][0] / allProbability[index][1] / allProbability[index][2] + allProbability[index][3] == TWENTY_FOUR) {185 allResult.push(`${allProbability[index][0]} / ${allProbability[index][1]} / ${allProbability[index][2]} + ${allProbability[index][3]} = 24`)186 }187 if (allProbability[index][0] / allProbability[index][1] / allProbability[index][2] - allProbability[index][3] == TWENTY_FOUR) {188 allResult.push(`${allProbability[index][0]} / ${allProbability[index][1]} / ${allProbability[index][2]} - ${allProbability[index][3]} = 24`)189 }190 if (allProbability[index][0] / allProbability[index][1] / allProbability[index][2] * allProbability[index][3] == TWENTY_FOUR) {191 allResult.push(`${allProbability[index][0]} / ${allProbability[index][1]} / ${allProbability[index][2]} * ${allProbability[index][3]} = 24`)192 }193 if (allProbability[index][0] / allProbability[index][1] / allProbability[index][2] / allProbability[index][3] == TWENTY_FOUR) {194 allResult.push(`${allProbability[index][0]} / ${allProbability[index][1]} / ${allProbability[index][2]} / ${allProbability[index][3]} = 24`)195 }196 }197}198function permute(permutation) {199 var length = permutation.length,200 result = [permutation.slice()],201 c = new Array(length).fill(0),202 i = 1, k, p;203 while (i < length) {204 if (c[i] < i) {205 k = i % 2 && c[i];206 p = permutation[i];207 permutation[i] = permutation[k];208 permutation[k] = p;209 ++c[i];210 i = 1;211 result.push(permutation.slice());212 } else {213 c[i] = 0;214 ++i;215 }216 }217 return result;218}219function solver24(combination) {220 let allProbability = permute(combination);221 let allResult = [];222 checker(allProbability, allResult)223 let finalArray = [...new Set(allResult)];224 return finalArray;225 // if (finalArray.length == 0) {226 // return(`tidak ada solusi untuk kombinasi angka tersebut`)227 // } else {228 // return(`total ada ${finalArray.length} solusi`)229 // }230 // finalArray.forEach((result, index) => {231 // return(`solusi ${index + 1} untuk penyelesaian game adalah ${result}`)232 // })233}...
batch_allreduce.py
Source:batch_allreduce.py
1"""Contains classes and functions for doing a single-machine batch all-reduce.2An all-reduce is taking the reduction (typically a sum) of a list of tensors,3each on a different device. The result must end up back on each device, which is4where the word "all" comes from. In summary, each device starts with a single5tensor, and ends up with the reduction of all tensors.6A batch all-reduce is doing several independent all-reduces. When doing a batch7all-reduce, care is taken to evenly distribute the reduction computations8across devices and inter-device tensor transfers across device links.9"""10from __future__ import absolute_import11from __future__ import division12from __future__ import print_function13# all-reduce code that this file calls. allreduce.py also supports distributed14# batch-reduce while this file only supports single-machine all-reduce.15import pdb16import abc17from collections import namedtuple18import six19import tensorflow as tf20from tensorflow.python.framework import ops21from tensorflow.python.ops import data_flow_ops22import allreduce23def _all_reduce_using_copy(tensors_across_devices, use_mean):24 """Does an all-reduce of a list of tensors by copying to the current device.25 The tensors are copied to the current device and then reduced.26 Args:27 tensors_across_devices: A list of tensors, each on a different device.28 use_mean: Whether to take the mean of the tensors instead of a sum:29 Returns:30 A reduced tensor on the current device.31 """32 reduced_tensor = tf.add_n(tensors_across_devices)33 if use_mean:34 reduced_tensor *= 1 / len(tensors_across_devices)35 return reduced_tensor36@six.add_metaclass(abc.ABCMeta)37class BatchAllReduceAlgorithm(object):38 """Represents an algorithm for performing a batch all-reduce operation."""39 def batch_all_reduce(self, all_device_tensors, num_splits, compact_tensors,40 defer_tensors):41 """Performs a batch all-reduce.42 The reduction done is a sum.43 `all_device_tensors` is a list of list of tensors that will be batch44 all-reduced. All tensors within a single inner list must be on the same45 device. The nth element in each list, for any n, will be reduced together.46 The return value is in the same form as `all_device_tensors`, except that47 each tensor is reduced.48 For example, if `all_device_tensors` is:49 [[ A, B ], # A and B are on GPU 050 [ C, D ]] # C and D are on GPU 151 Then the return value will be:52 [[ A+C, B+D ], # These two tensors are on GPU 053 [ A+C, B+D ]] # These two tensors are on GPU 154 Arguments:55 all_device_tensors: A list of list of tensors. `all_device_tensors[i][j]`56 is a tensor where `i` is the device index and `j` is the tensor index.57 num_splits: If not None, tensors will be concatenated and split into this58 many pieces during the all-reduce, then split back into their original59 shapes afterwards. Has no impact on correctness and can improve60 performance.61 compact_tensors: If True, tensors are casted to fp16 before being all-62 reduced. Improves performance, but hurts numerical stability.63 defer_tensors: If True, every time the return value64 `reduced_all_device_tensors` is evaluated, the result will be the65 reduced tensors values of `all_device_tensors` from the previous session66 run instead of the current session run, or zero on the first session67 run. This can improve performance. When training neural networks,68 deferring gradients often does not harm training, so this can be used to69 improve performance.70 Returns:71 reduced_all_device_tensors: A list in the same form as72 `all_device_tensors`, except each tensor has been reduced.73 warmup_ops: A list of ops needed to be run once before the all-reduce can74 occur.75 """76 # Before all-reducing tensors, we do several preprocessing functions that77 # can speed up the all-reduce. We undo these functions after all-reducing78 # the tensors.79 warmup_ops = []80 if num_splits:81 packer = _TensorPacker(num_splits)82 all_device_tensors = packer.concat_all_device_tensors(83 all_device_tensors)84 # If enabled, we compact and defer tensors in between concatenating them85 # and splitting them, because it is faster to do operations on a single86 # concatenated tensor than on multiple smaller tensors.87 if compact_tensors:88 all_device_tensors_before_compact = all_device_tensors89 all_device_tensors = _compact_all_device_tensors(90 all_device_tensors)91 if defer_tensors:92 all_device_tensors, put_ops, warmup_ops = _defer_all_device_tensors(93 all_device_tensors)94 if num_splits:95 all_device_tensors = packer.split_all_device_tensors(96 all_device_tensors)97 all_device_tensors = self._do_batch_all_reduce(all_device_tensors)98 # Undo the preprocessing operations in opposite order as we applied them.99 if num_splits:100 all_device_tensors = packer.undo_split_all_device_tensors(101 all_device_tensors)102 # Note: There is no undo operation for deferring tensors. But we do need to103 # call _add_put_op_control_deps at the end if we deferred the tensors.104 if compact_tensors:105 all_device_tensors = _undo_compact_all_device_tensors(106 all_device_tensors, all_device_tensors_before_compact)107 if num_splits:108 all_device_tensors = packer.undo_concat_all_device_tensors(109 all_device_tensors)110 if defer_tensors:111 all_device_tensors = _add_put_op_control_deps(all_device_tensors,112 num_splits, put_ops)113 return all_device_tensors, warmup_ops114 @abc.abstractmethod115 def _do_batch_all_reduce(self, all_device_tensors):116 """Performs a batch all-reduce.117 Unlike `self.batch_all_reduce`, this does not do any preprocessing of the118 tensors.119 Args:120 all_device_tensors: A list of list of tensors. `all_device_tensors[i][j]`121 is a tensor where `i` is the device index and `j` is the tensor index.122 Returns:123 reduced_all_device_tensors: A list in the same form as124 `all_device_tensors`, except each tensor has been reduced.125 """126 pass127class AllReduceSpecAlgorithm(BatchAllReduceAlgorithm):128 """An algorithm that uses an all reduce spec."""129 def __init__(self, all_reduce_spec, gpu_indices, agg_small_grads_max_bytes,130 agg_small_grads_max_group):131 spec = allreduce.parse_all_reduce_spec(all_reduce_spec)132 if len(spec) != 1:133 raise ValueError(134 "Replicated mode does not support hybrid all-reduce strategies")135 self._all_reduce_spec = spec[0]136 self._gpu_indices = gpu_indices137 self._agg_small_grads_max_bytes = agg_small_grads_max_bytes138 self._agg_small_grads_max_group = agg_small_grads_max_group139 def _do_batch_all_reduce(self, all_device_tensors):140 tower_grads = [[(t, None) for t in device_tensors]141 for device_tensors in all_device_tensors]142 aggregated_device_grads = allreduce.sum_gradients_all_reduce(143 ["/job:localhost"],144 tower_grads,145 1,146 self._all_reduce_spec.alg,147 self._all_reduce_spec.shards,148 self._gpu_indices,149 agg_small_grads_max_bytes=self._agg_small_grads_max_bytes,150 agg_small_grads_max_group=self._agg_small_grads_max_group)151 return [[t for t, _ in grad_vars]152 for grad_vars in aggregated_device_grads]153def algorithm_from_params(params, num_gpus):154 """Returns a BatchAllReduceAlgorithm from a Params tuple."""155 if params.all_reduce_spec:156 gpu_indices = [i for i in range(num_gpus)]157 return AllReduceSpecAlgorithm(params.all_reduce_spec, gpu_indices,158 params.agg_small_grads_max_bytes,159 params.agg_small_grads_max_group)160 else:161 raise NotImplementedError("Not implemented yet.")162def _apply_to_all_device_tensors(all_device_tensors, apply_func,163 colocate=True):164 """Applies a function to each tensor in `all_device_tensors`.165 A new list of lists of tensors is returned, where every tensor in166 `all_device_tensors` has had `apply_func` called on it. `all_device_tensors`167 is not modified.168 Args:169 all_device_tensors: A list of list of tensors. `all_device_tensors[i][j]` is170 a tensor where `i` is the device index and `j` is the tensor index.171 apply_func: A function taking in three arguments: tensor, device_index,172 tensor_index, and returning a modified tensor.173 `tensor` is `all_device_tensors[device_index][tensor_index]`.174 colocate: If True, apply_func will be run under context manager colocated175 with it"s input tensor.176 Returns:177 A list in the same form as `all_device_tensors`, except each tensor has had178 `apply_func` called on it.179 """180 new_all_device_tensors = []181 for device_index, device_tensors in enumerate(all_device_tensors):182 new_device_tensors = []183 for tensor_index, t in enumerate(device_tensors):184 if colocate:185 with tf.colocate_with(t):186 new_t = apply_func(t, device_index, tensor_index)187 else:188 new_t = apply_func(t, device_index, tensor_index)189 new_device_tensors.append(new_t)190 new_all_device_tensors.append(new_device_tensors)191 return new_all_device_tensors192def _defer_tensor(tensor):193 """Defers the retrieval of a tensor.194 The tensor is put into a StagingArea, and the return value is the195 retrieval of the tensor from the StagingArea. The effect is that the196 tensor returned from this function is the tensor that was put in the197 StagingArea for the previous Session.run() call.198 Args:199 tensor: The tensor to defer for one step.200 Returns:201 deferred_tensor: The tensor deferred for one step.202 put_op: An op to put `tensor` in the StagingArea. Must be run every step203 that `deferred_tensor` is run.204 warmup_op: A warmup op that should be called before the first step. Puts205 a zero tensor into the StagingArea.206 """207 tensor_stage = data_flow_ops.StagingArea([tensor.dtype], [tensor.shape])208 put_op = tensor_stage.put([tensor])209 warmup_op = tensor_stage.put([tf.zeros(tensor.shape, dtype=tensor.dtype)])210 # Fetch the next tensor to use.211 (tensor, ) = tensor_stage.get()212 return tensor, put_op, warmup_op213def _defer_all_device_tensors(all_device_tensors):214 """Defers every tensor in `all_device_tensors`."""215 put_ops = [[] for _ in all_device_tensors]216 warmup_ops = [[] for _ in all_device_tensors]217 def apply_func(tensor, device_index, tensor_index):218 del tensor_index219 tensor, put_op, warmup_op = _defer_tensor(tensor)220 put_ops[device_index].append(put_op)221 warmup_ops[device_index].append(warmup_op)222 return tensor223 new_all_device_tensors = _apply_to_all_device_tensors(all_device_tensors,224 apply_func)225 return new_all_device_tensors, put_ops, warmup_ops226def _add_put_op_control_deps(all_device_tensors, num_splits, put_ops):227 """Add control dependencies from `put_ops` to `all_device_tensors`.228 This should only be called when deferred tensors are being used.229 The control dependencies are added so that the put ops are run whenever230 `all_device_tensors` is run. That way, the caller does not have to explicitly231 run the put ops.232 Args:233 all_device_tensors: A list of list of tensors. `all_device_tensors[i][j]` is234 a tensor where `i` is the device index and `j` is the tensor index.235 num_splits: The number of splits that were used for the all-reduce.236 put_ops: A list of put ops from deferring the tensors.237 Returns:238 A list in the same form as `all_device_tensors`, except each tensor has a239 control dependency on an op in `put_ops`.240 """241 def apply_func(tensor, device_index, tensor_index):242 if num_splits == 0:243 deps = [put_ops[device_index][tensor_index]]244 else:245 deps = put_ops[device_index]246 assert len(deps) == 1247 with tf.control_dependencies(deps):248 return tf.identity(tensor, name="control_dependency")249 return _apply_to_all_device_tensors(all_device_tensors, apply_func)250def _compact_all_device_tensors(all_device_tensors):251 """Compacts each tensor by casting to fp16."""252 def apply_func(tensor, device_index, tensor_index):253 del device_index, tensor_index254 return tf.cast(tensor, tf.float16)255 return _apply_to_all_device_tensors(all_device_tensors, apply_func)256def _undo_compact_all_device_tensors(all_device_tensors,257 orig_all_device_tensors):258 """Uncompacts each tensor by casting to it"s original dtype."""259 def apply_func(tensor, device_index, tensor_index):260 orig_tensor = orig_all_device_tensors[device_index][tensor_index]261 with tf.colocate_with(orig_tensor):262 return tf.cast(tensor, orig_tensor.dtype)263 return _apply_to_all_device_tensors(264 all_device_tensors, apply_func, colocate=False)265class _TensorPacker(object):266 """Packs and unpacks tensors into groups.267 This class first concatenates a set of tensors, then split the concatenated268 tensor into a small number of chunks. This is useful for all-reducing tensors,269 as doing a small number of all-reduces on large tensors can be faster than270 doing a large number of all-reduces on small tensors.271 """272 def __init__(self, num_splits):273 """Initializes the _TensorPacker.274 Args:275 num_splits: The number of tensors to split the concatenated tensor into.276 The batch all-reduce will consist of `num_splits` all-reduces.277 """278 assert num_splits > 0279 self._num_splits = num_splits280 self._next_method = "concat"281 _concat_tensor_state = namedtuple("_concat_tensor_state",282 ["orig_shapes", "orig_sizes"])283 def _concat_tensors(self, device_tensors):284 """Concatenate tensors into a single tensor."""285 flat_tensors = [tf.reshape(t, [-1]) for t in device_tensors]286 orig_shapes = [t.shape for t in device_tensors]287 orig_sizes = [s.num_elements() for s in orig_shapes]288 # All shapes must be fully defined.289 assert None not in orig_sizes290 concatenated_grad = tf.concat(flat_tensors, 0)291 return concatenated_grad, self._concat_tensor_state(orig_shapes,292 orig_sizes)293 def _split_tensors(self, concatenated_tensor):294 """Splits concatenated tensor into `num_splits` pieces."""295 total_tensor_size = concatenated_tensor.shape.num_elements()296 split_size = total_tensor_size // self._num_splits297 split_size_last = total_tensor_size - split_size * (self._num_splits -298 1)299 split_sizes = [split_size] * (self._num_splits - 1) + [split_size_last]300 tensor_packs = tf.split(concatenated_tensor, split_sizes)301 return tensor_packs302 def _undo_split_tensors(self, tensor_packs):303 """Undoes self._split_tensors()."""304 return tf.concat(tensor_packs, 0)305 def _undo_concat_tensors(self, concatenated_tensor, concat_tensor_state):306 """Undoes self._concat_tensors()."""307 tensors_with_sizes = tf.split(concatenated_tensor,308 concat_tensor_state.orig_sizes)309 tensors_with_shapes = [310 tf.reshape(grad, shape)311 for grad, shape in zip(tensors_with_sizes,312 concat_tensor_state.orig_shapes)313 ]314 return tensors_with_shapes315 def concat_all_device_tensors(self, all_device_tensors):316 """For each device, concatenate the device"s tensors into a single tensor.317 Args:318 all_device_tensors: A list of list of tensors. `all_device_tensors[i][j]`319 is a tensor where `i` is the device index and `j` is the tensor index.320 Returns:321 A list of list of tensors in a similar form as all_device_tensors, except322 the tensors on each device have been concatenated. Each inner list323 consists of a single concatenated tensor.324 """325 assert self._next_method == "concat"326 new_all_device_tensors = []327 tensor_states = []328 for device_tensors in all_device_tensors:329 with tf.colocate_with(device_tensors[0]):330 concat_tensor, tensor_state = self._concat_tensors(331 device_tensors)332 new_all_device_tensors.append([concat_tensor])333 tensor_states.append(tensor_state)334 self._tensor_states = tensor_states335 self._next_method = "split"336 return new_all_device_tensors337 def split_all_device_tensors(self, all_device_tensors):338 """Splits concatenated tensors into `num_splits` pieces.339 `num_splits` is specified in the constructor. In the case where the total340 size of a concatenated tensor is not divisible by `num_splits`, the last341 split tensor gets more elements.342 Args:343 all_device_tensors: A list of list of tensors. `all_device_tensors[i][j]`344 is a tensor where `i` is the device index and `j` is the tensor index.345 For each i, `all_device_tensors[i]` must be a list of length 1 of a346 single concatenated tensor.347 Returns:348 A list of list of tensors in a similar form as all_device_tensors, except349 the concatenated tensor on each device have been split. Each inner list350 is a list of length `num_splits`.351 """352 assert self._next_method == "split"353 new_all_device_tensors = []354 for [concat_tensor] in all_device_tensors:355 with tf.colocate_with(concat_tensor):356 new_all_device_tensors.append(357 self._split_tensors(concat_tensor))358 self._orig_concat_all_device_tensors = all_device_tensors359 self._next_method = "undo_split"360 return new_all_device_tensors361 def undo_split_all_device_tensors(self, all_device_tensors):362 """Undoes the effects of `split_all_device_tensors`."""363 assert self._next_method == "undo_split"364 new_all_device_tensors = []365 for i, device_tensors in enumerate(all_device_tensors):366 [orig_tensor] = self._orig_concat_all_device_tensors[i]367 with tf.colocate_with(orig_tensor):368 new_all_device_tensors.append(369 [self._undo_split_tensors(device_tensors)])370 self._next_method = "undo_concat"371 return new_all_device_tensors372 def undo_concat_all_device_tensors(self, all_device_tensors):373 """Undoes the effects of `concat_all_device_tensors`."""374 assert self._next_method == "undo_concat"375 new_all_device_tensors = []376 for [concat_tensor], tensor_state in zip(all_device_tensors,377 self._tensor_states):378 with tf.colocate_with(concat_tensor):379 new_all_device_tensors.append(380 self._undo_concat_tensors(concat_tensor, tensor_state))381 self._next_method = None...
sort.js
Source:sort.js
1/*2Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.3For licensing, see LICENSE.html or http://ckeditor.com/license4*/5jQuery(document).ready(function() {6 function Tools(event, ui) {7 //outer loop for rows8 var tools = "[\n";9 rows = jQuery("#groupLayout div.sortableListDiv").length;10 jQuery.each(jQuery("#groupLayout div.sortableListDiv"), function(rowIndex, rowValue) {11 if (jQuery("li",rowValue).length > 0) {12 tools = tools + " [";13 }14 //inner loop for toolbar buttons15 jQuery.each(jQuery("li",rowValue), function(buttonIndex, buttonValue) {16 if (jQuery(buttonValue).hasClass('spacer')) {17 tools = tools + ",'-'";18 }19 else if (jQuery(buttonValue).hasClass('group')) {20 tools = tools + "],\n [";21 }22 else {23 tools = tools + ",'" + jQuery(buttonValue).attr('id') + "'" ;24 }25 });26 if (jQuery("li" ,rowValue).length > 0) {27 if (rowIndex < (rows -1)) {28 tools = tools + "],\n '/',\n";29 }30 else {31 tools = tools + "]\n";32 }33 }34 });35 tools = tools + "]";36 tools = tools.replace(/\[,/g, '[');37 tools = tools.replace(/\[],/g, '');38 jQuery("#edit-toolbar").attr('value', tools);39 }40 Drupal.ckeditorToolbaInit = function() {41 Drupal.ckeditorToolbarUsedRender();42 Drupal.ckeditorToolbarAllRender();43 var firefox = navigator.userAgent.toLowerCase().match(/firefox\/[0-9]\./);44 jQuery(".sortableList").sortable({45 connectWith: ".sortableList",46 items: "div.sortableListDiv",47 sort: function(event, ui) {48 if (firefox){49 ui.helper.css({'top' : ui.position.top - 35 + 'px'});50 }51 },52 stop: function(event, ui) {53 Tools(event, ui);54 }55 }).disableSelection();56 jQuery(".sortableRow").sortable({57 connectWith: ".sortableRow",58 items: "li.sortableItem",59 sort: function(event, ui) {60 if (firefox){61 ui.helper.css({'top' : ui.position.top - 35 + 'px'});62 }63 },64 stop: function(event, ui) {65 Tools(event, ui);66 }67 }).disableSelection();68 jQuery("li.sortableItem").mouseover(function(){69 jQuery(".sortableList").sortable("disable");70 });71 jQuery("li.sortableItem").mouseout(function(){72 jQuery(".sortableList").sortable("enable");73 });74 }75 Drupal.ckeditorToolbarReload = function() {76 jQuery(".sortableList").sortable('destroy');77 jQuery(".sortableRow").sortable('destroy');78 jQuery("li.sortableItem").unbind();79 Drupal.ckeditorToolbaInit();80 }81 Drupal.ckeditorToolbarUsedRender = function() {82 var toolbar = jQuery('#edit-toolbar').val();83 toolbar = eval(toolbar);84 var html = '<div class="sortableListDiv"><span class="sortableListSpan"><ul class="sortableRow">';85 var group = false;86 for (var row in toolbar) {87 if (typeof toolbar[row] == 'string' && toolbar[row] == '/') {88 group = false;89 html += '</ul></span></div><div class="sortableListDiv"><span class="sortableListSpan"><ul class="sortableRow">';90 }91 else {92 if (group == false){93 group = true;94 }95 else {96 html += '<li class="sortableItem group"><img src="' + Drupal.settings.cke_toolbar_buttons_all['__group']['icon'] + '" alt="group" title="group" /></li>';97 }98 for (var button in toolbar[row]) {99 if (toolbar[row][button] == '-') {100 html += '<li class="sortableItem spacer"><img src="' + Drupal.settings.cke_toolbar_buttons_all['__spacer']['icon'] + '" alt="spacer" title="spacer" /></li>';101 }102 else if (Drupal.settings.cke_toolbar_buttons_all[toolbar[row][button]]) {103 html += '<li class="sortableItem" id="' + Drupal.settings.cke_toolbar_buttons_all[toolbar[row][button]]['name'] + '"><img src="' + Drupal.settings.cke_toolbar_buttons_all[toolbar[row][button]]['icon'] + '" alt="' + Drupal.settings.cke_toolbar_buttons_all[toolbar[row][button]]['title'] + '" title="' + Drupal.settings.cke_toolbar_buttons_all[toolbar[row][button]]['title'] + '" /></li>';104 }105 }106 }107 }108 html += '</ul></span></div>';109 jQuery('#groupLayout').empty().append(html);110 }111 Drupal.ckeditorToolbarAllRender = function() {112 var toolbarUsed = jQuery('#edit-toolbar').val();113 var toolbarAll = Drupal.settings.cke_toolbar_buttons_all;114 var htmlArray = new Array();115 var html = '';116 for (var i in toolbarAll) {117 if (new RegExp("\'[\s]*" + toolbarAll[i].name + "[\s]*\'").test(toolbarUsed) == false) {118 if (toolbarAll[i].name == false) continue;119 if (typeof htmlArray[toolbarAll[i].row] == 'undefined') htmlArray[toolbarAll[i].row] = '';120 htmlArray[toolbarAll[i].row] += '<li class="sortableItem" id="' + toolbarAll[i].name + '"><img src="' + toolbarAll[i].icon + '" alt="' + toolbarAll[i].title + '" title="' + toolbarAll[i].title + '" /></li>';121 }122 }123 if (typeof htmlArray[5] == 'undefined') htmlArray[5] = '';124 htmlArray[5] += '<li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li>';125 if (typeof htmlArray[6] == 'undefined') htmlArray[6] = '';126 htmlArray[6] += '<li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li>';127 if (typeof htmlArray[7] == 'undefined') htmlArray[7] = '';128 for (var j in htmlArray){129 html += '<div class="sortableListDiv"><span class="sortableListSpan"><ul class="sortableRow">' + htmlArray[j] + '</ul></span></div>';130 }131 jQuery('#allButtons').empty().append(html);132 }133 Drupal.ckeditorToolbaInit();...
BUILD
Source:BUILD
1# Description:2# TensorFlow is a computational framework, primarily for use in machine3# learning applications.4package(default_visibility = [":internal"])5licenses(["notice"]) # Apache 2.06exports_files([7 "LICENSE",8 "ACKNOWLEDGMENTS",9])10# Config setting for determining if we are building for Android.11config_setting(12 name = "android",13 values = {14 "crosstool_top": "//external:android/crosstool",15 },16 visibility = ["//visibility:public"],17)18config_setting(19 name = "android_arm",20 values = {21 "crosstool_top": "//external:android/crosstool",22 "android_cpu": "armeabi-v7a",23 },24 visibility = ["//visibility:public"],25)26config_setting(27 name = "android_arm64",28 values = {29 "crosstool_top": "//external:android/crosstool",30 "android_cpu": "arm64-v8a",31 },32 visibility = ["//visibility:public"],33)34config_setting(35 name = "darwin",36 values = {"cpu": "darwin"},37 visibility = ["//visibility:public"],38)39config_setting(40 name = "windows",41 values = {"cpu": "x64_windows_msvc"},42 visibility = ["//visibility:public"],43)44config_setting(45 name = "ios",46 values = {47 "crosstool_top": "//tools/osx/crosstool:crosstool",48 },49 visibility = ["//visibility:public"],50)51package_group(52 name = "internal",53 packages = ["//tensorflow/..."],54)55filegroup(56 name = "all_files",57 srcs = glob(58 ["**/*"],59 exclude = [60 "**/METADATA",61 "**/OWNERS",62 "g3doc/sitemap.md",63 ],64 ),65 visibility = ["//tensorflow:__subpackages__"],66)67py_library(68 name = "tensorflow_py",69 srcs = ["__init__.py"],70 srcs_version = "PY2AND3",71 visibility = ["//visibility:public"],72 deps = ["//tensorflow/python"],73)74filegroup(75 name = "all_opensource_files",76 data = [77 ":all_files",78 "//tensorflow/c:all_files",79 "//tensorflow/cc:all_files",80 "//tensorflow/cc/saved_model:all_files",81 "//tensorflow/contrib:all_files",82 "//tensorflow/contrib/android:all_files",83 "//tensorflow/contrib/bayesflow:all_files",84 "//tensorflow/contrib/copy_graph:all_files",85 "//tensorflow/contrib/crf:all_files",86 "//tensorflow/contrib/cudnn_rnn:all_files",87 "//tensorflow/contrib/distributions:all_files",88 "//tensorflow/contrib/factorization:all_files",89 "//tensorflow/contrib/factorization/kernels:all_files",90 "//tensorflow/contrib/ffmpeg:all_files",91 "//tensorflow/contrib/ffmpeg/default:all_files",92 "//tensorflow/contrib/framework:all_files",93 "//tensorflow/contrib/graph_editor:all_files",94 "//tensorflow/contrib/grid_rnn:all_files",95 "//tensorflow/contrib/integrate:all_files",96 "//tensorflow/contrib/labeled_tensor:all_files",97 "//tensorflow/contrib/layers:all_files",98 "//tensorflow/contrib/layers/kernels:all_files",99 "//tensorflow/contrib/learn:all_files",100 "//tensorflow/contrib/learn/python/learn/datasets:all_files",101 "//tensorflow/contrib/linear_optimizer:all_files",102 "//tensorflow/contrib/lookup:all_files",103 "//tensorflow/contrib/losses:all_files",104 "//tensorflow/contrib/metrics:all_files",105 "//tensorflow/contrib/metrics/kernels:all_files",106 "//tensorflow/contrib/ndlstm:all_files",107 "//tensorflow/contrib/opt:all_files",108 "//tensorflow/contrib/rnn:all_files",109 "//tensorflow/contrib/seq2seq:all_files",110 "//tensorflow/contrib/session_bundle:all_files",111 "//tensorflow/contrib/session_bundle/example:all_files",112 "//tensorflow/contrib/slim:all_files",113 "//tensorflow/contrib/slim/python/slim/data:all_files",114 "//tensorflow/contrib/slim/python/slim/nets:all_files",115 "//tensorflow/contrib/solvers:all_files",116 "//tensorflow/contrib/specs:all_files",117 "//tensorflow/contrib/stat_summarizer:all_files",118 "//tensorflow/contrib/tensor_forest:all_files",119 "//tensorflow/contrib/tensor_forest/hybrid:all_files",120 "//tensorflow/contrib/tensorboard:all_files",121 "//tensorflow/contrib/testing:all_files",122 "//tensorflow/contrib/tfprof/python/tools/tfprof:all_files",123 "//tensorflow/contrib/training:all_files",124 "//tensorflow/contrib/util:all_files",125 "//tensorflow/core:all_files",126 "//tensorflow/core/debug:all_files",127 "//tensorflow/core/distributed_runtime:all_files",128 "//tensorflow/core/distributed_runtime/rpc:all_files",129 "//tensorflow/core/kernels:all_files",130 "//tensorflow/core/kernels/hexagon:all_files",131 "//tensorflow/core/ops/compat:all_files",132 "//tensorflow/core/platform/cloud:all_files",133 "//tensorflow/core/platform/default/build_config:all_files",134 "//tensorflow/core/platform/hadoop:all_files",135 "//tensorflow/core/util/ctc:all_files",136 "//tensorflow/core/util/tensor_bundle:all_files",137 "//tensorflow/examples/android:all_files",138 "//tensorflow/examples/how_tos/reading_data:all_files",139 "//tensorflow/examples/image_retraining:all_files",140 "//tensorflow/examples/label_image:all_files",141 "//tensorflow/examples/learn:all_files",142 "//tensorflow/examples/tutorials/estimators:all_files",143 "//tensorflow/examples/tutorials/mnist:all_files",144 "//tensorflow/examples/tutorials/word2vec:all_files",145 "//tensorflow/g3doc/how_tos/adding_an_op:all_files",146 "//tensorflow/g3doc/tutorials:all_files",147 "//tensorflow/go:all_files",148 "//tensorflow/models/embedding:all_files",149 "//tensorflow/models/image/alexnet:all_files",150 "//tensorflow/models/image/cifar10:all_files",151 "//tensorflow/models/image/imagenet:all_files",152 "//tensorflow/models/image/mnist:all_files",153 "//tensorflow/models/rnn:all_files",154 "//tensorflow/models/rnn/ptb:all_files",155 "//tensorflow/models/rnn/translate:all_files",156 "//tensorflow/python:all_files",157 "//tensorflow/python/debug:all_files",158 "//tensorflow/python/kernel_tests:all_files",159 "//tensorflow/python/saved_model:all_files",160 "//tensorflow/python/saved_model/example:all_files",161 "//tensorflow/python/tools:all_files",162 "//tensorflow/tensorboard:all_files",163 "//tensorflow/tensorboard/app:all_files",164 "//tensorflow/tensorboard/backend:all_files",165 "//tensorflow/tensorboard/components:all_files",166 "//tensorflow/tensorboard/components/vz_data_summary:all_files",167 "//tensorflow/tensorboard/components/vz_projector:all_files",168 "//tensorflow/tensorboard/lib:all_files",169 "//tensorflow/tensorboard/lib/python:all_files",170 "//tensorflow/tensorboard/scripts:all_files",171 "//tensorflow/tools/dist_test/server:all_files",172 "//tensorflow/tools/docker:all_files",173 "//tensorflow/tools/docker/notebooks:all_files",174 "//tensorflow/tools/docs:all_files",175 "//tensorflow/tools/git:all_files",176 "//tensorflow/tools/proto_text:all_files",177 "//tensorflow/tools/quantization:all_files",178 "//tensorflow/tools/test:all_files",179 "//tensorflow/tools/tfprof:all_files",180 "//tensorflow/tools/tfprof/internal:all_files",181 "//tensorflow/user_ops:all_files",182 "//third_party/hadoop:all_files",183 "//third_party/sycl:all_files",184 "//third_party/sycl/sycl:all_files",185 ],186 visibility = [":__subpackages__"],187)188# -------------------------------------------189# New rules should be added above this target.190# -------------------------------------------191cc_binary(192 name = "libtensorflow.so",193 linkshared = 1,194 deps = [195 "//tensorflow/c:c_api",196 "//tensorflow/core:tensorflow",197 ],198)199cc_binary(200 name = "libtensorflow_c.so",201 linkshared = 1,202 deps = [203 "//tensorflow/c:c_api",204 "//tensorflow/core:tensorflow",205 ],206)207cc_binary(208 name = "libtensorflow_cc.so",209 linkshared = 1,210 deps = [211 "//tensorflow/c:c_api",212 "//tensorflow/cc:cc_ops",213 "//tensorflow/core:tensorflow",214 ],...
__init__.py
Source:__init__.py
1from __future__ import division, absolute_import, print_function2import math3from .info import __doc__4from numpy.version import version as __version__5from .type_check import *6from .index_tricks import *7from .function_base import *8from .mixins import *9from .nanfunctions import *10from .shape_base import *11from .stride_tricks import *12from .twodim_base import *13from .ufunclike import *14from .histograms import *15from . import scimath as emath16from .polynomial import *17#import convertcode18from .utils import *19from .arraysetops import *20from .npyio import *21from .financial import *22from .arrayterator import Arrayterator23from .arraypad import *24from ._version import *25from numpy.core._multiarray_umath import tracemalloc_domain26__all__ = ['emath', 'math', 'tracemalloc_domain']27__all__ += type_check.__all__28__all__ += index_tricks.__all__29__all__ += function_base.__all__30__all__ += mixins.__all__31__all__ += shape_base.__all__32__all__ += stride_tricks.__all__33__all__ += twodim_base.__all__34__all__ += ufunclike.__all__35__all__ += arraypad.__all__36__all__ += polynomial.__all__37__all__ += utils.__all__38__all__ += arraysetops.__all__39__all__ += npyio.__all__40__all__ += financial.__all__41__all__ += nanfunctions.__all__42__all__ += histograms.__all__43from numpy._pytesttester import PytestTester44test = PytestTester(__name__)...
Using AI Code Generation
1import { storiesOf } from '@storybook/react';2import { action } from '@storybook/addon-actions';3import { linkTo } from '@storybook/addon-links';4import { withInfo } from '@storybook/addon-info';5import { withKnobs, text, boolean, number } from '@storybook/addon-knobs/react';6import Button from '../Button';7import Welcome from '../Welcome';8import { withReadme } from 'storybook-readme';9import readme from '../Button/README.md';10storiesOf('Button', module)11 .addDecorator(withKnobs)12 .addDecorator(withReadme(readme))13 .add('with text', () => (14 <Button onClick={action('clicked')}>{text('Label', 'Hello Button')}</Button>15 .add('with some emoji', () => (16 <Button onClick={action('clicked')}>{text('Label', 'π π π π―')}</Button>17 .add('with some emoji and action', () => (18 <Button onClick={action('clicked')}>{text('Label', 'π π π π―')}</Button>19 .add('with some emoji and action', () => (20 <Button onClick={action('clicked')}>{text('Label', 'π π π π―')}</Button>21 ));22import Button from 'Button';23<Button onClick={action('clicked')}>Hello Button</Button>24<Button onClick={action('clicked')}>Hello Button</Button>25{26 "scripts": {27 },
Using AI Code Generation
1storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);2storiesOf('Button', module)3 .add('with text', () => (4 <Button onClick={action('clicked')}>Hello Button</Button>5 .add('with some emoji', () => (6 <Button onClick={action('clicked')}>π π π π―</Button>7 ));8storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);9storiesOf('Button', module)10 .add('with text', () => (11 <Button onClick={action('clicked')}>Hello Button</Button>12 .add('with some emoji', () => (13 <Button onClick={action('clicked')}>π π π π―</Button>14 ));15storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);16storiesOf('Button', module)17 .add('with text', () => (18 <Button onClick={action('clicked')}>Hello Button</Button>19 .add('with some emoji', () => (20 <Button onClick={action('clicked')}>π π π π―</Button>21 ));
Using AI Code Generation
1import { All } from 'storybook-root-provider';2const { All } = require('storybook-root-provider');3const All = require('storybook-root-provider').All;4const obj = {5 d: () => 4,6 e: () => 5,7};8const result = All(obj);9console.log(result);10const obj = {11 d: () => 4,12 e: () => 5,13};14const result = AllExcept(obj, ['a', 'c']);15console.log(result);16const obj = {17 d: () => 4,18 e: () => 5,19};20const result = AllExceptOne(obj, 'a');21console.log(result);22const obj = {23 d: () => 4,24 e: () => 5,25};26const result = AllExceptTwo(obj, 'a', 'b');27console.log(result);
Using AI Code Generation
1import { storiesOf } from '@storybook/react';2import { All } from 'storybook-root';3import * as stories from '../src/stories';4storiesOf('All', module)5 .add('All', () => (6 <All stories={stories} />7 ));8MIT Β© [karanjthakkar](
Using AI Code Generation
1import { storiesOf } from '@storybook/react';2import { All } from 'storybook-addon-styled-component-theme/dist';3import { Button } from './button';4storiesOf('Button', module)5 .add('All', () => <All><Button /></All>);6import { storiesOf } from '@storybook/react';7import { All } from 'storybook-addon-styled-component-theme/dist';8import { Button } from './button';9storiesOf('Button', module)10 .add('All', () => <All><Button /></All>);11import { storiesOf } from '@storybook/react';12import { All } from 'storybook-addon-styled-component-theme/dist';13import { Button } from './button';14storiesOf('Button', module)15 .add('All', () => <All><Button /></All>);16import { storiesOf } from '@storybook/react';17import { All } from 'storybook-addon-styled-component-theme/dist';18import { Button } from './button';19storiesOf('Button', module)20 .add('All', () => <All><Button /></All>);21import { storiesOf } from '@storybook/react';22import { All } from 'storybook-addon-styled-component-theme/dist';23import { Button } from './button';24storiesOf('Button', module)25 .add('All', () => <All><Button /></All>);26import { storiesOf } from '@storybook/react';27import { All } from 'storybook-addon-styled-component-theme/dist';28import { Button } from './button';29storiesOf('Button', module)30 .add('All', () => <All><Button /></All>);31import { storiesOf } from '@storybook/react';32import { All } from 'storybook-addon-styled-component-theme/dist';33import { Button } from './button';34storiesOf('Button', module)35 .add('All', () => <All><Button /></All>);36import { storiesOf } from '@storybook/react';37import { All } from 'storybook-addon-styled-component-theme/dist';38import { Button } from './button';39storiesOf('Button',
Using AI Code Generation
1import { storiesOf } from "@storybook/react";2import { All } from "storybook-root";3storiesOf("All", module).add("All", () => <All />);4import { storiesOf } from "@storybook/react";5import { All } from "storybook-root";6storiesOf("All", module).add("All", () => <All />);7import { storiesOf } from "@storybook/react";8import { All } from "storybook-root";9storiesOf("All", module).add("All", () => <All />);10import { storiesOf } from "@storybook/react";11import { All } from "storybook-root";12storiesOf("All", module).add("All", () => <All />);13import { storiesOf } from "@storybook/react";14import { All } from "storybook-root";15storiesOf("All", module).add("All", () => <All />);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!