FLatten the whole map
323906
function flattenAll() {
        var result = [];
        for (var role in permissions) {
            result = result.concat(flatten(role));
        }
        return uniq(result);
    }
805537
private Stream<Object> flatten(final Object o) {
        if (o instanceof Map<?, ?>) {
            return ((Map<?, ?>) o).values().stream().flatMap(this::flatten);
        }
        return Stream.of(o);
    }
669898
def flatten(self):
        
        size = prod(self.shape[:-1])
        return self.reshape(size, self.shape[-1])
1337522
function flattenInternal(output, element) {
  if (element) {
    element.forEach((obj) => {
      if (Array.isArray(obj)) {
        flattenInternal(output, obj);
      } else {
        output.push(obj);
      }
    });
  }
}
1351821
function flatten(source) {
  var output = {};

  function step(object, prev) {
    for (var key in object) {
      if (has.call(object, key)) {
        var value = object[key];
        var newKey = prev ? prev + ' ' + key : key;

        if (!is.array(value) && is.object(value)) {
          return step(value, newKey);
        }

        output[newKey] = value;
      }
    }
  }

  step(source);

  return output;
}
1339467
@SuppressWarnings("unchecked")
  Map<String, Object> flatten(Map<String, Object> source) {
    Map<String, Object> result = new LinkedHashMap<>();

    for (String key : source.keySet()) {
      Object value = source.get(key);

      if (value instanceof Map) {
        Map<String, Object> subMap = flatten((Map<String, Object>) value);

        for (String subkey : subMap.keySet()) {
          result.put(key + "." + subkey, subMap.get(subkey));
        }
      } else if (value instanceof Collection) {
        StringBuilder joiner = new StringBuilder();
        String separator = "";

        for (Object element : ((Collection) value)) {
          Map<String, Object> subMap = flatten(Collections.singletonMap(key, element));
          joiner
              .append(separator)
              .append(subMap.entrySet().iterator().next().getValue().toString());

          separator = ",";
        }

        result.put(key, joiner.toString());
      } else {
        result.put(key, value);
      }
    }

    return result;
  }
828031
function flatten(arr) {
  if (!isArray(arr)) {
    return arr;
  }
  var result = [];
  each(arr, function (item) {
    if (isArray(item)) {
      each(item, function (subItem) {
        result.push(subItem);
      });
    } else {
      result.push(item);
    }
  });
  return result;
}
747241
def flatMap(f: Callable, xs: Iterable) -> List:
    
    return flatten(lmap(f, xs))
696975
function flatten( sections ) {
	var out,
		key,
		i;

	out = {};
	for ( i = 0; i < sections.length; i++ ) {
		key = 'section:' + sections[ i ].replace( /\./, ':' );
		out[ key ] = true;
	}
	return out;
}
558419
function flatten(data, pre) {
  const prefix = pre || '';
  const keys = Object.keys(data);
  const result = {};
  keys.forEach((k) => {
    const value = data[k];
    const key = [prefix, k].join('-');
    if (isObject(value)) {
      Object.assign(result, flatten(value, key));
    } else {
      result[key] = value;
    }
  });
  return result;
}
746069
function flatten (arr) {
  return arr.reduce(function (acc, curr) {
    return acc.concat(Array.isArray(curr) ? flatten(curr) : curr)
  }, [])
}
381702
def flatten(x):
    
    # Lifted from: http://stackoverflow.com/a/406822/263969
    result = []
    for el in x:
        if hasattr(el, "__iter__") and not isinstance(el, basestring):
            result.extend(flatten(el))
        else:
            result.append(el)
    return result
1096026
def flatten_all_but_last(a):
  """"""
  ret = tf.reshape(a, [-1, tf.shape(a)[-1]])
  if not tf.executing_eagerly():
    ret.set_shape([None] + a.get_shape().as_list()[-1:])
  return ret
942258
def flatten(self, D):
        '''
        '''

        if not isinstance(D, dict):
            return D

        result = {}
        for k,v in D.items():
            if isinstance(v, dict):
                for _k,_v in self.flatten(v).items():
                    result['.'.join([k,_k])] = _v
            else:
                result[k] = v
        return result
535866
def flatten(value):
    """"""
    if isinstance(value, np.ndarray):
        def unflatten(vector):
            return np.reshape(vector, value.shape)
        return np.ravel(value), unflatten

    elif isinstance(value, float):
        return np.array([value]), lambda x: x[0]

    elif isinstance(value, tuple):
        if not value:
            return np.array([]), lambda x: ()

        flattened_first, unflatten_first = flatten(value[0])
        flattened_rest, unflatten_rest = flatten(value[1:])

        def unflatten(vector):
            N = len(flattened_first)
            return (unflatten_first(vector[:N]),) + unflatten_rest(vector[N:])

        return np.concatenate((flattened_first, flattened_rest)), unflatten

    elif isinstance(value, list):
        if not value:
            return np.array([]), lambda x: []
        flattened_first, unflatten_first = flatten(value[0])
        flattened_rest, unflatten_rest = flatten(value[1:])

        def unflatten(vector):
            N = len(flattened_first)
            return [unflatten_first(vector[:N])] + unflatten_rest(vector[N:])

        return np.concatenate((flattened_first, flattened_rest)), unflatten

    elif isinstance(value, dict):
        flattened = []
        unflatteners = []
        lengths = []
        keys = []
        for k, v in sorted(value.items(), key=itemgetter(0)):
            cur_flattened, cur_unflatten = flatten(v)
            flattened.append(cur_flattened)
            unflatteners.append(cur_unflatten)
            lengths.append(len(cur_flattened))
            keys.append(k)

        def unflatten(vector):
            split_ixs = np.cumsum(lengths)
            pieces = np.split(vector, split_ixs)
            return {key: unflattener(piece)
                    for piece, unflattener, key in zip(pieces,
                                                       unflatteners,
                                                       keys)}

        return np.concatenate(flattened), unflatten

    else:
        raise Exception("Don't know how to flatten type {}".format(type(value))
                        )
996260
function flattenDownDepth (array, result, depth) {
  depth--

  for (var i = 0; i < array.length; i++) {
    var value = array[i]

    if (depth > -1 && Array.isArray(value)) {
      flattenDownDepth(value, result, depth)
    } else {
      result.push(value)
    }
  }

  return result
}
730596
public Map flatten(Map target) {
        if (target == null)
            target = new ConfigObject();
        populate("", target, this);

        return target;
    }