nodes: 0, module; 1, function_definition; 2, function_name:_from_inferred_categories; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:inferred_categories; 7, identifier:inferred_codes; 8, identifier:dtype; 9, default_parameter; 10, expression_statement; 11, import_from_statement; 12, expression_statement; 13, expression_statement; 14, if_statement; 15, if_statement; 16, return_statement; 17, identifier:true_values; 18, None; 19, comment:"""
          Construct a Categorical from inferred values.
  
          For inferred categories (`dtype` is None) the categories are sorted.
          For explicit `dtype`, the `inferred_categories` are cast to the
          appropriate type.
  
          Parameters
          ----------
          inferred_categories : Index
          inferred_codes : Index
          dtype : CategoricalDtype or 'category'
          true_values : list, optional
              If none are provided, the default ones are
              "True", "TRUE", and "true."
  
          Returns
          -------
          Categorical
          """; 20, dotted_name; 21, dotted_name; 22, dotted_name; 23, dotted_name; 24, dotted_name; 25, assignment; 26, assignment; 27, identifier:known_categories; 28, comment:# Convert to a specialized type with `dtype` if specified.; 29, block; 30, identifier:known_categories; 31, comment:# Recode from observation order to dtype.categories order.; 32, block; 33, elif_clause; 34, else_clause; 35, call; 36, identifier:pandas; 37, identifier:Index; 38, identifier:to_numeric; 39, identifier:to_datetime; 40, identifier:to_timedelta; 41, identifier:cats; 42, call; 43, identifier:known_categories; 44, parenthesized_expression; 45, if_statement; 46, expression_statement; 47, expression_statement; 48, not_operator; 49, comment:# Sort categories and recode for unknown categories.; 50, block; 51, block; 52, identifier:cls; 53, argument_list; 54, identifier:Index; 55, argument_list; 56, boolean_operator; 57, call; 58, block; 59, elif_clause; 60, elif_clause; 61, elif_clause; 62, assignment; 63, assignment; 64, attribute; 65, expression_statement; 66, expression_statement; 67, expression_statement; 68, expression_statement; 69, expression_statement; 70, expression_statement; 71, identifier:codes; 72, keyword_argument; 73, keyword_argument; 74, identifier:inferred_categories; 75, call; 76, comparison_operator:dtype.categories is not None; 77, attribute; 78, argument_list; 79, expression_statement; 80, call; 81, block; 82, call; 83, block; 84, call; 85, block; 86, identifier:categories; 87, attribute; 88, identifier:codes; 89, call; 90, identifier:cats; 91, identifier:is_monotonic_increasing; 92, assignment; 93, assignment; 94, assignment; 95, assignment; 96, assignment; 97, assignment; 98, identifier:dtype; 99, identifier:dtype; 100, identifier:fastpath; 101, True; 102, identifier:isinstance; 103, argument_list; 104, attribute; 105, None; 106, attribute; 107, identifier:is_numeric; 108, assignment; 109, identifier:is_datetime64_dtype; 110, argument_list; 111, expression_statement; 112, identifier:is_timedelta64_dtype; 113, argument_list; 114, expression_statement; 115, attribute; 116, argument_list; 117, if_statement; 118, expression_statement; 119, identifier:dtype; 120, identifier:categories; 121, identifier:_recode_for_categories; 122, argument_list; 123, identifier:unsorted; 124, call; 125, identifier:categories; 126, call; 127, identifier:codes; 128, call; 129, identifier:dtype; 130, call; 131, identifier:dtype; 132, call; 133, identifier:codes; 134, identifier:inferred_codes; 135, identifier:dtype; 136, identifier:CategoricalDtype; 137, identifier:dtype; 138, identifier:categories; 139, identifier:dtype; 140, identifier:categories; 141, identifier:cats; 142, call; 143, attribute; 144, assignment; 145, attribute; 146, assignment; 147, attribute; 148, identifier:is_boolean; 149, comparison_operator:true_values is None; 150, block; 151, assignment; 152, identifier:inferred_codes; 153, identifier:cats; 154, identifier:categories; 155, attribute; 156, argument_list; 157, attribute; 158, argument_list; 159, identifier:_recode_for_categories; 160, argument_list; 161, identifier:CategoricalDtype; 162, argument_list; 163, identifier:CategoricalDtype; 164, argument_list; 165, identifier:to_numeric; 166, argument_list; 167, identifier:dtype; 168, identifier:categories; 169, identifier:cats; 170, call; 171, identifier:dtype; 172, identifier:categories; 173, identifier:cats; 174, call; 175, identifier:dtype; 176, identifier:categories; 177, identifier:true_values; 178, None; 179, expression_statement; 180, identifier:cats; 181, call; 182, identifier:cats; 183, identifier:copy; 184, identifier:cats; 185, identifier:sort_values; 186, identifier:inferred_codes; 187, identifier:unsorted; 188, identifier:categories; 189, identifier:categories; 190, keyword_argument; 191, identifier:cats; 192, keyword_argument; 193, identifier:inferred_categories; 194, keyword_argument; 195, identifier:to_datetime; 196, argument_list; 197, identifier:to_timedelta; 198, argument_list; 199, assignment; 200, attribute; 201, argument_list; 202, identifier:ordered; 203, False; 204, identifier:ordered; 205, False; 206, identifier:errors; 207, string:"coerce"; 208, identifier:inferred_categories; 209, keyword_argument; 210, identifier:inferred_categories; 211, keyword_argument; 212, identifier:true_values; 213, list; 214, identifier:cats; 215, identifier:isin; 216, identifier:true_values; 217, identifier:errors; 218, string:"coerce"; 219, identifier:errors; 220, string:"coerce"; 221, string:"True"; 222, string:"TRUE"; 223, string:"true"
code: def _from_inferred_categories(cls, inferred_categories, inferred_codes,
                                    dtype, true_values=None):
          """
          Construct a Categorical from inferred values.
  
          For inferred categories (`dtype` is None) the categories are sorted.
          For explicit `dtype`, the `inferred_categories` are cast to the
          appropriate type.
  
          Parameters
          ----------
          inferred_categories : Index
          inferred_codes : Index
          dtype : CategoricalDtype or 'category'
          true_values : list, optional
              If none are provided, the default ones are
              "True", "TRUE", and "true."
  
          Returns
          -------
          Categorical
          """
          from pandas import Index, to_numeric, to_datetime, to_timedelta
  
          cats = Index(inferred_categories)
          known_categories = (isinstance(dtype, CategoricalDtype) and
                              dtype.categories is not None)
  
          if known_categories:
              # Convert to a specialized type with `dtype` if specified.
              if dtype.categories.is_numeric():
                  cats = to_numeric(inferred_categories, errors="coerce")
              elif is_datetime64_dtype(dtype.categories):
                  cats = to_datetime(inferred_categories, errors="coerce")
              elif is_timedelta64_dtype(dtype.categories):
                  cats = to_timedelta(inferred_categories, errors="coerce")
              elif dtype.categories.is_boolean():
                  if true_values is None:
                      true_values = ["True", "TRUE", "true"]
  
                  cats = cats.isin(true_values)
  
          if known_categories:
              # Recode from observation order to dtype.categories order.
              categories = dtype.categories
              codes = _recode_for_categories(inferred_codes, cats, categories)
          elif not cats.is_monotonic_increasing:
              # Sort categories and recode for unknown categories.
              unsorted = cats.copy()
              categories = cats.sort_values()
  
              codes = _recode_for_categories(inferred_codes, unsorted,
                                             categories)
              dtype = CategoricalDtype(categories, ordered=False)
          else:
              dtype = CategoricalDtype(cats, ordered=False)
              codes = inferred_codes
  
          return cls(codes, dtype=dtype, fastpath=True)