code: def offset_coordinates(
      indices: Union[list, Sequence[int], Tuple[Any]],
      offset: tuple,
      img_shape: tuple,
  ):
      """
      Checks if offset coordinates are within the image frame.
          Adapted from: https://github.com/tleemann/road_evaluation.
  
      Parameters
      ----------
      indices: list
          List of indices to be offset.
      offset: tuple
          Offset for the coordinates, e.g. offset (1,1) adds 1 to both coordinates.
      img_shape: tuple
          Image shape in (channels, height, width) format.
  
      Returns
      -------
      list
          Offset coordinates for valid indices and the list of booleans which identifies valid ids.
      """
      x = indices // img_shape[2]
      y = indices % img_shape[2]
  
      x += offset[0]
      y += offset[1]
  
      valid = ~(
          (x < 0) | (y < 0) | (x >= img_shape[1]) | (y >= img_shape[2])
      )
      off_coords = indices + offset[0] * img_shape[2] + offset[1]
  
      return off_coords[valid], valid
  
imports: import copy
  import re
  from importlib import util
  from typing import Any, Dict, Optional, Sequence, Tuple, Union, List, TypeVar
  import numpy
  from skimage.segmentation import slic, felzenszwalb
  from quantus.helpers import asserts
  from quantus.helpers.model.model_interface import ModelInterface
label_desc: Use image node_id 20 for calling a global function with example usage: offset_coordinates(indices, offset, img_shape) and returns: off_coords,  valid