diff --git a/typedflow/counted_cache.py b/typedflow/counted_cache.py
index 2936edb..9b2027b 100644
--- a/typedflow/counted_cache.py
+++ b/typedflow/counted_cache.py
@@ -35,3 +35,6 @@ class CacheTable(Generic[H, T]):
             key: H,
             value: T) -> None:
         self.cache_table[key] = CacheItem(count=self.life, value=value)
+
+    def __len__(self) -> int:
+        return len(self.cache_table)
diff --git a/typedflow/nodes.py b/typedflow/nodes.py
index e5da85c..ff4ba9d 100644
--- a/typedflow/nodes.py
+++ b/typedflow/nodes.py
@@ -1,5 +1,5 @@
 from __future__ import annotations
-from dataclasses import dataclass
+from dataclasses import dataclass, field
 import logging
 from typing import (
     Dict,
@@ -26,11 +26,15 @@ logger = logging.getLogger(__file__)
 TD = TypeVar('TD', bound=TypedDict)
 
 
+@dataclass
 class ProviderNode(Generic[K]):
     """
     LoaderNode or TaskNode
     """
-    def __init__(self):
+    succ_count: int = field(init=False)
+    cache_table: CacheTable[int, Batch[K]] = field(init=False)
+
+    def __post_init__(self):
         self.succ_count: int = 0
         self.cache_table: CacheTable[int, Batch[K]]\
             = CacheTable[int, Batch[K]](life=0)
@@ -44,13 +48,17 @@ class ProviderNode(Generic[K]):
         self.cache_table.life += 1
 
 
+@dataclass
 class ConsumerNode(Generic[T]):
     """
     TaskNode or DumpNode
     Note: this is not defined as a dataclass due to the inheritance problem
     see: https://stackoverflow.com/questions/51575931/class-inheritance-in-python-3-7-dataclasses  # noqa
     """
-    def __init__(self, arg_type: Type[T]):
+    arg_type: Type[T] = field(init=False)  # must be same as T
+    precs: Dict[str, ProviderNode[T]] = field(init=False)
+
+    def __post_init__(self, arg_type: Type[T]):
         self.arg_type: Type[T] = arg_type  # must be same as T
         self.precs: Dict[str, ProviderNode[T]] = dict()
 

attributes are not inherited
diff --git a/typedflow/tests/nodes/test_provider.py b/typedflow/tests/nodes/test_provider.py
new file mode 100644
index 0000000..a48ada6
--- /dev/null
+++ b/typedflow/tests/nodes/test_provider.py
@@ -0,0 +1,20 @@
+from typing import List
+
+import pytest
+
+from typedflow.nodes import LoaderNode
+from typedflow.tasks import DataLoader
+
+
+@pytest.fixture
+def loader_node() -> LoaderNode[str]:
+    lst: List[str] = ['hi', 'hello']
+    loader: DataLoader[str] = DataLoader(gen=lst, batch_size=2)
+    node: LoaderNode[str] = LoaderNode(loader=loader)
+    return node
+
+
+def test_init(loader_node):
+    node = loader_node
+    assert node.succ_count == 0
+    assert len(node.cache_table) == 0

pip install -e .
parse_log_pytest
requirements.txt
pytest pytest-runner
apt-get update apt-get install -y gcc build-essential libomp-dev libopenblas-dev
3.8
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
dataclasses-json==0.6.7
exceptiongroup==1.2.2
iniconfig==2.1.0
marshmallow==3.22.0
mypy-extensions==1.0.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
pytest-runner==6.0.1
tomli==2.2.1
-e git+https://github.com/tarohi24/typedflow.git@f8b5acaeea4dd9adcded1c1089ad7af1b6953836#egg=typedflow
typing-inspect==0.9.0
typing_extensions==4.13.0

name: typedflow
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=24.2=py38h06a4308_0
  - python=3.8.20=he870216_0
  - readline=8.2=h5eee18b_0
  - setuptools=75.1.0=py38h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.44.0=py38h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - dataclasses-json==0.6.7
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - marshmallow==3.22.0
      - mypy-extensions==1.0.0
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - pytest-runner==6.0.1
      - tomli==2.2.1
      - typing-extensions==4.13.0
      - typing-inspect==0.9.0
prefix: /opt/conda/envs/typedflow

typedflow/tests/nodes/test_provider.py::test_init
typedflow/nodes.py typedflow/counted_cache.py
typedflow/nodes.py typedflow/counted_cache.py