Creates an XDR Operation object that represents this
        :class:`BumpSequence`.
348501
def to_xdr_object(self):
        
        bump_sequence_op = Xdr.types.BumpSequenceOp(self.bump_to)
        self.body.type = Xdr.const.BUMP_SEQUENCE
        self.body.bumpSequenceOp = bump_sequence_op
        return super(BumpSequence, self).to_xdr_object()
870273
def to_xdr_object(self):
        
        data_name = bytearray(self.data_name, encoding='utf-8')

        if self.data_value is not None:
            if isinstance(self.data_value, bytes):
                data_value = [bytearray(self.data_value)]
            else:
                data_value = [bytearray(self.data_value, 'utf-8')]
        else:
            data_value = []
        manage_data_op = Xdr.types.ManageDataOp(data_name, data_value)
        self.body.type = Xdr.const.MANAGE_DATA
        self.body.manageDataOp = manage_data_op
        return super(ManageData, self).to_xdr_object()
1004260
def _add_sp(self, autoshape_type, x, y, cx, cy):
        
        id_ = self._next_shape_id
        name = '%s %d' % (autoshape_type.basename, id_-1)
        sp = self._grpSp.add_autoshape(
            id_, name, autoshape_type.prst, x, y, cx, cy
        )
        return sp
1256219
def new(cls, pic_id, filename, rId, cx, cy):
        
        pic = parse_xml(cls._pic_xml())
        pic.nvPicPr.cNvPr.id = pic_id
        pic.nvPicPr.cNvPr.name = filename
        pic.blipFill.blip.embed = rId
        pic.spPr.cx = cx
        pic.spPr.cy = cy
        return pic
96124
def construct_xblock_from_class(self, cls, scope_ids, field_data=None, *args, **kwargs):
        
        return self.mixologist.mix(cls)(
            runtime=self,
            field_data=field_data,
            scope_ids=scope_ids,
            *args, **kwargs
        )
98407
public Xid createXid() {
        byte[] globalId = baseId.clone();
        long id;
        synchronized (this) {
            id = count++;
        }
        insertLong(id, globalId, 0);
        return new XidImpl(globalId);
    }
902513
def generate(self, x, **kwargs):
    
    # Parse and save attack-specific parameters
    assert self.parse_params(**kwargs)

    if self.ord != np.inf:
      raise NotImplementedError(self.ord)
    eta = tf.random_uniform(tf.shape(x), -self.eps, self.eps,
                            dtype=self.tf_dtype)
    adv_x = x + eta
    if self.clip_min is not None or self.clip_max is not None:
      assert self.clip_min is not None and self.clip_max is not None
      adv_x = tf.clip_by_value(adv_x, self.clip_min, self.clip_max)

    return adv_x
907572
def generate(self, x, **kwargs):
    
    self.parse_params(**kwargs)
    shape = [int(i) for i in x.get_shape().as_list()[1:]]

    assert self.sess is not None, \
        'Cannot use `generate` when no `sess` was provided'
    _check_first_dimension(x, 'input')
    if self.y_target is not None:
      _check_first_dimension(self.y_target, 'y_target')
      assert self.image_target is not None, \
          'Require a target image for targeted attack.'
      _check_first_dimension(self.image_target, 'image_target')

    # Set shape and d.
    self.shape = shape
    self.d = int(np.prod(shape))

    # Set binary search threshold.
    if self.constraint == 'l2':
      self.theta = self.gamma / np.sqrt(self.d)
    else:
      self.theta = self.gamma / self.d

    # Construct input placeholder and output for decision function.
    self.input_ph = tf.placeholder(
        tf_dtype, [None] + list(self.shape), name='input_image')
    self.logits = self.model.get_logits(self.input_ph)

    def bapp_wrap(x, target_label, target_image):
      """ Wrapper to use tensors as input and output. """
      return np.array(self._bapp(x, target_label, target_image),
                      dtype=self.np_dtype)

    if self.y_target is not None:
      # targeted attack that requires target label and image.
      wrap = tf.py_func(bapp_wrap,
                        [x[0], self.y_target[0], self.image_target[0]],
                        self.tf_dtype)
    else:
      if self.image_target is not None:
        # untargeted attack with an initialized image.
        wrap = tf.py_func(lambda x, target_image: bapp_wrap(x,
                                                            None, target_image),
                          [x[0], self.image_target[0]],
                          self.tf_dtype)
      else:
        # untargeted attack without an initialized image.
        wrap = tf.py_func(lambda x: bapp_wrap(x, None, None),
                          [x[0]],
                          self.tf_dtype)

    wrap.set_shape(x.get_shape())

    return wrap
896933
def create(lr, epochs, optimizer):
    
    return GenericPhase(
        lr=lr,
        epochs=epochs,
        optimizer_factory=optimizer,
    )
421265
def new(cls, shapes, start_x, start_y, x_scale, y_scale):
        
        return cls(
            shapes, int(round(start_x)), int(round(start_y)),
            x_scale, y_scale
        )
41725
def from_xdr(cls, xdr):
        
        xdr_decoded = base64.b64decode(xdr)
        te = Xdr.StellarXDRUnpacker(xdr_decoded)
        te_xdr_object = te.unpack_TransactionEnvelope()
        signatures = te_xdr_object.signatures
        tx_xdr_object = te_xdr_object.tx
        tx = Transaction.from_xdr_object(tx_xdr_object)
        te = TransactionEnvelope(tx, signatures=signatures)
        # te = TransactionEnvelope(
        #     tx, {'signatures': signatures, 'network_id': 'PUBLIC'})
        return te
1031342
def create(cls, expr, binds):
        
        return cls(expr=expr, binds=binds, dtype=bool_dtype)
112628
def to_xdr_object(self):
        """"""
        return Xdr.types.Memo(type=Xdr.const.MEMO_ID, id=self.memo_id)
1277252
def generate(self, x, **kwargs):
    
    assert self.sess is not None, \
        'Cannot use `generate` when no `sess` was provided'
    from cleverhans.utils_tf import jacobian_graph

    # Parse and save attack-specific parameters
    assert self.parse_params(**kwargs)

    # Define graph wrt to this input placeholder
    logits = self.model.get_logits(x)
    self.nb_classes = logits.get_shape().as_list()[-1]
    assert self.nb_candidate <= self.nb_classes, \
        'nb_candidate should not be greater than nb_classes'
    preds = tf.reshape(
        tf.nn.top_k(logits, k=self.nb_candidate)[0],
        [-1, self.nb_candidate])
    # grads will be the shape [batch_size, nb_candidate, image_size]
    grads = tf.stack(jacobian_graph(preds, x, self.nb_candidate), axis=1)

    # Define graph
    def deepfool_wrap(x_val):
      """deepfool function for py_func"""
      return deepfool_batch(self.sess, x, preds, logits, grads, x_val,
                            self.nb_candidate, self.overshoot,
                            self.max_iter, self.clip_min, self.clip_max,
                            self.nb_classes)

    wrap = tf.py_func(deepfool_wrap, [x], self.tf_dtype)
    wrap.set_shape(x.get_shape())
    return wrap
1320115
def from_xdr_object(cls, op_xdr_object):
        
        if not op_xdr_object.sourceAccount:
            source = None
        else:
            source = encode_check(
                'account', op_xdr_object.sourceAccount[0].ed25519).decode()

        data_name = op_xdr_object.body.manageDataOp.dataName.decode()

        if op_xdr_object.body.manageDataOp.dataValue:
            data_value = op_xdr_object.body.manageDataOp.dataValue[0]
        else:
            data_value = None
        return cls(source=source, data_name=data_name, data_value=data_value)
508422
def new(self):
        # type: () -> None
        '''
        
        '''
        if self._initialized:
            raise pycdlibexception.PyCdlibInternalError('This XARecord is already initialized!')

        # FIXME: we should allow the user to set these
        self._group_id = 0
        self._user_id = 0
        self._attributes = 0
        self._filenum = 0
        self._initialized = True
357007
def xdr(self):
        
        kp = Xdr.StellarXDRPacker()
        kp.pack_PublicKey(self.account_xdr_object())
        return base64.b64encode(kp.get_buffer())