code: def three_spatial_crops_with_state(images, state, crop_size):
      """Returns three spatial crops of the same frame, as done by SlowFast."""
      height, width = tf.shape(images)[1], tf.shape(images)[2]
  
      result = []
      for spatial_idx in range(3):
          y_offset = tf.cast(
              tf.math.ceil((height - crop_size) / 2), tf.int32
          )
          x_offset = tf.cast(
              tf.math.ceil((width - crop_size) / 2), tf.int32
          )
          if height > width:
              if spatial_idx == 0:
                  y_offset = 0
              elif spatial_idx == 2:
                  y_offset = height - crop_size
          else:
              if spatial_idx == 0:
                  x_offset = 0
              elif spatial_idx == 2:
                  x_offset = width - crop_size
          images_cropped = tf.slice(
              images,
              [0, y_offset, x_offset, 0],
              [-1, crop_size, crop_size, -1],
          )
          if state is not None:
              offset = tf.convert_to_tensor(
                  value=(0, y_offset, x_offset, 0)
              )
              shape = tf.convert_to_tensor(
                  value=(-1, height, width, -1)
              )
              offset_proportion = tf.cast(offset, tf.float32) / tf.cast(
                  shape, tf.float32
              )
              state[
                  f"crop_offset_proportion_{spatial_idx}"
              ] = offset_proportion  # 4
              state[f"crop_ori_shape_{spatial_idx}"] = shape  # 4
              state[f"crop_offset_abs_{spatial_idx}"] = offset  # 4
          result.append(images_cropped)
  
      return tf.concat(result, axis=0)
  
imports: from typing import Optional, Union
  from absl import logging
  from dmvr import builders
  from dmvr import processors
  import ml_collections
  import tensorflow
label_desc: Use image node_id 8 for calling a global function with example usage: three_spatial_crops_with_state(images, state, crop_size) and returns: tf