code: def test_multi_hot_encoder_with_max_categories():
      """Tests basic MultiHotEncoder functionality with limit."""
      col_a = ["red", "green", "blue", "red"]
      col_b = ["warm", "cold", "hot", "cold"]
      col_c = [1, 10, 5, 10]
      col_d = [["warm"], [], ["hot", "warm", "cold"], ["cold", "cold"]]
      in_df = pd.DataFrame.from_dict(
          {"A": col_a, "B": col_b, "C": col_c, "D": col_d}
      )
      ds = ray.data.from_pandas(in_df)
  
      encoder = MultiHotEncoder(
          ["B", "C", "D"], max_categories={"B": 2}
      )
  
      ds_out = encoder.fit_transform(ds)
      assert len(ds_out.to_pandas()["B"].iloc[0]) == 2
      assert len(ds_out.to_pandas()["C"].iloc[0]) == 3
      assert len(ds_out.to_pandas()["D"].iloc[0]) == 3
  
file_path: ray/python/ray/data/tests/preprocessors/test_encoder.py
imports: import numpy
  import pandas
  import pytest
  import ray
  from ray.data.preprocessor import PreprocessorNotFittedException
  from ray.data.preprocessors import Categorizer, LabelEncoder, MultiHotEncoder, OneHotEncoder, OrdinalEncoder
label_desc: Use image node_id 6 for calling a global function with example usage: test_multi_hot_encoder_with_max_categories() without return types