code: def count_num_graphs(self, result, num_graphs=0):
      for k, v in result.items():
          if isinstance(v, Tensor) and v.grad_fn is not None:
              num_graphs += 1
          if isinstance(v, dict):
              num_graphs += self.count_num_graphs(v)
  
      return num_graphs
  
imports: import torch
  from lightning.pytorch.core.module import LightningModule
  from torch import Tensor, nn
  from torch.utils.data import DataLoader, Dataset
label_desc: Use image node_id 4 for calling the DeterministicModel obj's underlying member method code with example usage: obj.count_num_graphs(result, num_graphs) and returns: num_graphs