# Path: gelato/_compile.py
# def define(name, template, namespace, frame_offset=1):
#     try:
#         exec_(template, namespace)
#     except SyntaxError as e:
#         raise SyntaxError(str(e) + ':\n' + template)
#     result = namespace[name]
#     frm = inspect.stack()[frame_offset]
#     mod = inspect.getmodule(frm[0])
#     result.__name__ = name
#     if mod is None:
#         result.__module__ = '__main__'
#     else:
#         result.__module__ = mod.__name__
#     return result


import six
import copy
import itertools
import functools
import inspect
import pymc3 as pm
from theano import theano
from theano.tensor.basic import _tensor_py_operators
from lasagne import init
from gelato._compile import define
class BaseSpec(init.Initializer):
    _counter = itertools.count(0)
    name = None
    tag = 'default'
    _shape = None

    def auto(self):
        if self.name is None:
            return 'auto_{}'.format(next(type(self)._counter))
        else:
            name = self.name
            self.name = None
            return name

    def with_name(self, name):
        self.name = name
        return self

    def with_tag(self, tag):
        self.tag = tag
        return self

    def with_shape(self, shape):
        if callable(shape):
            self._shape = shape
        elif shape is not None:
            self._shape = shape
            self.tag = 'custom'
        else:
            self._shape = None

# Path: gelato/_compile.py
# def define(name, template, namespace, frame_offset=1):
#     try:
#         exec_(template, namespace)
#     except SyntaxError as e:
#         raise SyntaxError(str(e) + ':\n' + template)
#     result = namespace[name]
#     frm = inspect.stack()[frame_offset]
#     mod = inspect.getmodule(frm[0])
#     result.__name__ = name
#     if mod is None:
#         result.__module__ = '__main__'
#     else:
#         result.__module__ = mod.__name__
#     return result


# Path: gelato/specs/base.py
import six
import copy
import itertools
import functools
import inspect
import pymc3 as pm
from theano import theano
from theano.tensor.basic import _tensor_py_operators
from lasagne import init
from gelato._compile import define

class BaseSpec(init.Initializer):
    _counter = itertools.count(0)
    name = None
    tag = 'default'
    _shape = None

    def auto(self):
        if self.name is None:
            return 'auto_{}'.format(next(type(self)._counter))
        else:
            name = self.name
            self.name = None
            return name

    def with_name(self, name):
        self.name = name
        return self

    def with_tag(self, tag):
        self.tag = tag
        return self

    def with_shape(self, shape):
        if callable(shape):
            self._shape = shape
        elif shape is not None:
            self._shape = shape
            self.tag = 'custom'
        else:
            self._shape = None

            self.tag = 'default'