class_docstr: Resizes image to a given size, adding padding to perserve the aspect ratio.
  
  Padding is added on the bottom and right.
  
  Attr:
    size: The new size of the image: either an integer H, where H is both the
      new height and width, or a tuple or list [H, W] of integers, where H and W
      are new image's height and width respectively.
    pad_value: Value to use for padding.
    antialias: Whether to use an anti-aliasing filter when downsampling an
      image.
class_docstr_tok: ["Resizes","image","to","a","given","size",",","adding","padding","to","perserve","the","aspect","ratio",".","Padding","is","added","on","the","bottom","and","right",".","Attr",":","size",":","The","new","size","of","the","image",":","either","an","integer","H",",","where","H","is","both","the","new","height","and","width",",","or","a","tuple","or","list","[","H",",","W","]","of","integers",",","where","H","and","W","are","new","image","'s","height","and","width","respectively",".","pad_value",":","Value","to","use","for","padding",".","antialias",":","Whether","to","use","an","anti-aliasing","filter","when","downsampling","an","image","."]
code: def apply_boxes(
      self, boxes: tf.Tensor, image_size: transforms.SizeTuple
  ) -> tf.Tensor:
      transforms.assert_boxes_are_relative(boxes)
  
      # Get relative image size before padding (w.r.t. padded output image):
      h_orig, w_orig = image_size
      long_edge = tf.maximum(h_orig, w_orig)
      h_rel = h_orig / long_edge
      w_rel = w_orig / long_edge
  
      # Pad the boxes to the output size:
      padded_size = self.size
      if isinstance(padded_size, int):
          padded_size = (padded_size, padded_size)
      return transforms.crop_or_pad_boxes(
          boxes=boxes,
          top=0,
          left=0,
          height=padded_size[0],
          width=padded_size[1],
          h_orig=tf.cast(h_rel * padded_size[0], h_orig.dtype),
          w_orig=tf.cast(w_rel * padded_size[1], w_orig.dtype),
      )
  
imports: import abc
  import dataclasses
  from typing import Optional, Sequence, Tuple, Union
  from clu import preprocess_spec
  from scenic.projects.owl_vit.preprocessing import modalities
  from scenic.projects.owl_vit.preprocessing import transforms
  import tensorflow
label_desc: Use image node_id 3 for calling the ResizeWithPad obj's underlying member method code with example usage: obj.apply_boxes(boxes, image_size) and returns: transforms