```python
from __future__ import print_function

from textwrap import dedent

import pytablewriter

table_name = "example_table"
headers = ["int", "float", "str", "bool", "mix", "time"]
data = [
    [0,   0.1,      "hoge", True,   0,      "2017-01-01 03:04:05+0900"],
    [2,   "-2.23",  "foo",  False,  None,   "2017-12-23 12:34:51+0900"],
    [3,   0,        "bar",  "true",  "inf", "2017-03-03 22:44:55+0900"],
    [-10, -9.9,     "",     "FALSE", "nan", "2017-01-01 00:00:00+0900"],
]
```

```python
for name in pytablewriter.TableWriterFactory.get_format_names():
    print(name)
```

    adoc
    asciidoc
    bold_unicode
    borderless
    css
    csv
    elasticsearch
    excel
    htm
    html
    javascript
    js
    json
    json_lines
    jsonl
    latex_matrix
    latex_table
    ldjson
    ltsv
    markdown
    md
    mediawiki
    ndjson
    null
    numpy
    pandas
    pandas_pickle
    py
    python
    rst
    rst_csv
    rst_csv_table
    rst_grid
    rst_grid_table
    rst_simple
    rst_simple_table
    space_aligned
    sqlite
    toml
    tsv
    unicode
    yaml

```python
for name in pytablewriter.TableWriterFactory.get_extensions():
    print(name)
```

    adoc
    asc
    asciidoc
    css
    csv
    htm
    html
    js
    json
    jsonl
    ldjson
    ltsv
    md
    ndjson
    py
    rst
    sqlite
    sqlite3
    tex
    toml
    tsv
    xls
    xlsx
    yml

```python
from pytablewriter import MarkdownTableWriter

writer = MarkdownTableWriter()
writer.table_name = "zone"
writer.headers = ["zone_id", "country_code", "zone_name"]
writer.value_matrix = [
    ["1", "AD", "Europe/Andorra"],
    ["2", "AE", "Asia/Dubai"],
    ["3", "AF", "Asia/Kabul"],
    ["4", "AG", "America/Antigua"],
    ["5", "AI", "America/Anguilla"],
]

writer.write_table()
```

    # zone
    |zone_id|country_code|   zone_name    |
    |------:|------------|----------------|
    |      1|AD          |Europe/Andorra  |
    |      2|AE          |Asia/Dubai      |
    |      3|AF          |Asia/Kabul      |
    |      4|AG          |America/Antigua |
    |      5|AI          |America/Anguilla|

```python
writer = pytablewriter.CsvTableWriter()
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    "int","float","str","bool","mix","time"
    0,0.1,"hoge",True,0,"2017-01-01 03:04:05+0900"
    2,-2.23,"foo",False,,"2017-12-23 12:34:51+0900"
    3,0,"bar",True,Infinity,"2017-03-03 22:44:55+0900"
    -10,-9.9,,False,NaN,"2017-01-01 00:00:00+0900"

```python
writer = pytablewriter.SpaceAlignedTableWriter()
writer.headers = ["PID", "USER", "PR", "NI", "VIRT", "RES", "SHR", "S", "%CPU", "%MEM", "TIME+", "COMMAND"]
writer.value_matrix = csv1 = [
    [32866, "root", 20, 0, 48344, 3924, 3448, "R", 5.6, 0.2, "0:00.03", "top"],
    [1, "root", 20, 0, 212080, 7676, 5876, "S", 0, 0.4, "1:06.56", "systemd"],
    [2, "root", 20, 0, 0, 0, 0, "S", 0, 0, "0:01.92", "kthreadd"],
    [4, "root", 0, -20, 0, 0, 0, "S", 0, 0, "0:00.00", "kworker/0:0H"],
]

writer.write_table()
```

     PID   USER  PR  NI    VIRT   RES   SHR   S  %CPU  %MEM   TIME+     COMMAND
    32866  root  20    0   48344  3924  3448  R   5.6   0.2  0:00.03  top
        1  root  20    0  212080  7676  5876  S   0.0   0.4  1:06.56  systemd
        2  root  20    0       0     0     0  S   0.0   0.0  0:01.92  kthreadd
        4  root   0  -20       0     0     0  S   0.0   0.0  0:00.00  kworker/0:0H

```python
writer = pytablewriter.TsvTableWriter()
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    "int"	"float"	"str"	"bool"	"mix"	"time"
    0	0.1	"hoge"	True	0	"2017-01-01 03:04:05+0900"
    2	-2.23	"foo"	False		"2017-12-23 12:34:51+0900"
    3	0	"bar"	True	Infinity	"2017-03-03 22:44:55+0900"
    -10	-9.9		False	NaN	"2017-01-01 00:00:00+0900"

```python
writer = pytablewriter.HtmlTableWriter()
writer.table_name = table_name
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

example_table

                int
                float
                str
                bool
                mix
                time

                0
                0.10
                hoge
                True
                0
                2017-01-01 03:04:05+0900

                2
                -2.23
                foo
                False

                2017-12-23 12:34:51+0900

                3
                0.00
                bar
                True
                Infinity
                2017-03-03 22:44:55+0900

                -10
                -9.90

                False
                NaN
                2017-01-01 00:00:00+0900

```python
writer = pytablewriter.JavaScriptTableWriter()
writer.table_name = table_name
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    const example_table = [
        ["int", "float", "str", "bool", "mix", "time"],
        [0, 0.1, "hoge", true, 0, "2017-01-01 03:04:05+0900"],
        [2, -2.23, "foo", false, null, "2017-12-23 12:34:51+0900"],
        [3, 0, "bar", true, Infinity, "2017-03-03 22:44:55+0900"],
        [-10, -9.9, "", "FALSE", NaN, "2017-01-01 00:00:00+0900"]
    ];

```python
writer = pytablewriter.JsonTableWriter()
#writer.table_name = "Timezone"
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    [
        {
            "int": 0,
            "float": 0.1,
            "str": "hoge",
            "bool": true,
            "mix": 0,
            "time": "2017-01-01 03:04:05+0900"
        },
        {
            "int": 2,
            "float": -2.23,
            "str": "foo",
            "bool": false,
            "mix": null,
            "time": "2017-12-23 12:34:51+0900"
        },
        {
            "int": 3,
            "float": 0,
            "str": "bar",
            "bool": "true",
            "mix": "Infinity",
            "time": "2017-03-03 22:44:55+0900"
        },
        {
            "int": -10,
            "float": -9.9,
            "str": "",
            "bool": "FALSE",
            "mix": "NaN",
            "time": "2017-01-01 00:00:00+0900"
        }
    ]

```python
writer = pytablewriter.JsonLinesTableWriter()
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    {"int": 0, "float": 0.1, "str": "hoge", "bool": true, "mix": 0, "time": "2017-01-01 03:04:05+0900"}
    {"int": 2, "float": -2.23, "str": "foo", "bool": false, "mix": null, "time": "2017-12-23 12:34:51+0900"}
    {"int": 3, "float": 0, "str": "bar", "bool": "true", "mix": "Infinity", "time": "2017-03-03 22:44:55+0900"}
    {"int": -10, "float": -9.9, "str": "", "bool": "FALSE", "mix": "NaN", "time": "2017-01-01 00:00:00+0900"}

```python
writer = pytablewriter.JsonTableWriter()
writer.table_name = table_name
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    { "example_table" : [
        {
            "int": 0,
            "float": 0.1,
            "str": "hoge",
            "bool": true,
            "mix": 0,
            "time": "2017-01-01 03:04:05+0900"
        },
        {
            "int": 2,
            "float": -2.23,
            "str": "foo",
            "bool": false,
            "mix": null,
            "time": "2017-12-23 12:34:51+0900"
        },
        {
            "int": 3,
            "float": 0,
            "str": "bar",
            "bool": "true",
            "mix": "Infinity",
            "time": "2017-03-03 22:44:55+0900"
        },
        {
            "int": -10,
            "float": -9.9,
            "str": "",
            "bool": "FALSE",
            "mix": "NaN",
            "time": "2017-01-01 00:00:00+0900"
        }
    ]}

```python
writer = pytablewriter.LatexMatrixWriter()
writer.table_name = "A"
writer.value_matrix = [
    [0.01, 0.00125, 0.0],
    [1.0, 99.9,  0.01],
    [1.2, 999999.123, 0.001],
]
writer.write_table()
```

    \begin{equation}
        A = \left( \begin{array}{rrr}
            0.01 &      0.0012 & 0.000 \\
            1.00 &     99.9000 & 0.010 \\
            1.20 & 999999.1230 & 0.001 \\
        \end{array} \right)
    \end{equation}

\begin{equation}
    A = \left( \begin{array}{rrr}
        0.01 &      0.0012 & 0.000 \\
        1.00 &     99.9000 & 0.010 \\
        1.20 & 999999.1230 & 0.001 \\
    \end{array} \right)
\end{equation}

```python
writer = pytablewriter.LatexMatrixWriter()
writer.table_name = "B"
writer.value_matrix = [
    ["a_{11}", "a_{12}", "\\ldots", "a_{1n}"],
    ["a_{21}", "a_{22}", "\\ldots", "a_{2n}"],
    [r"\vdots", "\\vdots", "\\ddots", "\\vdots"],
    ["a_{n1}", "a_{n2}", "\\ldots", "a_{nn}"],
]
writer.write_table()
```

    \begin{equation}
        B = \left( \begin{array}{llll}
            a_{11} & a_{12} & \ldots & a_{1n} \\
            a_{21} & a_{22} & \ldots & a_{2n} \\
            \vdots & \vdots & \ddots & \vdots \\
            a_{n1} & a_{n2} & \ldots & a_{nn} \\
        \end{array} \right)
    \end{equation}

\begin{equation}
    B = \left( \begin{array}{llll}
        a_{11} & a_{12} & \ldots & a_{1n} \\
        a_{21} & a_{22} & \ldots & a_{2n} \\
        \vdots & \vdots & \ddots & \vdots \\
        a_{n1} & a_{n2} & \ldots & a_{nn} \\
    \end{array} \right)
\end{equation}

```python
writer = pytablewriter.LatexTableWriter()
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    \begin{array}{r | r | l | l | l | l} \hline
        \verb|int| & \verb|float| & \verb|str | & \verb|bool | & \verb| mix  | & \verb|          time          | \\ \hline
        \hline
          0 &  0.10 & hoge & True  &      0 & \verb|2017-01-01 03:04:05+0900| \\ \hline
          2 & -2.23 & foo  & False &        & \verb|2017-12-23 12:34:51+0900| \\ \hline
          3 &  0.00 & bar  & True  & \infty & \verb|2017-03-03 22:44:55+0900| \\ \hline
        -10 & -9.90 &      & False & NaN    & \verb|2017-01-01 00:00:00+0900| \\ \hline
    \end{array}

\begin{array}{r | r | l | l | l | l} \hline
    \verb|int| & \verb|float| & \verb|str| & \verb|bool| & \verb|mix| & \verb|time| \\ \hline
    \hline
    0 & 0.10 & hoge & True & 0 & \verb|2017-01-01 03:04:05+0900| \\ \hline
    2 & -2.23 & foo & False &  & \verb|2017-12-23 12:34:51+0900| \\ \hline
    3 & 0.00 & bar & True & \infty & \verb|2017-03-03 22:44:55+0900| \\ \hline
    -10 & -9.90 &  & False & NaN & \verb|2017-01-01 00:00:00+0900| \\ \hline
\end{array}

```python
from pytablewriter import MarkdownTableWriter

writer = MarkdownTableWriter()
writer.table_name = table_name
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    # example_table
    |int|float|str |bool |  mix   |          time          |
    |--:|----:|----|-----|-------:|------------------------|
    |  0| 0.10|hoge|True |       0|2017-01-01 03:04:05+0900|
    |  2|-2.23|foo |False|        |2017-12-23 12:34:51+0900|
    |  3| 0.00|bar |True |Infinity|2017-03-03 22:44:55+0900|
    |-10|-9.90|    |False|     NaN|2017-01-01 00:00:00+0900|

```python
from pytablewriter import MarkdownTableWriter

writer = MarkdownTableWriter()
writer.table_name = "write example with a margin"
writer.headers = headers
writer.value_matrix = data
writer.margin = 1  # add a whitespace for both sides of each cell

writer.write_table()
```

    # write example with a margin
    | int | float | str  | bool  |   mix    |           time           |
    | --: | ----: | ---- | ----- | -------: | ------------------------ |
    |   0 |  0.10 | hoge | True  |        0 | 2017-01-01 03:04:05+0900 |
    |   2 | -2.23 | foo  | False |          | 2017-12-23 12:34:51+0900 |
    |   3 |  0.00 | bar  | True  | Infinity | 2017-03-03 22:44:55+0900 |
    | -10 | -9.90 |      | False |      NaN | 2017-01-01 00:00:00+0900 |

```python
writer = pytablewriter.MediaWikiTableWriter()
writer.table_name = table_name
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    {| class="wikitable"
    |+example_table
    ! int
    ! float
    ! str
    ! bool
    ! mix
    ! time
    |-
    | style="text-align:right"| 0
    | style="text-align:right"| 0.10
    | hoge
    | True
    | style="text-align:right"| 0
    | 2017-01-01 03:04:05+0900
    |-
    | style="text-align:right"| 2
    | style="text-align:right"| -2.23
    | foo
    | False
    |
    | 2017-12-23 12:34:51+0900
    |-
    | style="text-align:right"| 3
    | style="text-align:right"| 0.00
    | bar
    | True
    | Infinity
    | 2017-03-03 22:44:55+0900
    |-
    | style="text-align:right"| -10
    | style="text-align:right"| -9.90
    |
    | False
    | NaN
    | 2017-01-01 00:00:00+0900
    |}

```python
writer = pytablewriter.NumpyTableWriter()
writer.table_name = table_name
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    example_table = np.array([
        ["int", "float", "str", "bool", "mix", "time"],
        [0, 0.1, "hoge", True, 0, "2017-01-01 03:04:05+0900"],
        [2, -2.23, "foo", False, None, "2017-12-23 12:34:51+0900"],
        [3, 0, "bar", True, np.inf, "2017-03-03 22:44:55+0900"],
        [-10, -9.9, "", False, np.nan, "2017-01-01 00:00:00+0900"],
    ])

```python
writer = pytablewriter.PandasDataFrameWriter()
writer.table_name = table_name
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    example_table = pd.DataFrame([
        [0, 0.1, "hoge", True, 0, "2017-01-01 03:04:05+0900"],
        [2, -2.23, "foo", False, None, "2017-12-23 12:34:51+0900"],
        [3, 0, "bar", True, np.inf, "2017-03-03 22:44:55+0900"],
        [-10, -9.9, "", False, np.nan, "2017-01-01 00:00:00+0900"],
    ], columns=["int", "float", "str", "bool", "mix", "time"])

```python
writer = pytablewriter.PandasDataFrameWriter()
writer.table_name = table_name
writer.headers = headers
writer.value_matrix = data
writer.is_datetime_instance_formatting = False

writer.write_table()
```

    example_table = pd.DataFrame([
        [0, 0.1, "hoge", True, 0, "2017-01-01 03:04:05+0900"],
        [2, -2.23, "foo", False, None, "2017-12-23 12:34:51+0900"],
        [3, 0, "bar", True, np.inf, "2017-03-03 22:44:55+0900"],
        [-10, -9.9, "", False, np.nan, "2017-01-01 00:00:00+0900"],
    ], columns=["int", "float", "str", "bool", "mix", "time"])

```python
writer = pytablewriter.PythonCodeTableWriter()
writer.table_name = table_name
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    example_table = [
        ["int", "float", "str", "bool", "mix", "time"],
        [0, 0.1, "hoge", True, 0, "2017-01-01 03:04:05+0900"],
        [2, -2.23, "foo", False, None, "2017-12-23 12:34:51+0900"],
        [3, 0, "bar", True, float("inf"), "2017-03-03 22:44:55+0900"],
        [-10, -9.9, "", False, float("nan"), "2017-01-01 00:00:00+0900"],
    ]

```python
writer = pytablewriter.PythonCodeTableWriter()
writer.table_name = table_name
writer.headers = headers
writer.value_matrix = data
writer.is_datetime_instance_formatting = False

writer.write_table()
```

    example_table = [
        ["int", "float", "str", "bool", "mix", "time"],
        [0, 0.1, "hoge", True, 0, "2017-01-01 03:04:05+0900"],
        [2, -2.23, "foo", False, None, "2017-12-23 12:34:51+0900"],
        [3, 0, "bar", True, float("inf"), "2017-03-03 22:44:55+0900"],
        [-10, -9.9, "", False, float("nan"), "2017-01-01 00:00:00+0900"],
    ]

```python
writer = pytablewriter.RstGridTableWriter()
writer.table_name = table_name
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    .. table:: example_table

        +---+-----+----+-----+--------+------------------------+
        |int|float|str |bool |  mix   |          time          |
        +===+=====+====+=====+========+========================+
        |  0| 0.10|hoge|True |       0|2017-01-01 03:04:05+0900|
        +---+-----+----+-----+--------+------------------------+
        |  2|-2.23|foo |False|        |2017-12-23 12:34:51+0900|
        +---+-----+----+-----+--------+------------------------+
        |  3| 0.00|bar |True |Infinity|2017-03-03 22:44:55+0900|
        +---+-----+----+-----+--------+------------------------+
        |-10|-9.90|    |False|     NaN|2017-01-01 00:00:00+0900|
        +---+-----+----+-----+--------+------------------------+

```python
writer = pytablewriter.RstSimpleTableWriter()
writer.table_name = table_name
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    .. table:: example_table

        ===  =====  ====  =====  ========  ========================
        int  float  str   bool     mix               time
        ===  =====  ====  =====  ========  ========================
          0   0.10  hoge  True          0  2017-01-01 03:04:05+0900
          2  -2.23  foo   False            2017-12-23 12:34:51+0900
          3   0.00  bar   True   Infinity  2017-03-03 22:44:55+0900
        -10  -9.90        False       NaN  2017-01-01 00:00:00+0900
        ===  =====  ====  =====  ========  ========================

```python
writer = pytablewriter.RstCsvTableWriter()
writer.table_name = table_name
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    .. csv-table:: example_table
        :header: "int", "float", "str", "bool", "mix", "time"
        :widths: 5, 7, 6, 6, 8, 26

        0, 0.10, "hoge", True, 0, "2017-01-01 03:04:05+0900"
        2, -2.23, "foo", False, , "2017-12-23 12:34:51+0900"
        3, 0.00, "bar", True, Infinity, "2017-03-03 22:44:55+0900"
        -10, -9.90, , False, NaN, "2017-01-01 00:00:00+0900"

```python
writer = pytablewriter.LtsvTableWriter()
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    int:0	float:0.1	str:"hoge"	bool:True	mix:0	time:"2017-01-01 03:04:05+0900"
    int:2	float:-2.23	str:"foo"	bool:False	time:"2017-12-23 12:34:51+0900"
    int:3	float:0	str:"bar"	bool:True	mix:Infinity	time:"2017-03-03 22:44:55+0900"
    int:-10	float:-9.9	bool:False	mix:NaN	time:"2017-01-01 00:00:00+0900"

```python
writer = pytablewriter.TomlTableWriter()
writer.table_name = table_name
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    [[example_table]]
    int = 0
    float = 0.1
    str = "hoge"
    bool = true
    mix = 0
    time = "2017-01-01 03:04:05+0900"

    [[example_table]]
    int = 2
    float = -2.23
    str = "foo"
    bool = false
    time = "2017-12-23 12:34:51+0900"

    [[example_table]]
    int = 3
    float = 0
    str = "bar"
    bool = true
    mix = inf
    time = "2017-03-03 22:44:55+0900"

    [[example_table]]
    int = -10
    float = -9.9
    str = ""
    bool = false
    mix = nan
    time = "2017-01-01 00:00:00+0900"

```python
from datetime import datetime
from pytablewriter import JavaScriptTableWriter
from pytablewriter.typehint import DateTime, Integer, String

def main():
    writer = JavaScriptTableWriter()
    writer.headers = ["header_a", "header_b", "header_c"]
    writer.value_matrix = [
        [-1.1, "2017-01-02 03:04:05", datetime(2017, 1, 2, 3, 4, 5)],
        [0.12, "2017-02-03 04:05:06", datetime(2017, 2, 3, 4, 5, 6)],
    ]

    print("// without type hints:  column data types detected automatically by default")
    writer.table_name = "without type hint"
    writer.write_table()

    print("// with type hints: Integer, DateTime, String")
    writer.table_name = "with type hint"
    writer.type_hints = [Integer, DateTime, String]
    writer.write_table()

if __name__ == "__main__":
    main()
```

    // without type hints:  column data types detected automatically by default
    const without_type_hint = [
        ["header_a", "header_b", "header_c"],
        [-1.1, "2017-01-02 03:04:05", new Date("2017-01-02T03:04:05")],
        [0.12, "2017-02-03 04:05:06", new Date("2017-02-03T04:05:06")]
    ];
    // with type hints: Integer, DateTime, String
    const with_type_hint = [
        ["header_a", "header_b", "header_c"],
        [-1, new Date("2017-01-02T03:04:05"), "2017-01-02 03:04:05"],
        [0, new Date("2017-02-03T04:05:06"), "2017-02-03 04:05:06"]
    ];

```python
from datetime import datetime
from pytablewriter import PythonCodeTableWriter
from pytablewriter.typehint import DateTime, Integer, String

def main():
    writer = PythonCodeTableWriter()
    writer.value_matrix = [
        [-1.1, float("inf"), "2017-01-02 03:04:05", datetime(2017, 1, 2, 3, 4, 5)],
        [0.12, float("nan"), "2017-02-03 04:05:06", datetime(2017, 2, 3, 4, 5, 6)],
    ]

    # column data types detected automatically by default
    writer.table_name = "python variable without type hints"
    writer.headers = ["float", "infnan", "string", "datetime"]
    writer.write_table()

    # set type hints
    writer.table_name = "python variable with type hints"
    writer.headers = ["hint_int", "hint_str", "hint_datetime", "hint_str"]
    writer.type_hints = [Integer, String, DateTime, String]
    writer.write_table()

if __name__ == "__main__":
    main()
```

    python_variable_without_type_hints = [
        ["float", "infnan", "string", "datetime"],
        [-1.1, float("inf"), "2017-01-02 03:04:05", dateutil.parser.parse("2017-01-02T03:04:05")],
        [0.12, float("nan"), "2017-02-03 04:05:06", dateutil.parser.parse("2017-02-03T04:05:06")],
    ]
    python_variable_with_type_hints = [
        ["hint_int", "hint_str", "hint_datetime", "hint_str"],
        [-1, "inf", dateutil.parser.parse("2017-01-02T03:04:05"), "2017-01-02 03:04:05"],
        [0, "nan", dateutil.parser.parse("2017-02-03T04:05:06"), "2017-02-03 04:05:06"],
    ]

```python
writer = pytablewriter.MarkdownTableWriter()
writer.from_csv(dedent("""\
    "i","f","c","if","ifc","bool","inf","nan","mix_num","time"
    1,1.10,"aa",1.0,"1",True,Infinity,NaN,1,"2017-01-01 00:00:00+09:00"
    2,2.20,"bbb",2.2,"2.2",False,Infinity,NaN,Infinity,"2017-01-02 03:04:05+09:00"
    3,3.33,"cccc",-3.0,"ccc",True,Infinity,NaN,NaN,"2017-01-01 00:00:00+09:00"
    """))
writer.write_table()
```

    | i | f  | c  | if |ifc|bool |  inf   |nan|mix_num |          time           |
    |--:|---:|----|---:|---|-----|--------|---|-------:|-------------------------|
    |  1|1.10|aa  | 1.0|  1|True |Infinity|NaN|       1|2017-01-01 00:00:00+09:00|
    |  2|2.20|bbb | 2.2|2.2|False|Infinity|NaN|Infinity|2017-01-02 03:04:05+09:00|
    |  3|3.33|cccc|-3.0|ccc|True |Infinity|NaN|     NaN|2017-01-01 00:00:00+09:00|

```python
writer = pytablewriter.MarkdownTableWriter()
writer.table_name = "ps"
writer.from_csv(
    dedent("""\
        USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
        root         1  0.0  0.4  77664  8784 ?        Ss   May11   0:02 /sbin/init
        root         2  0.0  0.0      0     0 ?        S    May11   0:00 [kthreadd]
        root         4  0.0  0.0      0     0 ?        I<   May11   0:00 [kworker/0:0H]
        root         6  0.0  0.0      0     0 ?        I<   May11   0:00 [mm_percpu_wq]
        root         7  0.0  0.0      0     0 ?        S    May11   0:01 [ksoftirqd/0]
    """),
    delimiter=" ")
writer.write_table()
```

    # ps
    |USER|PID|%CPU|%MEM| VSZ |RSS |TTY|STAT|START|TIME|   COMMAND    |
    |----|--:|---:|---:|----:|---:|---|----|-----|----|--------------|
    |root|  1|   0| 0.4|77664|8784|?  |Ss  |May11|0:02|/sbin/init    |
    |root|  2|   0| 0.0|    0|   0|?  |S   |May11|0:00|[kthreadd]    |
    |root|  4|   0| 0.0|    0|   0|?  |I<  |May11|0:00|[kworker/0:0H]|
    |root|  6|   0| 0.0|    0|   0|?  |I<  |May11|0:00|[mm_percpu_wq]|
    |root|  7|   0| 0.0|    0|   0|?  |S   |May11|0:01|[ksoftirqd/0] |

```python
from pytablewriter import MarkdownTableWriter
from pytablewriter.style import Align, Style

writer = MarkdownTableWriter()
writer.table_name = "specify alignment for each column manually"
writer.headers = ["left", "right", "center", "auto (int)", "auto (str)", "None (same as AUTO)"]
writer.value_matrix = [
    [0, "r", "center align", 0, "a", "n"],
    [11, "right align", "c", 11, "auto", "none"],
]

# set alignments for each column
writer.column_styles = [
    Style(align=Align.LEFT),
    Style(align=Align.RIGHT),
    Style(align=Align.CENTER),
    Style(align=Align.AUTO),
    Style(align=Align.AUTO),
    None,
]

writer.write_table()
```

    # specify alignment for each column manually
    |left|   right   |   center   |auto (int)|auto (str)|None (same as AUTO)|
    |----|----------:|:----------:|---------:|----------|-------------------|
    |0   |          r|center align|         0|a         |n                  |
    |11  |right align|     c      |        11|auto      |none               |

```python
from pytablewriter import MarkdownTableWriter
from pytablewriter.style import Style

writer = MarkdownTableWriter()
writer.table_name = "set style by styles"
writer.headers = [
    "auto align",
    "left align",
    "center align",
    "bold",
    "italic",
    "bold italic ts",
]
writer.value_matrix = [
    [11, 11, 11, 11, 11, 11],
    [1234, 1234, 1234, 1234, 1234, 1234],
]

# specify styles for each column
writer.column_styles = [
    Style(),
    Style(align="left"),
    Style(align="center"),
    Style(font_weight="bold"),
    Style(font_style="italic"),
    Style(font_weight="bold", font_style="italic", thousand_separator=","),
]

writer.write_table()

```

    # set style by styles
    |auto align|left align|center align|  bold  |italic|bold italic ts|
    |---------:|----------|:----------:|-------:|-----:|-------------:|
    |        11|11        |     11     |  **11**|  _11_|      _**11**_|
    |      1234|1234      |    1234    |**1234**|_1234_|   _**1,234**_|

```python
from pytablewriter import MarkdownTableWriter
from pytablewriter.style import Style

writer = MarkdownTableWriter()
writer.headers = ["A", "B", "C",]
writer.value_matrix = [[11, 11, 11], [1234, 1234, 1234]]

writer.table_name = "set style by column index"
writer.set_style(1, Style(align="center", font_weight="bold"))
writer.set_style(2, Style(thousand_separator=" "))
writer.write_table()
writer.write_null_line()

writer.table_name = "set style by header"
writer.set_style("B", Style(font_style="italic"))
writer.write_table()

```

    # set style by column index
    | A  |   B    |  C  |
    |---:|:------:|----:|
    |  11| **11** |   11|
    |1234|**1234**|1 234|

    # set style by header
    | A  |  B   |  C  |
    |---:|-----:|----:|
    |  11|  _11_|   11|
    |1234|_1234_|1 234|

```python
import pytablewriter

writer = pytablewriter.MarkdownTableWriter()
writer.headers = ["int", "float", "str", "bool", "mix", "time"]
writer.value_matrix = [
    [0,   0.1,      "hoge", True,   0,      "2017-01-01 03:04:05+0900"],
    [2,   "-2.23",  "foo",  False,  None,   "2017-12-23 45:01:23+0900"],
    [3,   0,        "bar",  "true",  "inf", "2017-03-03 33:44:55+0900"],
    [-10, -9.9,     "",     "FALSE", "nan", "2017-01-01 00:00:00+0900"],
]

print(writer.dumps())
```

    |int|float|str |bool |  mix   |          time          |
    |--:|----:|----|-----|-------:|------------------------|
    |  0| 0.10|hoge|True |       0|2017-01-01 03:04:05+0900|
    |  2|-2.23|foo |False|        |2017-12-23 45:01:23+0900|
    |  3| 0.00|bar |True |Infinity|2017-03-03 33:44:55+0900|
    |-10|-9.90|    |False|     NaN|2017-01-01 00:00:00+0900|

```python
from pytablewriter import MarkdownTableWriter
from pytablewriter.style import ThousandSeparator

writer = MarkdownTableWriter()
writer.headers = ["wo_format", "comma_i", "space_f"]
writer.value_matrix = [
    [1000, 1234567, 1234567.8],
    [1000, 1234567, 1234567.8],
    [1000, 1234567, 1234567.8],
]
writer.column_styles = [
    Style(thousand_separator=ThousandSeparator.NONE),
    Style(thousand_separator=ThousandSeparator.COMMA),
    Style(thousand_separator=ThousandSeparator.SPACE),
]
writer.write_table()
```

    |wo_format| comma_i |  space_f  |
    |--------:|--------:|----------:|
    |     1000|1,234,567|1 234 567.8|
    |     1000|1,234,567|1 234 567.8|
    |     1000|1,234,567|1 234 567.8|

```python
from pytablewriter import LatexTableWriter
from pytablewriter.style import Style, FontSize

writer = LatexTableWriter()
writer.table_name = "style test: font size"
writer.headers = ["none", "empty_style", "tiny", "small", "medium", "large"]
writer.value_matrix = [[111, 111, 111, 111, 111, 111], [1234, 1234, 1234, 1234, 1234, 1234]]
writer.column_styles = [
    None,
    Style(),
    Style(font_size=FontSize.TINY),
    Style(font_size=FontSize.SMALL),
    Style(font_size=FontSize.MEDIUM),
    Style(font_size=FontSize.LARGE),
]
writer.write_table()
```

    \begin{array}{r | r | r | r | r | r} \hline
        \verb|none| & \verb|empty_style| & \verb|  tiny   | & \verb|  small   | & \verb|    medium     | & \verb|  large   | \\ \hline
        \hline
         111 &         111 & \tiny 111 & \small 111 & \normalsize 111 & \large 111 \\ \hline
        1234 &        1234 & \tiny 1234 & \small 1234 & \normalsize 1234 & \large 1234 \\ \hline
    \end{array}

\begin{array}{r | r | r | r | r | r} \hline
    \verb|none| & \verb|empty_style| & \verb|tiny| & \verb|small| & \verb|medium| & \verb|large| \\ \hline
    \hline
     111 &         111 & \tiny 111 & \small 111 & \normalsize 111 & \large 111 \\ \hline
    1234 &        1234 & \tiny 1234 & \small 1234 & \normalsize 1234 & \large 1234 \\ \hline
\end{array}

```python
from pytablewriter import UnicodeTableWriter

writer = UnicodeTableWriter()
writer.table_name = table_name
writer.headers = headers
writer.value_matrix = data

writer.write_table()
```

    ┌───┬─────┬────┬─────┬────────┬────────────────────────┐
    │int│float│str │bool │  mix   │          time          │
    ├───┼─────┼────┼─────┼────────┼────────────────────────┤
    │  0│ 0.10│hoge│True │       0│2017-01-01 03:04:05+0900│
    ├───┼─────┼────┼─────┼────────┼────────────────────────┤
    │  2│-2.23│foo │False│        │2017-12-23 12:34:51+0900│
    ├───┼─────┼────┼─────┼────────┼────────────────────────┤
    │  3│ 0.00│bar │True │Infinity│2017-03-03 22:44:55+0900│
    ├───┼─────┼────┼─────┼────────┼────────────────────────┤
    │-10│-9.90│    │False│     NaN│2017-01-01 00:00:00+0900│
    └───┴─────┴────┴─────┴────────┴────────────────────────┘

```python
from textwrap import dedent
import pandas as pd
import io
from pytablewriter import MarkdownTableWriter

def main():
    csv_data = io.StringIO(dedent("""\
        "i","f","c","if","ifc","bool","inf","nan","mix_num","time"
        1,1.10,"aa",1.0,"1",True,Infinity,NaN,1,"2017-01-01 00:00:00+09:00"
        2,2.20,"bbb",2.2,"2.2",False,Infinity,NaN,Infinity,"2017-01-02 03:04:05+09:00"
        3,3.33,"cccc",-3.0,"ccc",True,Infinity,NaN,NaN,"2017-01-01 00:00:00+09:00"
        """))
    df = pd.read_csv(csv_data, sep=',')

    writer = MarkdownTableWriter(dataframe=df)
    writer.write_table()

if __name__ == "__main__":
    main()

```

    | i | f  | c  | if |ifc|bool |  inf   |nan|mix_num |          time           |
    |--:|---:|----|---:|---|-----|--------|---|-------:|-------------------------|
    |  1|1.10|aa  | 1.0|  1|True |Infinity|NaN|       1|2017-01-01 00:00:00+09:00|
    |  2|2.20|bbb | 2.2|2.2|False|Infinity|NaN|Infinity|2017-01-02 03:04:05+09:00|
    |  3|3.33|cccc|-3.0|ccc|True |Infinity|NaN|     NaN|2017-01-01 00:00:00+09:00|

```python

```


```python
try:
    %cd /content
    !git clone https://github.com/mveer1/Fake-News-Detection.git
except:
    !rm -r /content/Fake-News-Detection
    !git clone https://github.com/mveer1/Fake-News-Detection.git

# !git clone https://github.com/mveer1/Fake-News-Detection.git
```

    /content
    Cloning into 'Fake-News-Detection'...
    remote: Enumerating objects: 63, done.
    remote: Counting objects: 100% (63/63), done.
    remote: Compressing objects: 100% (44/44), done.
    remote: Total 63 (delta 23), reused 44 (delta 16), pack-reused 0
    Unpacking objects: 100% (63/63), done.

```python
# !rm -r /content/Fake-News-Detection
```

```python
%cd /content/Fake-News-Detection/
```

    /content/Fake-News-Detection

```python
import os
os.chdir("/content/Fake-News-Detection/")
!pwd
```

    /content/Fake-News-Detection

future==0.17.1
h5py
Keras
Keras-Applications
Keras-Preprocessing
matplotlib
nvidia-ml-py
pandas
python-apt
python-dateutil==2.8.0
python-debian
python-slugify==3.0.3
python-systemd
pytorch-pretrained-bert
pytorch-transformers==1.0.0
scikit-image==0.14.2
scikit-learn==0.20.2
scipy
seaborn==0.9.0
six
sympy==1.4
tqdm

```python
!pip install -r requirements.txt
```

    Requirement already satisfied: future==0.17.1 in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 1)) (0.17.1)
    Requirement already satisfied: h5py in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 2)) (3.1.0)
    Requirement already satisfied: Keras in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 3)) (2.7.0)
    Requirement already satisfied: Keras-Applications in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 4)) (1.0.8)
    Requirement already satisfied: Keras-Preprocessing in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 5)) (1.1.2)
    Requirement already satisfied: matplotlib in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 6)) (3.2.2)
    Requirement already satisfied: nvidia-ml-py in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 7)) (11.495.46)
    Requirement already satisfied: pandas in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 8)) (1.1.5)
    Requirement already satisfied: python-apt in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 9)) (0.0.0)
    Requirement already satisfied: python-dateutil==2.8.0 in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 10)) (2.8.0)
    Requirement already satisfied: python-debian in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 11)) (0.1.42)
    Requirement already satisfied: python-slugify==3.0.3 in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 12)) (3.0.3)
    Requirement already satisfied: python-systemd in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 13)) (0.0.9)
    Requirement already satisfied: pytorch-pretrained-bert in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 14)) (0.6.2)
    Requirement already satisfied: pytorch-transformers==1.0.0 in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 15)) (1.0.0)
    Requirement already satisfied: scikit-image==0.14.2 in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 16)) (0.14.2)
    Requirement already satisfied: scikit-learn==0.20.2 in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 17)) (0.20.2)
    Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 18)) (1.4.1)
    Requirement already satisfied: seaborn==0.9.0 in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 19)) (0.9.0)
    Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 20)) (1.15.0)
    Requirement already satisfied: sympy==1.4 in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 21)) (1.4)
    Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 22)) (4.62.3)
    Requirement already satisfied: text-unidecode==1.2 in /usr/local/lib/python3.7/dist-packages (from python-slugify==3.0.3->-r requirements.txt (line 12)) (1.2)
    Requirement already satisfied: torch>=0.4.1 in /usr/local/lib/python3.7/dist-packages (from pytorch-transformers==1.0.0->-r requirements.txt (line 15)) (1.10.0+cu111)
    Requirement already satisfied: sentencepiece in /usr/local/lib/python3.7/dist-packages (from pytorch-transformers==1.0.0->-r requirements.txt (line 15)) (0.1.96)
    Requirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (from pytorch-transformers==1.0.0->-r requirements.txt (line 15)) (2.23.0)
    Requirement already satisfied: boto3 in /usr/local/lib/python3.7/dist-packages (from pytorch-transformers==1.0.0->-r requirements.txt (line 15)) (1.20.20)
    Requirement already satisfied: regex in /usr/local/lib/python3.7/dist-packages (from pytorch-transformers==1.0.0->-r requirements.txt (line 15)) (2019.12.20)
    Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from pytorch-transformers==1.0.0->-r requirements.txt (line 15)) (1.19.5)
    Requirement already satisfied: PyWavelets>=0.4.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image==0.14.2->-r requirements.txt (line 16)) (1.2.0)
    Requirement already satisfied: cloudpickle>=0.2.1 in /usr/local/lib/python3.7/dist-packages (from scikit-image==0.14.2->-r requirements.txt (line 16)) (1.3.0)
    Requirement already satisfied: pillow>=4.3.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image==0.14.2->-r requirements.txt (line 16)) (7.1.2)
    Requirement already satisfied: networkx>=1.8 in /usr/local/lib/python3.7/dist-packages (from scikit-image==0.14.2->-r requirements.txt (line 16)) (2.6.3)
    Requirement already satisfied: dask[array]>=1.0.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image==0.14.2->-r requirements.txt (line 16)) (2.12.0)
    Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.7/dist-packages (from sympy==1.4->-r requirements.txt (line 21)) (1.2.1)
    Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->-r requirements.txt (line 6)) (3.0.6)
    Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->-r requirements.txt (line 6)) (1.3.2)
    Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib->-r requirements.txt (line 6)) (0.11.0)
    Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.7/dist-packages (from pandas->-r requirements.txt (line 8)) (2018.9)
    Requirement already satisfied: toolz>=0.7.3 in /usr/local/lib/python3.7/dist-packages (from dask[array]>=1.0.0->scikit-image==0.14.2->-r requirements.txt (line 16)) (0.11.2)
    Requirement already satisfied: typing-extensions in /usr/local/lib/python3.7/dist-packages (from torch>=0.4.1->pytorch-transformers==1.0.0->-r requirements.txt (line 15)) (3.10.0.2)
    Requirement already satisfied: cached-property in /usr/local/lib/python3.7/dist-packages (from h5py->-r requirements.txt (line 2)) (1.5.2)
    Requirement already satisfied: chardet in /usr/local/lib/python3.7/dist-packages (from python-debian->-r requirements.txt (line 11)) (3.0.4)
    Requirement already satisfied: s3transfer<0.6.0,>=0.5.0 in /usr/local/lib/python3.7/dist-packages (from boto3->pytorch-transformers==1.0.0->-r requirements.txt (line 15)) (0.5.0)
    Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /usr/local/lib/python3.7/dist-packages (from boto3->pytorch-transformers==1.0.0->-r requirements.txt (line 15)) (0.10.0)
    Requirement already satisfied: botocore<1.24.0,>=1.23.20 in /usr/local/lib/python3.7/dist-packages (from boto3->pytorch-transformers==1.0.0->-r requirements.txt (line 15)) (1.23.20)
    Requirement already satisfied: urllib3<1.27,>=1.25.4 in /usr/local/lib/python3.7/dist-packages (from botocore<1.24.0,>=1.23.20->boto3->pytorch-transformers==1.0.0->-r requirements.txt (line 15)) (1.25.11)
    Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests->pytorch-transformers==1.0.0->-r requirements.txt (line 15)) (2021.10.8)
    Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->pytorch-transformers==1.0.0->-r requirements.txt (line 15)) (2.10)

```python
from google.colab import drive
drive.mount('/content/drive')
```

    Mounted at /content/drive

```python
!cp '/content/drive/MyDrive/NLP/triBERT.pth' '/content/Fake-News-Detection/'
```

```python
!python3 FakeNewsDetection.py -num_labels 6 -num_epochs 3 -load_model False
```

    /usr/local/lib/python3.7/dist-packages/statsmodels/tools/_testing.py:19: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.
      import pandas.util.testing as tm
    INFO:pytorch_pretrained_bert.tokenization:loading vocabulary file https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-vocab.txt from cache at /root/.pytorch_pretrained_bert/26bc1ad6c0ac742e9b52263248f6d0f00068293b33709fae12320c0e35ccfbbb.542ce4285a40d23a559526243235df47c5f75c197f04f37d1a0c124c32c9a084
    INFO:pytorch_pretrained_bert.modeling:loading archive file https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased.tar.gz from cache at /root/.pytorch_pretrained_bert/9c41111e2de84547a463fd39217199738d1e3deb72d4fec4399e6e241983c6f0.ae3cef932725ca7a30cdcb93fc6e09150a55e2a130ec7af63975a16c153ae2ba
    INFO:pytorch_pretrained_bert.modeling:extracting archive file /root/.pytorch_pretrained_bert/9c41111e2de84547a463fd39217199738d1e3deb72d4fec4399e6e241983c6f0.ae3cef932725ca7a30cdcb93fc6e09150a55e2a130ec7af63975a16c153ae2ba to temp dir /tmp/tmpnenb59jc
    INFO:pytorch_pretrained_bert.modeling:Model config {
      "attention_probs_dropout_prob": 0.1,
      "hidden_act": "gelu",
      "hidden_dropout_prob": 0.1,
      "hidden_size": 768,
      "initializer_range": 0.02,
      "intermediate_size": 3072,
      "max_position_embeddings": 512,
      "num_attention_heads": 12,
      "num_hidden_layers": 12,
      "type_vocab_size": 2,
      "vocab_size": 30522
    }

    cuda:0
    Dataloader : <torch.utils.data.dataloader.DataLoader object at 0x7fda25642a90>
    New statement input : tensor([[ 2311,  1037,  2813,  ...,     0,     0,     0],
            [ 5273,  2003,  2006,  ...,     0,     0,     0],
            [ 2758,  2198, 19186,  ...,     0,     0,     0],
            ...,
            [ 2758,  5401,  3867,  ...,     0,     0,     0],
            [ 2006, 14079,  5918,  ...,     0,     0,     0],
            [ 2758,  1996, 12163,  ...,     0,     0,     0]])
    Justification input : tensor([[ 2311,  1037,  2813,  ...,     0,     0,     0],
            [ 5273,  2003,  2006,  ...,     0,     0,     0],
            [ 2758,  2198, 19186,  ...,     0,     0,     0],
            ...,
            [ 2758,  5401,  3867,  ...,     0,     0,     0],
            [ 2006, 14079,  5918,  ...,     0,     0,     0],
            [ 2758,  1996, 12163,  ...,     0,     0,     0]])
    Meta data input : tensor([[11324,  1040,  4576,  2638,  1011,  8945,  3270,  2278,  2110,  4387,
              3146,  3951,  1037,  5653,  2121,     0,     0,     0,     0,     0,
                 0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
                 0,     0],
            [ 2943,  1010,  2381,  1010,  3105,  1011, 17571,  3660,  1011,  7505,
             21818,  3363,  2110, 11849,  3448,  7672,  1037,  2723,  4613,  1012,
                 0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
                 0,     0],
            [ 3097,  1011,  3343, 13857,  1011,  8112,  2343,  4307,  7672,  7573,
                 0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
                 0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
                 0,     0],
            [ 2740,  1011,  2729,  9927,  1011, 14739,  3904,  3904,  3904,  1037,
              2739,  2713,     0,     0,     0,     0,     0,     0,     0,     0,
                 0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
                 0,     0],
            [ 4610,  1010,  5841,  4918,  1011, 13675,  2923,  3904,  3516,  7672,
              2019,  4357,  2006, 13229,     0,     0,     0,     0,     0,     0,
                 0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
                 0,     0],
            [ 2495,  5863,  1011, 29536,  2015,  5273,  3320,  5882,  5273,  3951,
              1037,  2019,  3784,  5448,  1011,  3538,     0,     0,     0,     0,
                 0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
                 0,     0],
            [ 5347,  1011,  8308,  3951,  1011,  2283,  1011,  3146,  3904,  3146,
              3951,  1037,  2811,  2713,  1012,     0,     0,     0,     0,     0,
                 0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
                 0,     0],
            [ 9615, 13857,  1011,  8112,  2343,  4307,  7672,  1037,  3537,  5981,
              1999,  4407,  1010,  6643,  1012,     0,     0,     0,     0,     0,
                 0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
                 0,     0],
            [ 5841,  5392,  1011, 15213,  3904,  3904,  3029,  1037,  4037,     0,
                 0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
                 0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
                 0,     0],
            [ 2943,  1010,  4471,  1011,  3698,  1011,  2297,  1010,  6830,  1011,
              2501,  2349,  2100,  1011,  2358,  3217, 15878,  2884,  2110,  4387,
              5273,  3951,  2019,  3784,  2678,     0,     0,     0,     0,     0,
                 0,     0],
            [ 3864,  2728,  1011,  2273, 28787,  1057,  1012,  1055,  1012,  5205,
              2047,  3933,  7672,  1037,  4613,     0,     0,     0,     0,     0,
                 0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
                 0,     0],
            [ 4610,  1010,  5841,  1010,  2047,  1011,  7035,  1011,  2262,  1010,
              5635, 15941,  1011,  1055,  1057,  1012,  1055,  1012,  5205,  8839,
              2981,  1037,  1056, 28394,  2102,     0,     0,     0,     0,     0,
                 0,     0],
            [ 2381,  1010,  2110,  1011,  5166, 10210,  2102,  1011, 19615,  2280,
              3099,  4404,  3951,  2019,  4357,  2007, 21824,  2739,     0,     0,
                 0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
                 0,     0],
            [ 4610,  1010,  2976,  1011,  5166,  1010,  2740,  1011,  2729, 20160,
              5267,  4917,  3904,  3904,  3904,  1037, 20160,  5267,  4917,  6167,
              1999,  1996,  4465,  5888,     0,     0,     0,     0,     0,     0,
                 0,     0],
            [ 2740,  1011,  2729,  2577,  1011,  2097, 13317,  5374, 13317,  7928,
              2006,  1000,  4419,  2739,  4465,  1000,     0,     0,     0,     0,
                 0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
                 0,     0],
            [ 3864, 15941,  1011,  1055,  1057,  1012,  1055,  1012,  5205,  8839,
              2981,  1037,  2237,  2534,  1999,  5899,  1010,  3146,     0,     0,
                 0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
                 0,     0]])
    Credit scores input : tensor([[0.6510, 0.6510, 0.6510,  ..., 0.6510, 0.6510, 0.6510],
            [0.8000, 0.8000, 0.8000,  ..., 0.8000, 0.8000, 0.8000],
            [0.7477, 0.7477, 0.7477,  ..., 0.7477, 0.7477, 0.7477],
            ...,
            [0.7702, 0.7702, 0.7702,  ..., 0.7702, 0.7702, 0.7702],
            [0.6417, 0.6417, 0.6417,  ..., 0.6417, 0.6417, 0.6417],
            [0.6849, 0.6849, 0.6849,  ..., 0.6849, 0.6849, 0.6849]])
    Fakeness : tensor([[1, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 1, 0],
            [0, 0, 0, 0, 1, 0],
            [0, 0, 1, 0, 0, 0],
            [0, 0, 0, 0, 0, 1],
            [1, 0, 0, 0, 0, 0],
            [1, 0, 0, 0, 0, 0],
            [0, 0, 0, 1, 0, 0],
            [1, 0, 0, 0, 0, 0],
            [0, 0, 0, 1, 0, 0],
            [0, 0, 0, 1, 0, 0],
            [0, 0, 0, 1, 0, 0],
            [0, 0, 0, 0, 0, 1],
            [0, 0, 0, 0, 1, 0],
            [0, 0, 1, 0, 0, 0],
            [1, 0, 0, 0, 0, 0]])
    Traceback (most recent call last):
      File "FakeNewsDetection.py", line 575, in <module>
        test_model(model)
      File "FakeNewsDetection.py", line 541, in test_model
        output = F.softmax(model(inputs1, inputs2, inputs3, inputs4))
      File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
        return forward_call(*input, **kwargs)
      File "FakeNewsDetection.py", line 320, in forward
        output1 = self.forward_once(input_ids1, token_type_ids=None, attention_mask=None, labels=None)
      File "FakeNewsDetection.py", line 312, in forward_once
        _, pooled_output = self.bert(input_ids, token_type_ids, attention_mask, output_all_encoded_layers=False)
      File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
        return forward_call(*input, **kwargs)
      File "/usr/local/lib/python3.7/dist-packages/pytorch_pretrained_bert/modeling.py", line 730, in forward
        embedding_output = self.embeddings(input_ids, token_type_ids)
      File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
        return forward_call(*input, **kwargs)
      File "/usr/local/lib/python3.7/dist-packages/pytorch_pretrained_bert/modeling.py", line 267, in forward
        words_embeddings = self.word_embeddings(input_ids)
      File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
        return forward_call(*input, **kwargs)
      File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/sparse.py", line 160, in forward
        self.norm_type, self.scale_grad_by_freq, self.sparse)
      File "/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py", line 2044, in embedding
        return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
    RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper__index_select)

```python

```

```python

```