See docs for `Model` abstract base class.
556507
def mu(self):
        """"""
        mu = self._models[0].mu
        assert all([mu == model.mu for model in self._models])
        return mu
1072202
def get_value(self, meta, base_model_meta, mcs_args: McsArgs):
        """"""
        if mcs_args.Meta.abstract:
            return None
        value = getattr(base_model_meta, self.name, {}) or {}
        value.update(getattr(meta, self.name, {}))
        return value
1238077
def find_model(self, constructor, constraints=None, *, columns=None, table_name=None,
                 order_by=None):
    """"""
    return self._find_model(constructor, table_name or constructor.table_name, constraints,
                            columns=columns, order_by=order_by)
792074
def _get_kind(cls):
    
    bases = cls._get_hierarchy()
    if not bases:
      # We have to jump through some hoops to call the superclass'
      # _get_kind() method.  First, this is called by the metaclass
      # before the PolyModel name is defined, so it can't use
      # super(PolyModel, cls)._get_kind().  Second, we can't just call
      # Model._get_kind() because that always returns 'Model'.  Hence
      # the 'im_func' hack.
      return model.Model._get_kind.im_func(cls)
    else:
      return bases[0]._class_name()
727037
def _initialize_references(model_class, name, bases, attrs):
    """"""
    model_class._references = {}
    h = {}
    deferred = []
    for k, v in attrs.iteritems():
        if isinstance(v, ReferenceField):
            model_class._references[k] = v
            v.name = v.name or k
            att = Attribute(name=v.attname)
            h[v.attname] = att
            setattr(model_class, v.attname, att)
            refd = _initialize_referenced(model_class, v)
            if refd:
                deferred.append(refd)
    attrs.update(h)
    return deferred
133007
def doc(model):
    
    ins = inspect(model)

    return SaModelDoc(
        name=model.__name__,
        table=[t.name for t in ins.tables],
        doc=getdoc(ins.class_),
        columns=_model_columns(ins),
        primary=_model_primary(ins),
        foreign=_model_foreign(ins),
        unique=_model_unique(ins),
        relations=_model_relations(ins)
    )
990810
function BaseMiddleware (Model, key) {
  // constructor
  var instance = function (req, res, next) {
    return instance.exec()(req, res, next);
  };
  instance.Model = Model;
  instance.methodChain = [];

  instance.__proto__ = this.__proto__;

  instance.setKey = function (key) {
    key = key || Model.modelName.toLowerCase();
    instance.modelKey = inflect.singularize(key);
    instance.collectionKey = inflect.pluralize(key);
  };
  instance.setKey(key);
  return instance;
}
1067434
def _determine_rule_types(self, metamodel):
        """"""

        def _determine_rule_type(cls):
            """
            Determine rule type (abstract, match, common) and inherited
            classes.
            """

            if cls in resolved_classes:
                return
            resolved_classes.add(cls)

            # If there are attributes collected than this is a common
            # rule
            if len(cls._tx_attrs) > 0:
                if cls._tx_type != RULE_COMMON:
                    cls._tx_type = RULE_COMMON
                    has_change[0] = True
                return

            rule = cls._tx_peg_rule

            # Check if this rule is abstract. Abstract are root rules which
            # haven't got any attributes and reference at least one non-match
            # rule.
            abstract = False
            if rule.rule_name and cls.__name__ != rule.rule_name:
                # Special case. Body of the rule is a single rule reference and
                # the referenced rule is not match rule.
                target_cls = metamodel[rule.rule_name]
                _determine_rule_type(target_cls)
                abstract = target_cls._tx_type != RULE_MATCH
            else:
                # Find at least one referenced rule that is not match rule by
                # going down the parser model and finding root rules.
                def _has_nonmatch_ref(rule):
                    for r in rule.nodes:
                        if r.root:
                            _determine_rule_type(r._tx_class)
                            result = r._tx_class._tx_type != RULE_MATCH
                        else:
                            result = _has_nonmatch_ref(r)
                        if result:
                            return True
                abstract = _has_nonmatch_ref(rule)

            if abstract and cls._tx_type != RULE_ABSTRACT:
                cls._tx_type = RULE_ABSTRACT
                has_change[0] = True
                # Add inherited classes to this rule's meta-class
                if rule.rule_name and cls.__name__ != rule.rule_name:
                    if rule._tx_class not in cls._tx_inh_by:
                        cls._tx_inh_by.append(rule._tx_class)
                else:
                    # Recursively append all referenced classes.
                    def _add_reffered_classes(rule, inh_by, start=False):
                        if rule.root and not start:
                            if hasattr(rule, '_tx_class'):
                                _determine_rule_type(rule._tx_class)
                                if rule._tx_class._tx_type != RULE_MATCH and\
                                        rule._tx_class not in inh_by:
                                    inh_by.append(rule._tx_class)
                        else:
                            for r in rule.nodes:
                                _add_reffered_classes(r, inh_by)

                    if type(rule) is OrderedChoice:
                        for r in rule.nodes:
                            _add_reffered_classes(r, cls._tx_inh_by)
                    else:
                        _add_reffered_classes(rule, cls._tx_inh_by, start=True)

        # Multi-pass rule type resolving to support circular rule references.
        # `has_change` is a list to support outer scope variable change in
        # Python 2.x
        has_change = [True]
        while has_change[0]:
            has_change[0] = False
            resolved_classes = set()
            for cls in metamodel:
                _determine_rule_type(cls)
1286814
def abstract(cls):
    ''' 

    '''
    if not issubclass(cls, HasProps):
        raise TypeError("%s is not a subclass of HasProps" % cls.__name__)

    # running python with -OO will discard docstrings -> __doc__ is None
    if cls.__doc__ is not None:
        cls.__doc__ += _ABSTRACT_ADMONITION

    return cls
414738
def get_model(model, ctx, opt):
    """"""
    kwargs = {'ctx': ctx, 'pretrained': opt.use_pretrained, 'classes': classes}
    if model.startswith('resnet'):
        kwargs['thumbnail'] = opt.use_thumbnail
    elif model.startswith('vgg'):
        kwargs['batch_norm'] = opt.batch_norm

    net = models.get_model(model, **kwargs)
    if opt.resume:
        net.load_parameters(opt.resume)
    elif not opt.use_pretrained:
        if model in ['alexnet']:
            net.initialize(mx.init.Normal())
        else:
            net.initialize(mx.init.Xavier(magnitude=2))
    net.cast(opt.dtype)
    return net
570435
def base_concrete_modeladmin(self):
        
        candidates = [self.__class__]
        while candidates:
            candidate = candidates.pop()
            if ContentTypedAdmin in candidate.__bases__:
                return candidate
            candidates.extend(candidate.__bases__)

        raise Exception("Can't find base concrete ModelAdmin class.")
821257
def get_external_model(class_object):
    
    class_abstract = class_object.CodenerixMeta.abstract
    if class_abstract is not None:
        for class_related in class_object._meta.related_objects:
            if issubclass(class_related.related_model, class_abstract):
                return class_related.related_model
    return None
1170356
def abstract(cls, predstr):
        """"""
        lemma, pos, sense, _ = split_pred_string(predstr)
        return cls(Pred.ABSTRACT, lemma, pos, sense, predstr)
357240
def _algebraic_data(metaclass):
  """"""
  def wrapper(cls):
    cls.__bases__ += (metaclass,)
    cls._list_fields = metaclass._list_fields
    return cls
  return wrapper
201058
def generate_models(args):
  """"""
  data_table = get_data_table(args.filename)
  tables = to_tables(data_table.rows_to_dicts())
  attr_indent = "\n" + args.indent * 2
  attr_sep = "," + attr_indent

  for tname, cols in tables.items():
    model_name = table_to_model_name(tname, list(cols.values())[0]["table_schema"])
    pk_cols, oth_cols = split_pks(cols)
    timestamps = get_timestamps(cols, args.created_at_col_name, args.updated_at_col_name)
    is_auto = len(pk_cols) == 1 and cols[pk_cols[0]]["is_auto"] == "t"

    attrs = OrderedDict()
    for cname in oth_cols:
      if cname not in timestamps:
        attrs[cname] = None

    print(_MODEL_SOURCE.format(
      class_name=model_name,
      base_class_name="ModelBase",
      indent=args.indent,
      table_name=repr(tname),
      pk_name=repr(pk_cols[0] if len(pk_cols) == 1 else pk_cols),
      pk_is_auto=is_auto,
      timestamps=timestamps,
      attrs="dict(" + attr_indent + attr_sep.join("{0}={1}".format(k, v) for k, v in attrs.items()) + ")"))
    print()
980419
def model_classes(classes = Map.model_classes)
      nested_hash = classes.each_with_object({}) do |klass, hash|
        hash[klass] = Node.new(klass)
      end
      nested_hash.each do |klass, node|
        node.parent = parent = nested_hash[klass.superclass]
        parent.children << node if parent
      end
      nested_hash.values.select { |v| v.parent.nil? }
    end
1276480
def get_model(model:nn.Module):
    ""
    return model.module if isinstance(model, (DistributedDataParallel, nn.DataParallel)) else model