Build structured numpy array.

        :param int type_name: StructType enum converted to integer.
        :param data: encoded data as a numpy array or a structured numpy array.
        :param data_dtype: numpy dtype.
        :param shape: in case when a list of numpy arrays is passed the length (shape) of
            that array is required.

        :return: structured numpy array.
            {
                '__type__': <struct_field_number>,
                '__data__': <numpy_array>
            }

def struct(cls, type_name: int, data: np.ndarray, data_dtype: np.dtype = None, shape: Tuple = None):
        """Build structured numpy array.

        :param int type_name: StructType enum converted to integer.
        :param data: encoded data as a numpy array or a structured numpy array.
        :param data_dtype: numpy dtype.
        :param shape: in case when a list of numpy arrays is passed the length (shape) of
            that array is required.

        :return: structured numpy array.
            {
                '__type__': <struct_field_number>,
                '__data__': <numpy_array>
            }
        """

        data_dtype = data.dtype if data_dtype is None else data_dtype
        shape = data.shape if shape is None and data.shape else shape
        data_dtype = [data_dtype]
        if shape:
            data_dtype = [data_dtype[0], shape]
        dtype = np.dtype([type_pattern(), (StructField.DATA.value, *data_dtype)])
        return np.array((type_name, data), dtype=dtype)