code: def _encode_struct_value(
      value: JsonValueType,
  ) -> Optional[struct_pb2.Struct]:
      if value is None:
          return None
      if not isinstance(value, dict):
          value = {
              _JSON_SINGLE_VALUE_KEY: value,
          }
      result = struct_pb2.Struct()
      json_format.ParseDict(value, result)
      return result
  
imports: import builtins
  import copy
  import importlib
  import json
  from typing import Any, Dict, List, Optional, Type, Union
  from absl import logging
  from tfx.types import artifact_property
  from tfx.types.system_artifacts import SystemArtifact
  from tfx.utils import doc_controls
  from tfx.utils import json_utils
  from tfx.utils import proto_utils
  from google.protobuf import struct_pb2
  from google.protobuf import json_format
  from google.protobuf import message
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 2 for calling a global function with example usage: _encode_struct_value(value) and returns: result, None