nodes: 0, module; 1, function_definition; 2, function_name:factorize; 3, parameters; 4, type; 5, block; 6, identifier:self; 7, typed_default_parameter; 8, generic_type; 9, expression_statement; 10, comment:# Impelmentor note: There are two ways to override the behavior of; 11, comment:# pandas.factorize; 12, comment:# 1. _values_for_factorize and _from_factorize.; 13, comment:#    Specify the values passed to pandas' internal factorization; 14, comment:#    routines, and how to convert from those values back to the; 15, comment:#    original ExtensionArray.; 16, comment:# 2. ExtensionArray.factorize.; 17, comment:#    Complete control over factorization.; 18, import_from_statement; 19, expression_statement; 20, expression_statement; 21, expression_statement; 22, return_statement; 23, identifier:na_sentinel; 24, type; 25, unary_operator; 26, identifier:Tuple; 27, type_parameter; 28, comment:"""
          Encode the extension array as an enumerated type.
  
          Parameters
          ----------
          na_sentinel : int, default -1
              Value to use in the `labels` array to indicate missing values.
  
          Returns
          -------
          labels : ndarray
              An integer NumPy array that's an indexer into the original
              ExtensionArray.
          uniques : ExtensionArray
              An ExtensionArray containing the unique values of `self`.
  
              .. note::
  
                 uniques will *not* contain an entry for the NA value of
                 the ExtensionArray if there are any missing values present
                 in `self`.
  
          See Also
          --------
          pandas.factorize : Top-level factorize method that dispatches here.
  
          Notes
          -----
          :meth:`pandas.factorize` offers a `sort` keyword as well.
          """; 29, dotted_name; 30, dotted_name; 31, assignment; 32, assignment; 33, assignment; 34, expression_list; 35, identifier:int; 36, integer:1; 37, type; 38, type; 39, identifier:pandas; 40, identifier:core; 41, identifier:algorithms; 42, identifier:_factorize_array; 43, pattern_list; 44, call; 45, pattern_list; 46, call; 47, identifier:uniques; 48, call; 49, identifier:labels; 50, identifier:uniques; 51, attribute; 52, identifier:ABCExtensionArray; 53, identifier:arr; 54, identifier:na_value; 55, attribute; 56, argument_list; 57, identifier:labels; 58, identifier:uniques; 59, identifier:_factorize_array; 60, argument_list; 61, attribute; 62, argument_list; 63, identifier:np; 64, identifier:ndarray; 65, identifier:self; 66, identifier:_values_for_factorize; 67, identifier:arr; 68, keyword_argument; 69, keyword_argument; 70, identifier:self; 71, identifier:_from_factorized; 72, identifier:uniques; 73, identifier:self; 74, identifier:na_sentinel; 75, identifier:na_sentinel; 76, identifier:na_value; 77, identifier:na_value
code: def factorize(
              self,
              na_sentinel: int = -1,
      ) -> Tuple[np.ndarray, ABCExtensionArray]:
          """
          Encode the extension array as an enumerated type.
  
          Parameters
          ----------
          na_sentinel : int, default -1
              Value to use in the `labels` array to indicate missing values.
  
          Returns
          -------
          labels : ndarray
              An integer NumPy array that's an indexer into the original
              ExtensionArray.
          uniques : ExtensionArray
              An ExtensionArray containing the unique values of `self`.
  
              .. note::
  
                 uniques will *not* contain an entry for the NA value of
                 the ExtensionArray if there are any missing values present
                 in `self`.
  
          See Also
          --------
          pandas.factorize : Top-level factorize method that dispatches here.
  
          Notes
          -----
          :meth:`pandas.factorize` offers a `sort` keyword as well.
          """
          # Impelmentor note: There are two ways to override the behavior of
          # pandas.factorize
          # 1. _values_for_factorize and _from_factorize.
          #    Specify the values passed to pandas' internal factorization
          #    routines, and how to convert from those values back to the
          #    original ExtensionArray.
          # 2. ExtensionArray.factorize.
          #    Complete control over factorization.
          from pandas.core.algorithms import _factorize_array
  
          arr, na_value = self._values_for_factorize()
  
          labels, uniques = _factorize_array(arr, na_sentinel=na_sentinel,
                                             na_value=na_value)
  
          uniques = self._from_factorized(uniques, self)
          return labels, uniques