code: def get_num_residuals(self):
      num_res = 2  # initial sample + mid block
      for down_block in self.down_blocks:
          num_res += len(down_block.resnets)
          if (
              hasattr(down_block, "downsamplers")
              and down_block.downsamplers is not None
          ):
              num_res += len(down_block.downsamplers)
      return num_res
  
file_path: ml-stable-diffusion/python_coreml_stable_diffusion/controlnet.py
imports: from diffusers.configuration_utils import ConfigMixin, register_to_config
  from diffusers import ModelMixin
  import torch
  import torch.nn
  import torch.nn.functional
  from .unet import Timesteps, TimestepEmbedding, get_down_block, UNetMidBlock2DCrossAttn, linear_to_conv2d_map
label_desc: Use image node_id 2 for calling the ControlNetModel obj's underlying member method code with example usage: obj.get_num_residuals() and returns: num_res