:type transformer: sklearn.tree.tree.BaseDecisionTree
        :type path: str
        :type model_name: str
        :type serialize_node: bool
        :param transformer:
        :param path:
        :param model_name:
        :return:
325940
def serialize_to_bundle(self, transformer, path, model_name, serialize_node=True):
        

        # Define attributes
        attributes = list()
        attributes.append(('num_features', transformer.n_features_))
        if isinstance(transformer, DecisionTreeClassifier):
            attributes.append(('num_classes', int(transformer.n_classes_)))

        inputs = []
        outputs = []
        if serialize_node:
            # define node inputs and outputs
            inputs = [{
                      "name": transformer.input_features,
                      "port": "features"
                    }]

            outputs = [{
                      "name": transformer.prediction_column,
                      "port": "prediction"
                    }]

        self.serialize(transformer, path, model_name, attributes, inputs, outputs, node=serialize_node)

        # Serialize tree.json
        tree_path = "{}/{}.node/tree.json".format(path, model_name)
        if not serialize_node:
            tree_path = "{}/{}/tree.json".format(path, model_name)
        with open(tree_path, 'w') as outfile:
            self.serialize_tree(transformer, transformer.feature_names, outfile)
335780
def load_model(file_path):
    
    if not path.exists(file_path):
        raise FileNotFoundError("{0} was not found.".format(file_path))
    model = onnx_proto.ModelProto()
    with open(file_path, 'rb') as f:
        model.ParseFromString(f.read())
    return model
541412
def get_schema_node(self, path: SchemaPath) -> Optional[SchemaNode]:
        
        return self.schema.get_schema_descendant(
            self.schema_data.path2route(path))
755817
def load(self, path):
        
        self.dct = wrapper.Dictionary()
        self.guide = wrapper.Guide()

        with open(path, 'rb') as f:
            self.dct.read(f)
            self.guide.read(f)

        return self
1045830
def find_or_create_by_path(path, attributes = {})
      subpath = _ct.build_ancestry_attr_path(path, attributes)
      return self if subpath.empty?

      found = find_by_path(subpath, attributes)
      return found if found

      attrs = subpath.shift
      _ct.with_advisory_lock do
        # shenanigans because children.create is bound to the superclass
        # (in the case of polymorphism):
        child = self.children.where(attrs).first || begin
          # Support STI creation by using base_class:
          _ct.create(self.class, attrs).tap do |ea|
            # We know that there isn't a cycle, because we just created it, and
            # cycle detection is expensive when the node is deep.
            ea._ct_skip_cycle_detection!
            self.children << ea
          end
        end
        child.find_or_create_by_path(subpath, attributes)
      end
    end
125045
def get_transformer(cls, method_name):
        """"""
        transform_function = getattr(cls, method_name)
        assert callable(transform_function)

        def transformer_method(self, node):
            kwargs = {}
            if inspect.signature(transform_function).parameters.get("helper"):
                kwargs["helper"] = self.helper
            return transform_function(node, **kwargs)

        return transformer_method
883640
def _helper_for_model(self, model_type):
        
        if model_type is models.containers.Container:
            return self.containers
        if model_type is models.images.Image:
            return self.images
        if model_type is models.networks.Network:
            return self.networks
        if model_type is models.volumes.Volume:
            return self.volumes

        raise ValueError('Unknown model type {}'.format(model_type))
1126620
function get_path(context, path, options = {}) {
	const node = get_node_by_path(context, path, options);
	return node_type(node) == NodeTypes.NODE
		? get_all_node_props(context, node, options)
		: node;
}
447182
def load_metagraph(model_path_prefix: Union[str, Path]) -> tf.train.Saver:
    

    model_path_prefix = str(model_path_prefix)
    metagraph = tf.train.import_meta_graph(model_path_prefix + ".meta")
    return metagraph
313476
def load_model_from_path(model_path, meta=False, **overrides):
    """"""
    from .tokenizer_loader import TokenizerLoader

    if not meta:
        meta = get_model_meta(model_path)
    tokenizer_loader = TokenizerLoader(meta=meta, **overrides)
    tokenizers = meta.get('tokenizers', [])
    disable = overrides.get('disable', [])
    if tokenizers is True:
        tokenizers = TokenizerLoader.Defaults.tokenizers
    elif tokenizers in (False, None):
        tokenizers = []
    for tokenizer_name in tokenizers:
        if tokenizer_name not in disable:
            config = meta.get('tokenizer_args', {}).get(tokenizer_name, {})
            component = tokenizer_loader.create_tokenizer(tokenizer_name, config=config)
            tokenizer_loader.add_tokenizer(component, name=tokenizer_name)
    return tokenizer_loader.from_disk(model_path)
1146024
def _serialize(self, target_obj, data_type=None, **kwargs):
        
        key_transformer = kwargs.get("key_transformer", self.key_transformer)
        keep_readonly = kwargs.get("keep_readonly", False)
        if target_obj is None:
            return None

        attr_name = None
        class_name = target_obj.__class__.__name__

        if data_type:
            return self.serialize_data(
                target_obj, data_type, **kwargs)

        if not hasattr(target_obj, "_attribute_map"):
            data_type = type(target_obj).__name__
            if data_type in self.basic_types.values():
                return self.serialize_data(
                    target_obj, data_type, **kwargs)

        # Force "is_xml" kwargs if we detect a XML model
        try:
            is_xml_model_serialization = kwargs["is_xml"]
        except KeyError:
            is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model())

        serialized = self._create_serialized_base(target_obj)  # Could be JSON or XML
        try:
            attributes = target_obj._attribute_map
            for attr, attr_desc in attributes.items():
                attr_name = attr
                if not keep_readonly and target_obj._validation.get(attr_name, {}).get('readonly', False):
                    continue

                if attr_name == "additional_properties" and attr_desc["key"] == '':
                    if target_obj.additional_properties is not None:
                        serialized.update(target_obj.additional_properties)
                    continue
                try:
                    ### Extract sub-data to serialize from model ###
                    orig_attr = getattr(target_obj, attr)
                    if target_obj.is_xml_model():
                        pass # Don't provide "transformer" for XML for now. Keep "orig_attr"
                    else: # JSON
                        keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr)
                        keys = keys if isinstance(keys, list) else [keys]

                    ### Serialize this data ###
                    kwargs["serialization_ctxt"] = attr_desc
                    new_attr = self.serialize_data(orig_attr, attr_desc['type'], **kwargs)

                    ### Incorporate this data in the right place ###
                    if is_xml_model_serialization:
                        xml_desc = attr_desc['xml']
                        xml_name = xml_desc['name']
                        if "attr" in xml_desc and xml_desc["attr"]:
                            serialized.set(xml_name, new_attr)
                            continue
                        if isinstance(new_attr, list):
                            serialized.extend(new_attr)
                        elif isinstance(new_attr, ET.Element):
                            # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces.
                            if 'name' not in getattr(orig_attr, '_xml_map', {}):
                                splitted_tag = new_attr.tag.split("}")
                                if len(splitted_tag) == 2: # Namespace
                                    new_attr.tag = "}".join([splitted_tag[0], xml_name])
                                else:
                                    new_attr.tag = xml_name
                            serialized.append(new_attr)
                        else:  # That's a basic type
                            # Integrate namespace if necessary
                            local_node = _create_xml_node(
                                xml_name,
                                xml_desc.get('prefix', None),
                                xml_desc.get('ns', None)
                            )
                            local_node.text = str(new_attr)
                            serialized.append(local_node)
                    else: # JSON
                        for k in reversed(keys):
                            unflattened = {k: new_attr}
                            new_attr = unflattened

                        _new_attr = new_attr
                        _serialized = serialized
                        for k in keys:
                            if k not in _serialized:
                                _serialized.update(_new_attr)
                            _new_attr = _new_attr[k]
                            _serialized = _serialized[k]
                except ValueError:
                    continue

        except (AttributeError, KeyError, TypeError) as err:
            msg = "Attribute {} in object {} cannot be serialized.\n{}".format(
                attr_name, class_name, str(target_obj))
            raise_with_traceback(SerializationError, msg, err)
        else:
            return serialized
539583
def get_model_path(self, name):
        """"""

        name, ext = os.path.splitext(name)
        ext = '.xml'
        xmlfile = name + self.config['file_suffix'] + ext
        xmlfile = utils.resolve_path(xmlfile,
                                     workdir=self.config['fileio']['workdir'])

        return xmlfile
110566
def find_node(self, attribute):
        

        for model in GraphModel._GraphModel__models_instances.itervalues():
            for node in foundations.walkers.nodes_walker(model.root_node):
                if attribute in node.get_attributes():
                    return node
1022236
def get_class_by_path(class_path: str, is_module: Optional[bool] = False) -> type:
    

    if is_module:
        try:
            backend_module = importlib.import_module(class_path)
        except ImportError:
            logger.warning("Can't import backend with name `%s`", class_path)
            raise
        else:
            return backend_module

    module_name, class_name = class_path.rsplit('.', 1)

    try:
        backend_module = importlib.import_module(module_name)
    except ImportError:
        logger.error("Can't import backend with name `%s`", module_name)
        raise

    try:
        backend_class = getattr(backend_module, class_name)
    except AttributeError:
        logger.error("Can't get backend class `%s` from `%s`", class_name, module_name)
        raise

    return backend_class
502875
def create_prj_model(self, ):
        
        prjs = djadapter.projects.all()
        rootdata = treemodel.ListItemData(['Name', 'Short', 'Rootpath'])
        prjroot = treemodel.TreeItem(rootdata)
        for prj in prjs:
            prjdata = djitemdata.ProjectItemData(prj)
            treemodel.TreeItem(prjdata, prjroot)
        prjmodel = treemodel.TreeModel(prjroot)
        return prjmodel
230662
def load(cls, sc, path):
        
        jmodel = sc._jvm.org.apache.spark.mllib.feature \
            .Word2VecModel.load(sc._jsc.sc(), path)
        model = sc._jvm.org.apache.spark.mllib.api.python.Word2VecModelWrapper(jmodel)
        return Word2VecModel(model)
961659
def _get_converter_module(sk_obj):
    
    try:
        cv_idx = _converter_lookup[sk_obj.__class__]
    except KeyError:
        raise ValueError(
                "Transformer '%s' not supported; supported transformers are %s."
                % (repr(sk_obj),
                    ",".join(k.__name__ for k in _converter_module_list)))

    return _converter_module_list[cv_idx]