neural_compressor.template.api_doc_example

This module is only used as reference to convert Python docstring to API document.

The created the API document is in API Doc.

Usage:

$python api_doc_example.py

Example:

def fun(a):
    return a+1

x = fun(2)
print(x)
neural_compressor.template.api_doc_example.attribute1[source]

Module level attribute.

Please set 1-100 integer.

Type:

int

Attributes

module_debug_level1

Module debug level document.

Classes

ExampleClass

Example for Class.

Functions

function1(param1, param2)

Example function1.

function2(→ bool)

Function with PEP 484 type annotations.

function3(param1[, param2])

This is an example of function3.

generator1(n)

Generators have a Yields section.

Module Contents

neural_compressor.template.api_doc_example.module_debug_level1 = 1[source]

Module debug level document.

Type:

int

neural_compressor.template.api_doc_example.function1(param1, param2)[source]

Example function1.

Parameters:
  • param1 (str) – The parameter1.

  • param2 (float) – The parameter2.

Example:

>>> python api_doc_example.py
>>> import os
... for i in range(3)
...     print(i)
0
1
2
Returns:

The return value. True|False.

Return type:

bool

neural_compressor.template.api_doc_example.function2(param1: str, param2: float) bool[source]

Function with PEP 484 type annotations.

Parameters:
  • param1 – The parameter1.

  • param2 – The parameter2.

Example

Style 3:

from neural_compressor.config import MixedPrecisionConfig
def eval_func(model):
    ...
    return accuracy

conf = MixedPrecisionConfig()
output_model = mix_precision.fit(
    model,
    conf,
    eval_func=eval_func,
)
Returns:

The return value. True|False.

neural_compressor.template.api_doc_example.function3(param1, param2=None, *args, **kwargs)[source]

This is an example of function3.

If *args or **kwargs are accepted, they should be listed as *args and **kwargs.

Parameters:
  • param1 (int) – The parameter1.

  • param2 (str, optional) – The parameter2.

  • *args – Arguments list.

  • **kwargs – Key-value dict.

Returns:

The return value. True|False.

The Returns section supports any reStructuredText formatting, including literal blocks:

{
    'param1': param1,
    'param2': param2
}

Return type:

bool

Raises:
  • AttributeError – The Raises section is a list of exceptions.

  • ValueError – If param2 is equal to param1.

neural_compressor.template.api_doc_example.generator1(n)[source]

Generators have a Yields section.

Parameters:

n (int) – range.

Yields:

int – The next number in [0, n - 1].

Examples:

>>> print([i for i in example_generator(4)])
[0, 1, 2, 3]
class neural_compressor.template.api_doc_example.ExampleClass(param1, param2, param3)[source]

Example for Class.

If the class has public attributes, they may be documented here in an Attributes section.

attr1[source]

Description of attr1.

Type:

str

attr2[source]

Description of attr2.

Type:

int, optional

attr5 = None[source]

Docstring after attribute, with type specified.

Type:

str