class_docstr: Randomly crops an image based on self._sample_random_crop_region.
class_docstr_tok: ["Randomly","crops","an","image","based","on","self._sample_random_crop_region","."]
code: def apply(self, image: tf.Tensor, seed: tf.Tensor) -> tf.Tensor:
      image_shape = tf.shape(image)
      begin, size = self._sample_random_crop_region(
          image_shape=image_shape, seed=seed
      )
  
      (
          offset_y,
          offset_x,
          crop_height,
          crop_width,
      ) = transforms.get_padding_params_from_crop_slice(begin, size)
      begin, size = transforms.get_within_bounds_crop_slice(
          begin, size, image_shape
      )
  
      image = tf.slice(image, begin, size)  # Slice.
      image = tf.image.pad_to_bounding_box(  # Maybe pad.
          image,
          offset_height=offset_y,
          offset_width=offset_x,
          target_height=crop_height,
          target_width=crop_width,
      )
  
      return tf.ensure_shape(image, (None, None, 3))
  
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 2 for calling the RandomCropBase obj's underlying member method code with example usage: obj.apply(image, seed) and returns: tf