code: def _compute_shear_matrix(shear: torch.Tensor) -> torch.Tensor:
      """Compute affine matrix for shearing."""
      matrix: torch.Tensor = eye_like(3, shear, shared_memory=False)
  
      shx, shy = torch.chunk(shear, chunks=2, dim=-1)
      matrix[..., 0, 1:2] += shx
      matrix[..., 1, 0:1] += shy
      return matrix
  
imports: from typing import Optional, Tuple, Union
  import torch
  from torch import nn
  from kornia.core import ones, ones_like, zeros
  from kornia.filters import gaussian_blur2d
  from kornia.utils import _extract_device_dtype
  from kornia.utils.image import perform_keep_shape_image
  from kornia.utils.misc import eye_like
  from .imgwarp import get_affine_matrix2d, get_projective_transform, get_rotation_matrix2d, warp_affine, warp_affine3d
label_desc: Use image node_id 7 for calling a global function with example usage: _compute_shear_matrix(shear) and returns: matrix