code: def intersection(*entities, pairwise=False, **kwargs):
      """The intersection of a collection of GeometryEntity instances.
  
      Parameters
      ==========
      entities : sequence of GeometryEntity
      pairwise (keyword argument) : Can be either True or False
  
      Returns
      =======
      intersection : list of GeometryEntity
  
      Raises
      ======
      NotImplementedError
          When unable to calculate intersection.
  
      Notes
      =====
      The intersection of any geometrical entity with itself should return
      a list with one item: the entity in question.
      An intersection requires two or more entities. If only a single
      entity is given then the function will return an empty list.
      It is possible for `intersection` to miss intersections that one
      knows exists because the required quantities were not fully
      simplified internally.
      Reals should be converted to Rationals, e.g. Rational(str(real_num))
      or else failures due to floating point issues may result.
  
      Case 1: When the keyword argument 'pairwise' is False (default value):
      In this case, the function returns a list of intersections common to
      all entities.
  
      Case 2: When the keyword argument 'pairwise' is True:
      In this case, the functions returns a list intersections that occur
      between any pair of entities.
  
      See Also
      ========
  
      sympy.geometry.entity.GeometryEntity.intersection
  
      Examples
      ========
  
      >>> from sympy import Ray, Circle, intersection
      >>> c = Circle((0, 1), 1)
      >>> intersection(c, c.center)
      []
      >>> right = Ray((0, 0), (1, 0))
      >>> up = Ray((0, 0), (0, 1))
      >>> intersection(c, right, up)
      [Point2D(0, 0)]
      >>> intersection(c, right, up, pairwise=True)
      [Point2D(0, 0), Point2D(0, 2)]
      >>> left = Ray((1, 0), (0, 0))
      >>> intersection(right, left)
      [Segment2D(Point2D(0, 0), Point2D(1, 0))]
  
      """
      if len(entities) <= 1:
          return []
  
      entities = list(entities)
      prec = None
      for i, e in enumerate(entities):
          if not isinstance(e, GeometryEntity):
              # entities may be an immutable tuple
              e = Point(e)
          # convert to exact Rationals
          d = {}
          for f in e.atoms(Float):
              prec = f._prec if prec is None else min(f._prec, prec)
              d.setdefault(f, nsimplify(f, rational=True))
          entities[i] = e.xreplace(d)
  
      if not pairwise:
          # find the intersection common to all objects
          res = entities[0].intersection(entities[1])
          for entity in entities[2:]:
              newres = []
              for x in res:
                  newres.extend(x.intersection(entity))
              res = newres
      else:
          # find all pairwise intersections
          ans = []
          for j in range(len(entities)):
              for k in range(j + 1, len(entities)):
                  ans.extend(intersection(entities[j], entities[k]))
          res = list(ordered(set(ans)))
  
      # convert back to Floats
      if prec is not None:
          p = prec_to_dps(prec)
          res = [i.n(p) for i in res]
      return res
  
imports: from collections import deque
  from math import sqrt
  from sympy import nsimplify
  from .entity import GeometryEntity
  from .exceptions import GeometryError
  from .point import Point, Point2D, Point3D
  from sympy.core.containers import OrderedSet
  from sympy.core.exprtools import factor_terms
  from sympy.core.function import Function, expand_mul
  from sympy.core.numbers import Float
  from sympy.core.sorting import ordered
  from sympy.core.symbol import Symbol
  from sympy.core.singleton import S
  from sympy.polys.polytools import cancel
  from sympy.functions.elementary.miscellaneous import sqrt
  from sympy.utilities.iterables import is_sequence
  from mpmath.libmp.libmpf import prec_to_dps
label_desc: Use image node_id 10 for calling a global function with example usage: intersection() and returns: res, list