code: def _ConvertAttributeContainerToDict(cls, attribute_container):
      
      if not isinstance(
          attribute_container, containers_interface.AttributeContainer):
        raise TypeError('{0:s} is not an attribute container type.'.format(
            type(attribute_container)))
  
      container_type = getattr(attribute_container, 'CONTAINER_TYPE', None)
      if not container_type:
        raise ValueError('Unsupported attribute container type: {0:s}.'.format(
            type(attribute_container)))
  
      json_dict = {
          '__type__': 'AttributeContainer',
          '__container_type__': container_type,
      }
  
      for attribute_name, attribute_value in attribute_container.GetAttributes():
        json_dict[attribute_name] = cls._ConvertAttributeValueToDict(
            attribute_value)
  
      return json_dict
docs: Converts an attribute container object into a JSON dictionary.
  
      The resulting dictionary of the JSON serialized objects consists of:
      {
          '__type__': 'AttributeContainer'
          '__container_type__': ...
          ...
      }
  
      Here '__type__' indicates the object base type. In this case
      'AttributeContainer'.
  
      '__container_type__' indicates the container type and rest of the elements
      of the dictionary make up the attributes of the container.
  
      Args:
        attribute_container (AttributeContainer): attribute container.
  
      Returns:
        dict[str, object]: JSON serialized objects.
  
      Raises:
        TypeError: if not an instance of AttributeContainer.
        ValueError: if the attribute container type is not supported.