code: def get_within_bounds_crop_slice(
      begin: tf.Tensor,
      size: tf.Tensor,
      image_shape: Union[tf.TensorShape, tf.Tensor],
  ) -> Tuple[tf.Tensor, tf.Tensor]:
      """Computes a within bounds crop slice from slice & image shape.
  
      Given a potentially outside of image bound crop slice, return a crop slice
      that strictly fall within the bound of the image.
  
      Args:
        begin: Beginning of the slice. Assumed to have 3 elements (W, H, C) with
          the channel slice starting at 0.
        size: Size of the slice. Assumed to have 3 elemets (W, H, C) with the
          channel slice covering the entire shape (i.e. equal to -1).
        image_shape: Size of the image being sliced.
  
      Returns:
        Updated begin and size that strictly fall within the image.
      """
      crop_ymin, crop_xmin, _ = tf.unstack(begin, axis=0)
      crop_height, crop_width, _ = tf.unstack(size, axis=0)
      crop_ymax = crop_ymin + crop_height
      crop_xmax = crop_xmin + crop_width
      ymax = tf.minimum(crop_ymax, image_shape[0])
      xmax = tf.minimum(crop_xmax, image_shape[1])
      ymin, xmin, _ = tf.unstack(tf.maximum(begin, 0), axis=0)
      begin = tf.stack([ymin, xmin, 0], axis=0)
      size = tf.stack([ymax - ymin, xmax - xmin, -1], axis=0)
      return begin, size
  
file_path: scenic/scenic/projects/owl_vit/preprocessing/transforms.py
imports: from typing import Any, Optional, Sequence, Tuple, Union
  import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: get_within_bounds_crop_slice(begin, size, image_shape) and returns: begin,  size