code: def codes_from_points(points: cpy.PointArray) -> cpy.CodeArray:
      """Determine codes for a single line, using the equality of the start and end points to
      determine if the line is closed or not.
      """
      check_point_array(points)
  
      n = len(points)
      codes = np.full(n, LINETO, dtype=code_dtype)
      codes[0] = MOVETO
      if np.all(points[0] == points[-1]):
          codes[-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 3 for calling a global function with example usage: codes_from_points(points) and returns: codes