code: def random_square_patch(
      input_region: List[int], min_width: int = 10
  ) -> List[int]:
      """Gets a random patch in the input region.
  
      Args:
          input_region (List[int]): Coordinates of the input region. [x1, y1, x2, y2]
          min_width (int): Minimum width of the returned patch.
      Example:
      >>> image = np.zeros((200,200,3))
      >>> x1, y1, x2, y2 = random_square_patch([100,100,200,200])
      >>> patched = image.copy()
      >>> patched[y1:y2, x1:x2, :] = 1
      >>> plt.imshow(patched)
  
      Returns:
          List[int]: Random square patch [x1, y1, x2, y2]
      """
      x1_i, y1_i, x2_i, y2_i = input_region
      cx, cy = np.random.randint(x1_i, x2_i), np.random.randint(
          y1_i, y2_i
      )
      shortest_dim = min(x2_i - x1_i, y2_i - y1_i)
      # make sure that shortest_dim is larger than min_width
      shortest_dim = max(shortest_dim, min_width + 1)
      rand_half_width = np.random.randint(min_width, shortest_dim) // 2
      x1, y1, x2, y2 = (
          cx - rand_half_width,
          cy - rand_half_width,
          cx + rand_half_width,
          cy + rand_half_width,
      )
  
      # border check
      if x1 < 0:
          x1 = 0
          x2 = 2 * rand_half_width
      elif x2 > x2_i:
          x2 = x2_i
          x1 = x2_i - 2 * rand_half_width
  
      if y1 < 0:
          y1 = 0
          y2 = 2 * rand_half_width
      elif y2 > y2_i:
          y2 = y2_i
          y1 = y2_i - 2 * rand_half_width
  
      return [x1, y1, x2, y2]
  
file_path: anomalib/tests/helpers/shapes.py
imports: from typing import List, Tuple
  import numpy
  from skimage.draw import polygon
label_desc: Use image node_id 1 for calling a global function with example usage: random_square_patch(input_region, min_width) and returns: list