class_docstr: Crops or pads the features to have uniform shapes.
class_docstr_tok: ["Crops","or","pads","the","features","to","have","uniform","shapes","."]
code: def apply(self, image: tf.Tensor) -> tf.Tensor:
      if self.size is None:
          return image
  
      c = image.shape[-1]
      paddings = transforms.get_paddings(
          tf.shape(image), self.size, allow_crop=self.allow_crop
      )
      image = tf.pad(image, paddings, constant_values=0)
      if self.allow_crop:
          image = image[: self.size, : self.size, :]
          image.set_shape((self.size, self.size, c))
          return image
      return image
  
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 1 for calling the CropOrPad obj's underlying member method code with example usage: obj.apply(image) and returns: image, image, image