code: def im2patches(
      x, patch_size, strides=[1, 1], padding="SAME", data_format="NCHW"
  ):
      """
      :param x: a 4-D Tensor.
      """
  
      with tf.name_scope("im2patches"):
          # To NHWC
          if data_format == "NCHW":
              x = tf.transpose(x, [0, 2, 3, 1])
  
          # we need NHWC because tf.extract_image_patches expects this
          patches = tf.image.extract_patches(
              images=x,
              sizes=[1, patch_size[0], patch_size[1], 1],
              strides=[1, strides[0], strides[1], 1],
              rates=[1, 1, 1, 1],
              padding=padding,
          )
          # To NCHW
          if data_format == "NCHW":
              patches = tf.transpose(patches, [0, 3, 1, 2])
  
      return patches
  
file_path: tf-encrypted/tf_encrypted/tensor/shared.py
imports: import math
  from typing import Optional
  import tensorflow
label_desc: Use image node_id 3 for calling a global function with example usage: im2patches(x, patch_size, strides, padding, data_format) and returns: patches