code: def test_check_distribution_compatibility() -> None:
      # Test the same distribution.
      for key in EXAMPLE_JSONS:
          distributions.check_distribution_compatibility(
              EXAMPLE_DISTRIBUTIONS[key], EXAMPLE_DISTRIBUTIONS[key]
          )
          # We need to create new objects to compare NaNs.
          # See https://github.com/optuna/optuna/pull/3567#pullrequestreview-974939837.
          distributions.check_distribution_compatibility(
              EXAMPLE_DISTRIBUTIONS[key],
              distributions.json_to_distribution(EXAMPLE_JSONS[key]),
          )
  
      # Test different distribution classes.
      pytest.raises(
          ValueError,
          lambda: distributions.check_distribution_compatibility(
              EXAMPLE_DISTRIBUTIONS["i"], EXAMPLE_DISTRIBUTIONS["fl"]
          ),
      )
  
      # Test compatibility between IntDistributions.
      distributions.check_distribution_compatibility(
          EXAMPLE_DISTRIBUTIONS["id"], EXAMPLE_DISTRIBUTIONS["i"]
      )
  
      with pytest.raises(ValueError):
          distributions.check_distribution_compatibility(
              EXAMPLE_DISTRIBUTIONS["i"], EXAMPLE_DISTRIBUTIONS["il"]
          )
  
      with pytest.raises(ValueError):
          distributions.check_distribution_compatibility(
              EXAMPLE_DISTRIBUTIONS["il"], EXAMPLE_DISTRIBUTIONS["id"]
          )
  
      # Test compatibility between FloatDistributions.
      distributions.check_distribution_compatibility(
          EXAMPLE_DISTRIBUTIONS["fd"], EXAMPLE_DISTRIBUTIONS["f"]
      )
  
      with pytest.raises(ValueError):
          distributions.check_distribution_compatibility(
              EXAMPLE_DISTRIBUTIONS["f"], EXAMPLE_DISTRIBUTIONS["fl"]
          )
  
      with pytest.raises(ValueError):
          distributions.check_distribution_compatibility(
              EXAMPLE_DISTRIBUTIONS["fl"], EXAMPLE_DISTRIBUTIONS["fd"]
          )
  
      # Test dynamic value range (CategoricalDistribution).
      pytest.raises(
          ValueError,
          lambda: distributions.check_distribution_compatibility(
              EXAMPLE_DISTRIBUTIONS["c2"],
              distributions.CategoricalDistribution(
                  choices=("Roppongi", "Akasaka")
              ),
          ),
      )
  
      # Test dynamic value range (except CategoricalDistribution).
      distributions.check_distribution_compatibility(
          EXAMPLE_DISTRIBUTIONS["i"],
          distributions.IntDistribution(low=-3, high=2),
      )
      distributions.check_distribution_compatibility(
          EXAMPLE_DISTRIBUTIONS["il"],
          distributions.IntDistribution(low=1, high=13, log=True),
      )
      distributions.check_distribution_compatibility(
          EXAMPLE_DISTRIBUTIONS["id"],
          distributions.IntDistribution(low=-3, high=1, step=2),
      )
      distributions.check_distribution_compatibility(
          EXAMPLE_DISTRIBUTIONS["f"],
          distributions.FloatDistribution(low=-3.0, high=-2.0),
      )
      distributions.check_distribution_compatibility(
          EXAMPLE_DISTRIBUTIONS["fl"],
          distributions.FloatDistribution(low=0.1, high=1.0, log=True),
      )
      distributions.check_distribution_compatibility(
          EXAMPLE_DISTRIBUTIONS["fd"],
          distributions.FloatDistribution(
              low=-1.0, high=11.0, step=0.5
          ),
      )
  
imports: import copy
  import json
  from typing import Any
  from typing import cast
  from typing import Dict
  from typing import Optional
  import warnings
  import numpy
  import pytest
  from optuna import distributions
label_desc: Use image node_id 4 for calling a global function with example usage: test_check_distribution_compatibility() without return types