code: def codes_from_offsets(offsets: cpy.OffsetArray) -> cpy.CodeArray:
      """Determine codes from offsets, assuming they all correspond to closed polygons."""
      check_offset_array(offsets)
  
      n = offsets[-1]
      codes = np.full(n, LINETO, dtype=code_dtype)
      codes[offsets[:-1]] = MOVETO
      codes[offsets[1:] - 1] = CLOSEPOLY
      return codes
  
imports: from __future__ import annotations
  from itertools import chain
  from typing import TYPE_CHECKING
  import numpy
  from contourpy.typecheck import check_code_array, check_offset_array, check_point_array
  from contourpy.types import CLOSEPOLY, LINETO, MOVETO, code_dtype, offset_dtype, point_dtype
label_desc: Use image node_id 1 for calling a global function with example usage: codes_from_offsets(offsets) and returns: codes