code: def get_binary_kernel2d(
      window_size: tuple[int, int] | int,
      *,
      device: Optional[Device] = None,
      dtype: Dtype = torch.float32,
  ) -> Tensor:
      """Create a binary kernel to extract the patches.
  
      If the window size is HxW will create a (H*W)x1xHxW kernel.
      """
      # TODO: add default dtype as None when kornia relies on torch > 1.12
  
      ky, kx = _unpack_2d_ks(window_size)
  
      window_range = kx * ky
  
      kernel = zeros(
          (window_range, window_range), device=device, dtype=dtype
      )
      idx = torch.arange(window_range, device=device)
      kernel[idx, idx] += 1.0
      return kernel.view(window_range, 1, ky, kx)
  
imports: from __future__ import annotations
  import math
  from math import sqrt
  from typing import Any, Optional
  import torch
  from kornia.core import Device, Dtype, Tensor, concatenate, cos, stack, tensor, where, zeros, zeros_like
  from kornia.core.check import KORNIA_CHECK, KORNIA_CHECK_IS_TENSOR, KORNIA_CHECK_SHAPE
  from kornia.utils import deprecated
label_desc: Use image node_id 14 for calling a global function with example usage: get_binary_kernel2d(window_size) and returns: kernel