code: def unfold(
      x, kernel_sizes, strides=1, paddings=0, dilations=1, name=None
  ):
      # Input checking
      if isinstance(kernel_sizes, int):
          kernel_sizes = [kernel_sizes, kernel_sizes]
      elif not isinstance(kernel_sizes, (list, tuple)):
          raise ivy.exceptions.IvyError(
              "Expected kernel size input as type int, tuple or list but got"
              f" {type(kernel_sizes)}"
          )
  
      if isinstance(strides, int):
          strides = [strides, strides]
      elif not isinstance(strides, (list, tuple)):
          raise ivy.exceptions.IvyError(
              f"Expected strides input as type int, tuple or list but got {type(strides)}"
          )
  
      if isinstance(dilations, int):
          dilations = [dilations, dilations]
      elif not isinstance(dilations, (list, tuple)):
          raise ivy.exceptions.IvyError(
              "Expected dilations input as type int, tuple or list but got"
              f" {type(dilations)}"
          )
  
      if isinstance(paddings, int):
          paddings = [paddings, paddings]
      elif not isinstance(paddings, (list, tuple)):
          raise ivy.exceptions.IvyError(
              "Expected paddings, input as type int, tuple or list but got"
              f" {type(paddings)}"
          )
  
      n, c, h, w = x.shape
      # Padding
      if paddings[0] >= 0 or paddings[1] >= 0:
          padding_tup = [(0, 0) for i in range(2)] + [
              (paddings[0], paddings[0]),
              (paddings[1], paddings[1]),
          ]
          x = ivy.pad(
              x, padding_tup, mode="constant", constant_values=0.0
          )
      else:
          raise ivy.exceptions.IvyError(
              f"Expected padding size larger than 0 but got {paddings[0]}/{paddings[1]}"
          )
  
      # Expected input shape
      h_steps = int(
          (
              h
              + (paddings[0] * 2)
              - dilations[0] * (kernel_sizes[0] - 1)
              - 1
          )
          / strides[0]
          + 1
      )
  
      w_steps = int(
          (
              w
              + (paddings[1] * 2)
              - dilations[1] * (kernel_sizes[1] - 1)
              - 1
          )
          / strides[1]
          + 1
      )
  
      if h_steps < 1 or w_steps < 1:
          raise ivy.exceptions.IvyError(
              "Expected at least one for height and width, but got expected output shape"
              f" H:{h_steps} W:{w_steps}]"
          )
  
      # sliding windows
      folder = []
      for i in range(0, h_steps * strides[0], strides[0]):
          for j in range(0, w_steps * strides[1], strides[1]):
              window = x[
                  :,
                  :,
                  i : i
                  + dilations[0] * (kernel_sizes[0] - 1)
                  + 1 : dilations[0],
                  j : j
                  + dilations[1] * (kernel_sizes[1] - 1)
                  + 1 : dilations[1],
              ]
              window = ivy.flatten(window, start_dim=1)
              folder.append(window)
      return ivy.stack(folder, axis=2)
  
file_path: ivy/ivy/functional/frontends/paddle/nn/functional/common.py
imports: import ivy
  from ivy.func_wrapper import with_supported_dtypes
  from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
label_desc: Use image node_id 8 for calling a global function with example usage: unfold(x, kernel_sizes, strides, paddings, dilations, name) and returns: ivy