code: def window_partition(
      x: torch.Tensor, window_size: Tuple[int, int]
  ) -> torch.Tensor:
      """
      Args:
          x: (B, H, W, C)
          window_size (int): window size
  
      Returns:
          windows: (num_windows*B, window_size, window_size, C)
      """
      B, H, W, C = x.shape
      x = x.view(
          B,
          H // window_size[0],
          window_size[0],
          W // window_size[1],
          window_size[1],
          C,
      )
      windows = (
          x.permute(0, 1, 3, 2, 4, 5)
          .contiguous()
          .view(-1, window_size[0], window_size[1], C)
      )
      return windows
  
imports: import math
  from typing import Callable, Optional, Tuple, Union, Set, Dict
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils.checkpoint
  from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
  from timm.layers import PatchEmbed, Mlp, DropPath, to_2tuple, trunc_normal_, _assert, ClassifierHead, resample_patch_embed
  from ._builder import build_model_with_cfg
  from ._features_fx import register_notrace_function
  from ._registry import generate_default_cfgs, register_model, register_model_deprecations
label_desc: Use image node_id 1 for calling a global function with example usage: window_partition(x, window_size) and returns: windows