code: def test_map_categorical(na_action, using_infer_string):
      values = pd.Categorical(
          list("ABBABCD"), categories=list("DCBA"), ordered=True
      )
      s = Series(values, name="XX", index=list("abcdefg"))
  
      result = s.map(lambda x: x.lower(), na_action=na_action)
      exp_values = pd.Categorical(
          list("abbabcd"), categories=list("dcba"), ordered=True
      )
      exp = Series(exp_values, name="XX", index=list("abcdefg"))
      tm.assert_series_equal(result, exp)
      tm.assert_categorical_equal(result.values, exp_values)
  
      result = s.map(lambda x: "A", na_action=na_action)
      exp = Series(["A"] * 7, name="XX", index=list("abcdefg"))
      tm.assert_series_equal(result, exp)
      assert (
          result.dtype == object if not using_infer_string else "string"
      )
  
imports: from collections import Counter, defaultdict
  from decimal import Decimal
  import math
  import numpy
  import pytest
  import pandas
  from pandas import DataFrame, Index, MultiIndex, Series, bdate_range, date_range, isna, timedelta_range
  import pandas._testing
label_desc: Use image node_id 40 for calling a global function with example usage: test_map_categorical(na_action, using_infer_string) without return types