File size: 6,381 Bytes
12f3253
 
 
 
 
ec03973
 
12f3253
 
 
ec03973
 
12f3253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53339de
 
 
 
 
 
 
 
 
 
 
 
 
ec03973
53339de
ec03973
 
53339de
ec03973
53339de
ec03973
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53339de
 
 
 
 
12f3253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201

import gradio as gr

from RenderMarkdownZh import md_introduction_zh, md_transform_zh, md_likelihood_zh, md_posterior_zh
from RenderMarkdownZh import md_forward_process_zh, md_backward_process_zh, md_fit_posterior_zh
from RenderMarkdownZh import md_posterior_transform_zh, md_deconvolution_zh, md_cond_kl_zh, md_approx_gauss_zh
from RenderMarkdownZh import md_non_expanding_zh, md_stationary_zh, md_reference_zh, md_about_zh

from RenderMarkdownEn import md_introduction_en, md_transform_en, md_likelihood_en, md_posterior_en
from RenderMarkdownEn import md_forward_process_en, md_backward_process_en, md_fit_posterior_en
from RenderMarkdownEn import md_posterior_transform_en, md_deconvolution_en, md_cond_kl_en, md_approx_gauss_en
from RenderMarkdownEn import md_non_expanding_en, md_stationary_en, md_reference_en, md_about_en


def md_introduction_block(md_type="offline"):
    if md_type == "offline":
        gr.Accordion(label="0. Introduction", elem_classes="first_md", elem_id="introduction")
    elif md_type == "zh":
        md_introduction_zh()
    elif md_type == "en":
        md_introduction_en()
    else:
        raise NotImplementedError
    return


def md_transform_block(md_type="offline"):
    if md_type == "offline":
        gr.Accordion(label="1. How To Transform", elem_classes="first_md", elem_id="transform")
    elif md_type == "zh":
        md_transform_zh()
    elif md_type == "en":
        md_transform_en()
    else:
        raise NotImplementedError
    return


def md_likelihood_block(md_type="offline"):
    if md_type == "offline":
        gr.Accordion(label="2. Likelihood of The Transform", elem_classes="first_md", elem_id="likelihood")
    elif md_type == "zh":
        md_likelihood_zh()
    elif md_type == "en":
        md_likelihood_en()
    else:
        raise NotImplementedError
    return


def md_posterior_block(md_type="offline"):
    if md_type == "offline":
        gr.Accordion(label="3. Posterior of The Transform", elem_classes="first_md", elem_id="posterior")
    elif md_type == "zh":
        md_posterior_zh()
    elif md_type == "en":
        md_posterior_en()
    else:
        raise NotImplementedError
    return


def md_forward_process_block(md_type="offline"):
    if md_type == "offline":
        title = "4. Transform Data Distribution To Normal Distribution"
        gr.Accordion(label=title, elem_classes="first_md", elem_id="forward_process")
    elif md_type == "zh":
        md_forward_process_zh()
    elif md_type == "en":
        md_forward_process_en()
    else:
        raise NotImplementedError
    return


def md_backward_process_block(md_type="offline"):
    if md_type == "offline":
        title = "5. Restore Data Distribution From Normal Distribution"
        gr.Accordion(label=title, elem_classes="first_md", elem_id="backward_process")
    elif md_type == "zh":
        md_backward_process_zh()
    elif md_type == "en":
        md_backward_process_en()
    else:
        raise NotImplementedError
    return


def md_fit_posterior_block(md_type="offline"):
    if md_type == "offline":
        title = "6. Fitting Posterior With Conditional Gaussian Model"
        gr.Accordion(label=title, elem_classes="first_md", elem_id="fit_posterior")
    elif md_type == "zh":
        md_fit_posterior_zh()
    elif md_type == "en":
        md_fit_posterior_en()
    else:
        raise NotImplementedError
    return


def md_posterior_transform_block(md_type="offline"):
    if md_type == "offline":
        gr.Accordion(label="7. Posterior Transform", elem_classes="first_md", elem_id="posterior_transform")
    elif md_type == "zh":
        md_posterior_transform_zh()
    elif md_type == "en":
        md_posterior_transform_en()
    else:
        raise NotImplementedError
    return


def md_deconvolution_block(md_type="offline"):
    if md_type == "offline":
        title = "8. Can the data distribution be restored by deconvolution?"
        gr.Accordion(label=title, elem_classes="first_md", elem_id="deconvolution")
    elif md_type == "zh":
        md_deconvolution_zh()
    elif md_type == "en":
        md_deconvolution_en()
    else:
        raise NotImplementedError
    return


def md_cond_kl_block(md_type="offline"):
    if md_type == "offline":
        title = "Appendix A Conditional KL Divergence"
        gr.Accordion(label=title, elem_classes="first_md", elem_id="cond_kl")
    elif md_type == "zh":
        md_cond_kl_zh()
    elif md_type == "en":
        md_cond_kl_en()
    else:
        raise NotImplementedError
    return


def md_approx_gauss_block(md_type="offline"):
    if md_type == "offline":
        title = "Appendix B When does the Posterior Approximate to Gaussian ?"
        gr.Accordion(label=title, elem_classes="first_md", elem_id="approx_gauss")
    elif md_type == "zh":
        md_approx_gauss_zh()
    elif md_type == "en":
        md_approx_gauss_en()
    else:
        raise NotImplementedError
    return


def md_non_expanding_block(md_type="offline"):
    if md_type == "offline":
        title = "Appendix C Posterior Transform is a Non-expanding Mapping"
        gr.Accordion(label=title, elem_classes="first_md", elem_id="non_expanding")
    elif md_type == "zh":
        md_non_expanding_zh()
    elif md_type == "en":
        md_non_expanding_en()
    else:
        raise NotImplementedError
    return


def md_stationary_block(md_type="offline"):
    if md_type == "offline":
        title = "Appendix D Posterior Transform Converges to the Unique Stationary Distribution"
        gr.Accordion(label=title, elem_classes="first_md", elem_id="stationary")
    elif md_type == "zh":
        md_stationary_zh()
    elif md_type == "en":
        md_stationary_en()
    else:
        raise NotImplementedError
    return


def md_reference_block(md_type="offline"):
    if md_type == "offline":
        gr.Accordion(label="Reference", elem_classes="first_md", elem_id="reference")
    elif md_type == "zh":
        md_reference_zh()
    elif md_type == "en":
        md_reference_en()
    else:
        raise NotImplementedError
    return


def md_about_block(md_type="offline"):
    if md_type == "offline":
        gr.Accordion(label="About", elem_classes="first_md", elem_id="about")
    elif md_type == "zh":
        md_about_zh()
    elif md_type == "en":
        md_about_en()
    else:
        raise NotImplementedError
    return