code: def _expand_window(
      low_res_path: np.ndarray, n: int, m: int, radius: int
  ) -> CRWindow:
      high_res_grid = CRWindow(n, m)
  
      def is_valid(cell):
          valid_x = 1 <= cell[0] <= n
          valid_y = 1 <= cell[1] <= m
  
          return valid_x and valid_y
  
      # up-sample path, 1 grid point computed at half-resolution becomes at least 4
      # (1,2) and (2,1) allows for better DWT solution, as it isn't diagonally constrained
      #
      # 4-sample         6-sample
      #     X X             X X
      #     X X    vs.    X X X
      # X X             X X X
      # X X             X X
  
      pattern = [(0, 0, 2), (1, 0, 3), (2, 1, 2)]
  
      for i, j in low_res_path:
          for column, start, end in pattern:
              # +1 offset since x[0], y[0] maps to DTW[1][1]
  
              column += i * 2 + 1
  
              # ensure no out of bounds
              # enlarge vertically by radius is O(1), due to compressed row representation
              start = max(1, min(m + 1, start + j * 2 - radius))
              end = max(1, min(m + 1, end + j * 2 + 1 + radius))
  
              # to create an nxn block, add (0-n) range n times
              # ensure no out of bounds
              #   if column is too large m-column -> 0
              #   if column-k is too small, column < radius+1
              for k in range(
                  0, min(radius + 1, column, n - column + 1)
              ):
                  high_res_grid.add_range(column - k, start, end)
  
      return high_res_grid
  
imports: import copy
  from typing import Callable, Optional, Union
  import numpy
  import pandas
  import xarray
  from darts import TimeSeries
  from darts.logging import get_logger, raise_if, raise_if_not
  from darts.timeseries import DIMS
  from .cost_matrix import CostMatrix
  from .window import CRWindow, NoWindow, Window
label_desc: Use image node_id 4 for calling a global function with example usage: _expand_window(low_res_path, n, m, radius) and returns: high_res_grid, unknown