# Buggy code
def __init__(self, bin_centers: List) -> None:
    # cannot pass directly nd.array because it is not serializable
    bc = mx.nd.array(bin_centers)
    assert len(bc.shape) == 1
    self.bin_centers = bc


# Traceback (TypeError)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/python/anaconda3/lib/python3.7/site-packages/pydantic/validators.py in find_validators(type_, arbitrary_types_allowed)
261         try:
--> 262             if issubclass(type_, val_type):
263                 return validators

TypeError: issubclass() arg 1 must be a class

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
<ipython-input-13-1fca1cb620ad> in <module>
----> 1 from gluonts.model.simple_feedforward import SimpleFeedForwardEstimator
2 from gluonts.trainer import Trainer

~/python/anaconda3/lib/python3.7/site-packages/gluonts/model/simple_feedforward/__init__.py in <module>
1 # Relative imports
----> 2 from ._estimator import SimpleFeedForwardEstimator
3
4 __all__ = ['SimpleFeedForwardEstimator']

~/python/anaconda3/lib/python3.7/site-packages/gluonts/model/simple_feedforward/_estimator.py in <module>
7 # First-party imports
8 from gluonts.core.component import validated
----> 9 from gluonts.distribution import DistributionOutput, StudentTOutput
10 from gluonts.model.estimator import GluonEstimator
11 from gluonts.model.predictor import Predictor, RepresentableBlockPredictor

~/python/anaconda3/lib/python3.7/site-packages/gluonts/distribution/__init__.py in <module>
14 # Relative imports
15 from . import bijection
---> 16 from .binned import Binned, BinnedOutput
17 from .distribution import Distribution
18 from .distribution_output import DistributionOutput

~/python/anaconda3/lib/python3.7/site-packages/gluonts/distribution/binned.py in <module>
166
167
--> 168 class BinnedOutput(DistributionOutput):
169     distr_cls: type = Binned
170

~/python/anaconda3/lib/python3.7/site-packages/gluonts/distribution/binned.py in BinnedOutput()
170
171     @validated()
--> 172     def __init__(self, bin_centers: List) -> None:
173         # cannot pass directly nd.array because it is not serializable
174         bc = mx.nd.array(bin_centers)

~/python/anaconda3/lib/python3.7/site-packages/gluonts/core/component.py in validator(ctor)
167                 f'{ctor_clsnme}Model',
168                 __config__=ConfigBase.Config,
--> 169                 **ctor_fields,
170             )
171         else:

~/python/anaconda3/lib/python3.7/site-packages/pydantic/main.py in create_model(model_name, __config__, __base__, **field_definitions)
408                 annotation=f_annotation,
409                 class_validators=vg.get_validators(f_name),
--> 410                 config=config,
411             )
412

~/python/anaconda3/lib/python3.7/site-packages/pydantic/fields.py in infer(cls, name, value, annotation, class_validators, config)
105             required=required,
106             model_config=config,
--> 107             schema=schema,
108         )
109

~/python/anaconda3/lib/python3.7/site-packages/pydantic/fields.py in __init__(self, name, type_, class_validators, default, required, model_config, alias, allow_none, schema)
85         self.shape: Shape = Shape.SINGLETON
86         self._schema: Schema = schema
---> 87         self.prepare()
88
89     @classmethod

~/python/anaconda3/lib/python3.7/site-packages/pydantic/fields.py in prepare(self)
134
135         self._populate_sub_fields()
--> 136         self._populate_validators()
137
138     def schema(self, by_alias=True):

~/python/anaconda3/lib/python3.7/site-packages/pydantic/fields.py in _populate_validators(self)
264                 *tuple(v.func for v in self.class_validators if not v.whole and v.pre),
265                 *(get_validators() if get_validators else find_validators(self.type_,
--> 266                                                                           self.model_config.arbitrary_types_allowed)),
267                 *tuple(v.func for v in self.class_validators if not v.whole and not v.pre),
268             )

~/python/anaconda3/lib/python3.7/site-packages/pydantic/validators.py in find_validators(type_, arbitrary_types_allowed)
263                 return validators
264         except TypeError as e:
--> 265             raise RuntimeError(f'error checking inheritance of {type_!r} (type: {display_as_type(type_)})') from e
266
267     if arbitrary_types_allowed:

RuntimeError: error checking inheritance of ~T (type: T)

# Fixed code
def __init__(self, bin_centers: List[float]) -> None:
    # cannot pass directly nd.array because it is not serializable
    bc = mx.nd.array(bin_centers)
    assert len(bc.shape) == 1
    self.bin_centers = bc