code: def test_stats_options_from_json(
      self,
      type_name: Optional[str] = None,
      want_exception: bool = False,
  ):
      if type_name:
          type_name_line = f',\n"TYPE_NAME": "{type_name}"\n'
      else:
          type_name_line = ""
      options_json = """{
        "_generators": null,
        "_feature_allowlist": null,
        "_schema": null,
        "_vocab_paths": null,
        "weight_feature": null,
        "label_feature": null,
        "_slice_functions": null,
        "_sample_rate": null,
        "num_top_values": 20,
        "frequency_threshold": 1,
        "weighted_frequency_threshold": 1.0,
        "num_rank_histogram_buckets": 1000,
        "_num_values_histogram_buckets": 10,
        "_num_histogram_buckets": 10,
        "_num_quantiles_histogram_buckets": 10,
        "epsilon": 0.01,
        "infer_type_from_schema": false,
        "_desired_batch_size": null,
        "enable_semantic_domain_stats": false,
        "_semantic_domain_stats_sample_rate": null,
        "_per_feature_weight_override": null,
        "_add_default_generators": true,
        "_use_sketch_based_topk_uniques": false,
        "_slice_sqls": null,
        "_experimental_result_partitions": 1,
        "_experimental_num_feature_partitions": 1,
        "_slicing_config": null,
        "_experimental_filter_read_paths": false
      """
      options_json += type_name_line + "}"
      if want_exception:
          with self.assertRaises(ValueError):
              _ = stats_options.StatsOptions.from_json(options_json)
      else:
          actual_options = stats_options.StatsOptions.from_json(
              options_json
          )
          expected_options_dict = stats_options.StatsOptions().__dict__
          self.assertEqual(
              expected_options_dict, actual_options.__dict__
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import sys
  from typing import Optional
  import unittest
  from absl.testing import absltest
  from absl.testing import parameterized
  from tensorflow_data_validation import types
  from tensorflow_data_validation.statistics import stats_options
  from tensorflow_data_validation.statistics.generators import lift_stats_generator
  from tensorflow_data_validation.utils import slicing_util
  from tfx_bsl.public.proto import slicing_spec_pb2
  from google.protobuf import text_format
  from tensorflow.python.util.protobuf import compare
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 6 for calling the StatsOptionsTest obj's underlying member method code with example usage: obj.test_stats_options_from_json(type_name, want_exception) without return types