jiahuimbzuai/CoQuIR huggingface dataset:
//  [python]
def multinomial_sampling(self, pr):
        """Multinomial Sampling of ratings

        Basic mechanics:
        For r classes, we sample r binomial distributions using the rejection method. This is possible
        since each class is statistically independent from the other. Note that this is the same method
        used in numpy's random.multinomial() function.

        1) extract a size r array of random numbers from a uniform distribution (g). As pr is normalized,
        we need to normalize g as well.

        2) For each user and item, compare pr with the reference distribution. Note that the latter needs
        to be the same for ALL the user/item pairs in the dataset, as by assumptions they are sampled
        from a common distribution.

        Args:
            pr (tf.Tensor, float32): A distributions of shape (m, n, r), where m is the number of examples, n the number
                 of features and r the number of classes. pr needs to be normalized, i.e. sum_k p(k) = 1 for all m, at fixed n.
            f (tf.Tensor, float32): Normalized, uniform probability used for comparison.

        Returns:
            tf.Tensor: An (m,n) float32 tensor of sampled rankings from 1 to r.
        """
        g = np.random.uniform(size=pr.shape[2])  # sample from a uniform distribution
        f = tf.convert_to_tensor(
            value=g / g.sum(), dtype=tf.float32
        )  # normalize and convert to tensor

        samp = tf.nn.relu(tf.sign(pr - f))  # apply rejection method

        # get integer index of the rating to be sampled
        v_argmax = tf.cast(tf.argmax(input=samp, axis=2), "int32")

        # lookup the rating using integer index
        v_samp = tf.cast(self.ratings_lookup_table.lookup(v_argmax), "float32")

        return v_samp
//  [python]
def metrics(self, logits, labels,mask):
        self.prediction_scores = tf.nn.softmax(logits=logits, name="prediction_scores")
        self.predictions = tf.argmax(self.prediction_scores, 3, name="predictions")

        targets = tf.argmax(labels, 3, name="targets")
        #correctly_predicted = tf.equal(self.predictions, targets, name="correctly_predicted")
        correctly_predicted = tf.equal(tf.boolean_mask(self.predictions, mask), tf.boolean_mask(targets,mask), name="correctly_predicted")
        self.overall_accuracy = tf.reduce_mean(tf.to_float(correctly_predicted), name="overall_accuracy")
//  [python]
def metrics(self, logits, labels,mask):
        self.prediction_scores = tf.nn.softmax(logits=logits, name="prediction_scores")
        self.predictions = tf.argmax(self.prediction_scores, 3, name="predictions")

        targets = tf.argmax(labels, 3, name="targets")
        #correctly_predicted = tf.equal(self.predictions, targets, name="correctly_predicted")
        correctly_predicted = tf.equal(tf.boolean_mask(self.predictions, mask), tf.boolean_mask(targets,mask), name="correctly_predicted")
        self.overall_accuracy = tf.reduce_mean(tf.cast(correctly_predicted, tf.float32), name="overall_accuracy")
//  [python]
def apply_mask(mask, x, value=0):
  """This function is used for gradient masking.

  The YOLO loss function makes extensive use of dynamically shaped tensors.
  To allow this use case on the TPU while preserving the gradient correctly
  for back propagation we use this masking function to use a tf.where operation
  to hard set masked location to have a gradient and a value of zero.

  Args:
    mask: A `Tensor` with the same shape as x used to select values of
      importance.
    x: A `Tensor` with the same shape as mask that will be getting masked.
    value: `float` constant additive value.

  Returns:
    x: A masked `Tensor` with the same shape as x.
  """
  mask = t.cast(mask, t.bool)
  masked = tf.where(mask, x, tf.zeros_like(x) + value)
  return masked
//  [python]
def apply_mask(mask, x, value=0):
  """This function is used for gradient masking.

  The YOLO loss function makes extensive use of dynamically shaped tensors.
  To allow this use case on the TPU while preserving the gradient correctly
  for back propagation we use this masking function to use a tf.where operation
  to hard set masked location to have a gradient and a value of zero.

  Args:
    mask: A `Tensor` with the same shape as x used to select values of
      importance.
    x: A `Tensor` with the same shape as mask that will be getting masked.
    value: `float` constant additive value.

  Returns:
    x: A masked `Tensor` with the same shape as x.
  """
  mask = tf.cast(mask, tf.bool)
  masked = tf.where(mask, x, tf.zeros_like(x) + value)
  return masked
//  [python]
def _build_anchor_grid(self, height, width, anchors, dtype):
    """Get the transformed anchor boxes for each dimention."""
    with tf.name_scope('anchor_grid'):
      num = tf.shape(anchors)[0]
      anchors = tf.cast(anchors, dtype=dtype)
      anchors = tf.reshape(anchors, [1, 1, 1, num, 2])
      anchors = tf.tile(anchors, [1, tf.cast(height, tf.int32),
                                  tf.cast(width, tf.int32), 1, 1])
    return anchors
//  [python]
def _build_grid_points(self, lheight, lwidth, anchors, dtype):
    """Generate a grid of fixed grid edges for box center decoding."""
    with tf.name_scope('center_grid'):
      y = tf.range(0, lheight)
      x = tf.range(0, lwidth)
      x_left = tf.tile(
          tf.transpose(tf.expand_dims(x, axis=-1), perm=[1, 0]), [lheight, 1])
      y_left = tf.tile(tf.expand_dims(y, axis=-1), [1, lwidth])
      x_y = tf.stack([x_left, y_left], axis=-1)
      x_y = tf.cast(x_y, dtype=dtype)
      num = tf.shape(anchors)[0]
      x_y = tf.expand_dims(
          tf.tile(tf.expand_dims(x_y, axis=-2), [1, 1, num, 1]), axis=0)
    return x_y
//  [python]
def __call__(self, height, width, batch_size, dtype=None):
    if dtype is None:
      self.dtype = tf_keras.backend.floatx()
    else:
      self.dtype = dtype
    grid_points = self._build_grid_points(height, width, self._anchors,
                                          self.dtype)
    anchor_grid = self._build_anchor_grid(
        height, width,
        tf.to_float(self._anchors) /
        tf.to_float(self._scale_anchors), self.dtype)

    grid_points = self._extend_batch(grid_points, batch_size)
    anchor_grid = self._extend_batch(anchor_grid, batch_size)
    return grid_points, anchor_grid
//  [python]
def __call__(self, height, width, batch_size, dtype=None):
    if dtype is None:
      self.dtype = tf_keras.backend.floatx()
    else:
      self.dtype = dtype
    grid_points = self._build_grid_points(height, width, self._anchors,
                                          self.dtype)
    anchor_grid = self._build_anchor_grid(
        height, width,
        tf.cast(self._anchors, self.dtype) /
        tf.cast(self._scale_anchors, self.dtype), self.dtype)

    grid_points = self._extend_batch(grid_points, batch_size)
    anchor_grid = self._extend_batch(anchor_grid, batch_size)
    return grid_points, anchor_grid
//  [python]
def average_iou(iou):
  """Computes the average intersection over union without counting locations.

  where the iou is zero.

  Args:
    iou: A `Tensor` representing the iou values.

  Returns:
    tf.stop_gradient(avg_iou): A `Tensor` representing average
     intersection over union.
  """
  iou_sum = tf.reduce_sum(iou, axis=tf.range(1, tf.shape(tf.shape(iou))[0]))
  counts = tf.to_int32(
      tf.math.count_nonzero(iou, axis=tf.range(1,
                                               tf.shape(tf.shape(iou))[0])))
  avg_iou = tf.reduce_mean(math_ops.divide_no_nan(iou_sum, counts))
  return tf.stop_gradient(avg_iou)
//  [python]
def average_iou(iou):
  """Computes the average intersection over union without counting locations.

  where the iou is zero.

  Args:
    iou: A `Tensor` representing the iou values.

  Returns:
    tf.stop_gradient(avg_iou): A `Tensor` representing average
     intersection over union.
  """
  iou_sum = tf.reduce_sum(iou, axis=tf.range(1, tf.shape(tf.shape(iou))[0]))
  counts = tf.cast(
      tf.math.count_nonzero(iou, axis=tf.range(1,
                                               tf.shape(tf.shape(iou))[0])),
      iou.dtype)
  avg_iou = tf.reduce_mean(math_ops.divide_no_nan(iou_sum, counts))
  return tf.stop_gradient(avg_iou)
//  [python]
def build_graph(self, modelpath=None):

        # input pipeline
        print("building input pipeline...")

        # input pipeline
        with tf.name_scope("input"):
            (x, sequence_lengths), (alllabels,) = self.input()
            self.alllabels = alllabels

        print("building inference...")
        self.logits = self.inference(input=(x, sequence_lengths))

        # reduce label size to same shape like logits (important for downsampling)
        b,w,h,d = self.logits.get_shape()

        # take first label -> assume labels do not change over timeseries
        first_labelmap = alllabels[:,0]

        # create one-hot labelmap from 0-num_classes
        labels = tf.one_hot(first_labelmap, self.num_classes+1)

        # mask out class 0 -> unknown
        unknown_mask = tf.to_int64(labels[:,:,:,0])
        not_unknown_mask = tf.logical_not(unknown_mask)

        # keep rest of labels
        self.labels = labels[:,:,:,1:]


        # mask out all classes labeled unknown (labelid=0)
        #not_unknown_mask = tf.not_equal(first_labelmap, tf.constant(0, dtype=tf.int32))

        #self.labels = self.reshape_labels(labels=first_labelmap, width=w, height=h)
        #self.labels = tf.one_hot(tf.reduce_mean(alllabels, axis=1), self.num_classes)

        print("building loss...")
        self.loss = self.loss(logits=self.logits, labels=self.labels, mask=not_unknown_mask,name="loss")

        print("building optimizer...")
        self.train_op = self.optimize(self.loss, name="train_op")

        print("building metrics and summaries...")
        self.metrics(logits=self.logits, labels=self.labels,mask=not_unknown_mask)

        self.summary_op = self.summary()

        n_trainparams = count_params(collector_fun=tf.trainable_variables)
        print("graph completed with {} trainable parameters".format(n_trainparams))

        if modelpath is not None:
            path = os.path.join(modelpath, MODEL_GRAPH_NAME)
            print("writing meta graph to {}".format(path))
            tf.train.export_meta_graph(filename=path)

            # write FLAGS to file
            cfg = configparser.ConfigParser()

            # TF 1.4
            #cfg["model"] = {"model": os.path.basename(__file__)}
            #cfg["flags"] = FLAGS.__dict__["__flags"]

            # TF 1.7
            flags_dict = dict()
            for name in FLAGS:
                flags_dict[name]=str(FLAGS[name].value)

            cfg["flags"] = flags_dict # FLAGS.__flags #  broke tensorflow=1.5


            path=os.path.join(modelpath, MODEL_CFG_FILENAME)
            print("writing parameters to {}".format(path))
            with open(path, 'w') as configfile:
                cfg.write(configfile)

            # write operation names to file for easier debugging
            path = os.path.join(modelpath, "nodes.txt")
            print("writing nodes list to {}".format(path))
            names = [n.name for n in tf.get_default_graph().as_graph_def().node]
            with open(path, 'w') as f:
                f.write("\n".join(names))
//  [python]
def build_graph(self, modelpath=None):

        # input pipeline
        print("building input pipeline...")

        # input pipeline
        with tf.name_scope("input"):
            (x, sequence_lengths), (alllabels,) = self.input()
            self.alllabels = alllabels

        print("building inference...")
        self.logits = self.inference(input=(x, sequence_lengths))

        # reduce label size to same shape like logits (important for downsampling)
        b,w,h,d = self.logits.get_shape()

        # take first label -> assume labels do not change over timeseries
        first_labelmap = alllabels[:,0]

        # create one-hot labelmap from 0-num_classes
        labels = tf.one_hot(first_labelmap, self.num_classes+1)

        # mask out class 0 -> unknown
        unknown_mask = tf.cast(labels[:,:,:,0], tf.bool)
        not_unknown_mask = tf.logical_not(unknown_mask)

        # keep rest of labels
        self.labels = labels[:,:,:,1:]


        # mask out all classes labeled unknown (labelid=0)
        #not_unknown_mask = tf.not_equal(first_labelmap, tf.constant(0, dtype=tf.int32))

        #self.labels = self.reshape_labels(labels=first_labelmap, width=w, height=h)
        #self.labels = tf.one_hot(tf.reduce_mean(alllabels, axis=1), self.num_classes)

        print("building loss...")
        self.loss = self.loss(logits=self.logits, labels=self.labels, mask=not_unknown_mask,name="loss")

        print("building optimizer...")
        self.train_op = self.optimize(self.loss, name="train_op")

        print("building metrics and summaries...")
        self.metrics(logits=self.logits, labels=self.labels,mask=not_unknown_mask)

        self.summary_op = self.summary()

        n_trainparams = count_params(collector_fun=tf.trainable_variables)
        print("graph completed with {} trainable parameters".format(n_trainparams))

        if modelpath is not None:
            path = os.path.join(modelpath, MODEL_GRAPH_NAME)
            print("writing meta graph to {}".format(path))
            tf.train.export_meta_graph(filename=path)

            # write FLAGS to file
            cfg = configparser.ConfigParser()

            # TF 1.4
            #cfg["model"] = {"model": os.path.basename(__file__)}
            #cfg["flags"] = FLAGS.__dict__["__flags"]

            # TF 1.7
            flags_dict = dict()
            for name in FLAGS:
                flags_dict[name]=str(FLAGS[name].value)

            cfg["flags"] = flags_dict # FLAGS.__flags #  broke tensorflow=1.5


            path=os.path.join(modelpath, MODEL_CFG_FILENAME)
            print("writing parameters to {}".format(path))
            with open(path, 'w') as configfile:
                cfg.write(configfile)

            # write operation names to file for easier debugging
            path = os.path.join(modelpath, "nodes.txt")
            print("writing nodes list to {}".format(path))
            names = [n.name for n in tf.get_default_graph().as_graph_def().node]
            with open(path, 'w') as f:
                f.write("\n".join(names))
//  [python]
def build_grid(indexes, truths, preds, ind_mask, update=False, grid=None):
  """This function is used to broadcast elements into the output shape.

  This function is used to broadcasts a list of truths into the correct index
  in the output shape. This is used for the ground truth map construction in
  the scaled loss and the classification map in the darknet loss.

  Args:
    indexes: A `Tensor` for the indexes
    truths: A `Tensor` for the ground truth.
    preds: A `Tensor` for the predictions.
    ind_mask: A `Tensor` for the index masks.
    update: A `bool` for updating the grid.
    grid: A `Tensor` for the grid.

  Returns:
    grid: A `Tensor` representing the augmented grid.
  """
  # this function is used to broadcast all the indexes to the correct
  # into the correct ground truth mask, used for iou detection map
  # in the scaled loss and the classification mask in the darknet loss
  num_flatten = tf.shape(preds)[-1]

  # is there a way to verify that we are not on the CPU?
  ind_mask = tf.cast(ind_mask, indexes.dtype)

  # find all the batch indexes using the cumulated sum of a ones tensor
  # cumsum(ones) - 1 yeild the zero indexed batches
  bhep = tf.reduce_max(tf.ones_like(indexes), axis=-1, keepdims=True)
  bhep = tf.math.cumsum(bhep, axis=0) - 1

  # concatnate the batch sizes to the indexes
  indexes = tf.concat([bhep, indexes], axis=-1)
  indexes = apply_mask(tf.cast(ind_mask, indexes.dtype), indexes)
  indexes = (indexes + (ind_mask - 1))

  # mask truths
  truths = apply_mask(tf.cast(ind_mask, truths.dtype), truths)
  truths = (truths + (tf.cast(ind_mask, truths.dtype) - 1))

  # reshape the indexes into the correct shape for the loss,
  # just flatten all indexes but the last
  indexes = tf.reshape(indexes, [-1, 4])

  # also flatten the ground truth value on all axis but the last
  truths = tf.reshape(truths, [-1, num_flatten])

  # build a zero grid in the samve shape as the predicitons
  if grid is None:
    grid = tf.zeros_like(preds)
  # remove invalid values from the truths that may have
  # come up from computation, invalid = nan and inf
  truths = math_ops.rm_nan_inf(truths)

  # scatter update the zero grid
  if update:
    grid = tf.tensor_scatter_nd_update(grid, indexes, truths)
  else:
    grid = tf.tensor_scatter_nd_max(grid, indexes, truths)

  # stop gradient and return to avoid TPU errors and save compute
  # resources
  return grid
//  [python]
def _scale_boxes(encoded_boxes, width, height, anchor_grid, grid_points,
                 scale_xy):
  """Decodes models boxes applying and exponential to width and height maps."""
  # split the boxes
  pred_xy = encoded_boxes[..., 0:2]
  pred_wh = encoded_boxes[..., 2:4]

  # build a scaling tensor to get the offset of th ebox relative to the image
  scaler = t.convert_to_tensor([height, width, height, width])
  scale_xy = t.cast(scale_xy, encoded_boxes.dtype)

  # apply the sigmoid
  pred_xy = tf.math.sigmoid(pred_xy)

  # scale the centers and find the offset of each box relative to
  # their center pixel
  pred_xy = pred_xy * scale_xy - 0.5 * (scale_xy - 1)

  # scale the offsets and add them to the grid points or a tensor that is
  # the realtive location of each pixel
  box_xy = grid_points + pred_xy

  # scale the width and height of the predictions and corlate them
  # to anchor boxes
  box_wh = tf.math.exp(pred_wh) * anchor_grid

  # build the final predicted box
  scaled_box = tf.concat([box_xy, box_wh], axis=-1)
  pred_box = scaled_box / scaler

  # shift scaled boxes
  scaled_box = tf.concat([pred_xy, box_wh], axis=-1)
  return (scaler, scaled_box, pred_box)
//  [python]
def _scale_boxes(encoded_boxes, width, height, anchor_grid, grid_points,
                 scale_xy):
  """Decodes models boxes applying and exponential to width and height maps."""
  # split the boxes
  pred_xy = encoded_boxes[..., 0:2]
  pred_wh = encoded_boxes[..., 2:4]

  # build a scaling tensor to get the offset of th ebox relative to the image
  scaler = tf.convert_to_tensor([height, width, height, width])
  scale_xy = tf.cast(scale_xy, encoded_boxes.dtype)

  # apply the sigmoid
  pred_xy = tf.math.sigmoid(pred_xy)

  # scale the centers and find the offset of each box relative to
  # their center pixel
  pred_xy = pred_xy * scale_xy - 0.5 * (scale_xy - 1)

  # scale the offsets and add them to the grid points or a tensor that is
  # the realtive location of each pixel
  box_xy = grid_points + pred_xy

  # scale the width and height of the predictions and corlate them
  # to anchor boxes
  box_wh = tf.math.exp(pred_wh) * anchor_grid

  # build the final predicted box
  scaled_box = tf.concat([box_xy, box_wh], axis=-1)
  pred_box = scaled_box / scaler

  # shift scaled boxes
  scaled_box = tf.concat([pred_xy, box_wh], axis=-1)
  return (scaler, scaled_box, pred_box)
//  [python]
def __call__(self,
               pred_boxes,
               pred_classes,
               boxes,
               classes,
               clip_thresh=0.0):
    num_boxes = tf.shape(boxes)[-2]
    num_tiles = (num_boxes // TILE_SIZE) - 1

    if self._min_conf > 0.0:
      pred_classes = tf.to_float(tf.greater(pred_classes, self._min_conf))

    def _loop_cond(unused_pred_box, unused_pred_class, boxes, unused_classes,
                   unused_running_boxes, unused_running_classes, unused_max_iou,
                   idx):

      # check that the slice has boxes that all zeros
      batch_size = tf.shape(boxes)[0]
      box_slice = tf.slice(boxes, [0, idx * TILE_SIZE, 0],
                           [batch_size, TILE_SIZE, 4])

      return tf.logical_and(idx < num_tiles,
                            tf.greater(tf.reduce_sum(box_slice), 0))

    running_boxes = tf.zeros_like(pred_boxes)
    running_classes = tf.zeros_like(tf.reduce_sum(running_boxes, axis=-1))
    max_iou = tf.zeros_like(tf.reduce_sum(running_boxes, axis=-1))
    max_iou = tf.expand_dims(max_iou, axis=-1)

    (pred_boxes, pred_classes, boxes, classes, running_boxes, running_classes,
     max_iou, _) = tf.while_loop(_loop_cond, self._search_body, [
         pred_boxes, pred_classes, boxes, classes, running_boxes,
         running_classes, max_iou,
         tf.constant(0)
     ])

    mask = tf.to_float(tf.greater(max_iou, clip_thresh))
    running_boxes *= mask
    running_classes *= tf.squeeze(mask, axis=-1)
    max_iou *= mask
    max_iou = tf.squeeze(max_iou, axis=-1)
    mask = tf.squeeze(mask, axis=-1)

    return (tf.stop_gradient(running_boxes), tf.stop_gradient(running_classes),
            tf.stop_gradient(max_iou), tf.stop_gradient(mask))
//  [python]
def __call__(self,
               pred_boxes,
               pred_classes,
               boxes,
               classes,
               clip_thresh=0.0):
    num_boxes = tf.shape(boxes)[-2]
    num_tiles = (num_boxes // TILE_SIZE) - 1

    if self._min_conf > 0.0:
      pred_classes = tf.cast(pred_classes > self._min_conf, pred_classes.dtype)

    def _loop_cond(unused_pred_box, unused_pred_class, boxes, unused_classes,
                   unused_running_boxes, unused_running_classes, unused_max_iou,
                   idx):

      # check that the slice has boxes that all zeros
      batch_size = tf.shape(boxes)[0]
      box_slice = tf.slice(boxes, [0, idx * TILE_SIZE, 0],
                           [batch_size, TILE_SIZE, 4])

      return tf.logical_and(idx < num_tiles,
                            tf.math.greater(tf.reduce_sum(box_slice), 0))

    running_boxes = tf.zeros_like(pred_boxes)
    running_classes = tf.zeros_like(tf.reduce_sum(running_boxes, axis=-1))
    max_iou = tf.zeros_like(tf.reduce_sum(running_boxes, axis=-1))
    max_iou = tf.expand_dims(max_iou, axis=-1)

    (pred_boxes, pred_classes, boxes, classes, running_boxes, running_classes,
     max_iou, _) = tf.while_loop(_loop_cond, self._search_body, [
         pred_boxes, pred_classes, boxes, classes, running_boxes,
         running_classes, max_iou,
         tf.constant(0)
     ])

    mask = tf.cast(max_iou > clip_thresh, running_boxes.dtype)
    running_boxes *= mask
    running_classes *= tf.squeeze(mask, axis=-1)
    max_iou *= mask
    max_iou = tf.squeeze(max_iou, axis=-1)
    mask = tf.squeeze(mask, axis=-1)

    return (tf.stop_gradient(running_boxes), tf.stop_gradient(running_classes),
            tf.stop_gradient(max_iou), tf.stop_gradient(mask))
//  [python]
def _darknet_boxes(encoded_boxes, width, height, anchor_grid, grid_points,
                   max_delta, scale_xy):
  """Wrapper for _scale_boxes to implement a custom gradient."""
  (scaler, scaled_box, pred_box) = _scale_boxes(encoded_boxes, width, height,
                                                anchor_grid, grid_points,
                                                scale_xy)

  def delta(unused_dy_scaler, dy_scaled, dy):
    dy_xy, dy_wh = tf.split(dy, 2, axis=-1)
    dy_xy_, dy_wh_ = tf.split(dy_scaled, 2, axis=-1)

    # add all the gradients that may have been applied to the
    # boxes and those that have been applied to the width and height
    dy_wh += dy_wh_
    dy_xy += dy_xy_

    # propagate the exponential applied to the width and height in
    # order to ensure the gradient propagated is of the correct
    # magnitude
    pred_wh = encoded_boxes[..., 2:4]
    dy_wh *= tf.math.exp(pred_wh)

    dbox = tf.concat([dy_xy, dy_wh], axis=-1)

    # apply the gradient clipping to xy and wh
    dbox = math_ops.rm_nan_inf(dbox)
    delta = tf.cast(max_delta, dbox.dtype)
    dbox = tf.clip_by_value(dbox, -delta, delta)
    return dbox, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0

  return (scaler, scaled_box, pred_box), delta
//  [python]
def input(self):

        #output_shapes = tf.placeholder_with_default(self.output_shapes, [6], name="data_shapes")
        #os = [tf.TensorShape(s) for s in self.output_shapes]

        iterator = tf.data.Iterator.from_string_handle(self.iterator_handle,
                                                               output_types=eval(FLAGS.expected_datatypes))

        with tf.name_scope("raw"):
            x10, x20, x60, doy, year, labels = iterator.get_next()

            self.x10 = tf.to_float(x10, name="x10")
            self.x20 = tf.to_float(x20, name="x20")
            self.x60 = tf.to_float(x60, name="x60")
            self.doy = tf.to_float(doy, name="doy")
            self.year = tf.to_float(year,name="year")
            self.y = tf.to_int32(labels,name="y")

        #self.x10.set_shape([2,46,24,24,5])

        # integer sequence lenths per batch for dynamic_rnn masking
        self.seq = sequence_lengths = tf.reduce_sum(tf.cast(self.x10[:, :, 0, 0, 0] > 0, tf.int32), axis=1, name="sequence_lengths")

        def resize(tensor, new_height, new_width):
            b = tf.shape(tensor)[0]
            t = tf.shape(tensor)[1]
            h = tf.shape(tensor)[2]
            w = tf.shape(tensor)[3]
            d = tf.shape(tensor)[4]

            # stack batch on times to fit 4D requirement of resize_tensor
            stacked_tensor = tf.reshape(tensor, [b * t, h, w, d])
            reshaped_stacked_tensor = tf.image.resize_images(stacked_tensor, size=(new_height, new_width))
            return tf.reshape(reshaped_stacked_tensor, [b, t, new_height, new_width, d])


        def expand3x(vector):
            vector = tf.expand_dims(vector, -1)
            vector = tf.expand_dims(vector, -1)
            vector = tf.expand_dims(vector, -1)
            return vector

        with tf.name_scope("reshaped"):

            b = tf.shape(self.x10)[0]
            t = tf.shape(self.x10)[1]
            px = tf.shape(self.x10)[2]

            #b,t,w,h,d = self.x10.shape()

            x20 = tf.identity(resize(self.x20, px, px),name="x20")
            x60 = tf.identity(resize(self.x60, px, px),name="x60")

            tf.add_to_collection(ADVANCED_SUMMARY_COLLECTION_NAME,tf.identity(self.x10, name="x10"))
            tf.add_to_collection(ADVANCED_SUMMARY_COLLECTION_NAME, x20)
            tf.add_to_collection(ADVANCED_SUMMARY_COLLECTION_NAME, x60)

            # expand
            doymat = tf.multiply(expand3x(self.doy), tf.ones((b,t,px,px,1)),name="doy")
            yearmat = self.yearmat = tf.multiply(expand3x(self.year), tf.ones((b, t, px, px, 1)),name="year")

            x = tf.concat((self.x10,x20,x60,doymat,yearmat),axis=-1,name="x")
            tf.add_to_collection(ADVANCED_SUMMARY_COLLECTION_NAME, x)

            # set depth of x for convolutions
            depth = FLAGS.num_bands_10m + FLAGS.num_bands_20m + FLAGS.num_bands_60m + 2 # doy and year

            # dynamic shapes. Fill for debugging

            x.set_shape([None, None, FLAGS.pix10m, FLAGS.pix10m, depth])
            self.y.set_shape((None,None,FLAGS.pix10m,FLAGS.pix10m))

        return (x, sequence_lengths), (self.y,)
//  [python]
def input(self):

        #output_shapes = tf.placeholder_with_default(self.output_shapes, [6], name="data_shapes")
        #os = [tf.TensorShape(s) for s in self.output_shapes]

        iterator = tf.data.Iterator.from_string_handle(self.iterator_handle,
                                                               output_types=eval(FLAGS.expected_datatypes))

        with tf.name_scope("raw"):
            x10, x20, x60, doy, year, labels = iterator.get_next()

            self.x10 = tf.cast(x10, tf.float32, name="x10")
            self.x20 = tf.cast(x20, tf.float32, name="x20")
            self.x60 = tf.cast(x60, tf.float32, name="x60")
            self.doy = tf.cast(doy, tf.float32, name="doy")
            self.year = tf.cast(year, tf.float32,name="year")
            self.y = tf.cast(labels, tf.int32,name="y")

        #self.x10.set_shape([2,46,24,24,5])

        # integer sequence lenths per batch for dynamic_rnn masking
        self.seq = sequence_lengths = tf.reduce_sum(tf.cast(self.x10[:, :, 0, 0, 0] > 0, tf.int32), axis=1, name="sequence_lengths")

        def resize(tensor, new_height, new_width):
            b = tf.shape(tensor)[0]
            t = tf.shape(tensor)[1]
            h = tf.shape(tensor)[2]
            w = tf.shape(tensor)[3]
            d = tf.shape(tensor)[4]

            # stack batch on times to fit 4D requirement of resize_tensor
            stacked_tensor = tf.reshape(tensor, [b * t, h, w, d])
            reshaped_stacked_tensor = tf.image.resize_images(stacked_tensor, size=(new_height, new_width))
            return tf.reshape(reshaped_stacked_tensor, [b, t, new_height, new_width, d])


        def expand3x(vector):
            vector = tf.expand_dims(vector, -1)
            vector = tf.expand_dims(vector, -1)
            vector = tf.expand_dims(vector, -1)
            return vector

        with tf.name_scope("reshaped"):

            b = tf.shape(self.x10)[0]
            t = tf.shape(self.x10)[1]
            px = tf.shape(self.x10)[2]

            #b,t,w,h,d = self.x10.shape()

            x20 = tf.identity(resize(self.x20, px, px),name="x20")
            x60 = tf.identity(resize(self.x60, px, px),name="x60")

            tf.add_to_collection(ADVANCED_SUMMARY_COLLECTION_NAME,tf.identity(self.x10, name="x10"))
            tf.add_to_collection(ADVANCED_SUMMARY_COLLECTION_NAME, x20)
            tf.add_to_collection(ADVANCED_SUMMARY_COLLECTION_NAME, x60)

            # expand
            doymat = tf.multiply(expand3x(self.doy), tf.ones((b,t,px,px,1)),name="doy")
            yearmat = self.yearmat = tf.multiply(expand3x(self.year), tf.ones((b, t, px, px, 1)),name="year")

            x = tf.concat((self.x10,x20,x60,doymat,yearmat),axis=-1,name="x")
            tf.add_to_collection(ADVANCED_SUMMARY_COLLECTION_NAME, x)

            # set depth of x for convolutions
            depth = FLAGS.num_bands_10m + FLAGS.num_bands_20m + FLAGS.num_bands_60m + 2 # doy and year

            # dynamic shapes. Fill for debugging

            x.set_shape([None, None, FLAGS.pix10m, FLAGS.pix10m, depth])
            self.y.set_shape((None,None,FLAGS.pix10m,FLAGS.pix10m))

        return (x, sequence_lengths), (self.y,)
//  [python]
def _new_coord_scale_boxes(encoded_boxes, width, height, anchor_grid,
                           grid_points, scale_xy):
  """Decodes models boxes by squaring and scaling the width and height maps."""
  # split the boxes
  pred_xy = encoded_boxes[..., 0:2]
  pred_wh = encoded_boxes[..., 2:4]

  # build a scaling tensor to get the offset of th ebox relative to the image
  scaler = tf.convert_to_tensor([height, width, height, width])
  scale_xy = tf.cast(scale_xy, pred_xy.dtype)

  # apply the sigmoid
  pred_xy = tf.math.sigmoid(pred_xy)
  pred_wh = tf.math.sigmoid(pred_wh)

  # scale the xy offset predictions according to the config
  pred_xy = pred_xy * scale_xy - 0.5 * (scale_xy - 1)

  # find the true offset from the grid points and the scaler
  # where the grid points are the relative offset of each pixel with
  # in the image
  box_xy = grid_points + pred_xy

  # decode the widht and height of the boxes and correlate them
  # to the anchor boxes
  box_wh = (2 * pred_wh)**2 * anchor_grid

  # build the final boxes
  scaled_box = tf.concat([box_xy, box_wh], axis=-1)
  pred_box = scaled_box / scaler

  # shift scaled boxes
  scaled_box = tf.concat([pred_xy, box_wh], axis=-1)
  return (scaler, scaled_box, pred_box)
//  [python]
def _darknet_new_coord_boxes(encoded_boxes, width, height, anchor_grid,
                             grid_points, max_delta, scale_xy):
  """Wrapper for _new_coord_scale_boxes to implement a custom gradient."""
  (scaler, scaled_box,
   pred_box) = _new_coord_scale_boxes(encoded_boxes, width, height, anchor_grid,
                                      grid_points, scale_xy)

  def delta(unused_dy_scaler, dy_scaled, dy):
    dy_xy, dy_wh = tf.split(dy, 2, axis=-1)
    dy_xy_, dy_wh_ = tf.split(dy_scaled, 2, axis=-1)

    # add all the gradients that may have been applied to the
    # boxes and those that have been applied to the width and height
    dy_wh += dy_wh_
    dy_xy += dy_xy_

    dbox = tf.concat([dy_xy, dy_wh], axis=-1)

    # apply the gradient clipping to xy and wh
    dbox = math_ops.rm_nan_inf(dbox)
    delta = t.cast(max_delta, dbox.dtype)
    dbox = tf.clip_by_value(dbox, -delta, delta)
    return dbox, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0

  return (scaler, scaled_box, pred_box), delta
//  [python]
def _darknet_new_coord_boxes(encoded_boxes, width, height, anchor_grid,
                             grid_points, max_delta, scale_xy):
  """Wrapper for _new_coord_scale_boxes to implement a custom gradient."""
  (scaler, scaled_box,
   pred_box) = _new_coord_scale_boxes(encoded_boxes, width, height, anchor_grid,
                                      grid_points, scale_xy)

  def delta(unused_dy_scaler, dy_scaled, dy):
    dy_xy, dy_wh = tf.split(dy, 2, axis=-1)
    dy_xy_, dy_wh_ = tf.split(dy_scaled, 2, axis=-1)

    # add all the gradients that may have been applied to the
    # boxes and those that have been applied to the width and height
    dy_wh += dy_wh_
    dy_xy += dy_xy_

    dbox = tf.concat([dy_xy, dy_wh], axis=-1)

    # apply the gradient clipping to xy and wh
    dbox = math_ops.rm_nan_inf(dbox)
    delta = tf.cast(max_delta, dbox.dtype)
    dbox = tf.clip_by_value(dbox, -delta, delta)
    return dbox, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0

  return (scaler, scaled_box, pred_box), delta
//  [python]
def simulate_bfloat16_transport(tensor):
    """ Convert a tensor to bfloat16 and then back to float32 """
    return t.cast(t.cast(tensor, dtype=t.bfloat16), dtype=t.float32)
//  [python]
def simulate_bfloat16_transport(tensor):
    """ Convert a tensor to bfloat16 and then back to float32 """
    return tf.cast(tf.cast(tensor, dtype=tf.bfloat16), dtype=tf.float32)
//  [python]
def _anchor_free_scale_boxes(encoded_boxes,
                             width,
                             height,
                             stride,
                             grid_points,
                             darknet=False):
  """Decode models boxes using FPN stride under anchor free conditions."""
  del darknet
  # split the boxes
  pred_xy = encoded_boxes[..., 0:2]
  pred_wh = encoded_boxes[..., 2:4]

  # build a scaling tensor to get the offset of th ebox relative to the image
  scaler = t.convert_to_tensor([height, width, height, width])

  # scale the offsets and add them to the grid points or a tensor that is
  # the realtive location of each pixel
  box_xy = (grid_points + pred_xy)

  # scale the width and height of the predictions and corlate them
  # to anchor boxes
  box_wh = t.math.exp(pred_wh)

  # build the final predicted box
  scaled_box = t.concat([box_xy, box_wh], axis=-1)

  # properly scaling boxes gradeints
  scaled_box = scaled_box * t.cast(stride, scaled_box.dtype)
  pred_box = scaled_box / t.cast(scaler * stride, scaled_box.dtype)
  return (scaler, scaled_box, pred_box)
//  [python]
def _anchor_free_scale_boxes(encoded_boxes,
                             width,
                             height,
                             stride,
                             grid_points,
                             darknet=False):
  """Decode models boxes using FPN stride under anchor free conditions."""
  del darknet
  # split the boxes
  pred_xy = encoded_boxes[..., 0:2]
  pred_wh = encoded_boxes[..., 2:4]

  # build a scaling tensor to get the offset of th ebox relative to the image
  scaler = tf.convert_to_tensor([height, width, height, width])

  # scale the offsets and add them to the grid points or a tensor that is
  # the realtive location of each pixel
  box_xy = (grid_points + pred_xy)

  # scale the width and height of the predictions and corlate them
  # to anchor boxes
  box_wh = tf.math.exp(pred_wh)

  # build the final predicted box
  scaled_box = tf.concat([box_xy, box_wh], axis=-1)

  # properly scaling boxes gradeints
  scaled_box = scaled_box * tf.cast(stride, scaled_box.dtype)
  pred_box = scaled_box / tf.cast(scaler * stride, scaled_box.dtype)
  return (scaler, scaled_box, pred_box)
//  [python]
def _add_gaussian_noise(tensors: List[tf.Tensor], stddev: float,
                        seed: Optional[int]) -> List[tf.Tensor]:
    if seed is not None:
        weight_seeds = tfp.random.split_seed(t.cast(seed, tf.int32),
                                             salt='add_gaussian_noise',
                                             n=len(tensors))
    else:
        weight_seeds = [None] * len(tensors)
    assert _normal_dist is not None
    return [
        tensor + t.cast(_normal_dist.sample(tensor.shape, seed=weight_seed),
                         tensor.dtype) * t.cast(stddev, tensor.dtype)
        for weight_seed, tensor in zip(weight_seeds, tensors)
    ]
//  [python]
def _add_gaussian_noise(tensors: List[tf.Tensor], stddev: float,
                        seed: Optional[int]) -> List[tf.Tensor]:
    if seed is not None:
        weight_seeds = tfp.random.split_seed(tf.cast(seed, tf.int32),
                                             salt='add_gaussian_noise',
                                             n=len(tensors))
    else:
        weight_seeds = [None] * len(tensors)
    assert _normal_dist is not None
    return [
        tensor + tf.cast(_normal_dist.sample(tensor.shape, seed=weight_seed),
                         tensor.dtype) * tf.cast(stddev, tensor.dtype)
        for weight_seed, tensor in zip(weight_seeds, tensors)
    ]
//  [python]
def _flatten(tensors: List[tf.Tensor]) -> tf.Tensor:
    return tf.concat(
        [tf.reshape(tf.to_float(v), [-1]) for v in tensors], axis=0)
//  [python]
def _flatten(tensors: List[tf.Tensor]) -> tf.Tensor:
    return tf.concat(
        [tf.cast(tf.reshape(v, [-1]), tf.float32) for v in tensors], axis=0)
//  [python]
def _add_laplacian_noise(tensors: List[tf.Tensor], scale: float,
                         seed: Optional[int]) -> List[tf.Tensor]:
    if seed is not None:
        weight_seeds = tfp.random.split_seed(t.cast(seed, tf.int32),
                                             salt='add_laplacian_noise',
                                             n=len(tensors))
    else:
        weight_seeds = [None] * len(tensors)
    assert _laplace_dist is not None
    return [
        tensor + t.cast(_laplace_dist.sample(tensor.shape, seed=weight_seed),
                         tensor.dtype) * t.cast(scale, tensor.dtype)
        for weight_seed, tensor in zip(weight_seeds, tensors)
    ]
//  [python]
def _add_laplacian_noise(tensors: List[tf.Tensor], scale: float,
                         seed: Optional[int]) -> List[tf.Tensor]:
    if seed is not None:
        weight_seeds = tfp.random.split_seed(tf.cast(seed, tf.int32),
                                             salt='add_laplacian_noise',
                                             n=len(tensors))
    else:
        weight_seeds = [None] * len(tensors)
    assert _laplace_dist is not None
    return [
        tensor + tf.cast(_laplace_dist.sample(tensor.shape, seed=weight_seed),
                         tensor.dtype) * tf.cast(scale, tensor.dtype)
        for weight_seed, tensor in zip(weight_seeds, tensors)
    ]
//  [python]
def setup(self):
        if self.batch_size is None or self.num_items is None:
            return

        if self.params_truncate_at == None:
            self.pred_truncate_at = self.num_items
        else:
            self.pred_truncate_at = self.params_truncate_at

        self.ndcg_at = min(self.params_ndcg_at, self.num_items)
        self.dcg_position_discounts = 1. / tf.experimental.numpy.log2(
                        tf.to_float(tf.range(self.pred_truncate_at) + 2))
        self.top_position_discounts = tf.reshape(self.dcg_position_discounts[:self.ndcg_at], (self.ndcg_at, 1))
        self.swap_importance = tf.abs(self.get_pairwise_diffs_for_vector(self.dcg_position_discounts))
        self.batch_indices = tf.reshape(tf.tile(tf.expand_dims(tf.range(self.batch_size), 1), [1, self.pred_truncate_at]),
                                        (self.pred_truncate_at * self.batch_size, 1))
        self.mask = tf.to_float(tf.reshape(1 - tf.pad(tf.ones(self.ndcg_at),
                                                  [[0, self.pred_truncate_at - self.ndcg_at]]),
                                       (1, self.pred_truncate_at)))
//  [python]
def setup(self):
        if self.batch_size is None or self.num_items is None:
            return

        if self.params_truncate_at == None:
            self.pred_truncate_at = self.num_items
        else:
            self.pred_truncate_at = self.params_truncate_at

        self.ndcg_at = min(self.params_ndcg_at, self.num_items)
        self.dcg_position_discounts = 1. / tf.experimental.numpy.log2(
                        tf.cast(tf.range(self.pred_truncate_at) + 2, self.dtype))
        self.top_position_discounts = tf.reshape(self.dcg_position_discounts[:self.ndcg_at], (self.ndcg_at, 1))
        self.swap_importance = tf.abs(self.get_pairwise_diffs_for_vector(self.dcg_position_discounts))
        self.batch_indices = tf.reshape(tf.tile(tf.expand_dims(tf.range(self.batch_size), 1), [1, self.pred_truncate_at]),
                                        (self.pred_truncate_at * self.batch_size, 1))
        self.mask = tf.cast(tf.reshape(1 - tf.pad(tf.ones(self.ndcg_at),
                                                  [[0, self.pred_truncate_at - self.ndcg_at]]),
                                       (1, self.pred_truncate_at)), self.dtype)
//  [python]
def evolve_trotter_defun(psi,
                         H,
                         step_size,
                         num_steps,
                         euclidean=False,
                         callback=None,
                         batch_size=1):
  """Evolve an initial wavefunction psi using a trotter decomposition of H.

  If the evolution is euclidean, the wavefunction will be normalized after
  each step.

  In this version, `batch_size` steps are "compiled" to a computational graph
  using `defun`, which greatly decreases overhead.

  Args:
    psi: An `N`-dimensional tensor representing the initial wavefunction.
    H: A list of `N-1` tensors representing nearest-neighbor operators.
    step_size: The trotter step size.
    num_steps: The number of trotter steps to take.
    euclidean: If `True`, evolve in Euclidean (imaginary) time.
    callback: Optional callback function for monitoring the evolution.
    batch_size: The number of steps to unroll in the computational graph.

  Returns:
    psi_t: The final wavefunction.
    t: The final time.
  """
  n_batches, rem = divmod(num_steps, batch_size)

  step_size = t.cast(step_size, psi.dtype)

  num_sites = len(psi.shape)
  layers = trotter_prepare_gates(H, step_size, num_sites, euclidean)

  t = 0.0
  for i in range(n_batches):
    psi, t_b = _evolve_trotter_gates_defun(
        psi, layers, step_size, batch_size, euclidean=euclidean, callback=None)
    t += t_b
    if callback is not None:
      callback(psi, t, (i + 1) * batch_size - 1)

  if rem > 0:
    psi, t_b = _evolve_trotter_gates_defun(
        psi, layers, step_size, rem, euclidean=euclidean, callback=None)
    t += t_b

  return psi, t
//  [python]
def evolve_trotter_defun(psi,
                         H,
                         step_size,
                         num_steps,
                         euclidean=False,
                         callback=None,
                         batch_size=1):
  """Evolve an initial wavefunction psi using a trotter decomposition of H.

  If the evolution is euclidean, the wavefunction will be normalized after
  each step.

  In this version, `batch_size` steps are "compiled" to a computational graph
  using `defun`, which greatly decreases overhead.

  Args:
    psi: An `N`-dimensional tensor representing the initial wavefunction.
    H: A list of `N-1` tensors representing nearest-neighbor operators.
    step_size: The trotter step size.
    num_steps: The number of trotter steps to take.
    euclidean: If `True`, evolve in Euclidean (imaginary) time.
    callback: Optional callback function for monitoring the evolution.
    batch_size: The number of steps to unroll in the computational graph.

  Returns:
    psi_t: The final wavefunction.
    t: The final time.
  """
  n_batches, rem = divmod(num_steps, batch_size)

  step_size = tf.cast(step_size, psi.dtype)

  num_sites = len(psi.shape)
  layers = trotter_prepare_gates(H, step_size, num_sites, euclidean)

  t = 0.0
  for i in range(n_batches):
    psi, t_b = _evolve_trotter_gates_defun(
        psi, layers, step_size, batch_size, euclidean=euclidean, callback=None)
    t += t_b
    if callback is not None:
      callback(psi, t, (i + 1) * batch_size - 1)

  if rem > 0:
    psi, t_b = _evolve_trotter_gates_defun(
        psi, layers, step_size, rem, euclidean=euclidean, callback=None)
    t += t_b

  return psi, t
//  [python]
def _helper_init_tensorarray(backend_fw, l_kwargs, fn=None):
    id_write, kwargs = l_kwargs
    with BackendHandler.update_backend(backend_fw) as ivy_backend:
        local_importer = ivy_backend.utils.dynamic_import
        tf_frontend = local_importer.import_module(
            "ivy.functional.frontends.tensorflow"
        )
        ta = tf_frontend.tensor.TensorArray(**kwargs)
        ta_gt = tf.TensorArray(**kwargs)
        if fn == "unstack":
            ta_gt = ta_gt.unstack(tf.constant(id_write))
            ta = ta.unstack(tf_frontend.constant(id_write))
        elif fn == "split":
            ta_gt = ta_gt.split(**id_write)
            ta = ta.split(**id_write)
        elif fn == "scatter":
            indices, value = [*zip(*id_write)]
            ta_gt = ta_gt.scatter(indices, tf.cast(tf.stack(value), dtype=ta_gt.dtype))
            value = tf_frontend.stack(list(map(tf_frontend.constant, value)))
            ta = ta.scatter(indices, tf.cast(value, ta.dtype))
        else:
            for id, write in id_write:
                ta_gt = ta_gt.write(id, tf.constant(write))
                ta = ta.write(id, tf_frontend.constant(write))
    return ta_gt, ta
//  [python]
def _helper_init_tensorarray(backend_fw, l_kwargs, fn=None):
    id_write, kwargs = l_kwargs
    with BackendHandler.update_backend(backend_fw) as ivy_backend:
        local_importer = ivy_backend.utils.dynamic_import
        tf_frontend = local_importer.import_module(
            "ivy.functional.frontends.tensorflow"
        )
        ta = tf_frontend.tensor.TensorArray(**kwargs)
        ta_gt = tf.TensorArray(**kwargs)
        if fn == "unstack":
            ta_gt = ta_gt.unstack(tf.constant(id_write))
            ta = ta.unstack(tf_frontend.constant(id_write))
        elif fn == "split":
            ta_gt = ta_gt.split(**id_write)
            ta = ta.split(**id_write)
        elif fn == "scatter":
            indices, value = [*zip(*id_write)]
            ta_gt = ta_gt.scatter(indices, tf.cast(tf.stack(value), dtype=ta_gt.dtype))
            value = tf_frontend.stack(list(map(tf_frontend.constant, value)))
            ta = ta.scatter(indices, tf_frontend.cast(value, ta.dtype))
        else:
            for id, write in id_write:
                ta_gt = ta_gt.write(id, tf.constant(write))
                ta = ta.write(id, tf_frontend.constant(write))
    return ta_gt, ta
//  [python]
def norm(tensor: tf.Tensor, order) -> tf.Tensor:
    """
    Calculate the norm of a tensor.

    :param tensor:
        A tensor to calculate the norm for.
    :param order:
        The order of the distance metric (norm).
    :returns:
        The norm.
    """
    if order == 1 or order == np.inf:
        tensor = tf.abs(tensor)

    norm_value = tf.reduce_max(tensor) if order == np.inf else tf.norm(
        t.float32(tensor), ord=order)
    return t.float32(norm_value)
//  [python]
def norm(tensor: tf.Tensor, order) -> tf.Tensor:
    """
    Calculate the norm of a tensor.

    :param tensor:
        A tensor to calculate the norm for.
    :param order:
        The order of the distance metric (norm).
    :returns:
        The norm.
    """
    if order == 1 or order == np.inf:
        tensor = tf.abs(tensor)

    norm_value = tf.reduce_max(tensor) if order == np.inf else tf.norm(
        tf.cast(tensor, tf.float32), ord=order)
    return tf.cast(norm_value, tf.float32)