code: def three_spatial_transform_box(boxes, state, crop_size):
      """Transform boxes given the state of image crop."""
      result = []
      for spatial_idx in range(3):
          assert (
              state
              and f"crop_offset_abs_{spatial_idx}" in state
              and f"crop_ori_shape_{spatial_idx}" in state
          )
          offset = state[f"crop_offset_abs_{spatial_idx}"]
          ori_shape = tf.cast(
              state[f"crop_ori_shape_{spatial_idx}"], tf.float32
          )
          pixel_offset = tf.reshape(
              tf.stack([offset[2], offset[1], offset[2], offset[1]]),
              (1, 1, 4),
          )
          ori_size = tf.stack(
              [ori_shape[2], ori_shape[1], ori_shape[2], ori_shape[1]]
          )
          ori_size = tf.reshape(ori_size, (1, 1, 4))
          ori_boxes = boxes * tf.cast(ori_size, tf.float32)
          crop_boxes = ori_boxes - tf.cast(pixel_offset, tf.float32)
          new_shape = tf.constant(
              [crop_size, crop_size, crop_size, crop_size],
              dtype=tf.float32,
              shape=[1, 1, 4],
          )
          out_boxes = crop_boxes / new_shape
          result.append(out_boxes)
      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 9 for calling a global function with example usage: three_spatial_transform_box(boxes, state, crop_size) and returns: tf