code: def generate_schema(
      input, output, input_description=None, output_description=None
  ):
      """
      Generate schema from a given sample input and output.
      A generated schema can be passed to a server together with a function to
      annotate it with information about input and output parameters, and
      examples thereof. The schema needs to follow the conventions of JSON Schema
      (see json-schema.org).
  
      Parameters
      -----------
      input : any python type | dict
      output: any python type | dict
      input_description : str | dict, optional
      output_description : str | dict, optional
  
      References
      -----------
      - `Json Schema <http://json-schema.org/documentation.html>`
  
      Examples
      ----------
      .. sourcecode:: python
          For just one input parameter, state the example directly.
          >>> from tabpy.tabpy_tools.schema import generate_schema
          >>> schema = generate_schema(
                                input=5,
                                output=25,
                                input_description='input value',
                                output_description='the squared value of input')
          >>> schema
          {'sample': 5,
           'input': {'type': 'integer', 'description': 'input value'},
           'output': {'type': 'integer', 'description': 'the squared value of input'}}
          For two or more input parameters, specify them using a dictionary.
          >>> import graphlab
          >>> schema = generate_schema(
                    input={'x': 3, 'y': 2},
                    output=6,
                    input_description={'x': 'value of x',
                                   'y': 'value of y'},
                output_description='x times y')
          >>> schema
          {'sample': {'y': 2, 'x': 3},
           'input': {'required': ['x', 'y'],
                     'type': 'object',
                     'properties': {'y': {'type': 'integer', 'description': 'value of y'},
                                    'x': {'type': 'integer', 'description': 'value of x'}}},
           'output': {'type': 'integer', 'description': 'x times y'}}
      """  # noqa: E501
      input_schema = _generate_schema_from_example_and_description(
          input, input_description
      )
      output_schema = _generate_schema_from_example_and_description(
          output, output_description
      )
      return {
          "input": input_schema,
          "sample": input,
          "output": output_schema,
      }
  
imports: import logging
  import genson
  import jsonschema
label_desc: Use image node_id 2 for calling a global function with example usage: generate_schema(input, output, input_description, output_description) and returns: dict