merges model elements which collectively all define the model component,
    mostly for multidimensional subscripts

    Parameters
    ----------
    element_list

    Returns
    -------
977123
def merge_partial_elements(element_list):
    
    outs = dict()  # output data structure
    for element in element_list:
        if element['py_expr'] != "None":  # for
            name = element['py_name']
            if name not in outs:
                # Use 'expr' for Vensim models, and 'eqn' for Xmile (This makes the Vensim equation prettier.)
                eqn = element['expr'] if 'expr' in element else element['eqn']

                outs[name] = {
                    'py_name': element['py_name'],
                    'real_name': element['real_name'],
                    'doc': element['doc'],
                    'py_expr': [element['py_expr']],  # in a list
                    'unit': element['unit'],
                    'subs': [element['subs']],
                    'lims': element['lims'],
                    'eqn': eqn,
                    'kind': element['kind'],
                    'arguments': element['arguments']
                }

            else:
                outs[name]['doc'] = outs[name]['doc'] or element['doc']
                outs[name]['unit'] = outs[name]['unit'] or element['unit']
                outs[name]['lims'] = outs[name]['lims'] or element['lims']
                outs[name]['eqn'] = outs[name]['eqn'] or element['eqn']
                outs[name]['py_expr'] += [element['py_expr']]
                outs[name]['subs'] += [element['subs']]
                outs[name]['arguments'] = element['arguments']

    return list(outs.values())
1247962
def merge_ligolws(elem):
	
	ligolws = [child for child in elem.childNodes if child.tagName == ligolw.LIGO_LW.tagName]
	if ligolws:
		dest = ligolws.pop(0)
		for src in ligolws:
			# copy children;  LIGO_LW elements have no attributes
			map(dest.appendChild, src.childNodes)
			# unlink from parent
			if src.parentNode is not None:
				src.parentNode.removeChild(src)
	return elem
534435
def concatenate_lists(*layers, **kwargs):  # pragma: no cover
    
    if not layers:
        return noop()
    drop_factor = kwargs.get("drop_factor", 1.0)
    ops = layers[0].ops
    layers = [chain(layer, flatten) for layer in layers]
    concat = concatenate(*layers)

    def concatenate_lists_fwd(Xs, drop=0.0):
        drop *= drop_factor
        lengths = ops.asarray([len(X) for X in Xs], dtype="i")
        flat_y, bp_flat_y = concat.begin_update(Xs, drop=drop)
        ys = ops.unflatten(flat_y, lengths)

        def concatenate_lists_bwd(d_ys, sgd=None):
            return bp_flat_y(ops.flatten(d_ys), sgd=sgd)

        return ys, concatenate_lists_bwd

    model = wrap(concatenate_lists_fwd, concat)
    return model
1053612
def _merge(self, value):
        
        if not value:
            return []

        if value is not None and not isinstance(value, list):
            # bogus value; will not pass validation but should be preserved
            return value

        item_spec = self._nested_validator
        return [x if x is None else item_spec.get_default_for(x) for x in value]
153331
function merge( elem, callback ) {
		var old = find( destChildren, elem.name ),
			nl;

		// merge with old element
		if ( old ) {
			if ( typeof callback == 'function' ) {
				return callback( old );
			}

			_.merge( old.attribs, elem.attribs );

			if ( elem.children ) {
				combine( old, elem );
			}
			// append new element
		} else {
			if ( dest.children ) {
				utils.appendChild( dest, elem );
			} else {
				utils.prepend( destChildren[ 0 ], elem );
				// fix for domutils issue
				elem.parent = destChildren[ 0 ].parent;
				destChildren.unshift( elem );
				destChildren.splice( destChildren.indexOf( elem ) + 1, 0, nl );
			}
		}
	}
1003293
def _register_elements(self, elements):
        
        self.elements = elements

        for key, obj in elements.items():
            obj.contribute_to_class(self.metadata, key)

        # Create the common Django fields
        fields = {}
        for key, obj in elements.items():
            if obj.editable:
                field = obj.get_field()
                if not field.help_text:
                    if key in self.bulk_help_text:
                        field.help_text = self.bulk_help_text[key]
                fields[key] = field

        # 0. Abstract base model with common fields
        base_meta = type('Meta', (), self.original_meta)
        class BaseMeta(base_meta):
            abstract = True
            app_label = 'seo'
        fields['Meta'] = BaseMeta
        # Do we need this?
        fields['__module__'] = __name__ #attrs['__module__']
        self.MetadataBaseModel = type('%sBase' % self.name, (models.Model,), fields)
1364964
def replace_elements(self, inds, new_submesh, component):
        
        self._dict[component] = np.hstack([self._dict[component][~inds], new_submesh])
994569
def list_model_columns(obj)
      items = obj.class.columns.map{ |col| info_pair(col.name, obj[col.name]) }
      content_tag(:ul, convert_to_list_items(items), :class => "model_columns")
    end
129553
def merge_dicts(*dict_list):
    
    # if not isinstance(dict_list, list):
    #     raise TypeError("dict_list is not a list. Please try again")
    # print(dict_list)
    all_dicts = []
    for ag in dict_list:
        if isinstance(ag, dict):
            all_dicts.append(ag)
    
    # Get all dictionaries
    # Merge them
    # Check if type is there
    try:
        qitem = { k: v for d in all_dicts for k, v in d.items() }
        return qitem
    except Exception:
        return {}
232338
def as_list_data(self):
        
        element = ElementTree.Element(self.list_type)
        id_ = ElementTree.SubElement(element, "id")
        id_.text = self.id
        name = ElementTree.SubElement(element, "name")
        name.text = self.name
        return element
1096473
def _convertToElementList(elements_list):
    
    elements = []
    current_element = []
    for node_index in elements_list:
        if node_index == -1:
            elements.append(current_element)
            current_element = []
        else:
            current_element.append(node_index)

    return elements
314974
def update_core_element_lists(self):
        
        def get_selected_elements_of_core_class(core_class):
            return set(element for element in self._selected if isinstance(element.core_element, core_class))
        self._states = get_selected_elements_of_core_class(State)
        self._transitions = get_selected_elements_of_core_class(Transition)
        self._data_flows = get_selected_elements_of_core_class(DataFlow)
        self._input_data_ports = get_selected_elements_of_core_class(InputDataPort)
        self._output_data_ports = get_selected_elements_of_core_class(OutputDataPort)
        self._scoped_variables = get_selected_elements_of_core_class(ScopedVariable)
        self._outcomes = get_selected_elements_of_core_class(Outcome)
339395
def define_elements_js(model_class, excluded_props = [])
      attributes = model_class.new.attributes.keys

      attributes.each do |attri|
        unless excluded_props.include? attri
          selector = "#"+attri
          # self.class.send "element", attri.to_sym, selector
          element attri, selector
        end

      end
    end
181053
def concatenate(cls, *args: List['ComponentRef']) -> 'ComponentRef':
        

        a = copy.deepcopy(args[0])
        n = a
        for b in args[1:]:
            while n.child:
                n = n.child[0]
            b = copy.deepcopy(b)  # Not strictly necessary
            n.child = [b]
        return a
580169
def split_model(model:nn.Module=None, splits:Collection[Union[nn.Module,ModuleList]]=None):
    ""
    splits = listify(splits)
    if isinstance(splits[0], nn.Module):
        layers = flatten_model(model)
        idxs = [layers.index(first_layer(s)) for s in splits]
        return split_model_idx(model, idxs)
    return [nn.Sequential(*s) for s in splits]
459547
def split_model_idx(model:nn.Module, idxs:Collection[int])->ModuleList:
    ""
    layers = flatten_model(model)
    if idxs[0] != 0: idxs = [0] + idxs
    if idxs[-1] != len(layers): idxs.append(len(layers))
    return [nn.Sequential(*layers[i:j]) for i,j in zip(idxs[:-1],idxs[1:])]
872706
def convert_type_list_elements(
    list_object  = None,
    element_type = str
    ):
    
    if element_type is str:
        return [str(element) if not isinstance(element, list) else convert_type_list_elements(
            list_object  = element,
            element_type = str
        ) for element in list_object]