code: def forward(
      self,
      sample,
      timestep,
      encoder_hidden_states,
      controlnet_cond,
  ):
      # 1. time
      t_emb = self.time_proj(timestep)
      emb = self.time_embedding(t_emb)
  
      # 2. pre-process
      sample = self.conv_in(sample)
  
      controlnet_cond = self.controlnet_cond_embedding(controlnet_cond)
  
      sample += controlnet_cond
  
      # 3. down
      down_block_res_samples = (sample,)
      for downsample_block in self.down_blocks:
          if (
              hasattr(downsample_block, "attentions")
              and downsample_block.attentions is not None
          ):
              sample, res_samples = downsample_block(
                  hidden_states=sample,
                  temb=emb,
                  encoder_hidden_states=encoder_hidden_states,
              )
          else:
              sample, res_samples = downsample_block(
                  hidden_states=sample, temb=emb
              )
  
          down_block_res_samples += res_samples
  
      # 4. mid
      if self.mid_block is not None:
          sample = self.mid_block(
              sample,
              emb,
              encoder_hidden_states=encoder_hidden_states,
          )
  
      # 5. Control net blocks
      controlnet_down_block_res_samples = ()
  
      for down_block_res_sample, controlnet_block in zip(
          down_block_res_samples, self.controlnet_down_blocks
      ):
          down_block_res_sample = controlnet_block(
              down_block_res_sample
          )
          controlnet_down_block_res_samples += (down_block_res_sample,)
  
      down_block_res_samples = controlnet_down_block_res_samples
  
      mid_block_res_sample = self.controlnet_mid_block(sample)
  
      return down_block_res_samples, mid_block_res_sample
  
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 3 for calling the ControlNetModel obj's underlying member method code with example usage: obj.forward(sample, timestep, encoder_hidden_states, controlnet_cond) and returns: down_block_res_samples,  mid_block_res_sample