<commit_before>import hyperchamber as hc
import tensorflow as tf
import numpy as np
import types
import uuid
import importlib
import hypergan
from tensorflow.python.ops.variables import RefVariable
from hypergan.ops.tensorflow import layer_regularizers
from hypergan.ops.tensorflow.activations import lrelu, selu, swish
from hypergan.ops.tensorflow.extended_ops import *
from hypergan.ops.tensorflow.sn import spectral_normed_weight
class TensorflowOps:
    def __init__(self, config={}, device="/gpu:0"):
        config = hc.Config(config)
        self.config = config
        dtype = config.dtype or "float32"
        initializer = self.config_option("initializer", "he_normal")

        self.dtype = self.parse_dtype(dtype)
        self.scope_count = 0
        self.description = ''
        self.weights = []
        self.biases = []
        self.device = config.device
        self.initialized = False
        self._reuse = False
        self.reuse_scope_count = 0
        self.reuse_context = 0
        self.initializer = self.lookup_initializer(initializer, config)

    def config_option(self, name, default=None, config=None):
        if config is None:
            config = self.config
        if name in config:
            return config[name]
        if "defaults" in config:
            if name in config["defaults"]:
                return config["defaults"][name]
        return default

    def lookup_initializer(self, name, config):
        if name == 'orthogonal':
            orthogonal_gain = self.config_option("orthogonal_gain", 1.0, config)
            return self.orthogonal_initializer(orthogonal_gain)
        elif name == 'he_normal':
            return self.he_normal_initializer()
        elif name == 'xavier':
            return self.xavier_initializer()
        elif name == 'stylegan':
            return self.stylegan_initializer(config or self.config)
        elif name == 'random_normal':
            return self.random_initializer(self.config_option("random_stddev", 0.02, config))
        else:
            raise Exception("initializer not found", name)

    def assert_tensor(self, net):
        if type(net) != tf.Tensor and type(net) != tf.Variable and type(net) != RefVariable:
            raise Exception("Expected a Tensor but received", net)

    def add_weights(self, weights):
        if not isinstance(weights, list):
            weights = [weights]
        self.weights += weights

    def variables(self):
        return self.biases + self.weights

    def random_initializer(self, stddev):<commit_msg>[fix] Variable test<commit_after>import hyperchamber as hc
import tensorflow as tf
import numpy as np
import types
import uuid
import importlib
import hypergan
from tensorflow.python.ops.variables import RefVariable
from hypergan.ops.tensorflow import layer_regularizers
from hypergan.ops.tensorflow.activations import lrelu, selu, swish
from hypergan.ops.tensorflow.extended_ops import *
from hypergan.ops.tensorflow.sn import spectral_normed_weight
class TensorflowOps:
    def __init__(self, config={}, device="/gpu:0"):
        config = hc.Config(config)
        self.config = config
        dtype = config.dtype or "float32"
        initializer = self.config_option("initializer", "he_normal")

        self.dtype = self.parse_dtype(dtype)
        self.scope_count = 0
        self.description = ''
        self.weights = []
        self.biases = []
        self.device = config.device
        self.initialized = False
        self._reuse = False
        self.reuse_scope_count = 0
        self.reuse_context = 0
        self.initializer = self.lookup_initializer(initializer, config)

    def config_option(self, name, default=None, config=None):
        if config is None:
            config = self.config
        if name in config:
            return config[name]
        if "defaults" in config:
            if name in config["defaults"]:
                return config["defaults"][name]
        return default

    def lookup_initializer(self, name, config):
        if name == 'orthogonal':
            orthogonal_gain = self.config_option("orthogonal_gain", 1.0, config)
            return self.orthogonal_initializer(orthogonal_gain)
        elif name == 'he_normal':
            return self.he_normal_initializer()
        elif name == 'xavier':
            return self.xavier_initializer()
        elif name == 'stylegan':
            return self.stylegan_initializer(config or self.config)
        elif name == 'random_normal':
            return self.random_initializer(self.config_option("random_stddev", 0.02, config))
        else:
            raise Exception("initializer not found", name)

    def assert_tensor(self, net):
        if type(net) != tf.Tensor and not isinstance(net, tf.Variable) and type(net) != RefVariable:
            raise Exception("Expected a Tensor but received", net)

    def add_weights(self, weights):
        if not isinstance(weights, list):
            weights = [weights]
        self.weights += weights

    def variables(self):
        return self.biases + self.weights

    def random_initializer(self, stddev):
{'fraction_non_alphanumeric': 0.09163735834310277, 'fraction_numerical': 0.0042985541227041815, 'mean_word_length': 2.674802584350323, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '642423', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1394, 'n_words': 378}