code: def get_group_index(labels, shape, sort, xnull):
      """
      For the particular label_list, gets the offsets into the hypothetical list
      representing the totally ordered cartesian product of all possible label
      combinations, *as long as* this space fits within int64 bounds;
      otherwise, though group indices identify unique combinations of
      labels, they cannot be deconstructed.
      - If `sort`, rank of returned ids preserve lexical ranks of labels.
        i.e. returned id's can be used to do lexical sort on labels;
      - If `xnull` nulls (-1 labels) are passed through.
  
      Parameters
      ----------
      labels: sequence of arrays
          Integers identifying levels at each location
      shape: sequence of ints same length as labels
          Number of unique levels at each location
      sort: boolean
          If the ranks of returned ids should match lexical ranks of labels
      xnull: boolean
          If true nulls are excluded. i.e. -1 values in the labels are
          passed through
      Returns
      -------
      An array of type int64 where two elements are equal if their corresponding
      labels are equal at all location.
      """
  
      def _int64_cut_off(shape):
          acc = long(1)
          for i, mul in enumerate(shape):
              acc *= long(mul)
              if not acc < _INT64_MAX:
                  return i
          return len(shape)
  
      def maybe_lift(lab, size):
          # promote nan values (assigned -1 label in lab array)
          # so that all output values are non-negative
          return (
              (lab + 1, size + 1) if (lab == -1).any() else (lab, size)
          )
  
      labels = map(ensure_int64, labels)
      if not xnull:
          labels, shape = map(
              list, zip(*map(maybe_lift, labels, shape))
          )
  
      labels = list(labels)
      shape = list(shape)
  
      # Iteratively process all the labels in chunks sized so less
      # than _INT64_MAX unique int ids will be required for each chunk
      while True:
          # how many levels can be done without overflow:
          nlev = _int64_cut_off(shape)
  
          # compute flat ids for the first `nlev` levels
          stride = np.prod(shape[1:nlev], dtype="i8")
          out = stride * labels[0].astype("i8", subok=False, copy=False)
  
          for i in range(1, nlev):
              if shape[i] == 0:
                  stride = 0
              else:
                  stride //= shape[i]
              out += labels[i] * stride
  
          if xnull:  # exclude nulls
              mask = labels[0] == -1
              for lab in labels[1:nlev]:
                  mask |= lab == -1
              out[mask] = -1
  
          if nlev == len(shape):  # all levels done!
              break
  
          # compress what has been done so far in order to avoid overflow
          # to retain lexical ranks, obs_ids should be sorted
          comp_ids, obs_ids = compress_group_index(out, sort=sort)
  
          labels = [comp_ids] + labels[nlev:]
          shape = [len(obs_ids)] + shape[nlev:]
  
      return out
  
imports: import warnings
  import numpy
  from pandas._libs import algos, hashtable, lib
  from pandas._libs.hashtable import unique_label_indices
  from pandas.compat import PY3, long, string_types
  from pandas.core.dtypes.cast import infer_dtype_from_array
  from pandas.core.dtypes.common import ensure_int64, ensure_platform_int, is_categorical_dtype, is_list_like
  from pandas.core.dtypes.missing import isna
  import pandas.core.algorithms
label_desc: Use image node_id 1 for calling a global function with example usage: get_group_index(labels, shape, sort, xnull) and returns: out, len, unknown, i