construct and return generator
505062
def get_generator():
    
    g_net = gluon.nn.Sequential()
    with g_net.name_scope():

        g_net.add(gluon.nn.Conv2DTranspose(
            channels=512, kernel_size=4, strides=1, padding=0, use_bias=False))
        g_net.add(gluon.nn.BatchNorm())
        g_net.add(gluon.nn.LeakyReLU(0.2))

        g_net.add(gluon.nn.Conv2DTranspose(
            channels=256, kernel_size=4, strides=2, padding=1, use_bias=False))
        g_net.add(gluon.nn.BatchNorm())
        g_net.add(gluon.nn.LeakyReLU(0.2))

        g_net.add(gluon.nn.Conv2DTranspose(
            channels=128, kernel_size=4, strides=2, padding=1, use_bias=False))
        g_net.add(gluon.nn.BatchNorm())
        g_net.add(gluon.nn.LeakyReLU(0.2))

        g_net.add(gluon.nn.Conv2DTranspose(
            channels=64, kernel_size=4, strides=2, padding=1, use_bias=False))
        g_net.add(gluon.nn.BatchNorm())
        g_net.add(gluon.nn.LeakyReLU(0.2))

        g_net.add(gluon.nn.Conv2DTranspose(channels=3, kernel_size=4, strides=2, padding=1, use_bias=False))
        g_net.add(gluon.nn.Activation('tanh'))

    return g_net
94133
def __construct_really (project, name, target_type, prop_set, sources):
    
    if __debug__:
        from .targets import ProjectTarget
        assert isinstance(project, ProjectTarget)
        assert isinstance(name, basestring) or name is None
        assert isinstance(target_type, basestring)
        assert isinstance(prop_set, property_set.PropertySet)
        assert is_iterable_typed(sources, virtual_target.VirtualTarget)
    viable_generators = find_viable_generators (target_type, prop_set)

    result = []

    dout("      *** %d viable generators" % len (viable_generators))

    generators_that_succeeded = []

    for g in viable_generators:
        __active_generators.append(g)
        r = try_one_generator (project, name, g, target_type, prop_set, sources)
        del __active_generators[-1]

        if r:
            generators_that_succeeded.append(g)
            if result:
                output = cStringIO.StringIO()
                print >>output, "ambiguity found when searching for best transformation"
                print >>output, "Trying to produce type '%s' from: " % (target_type)
                for s in sources:
                    print >>output, " - " + s.str()
                print >>output, "Generators that succeeded:"
                for g in generators_that_succeeded:
                    print >>output, " - " + g.id()
                print >>output, "First generator produced: "
                for t in result[1:]:
                    print >>output, " - " + str(t)
                print >>output, "Second generator produced:"
                for t in r[1:]:
                    print >>output, " - " + str(t)
                get_manager().errors()(output.getvalue())
            else:
                result = r;

    return result;
1165779
function Generator(sOutputFolder, bPrettyPrint) {
	if (!(this instanceof Generator)) {
		return new Generator(sOutputFolder, bPrettyPrint);
	}
	this._sOutputFolder = sOutputFolder;
	this._bPrettyPrint = bPrettyPrint;
	events.EventEmitter.call(this);
}
971233
function generate (generatorName, name, flags) {
  let generator

  switch (generatorName) {
    case 'app':
      generator = new generators.App(name)
      break
    case 'controller':
      generator = new generators.Controller(name, flags)
      break
    case 'model':
      generator = new generators.Model(name, flags)
      break
    case 'view':
      console.log(`generating view ${name} ...`)
      console.log('NotImplemented. View generation not yet available')
      break
    case 'migration':
      generator = new generators.Migration(name, flags)
      break
    case 'scaffold':
      console.log(`generating scaffold ${name} ...`)
      console.log('NotImplemented. Scaffold generation not yet available')
      break
    case 'user':
      console.log(`generating user ${name} ...`)
      console.log('NotImplemented. User generation not yet available')
      break
    default:
      if (!name) {
        return generate('app', generatorName)
      }
  }

  if (!generator) {
    return cli.showHelp(0)
  }

  return generator.run()
}
409066
def _generator_other(self):
        """"""
        for path in self.paths:
            for root, dnames, fnames in self._walker(path):
                yield from self._generator_rebase(dnames, root)
                yield from self._generator_rebase(fnames, root)
1121426
def spawn(func, kwargs):
    """"""
    t = threading.Thread(target=func, kwargs=kwargs)
    t.start()
    yield
    t.join()
619579
function generatorToPromise(fn) {
    if (typeof fn !== 'function') {
        throw Error('fn is not a function');
    }
    if (!isGenerator(fn)) {
        // assume it's Promise-based
        return fn;
    }
    return co.wrap(fn);
}
775158
def generator(self, t):
        """"""
        self.check_fit()

        return (1.0 / self.theta) * (np.power(t, -self.theta) - 1)
1333177
def cycle_generator(cycle, step=1, begin=(0, 0), end=None):
    '''
        
    '''
    (cycle_begin, cycle_end) = cycle
    (major, minor) = begin
    (end_major, end_minor) = end if end is not None else (None, None)

    while True:
        if end is not None and (major > end_major or (major == end_major and minor > end_minor)):
            return
        yield (major, minor)
        minor += step
        if minor > cycle_end:
            major += 1
            minor = cycle_begin
891663
def tuple_of(*generators):
    

    class TupleOfGenerators(ArbitraryInterface):
        """
        A closure class around the generators specified above, which
        generates a tuple of the generators.
        """

        @classmethod
        def arbitrary(cls):
            """
            Generate a tuple of the enclosed generators.
            """
            return tuple([
                arbitrary(generator) for generator in generators
                if generator is not tuple
            ])

    TupleOfGenerators.__name__ = ''.join([
        'tuple_of(', ', '.join(generator.__name__ for generator in generators),
        ')'
    ])
    return TupleOfGenerators
839336
def parse(self, generator):
        """"""
        gen = iter(generator)
        for line in gen:
            block = {}
            for rule in self.rules:
                if rule[0](line):
                    block = rule[1](line, gen)
                    break
            yield block
1361569
def get_results_generator(future_list, timeout=None, sort_by_completed=False):
    """"""
    try:
        # python2 not support yield from
        if sort_by_completed:
            for future in as_completed(future_list, timeout=timeout):
                yield future.x
        else:
            for future in future_list:
                yield future.x
    except TimeoutError:
        return
872373
def generate(node, environment, name, filename, stream=None,
             defer_init=False, optimized=True):
    """"""
    if not isinstance(node, nodes.Template):
        raise TypeError('Can\'t compile non template nodes')
    generator = environment.code_generator_class(environment, name, filename,
                                                 stream, defer_init,
                                                 optimized)
    generator.visit(node)
    if stream is None:
        return generator.stream.getvalue()
519848
def cached_generator(function):
    """"""
    cache_variable = '_cached_' + function.__name__
    @wraps(function)
    def function_wrapper(obj, *args, **kwargs):
        # values are cached in a list stored in the object
        try:
            for item in getattr(obj, cache_variable):
                yield item
        except AttributeError:
            setattr(obj, cache_variable, [])
            cache = getattr(obj, cache_variable)
            for item in function(obj, *args, **kwargs):
                cache.append(item)
                yield item
    return function_wrapper
1322122
function genIterator (obj) {
    if (obj) {
        var gen = obj[_.Promise.Symbol.iterator];
        if (_.isFunction(gen)) {
            return gen.call(obj);
        }

        if (obj instanceof Array) {
            return new ArrIter(obj);
        }

        if (_.isFunction(obj.next)) {
            return obj;
        }
    }
    throw new TypeError('invalid_argument');
}
889096
public function fetchAllGenerator(): Generator
    {
        if (!$this->wasExecuted()) {
            $this->exec();
        }

        $statement = $this->getAdapter()->getStatement();

        while ($record = $statement->fetch(PDO::FETCH_ASSOC)) {
            yield $record;
        }

        $statement->closeCursor();
    }
83827
function(name) {
        debug('.matchGenerator', name);
        for (var key in this.generators) {
          var generator = this.generators[key];
          if (generator.isMatch(name)) {
            return generator;
          }
        }
      }