code: def im2col(
      x,
      h_filter: int,
      w_filter: int,
      strides: list = [1, 1],
      padding: str = "SAME",
      data_format="NCHW",
  ) -> tf.Tensor:
      """Generic implementation of im2col on tf.Tensors."""
  
      with tf.name_scope("im2col"):
          if data_format == "NCHW":
              x = x.transpose([0, 2, 3, 1])
          channels = int(x.shape[3])
  
          patch_tensor = x.im2patches(
              (h_filter, w_filter),
              strides=strides,
              padding=padding,
              data_format="NHWC",
          )
  
          patch_tensor = patch_tensor.transpose([3, 1, 2, 0])
          patch_tensor = patch_tensor.reshape(
              (h_filter, w_filter, channels, -1)
          )
  
          if data_format == "NCHW":
              # Put channel first for each patch
              patch_tensor = patch_tensor.transpose([2, 0, 1, 3])
  
          # reshape to x_col
          x_col_tensor = patch_tensor.reshape(
              (channels * h_filter * w_filter, -1)
          )
  
          return x_col_tensor
  
file_path: tf-encrypted/tf_encrypted/tensor/shared.py
imports: import math
  from typing import Optional
  import tensorflow
label_desc: Use image node_id 6 for calling a global function with example usage: im2col(x, h_filter, w_filter, strides, padding, data_format) and returns: x_col_tensor