code: def generate_categorical_data():
      generated = False
  
      def _generate_data():
          if not generated:
              df = pd.DataFrame(
                  {
                      "cat1": ["a", "a", "b", "a", "c", "b", "d"],
                      "cat2": [
                          "aa",
                          "aa",
                          "aa",
                          "bb",
                          "bb",
                          "bb",
                          "cc",
                      ],
                      "num1": [1, 2, 1, 2, 1, 1, 1],
                  }
              )
  
          return df
  
      yield _generate_data
  
imports: import pandas
  import pytest
  from causalml.features import OneHotEncoder, LabelEncoder, load_data
label_desc: Use image node_id 1 for calling a global function with example usage: generate_categorical_data() and returns: df