Create broadcast compatible variables, with the same dimensions.

    Unlike the result of broadcast_variables(), some variables may have
    dimensions of size 1 instead of the the size of the broadcast dimension.
436210
def _broadcast_compat_variables(*variables):
    
    dims = tuple(_unified_dims(variables))
    return tuple(var.set_dims(dims) if var.dims != dims else var
                 for var in variables)
930260
public static INDArray rsub(INDArray x, INDArray y, INDArray z, int... dimensions) {
        if(dimensions == null || dimensions.length == 0) {
            validateShapesNoDimCase(x,y,z);
            return Nd4j.getExecutioner().exec(new OldSubOp(x,y,z));
        }

        return Nd4j.getExecutioner().exec(new BroadcastRSubOp(x,y,z,dimensions));
    }
191518
def _create_variables_dic(self):
        
        self.name_to_variable = {}
        for variable in self.space_expanded:
            self.name_to_variable[variable.name] = variable
532325
public static INDArray gt(INDArray x, INDArray y, INDArray z, int... dimensions) {
        if(dimensions == null || dimensions.length == 0) {
            validateShapesNoDimCase(x,y,z);
            return Nd4j.getExecutioner().exec(new OldGreaterThan(x,y,z));
        }

        return Nd4j.getExecutioner().exec(new BroadcastGreaterThan(x,y,z,dimensions));
    }
74424
def resolve_broadcast_params(inputs, function_proto, batch_size):
    '''
    '''
    f = function_proto  # alias

    # A. Detect multiple negative dimensions (not allowed).
    negative_count = 0
    for d in f.broadcast_param.shape.dim:
        if d < 0:
            negative_count += 1
    if negative_count > 1:
        raise ValueError('Reshape: shape has multiple negative number.')

    # B. Fill negative dimensions with batch size.
    shape = tuple(
        [d if d >= 0 else batch_size for d in f.broadcast_param.shape.dim])
    return shape
153111
def add_variables(vars)
      objective_buffer = build_pointer_array vars.map(&:coefficient), :double
      lb_buffer = build_pointer_array vars.map(&:lower_bound), :double
      ub_buffer = build_pointer_array vars.map(&:upper_bound), :double
      type_buffer = build_pointer_array(vars.map do |var|
        gurobi_type(var.type)
      end, :char)
      names_buffer = build_pointer_array array_to_pointers_to_names(vars),
                                         :pointer

      ret = Gurobi.GRBaddvars @ptr, vars.length, 0, nil, nil, nil,
                              objective_buffer, lb_buffer, ub_buffer,
                              type_buffer, names_buffer

      fail if ret != 0

      # Store all the variables in the model
      vars.each { |var| store_variable var }

      # Update the model with variables so constraint adds succeed
      ret = Gurobi.GRBupdatemodel @ptr
      fail if ret != 0
    end
1034776
def _create_latent_variables(self):
        

        # Input layer
        for unit in range(self.units):
            self.latent_variables.add_z('Constant | Layer ' + str(1) + ' | Unit ' + str(unit+1), fam.Cauchy(0,1,transform=None), fam.Normal(0, 3))

            for ar_term in range(self.ar):
                self.latent_variables.add_z('AR' + str(ar_term+1) + ' | Layer ' + str(1) + ' | Unit ' + str(unit+1), fam.Cauchy(0,1,transform=None), fam.Normal(0, 3))

            for z in range(len(self.X_names)):
                self.latent_variables.add_z('Weight ' + self.X_names[z], fam.Cauchy(0, 1, transform=None), fam.Normal(0, 3))

        # Hidden layers
        for layer in range(1, self.layers):
            for unit in range(self.units):
                for weight in range(self.units):
                    self.latent_variables.add_z('Weight ' + str(weight+1) + ' | Layer ' + str(layer+1) + ' | Unit ' + str(unit+1), fam.Cauchy(0,1,transform=None), fam.Normal(0, 3))

        # Output layer
        for weight in range(self.units):
            self.latent_variables.add_z('Output Weight ' + str(weight+1), fam.Cauchy(0,1,transform=None), fam.Normal(0, 3))
1143036
def _create_latent_variables(self):
        

        self.latent_variables.add_z('Sigma^2 irregular', fam.Flat(transform='exp'), fam.Normal(0,3))
        self.latent_variables.add_z('Sigma^2 level', fam.Flat(transform='exp'), fam.Normal(0,3))
        self.latent_variables.add_z('Sigma^2 trend', fam.Flat(transform='exp'), fam.Normal(0,3))
850910
def add_dimension(self, name, data=None):
        """"""
        self.dimensions.add(name)
        if data is None:
            valobj = self.__dimtype__()
        else:
            valobj = make_object(self.__dimtype__, data)
        self._data[name] = valobj
        setattr(self, name, valobj)
        return valobj
664990
def rvs(self, size=1):
        

        # create output FieldArray
        out = record.FieldArray(size, dtype=[(arg, float)
                                    for arg in self.variable_args])

        # loop until enough samples accepted
        n = 0
        while n < size:

            # draw samples
            samples = {}
            for dist in self.distributions:
                draw = dist.rvs(1)
                for param in dist.params:
                    samples[param] = draw[param][0]
            vals = numpy.array([samples[arg] for arg in self.variable_args])

            # determine if all parameter values are in prior space
            # if they are then add to output
            if self(**dict(zip(self.variable_args, vals))) > -numpy.inf:
                out[n] = vals
                n += 1

        return out
1228688
def add_variables(
        self, variables: Union[List["Variable"], "Variable"], index: int = None
    ) -> None:
        
        if isinstance(variables, Variable):
            addvars = copy.deepcopy([variables])
        else:
            addvars = copy.deepcopy(variables)

        if index is None:
            self.variables.extend(addvars)
        else:
            self.variables[index:index] = addvars
755692
protected function createLexicalVariables() {
    if (!$this->hasLexicalVariables()) {
      $this->lexicalUse = Token::_use();
      $this->lexicalOpenParen = Token::openParen();
      $this->lexicalVariables = new CommaListNode();
      $this->lexicalCloseParen = Token::closeParen();
      $this->closeParen->after([
        Token::space(),
        $this->lexicalUse,
        Token::space(),
        $this->lexicalOpenParen,
        $this->lexicalVariables,
        $this->lexicalCloseParen,
      ]);
    }
  }
726051
def _create_variables_no_pretrain(self, n_features):
        
        self.encoding_w_ = []
        self.encoding_b_ = []

        for l, layer in enumerate(self.layers):

            if l == 0:
                self.encoding_w_.append(tf.Variable(tf.truncated_normal(
                    shape=[n_features, self.layers[l]], stddev=0.1)))
                self.encoding_b_.append(tf.Variable(tf.truncated_normal(
                    [self.layers[l]], stddev=0.1)))
            else:
                self.encoding_w_.append(tf.Variable(tf.truncated_normal(
                    shape=[self.layers[l - 1], self.layers[l]], stddev=0.1)))
                self.encoding_b_.append(tf.Variable(tf.truncated_normal(
                    [self.layers[l]], stddev=0.1)))
244229
def _replace_with_new_dims(  # type: ignore
        self: T,
        variables: 'OrderedDict[Any, Variable]' = None,
        coord_names: set = None,
        attrs: 'Optional[OrderedDict]' = __default,
        indexes: 'Optional[OrderedDict[Any, pd.Index]]' = __default,
        inplace: bool = False,
    ) -> T:
        """"""
        dims = dict(calculate_dimensions(variables))
        return self._replace(
            variables, coord_names, dims, attrs, indexes, inplace=inplace)
490540
def add_variables(vars)
      # Allocate space for the new variables
      ret = LPSolve.resize_lp(@ptr, @constraints.length,
                              @variables.length + vars.length)
      fail if ret != 1

      # Store all the variables in the model
      vars.each { |var| store_variable var }
    end
1263875
def add_variable(self, start, variable):
        

        size = variable.size if variable.size is not None else 1

        self.add_object(start, variable, size)
343214
def build_variables(self, variable_placeholders):
        
        variables = self.__substitute_names_in_list(variable_placeholders)
        attributes = {}
        for i, variable in enumerate(variables):
            placeholder_name = variable_placeholders[i]
            try:
                vertices = self.g.vs.select(name=variable)
                attributes[placeholder_name] = vertices[0].attributes()
            except:
                pass
        for i, variable in enumerate(variables):
            placeholder_name = variable_placeholders[i]
            try:
                edges = self.g.es.select(name=variable)
                edge_attr = edges[0].attributes()
                attributes[placeholder_name] = edge_attr
            except:
                pass
        for i, variable in enumerate(variables):
            placeholder_name = variable_placeholders[i]
            try:
                attributes[placeholder_name] = self.match_info[placeholder_name]
            except:
                pass
        return attributes