from typing import Tuple


def get_tensor_dimensions(n_atom_types : int, n_formal_charge : int, n_num_h : int,
                          n_chirality : int, n_node_features : int, n_edge_features : int,
                          parameters : dict) -> Tuple[list, list, list, list, int]:
    """
    Returns dimensions for all tensors that describe molecular graphs. Tensor dimensions
    are `list`s, except for `dim_f_term` which is  simply an `int`. Each element
    of the lists indicate the corresponding dimension of a particular subgraph matrix
    (i.e. `nodes`, `f_add`, etc).
    """
    max_nodes = parameters["max_n_nodes"]

    # define the matrix dimensions as `list`s
    # first for the graph reps...
    dim_nodes = [max_nodes, n_node_features]

    dim_edges = [max_nodes, max_nodes, n_edge_features]

    # ... then for the APDs
    if parameters["use_chirality"]:
        if parameters["use_explicit_H"] or parameters["ignore_H"]:
            dim_f_add = [
                parameters["max_n_nodes"],
                n_atom_types,
                n_formal_charge,
                n_chirality,
                n_edge_features,
            ]
        else:
            dim_f_add = [
                parameters["max_n_nodes"],
                n_atom_types,
                n_formal_charge,
                n_num_h,
                n_chirality,
                n_edge_features,
            ]
    else:
        if parameters["use_explicit_H"] or parameters["ignore_H"]:
            dim_f_add = [
                parameters["max_n_nodes"],
                n_atom_types,
                n_formal_charge,
                n_edge_features,
            ]
        else:
            dim_f_add = [
                parameters["max_n_nodes"],
                n_atom_types,
                n_formal_charge,
                n_num_h,
                n_edge_features,
            ]

    dim_f_conn = [parameters["max_n_nodes"], n_edge_features]

    dim_f_term = 1

    return dim_nodes, dim_edges, dim_f_add, dim_f_conn, dim_f_term