code: def _generate_schema_from_example_and_description(input, description):
      """
      With an example input, a schema is automatically generated that conforms
      to the example in json-schema.org. The description given by the users
      is then added to the schema.
      """
      s = genson.SchemaBuilder(None)
      s.add_object(input)
      input_schema = s.to_schema()
  
      if description is not None:
          if "properties" in input_schema:
              # Case for input = {'x':1}, input_description='not a dict'
              if not isinstance(description, dict):
                  msg = f"{input} and {description} do not match"
                  logger.error(msg)
                  raise Exception(msg)
  
              for key in description:
                  # Case for input = {'x':1},
                  # input_description={'x':'x value', 'y':'y value'}
                  if key not in input_schema["properties"]:
                      msg = f"{key} not found in {input}"
                      logger.error(msg)
                      raise Exception(msg)
                  else:
                      input_schema["properties"][key][
                          "description"
                      ] = description[key]
          else:
              if isinstance(description, dict):
                  raise Exception(
                      f"{input} and {description} do not match"
                  )
              else:
                  input_schema["description"] = description
  
      try:
          # This should not fail unless there are bugs with either genson or
          # jsonschema.
          jsonschema.validate(input, input_schema)
      except Exception as e:
          logger.error(f"Internal error validating schema: {str(e)}")
          raise
  
      return input_schema
  
imports: import logging
  import genson
  import jsonschema
label_desc: Use image node_id 1 for calling a global function with example usage: _generate_schema_from_example_and_description(input, description) and returns: input_schema