'Compute std of a dataset. A limit can be specified for faster
computation, considering only \'limit\' first elements.'

def _compute_global_std(self, dataset, session, limit=None):

    _dataset = dataset
    std = 0.0
    if isinstance(limit, int):
        _dataset = _dataset[:limit]
    if (isinstance(_dataset, np.ndarray) and (not self.global_std_pc)):
        std = np.std(_dataset)
    else:
        for i in range(len(dataset)):
            if (not self.global_std_pc):
                std += (np.std(dataset[i]) / len(dataset))
            else:
                std += (np.std(dataset[i], axis=(0, 1), keepdims=True) / len(dataset))[0][0]
    self.global_std.assign(std, session)
    return std
