code: def build_train_valid_test_datasets(self):
      logging.info("Building datasets for Stable Diffusion...")
      if self.trainer.limit_val_batches > 1.0 and isinstance(
          self.trainer.limit_val_batches, float
      ):
          raise ValueError(
              "limit_val_batches must be an integer or float less than or equal to 1.0."
          )
  
      if self.cfg.first_stage_key.endswith("encoded"):
          (
              self._train_ds,
              self._validation_ds,
          ) = build_train_valid_precached_datasets(
              model_cfg=self.cfg,
              consumed_samples=self.compute_consumed_samples(0),
          )
      else:
          (
              self._train_ds,
              self._validation_ds,
          ) = build_train_valid_datasets(
              model_cfg=self.cfg,
              consumed_samples=self.compute_consumed_samples(0),
          )
      self._test_ds = None
  
      if self._train_ds is not None:
          logging.info(
              f"Length of train dataset: {len(self._train_ds)}"
          )
      if self._validation_ds is not None:
          logging.info(
              f"Length of val dataset: {len(self._validation_ds)}"
          )
      if self._test_ds is not None:
          logging.info(f"Length of test dataset: {len(self._test_ds)}")
      logging.info(f"Finished building datasets for LatentDiffusion.")
      return self._train_ds, self._validation_ds, self._test_ds
  
imports: from typing import Any
  import einops
  import torch
  import torch.nn
  from einops import rearrange, repeat
  from omegaconf import DictConfig
  from pytorch_lightning import Trainer
  from pytorch_lightning.utilities.rank_zero import rank_zero_only
  from torch._inductor import config
  from nemo.collections.multimodal.data.controlnet.controlnet_dataset import build_train_valid_datasets
  from nemo.collections.multimodal.models.text_to_image.stable_diffusion.ldm.ddpm import LatentDiffusion
  from nemo.collections.multimodal.models.text_to_image.stable_diffusion.samplers.ddim import DDIMSampler
  from nemo.collections.multimodal.modules.stable_diffusion.attention import SpatialTransformer
  from nemo.collections.multimodal.modules.stable_diffusion.diffusionmodules.openaimodel import AttentionBlock, Downsample, ResBlock, TimestepEmbedSequential, UNetModel
  from nemo.collections.multimodal.modules.stable_diffusion.diffusionmodules.util import conv_nd, linear, timestep_embedding, zero_module
  from nemo.collections.multimodal.parts.stable_diffusion.utils import exists, log_txt_as_img
  from nemo.collections.nlp.models.language_modeling.megatron_base_model import MegatronBaseModel
  from nemo.collections.nlp.modules.common.megatron.module import Float16Module
  from nemo.utils import logging
label_desc: Use image node_id 15 for calling the MegatronControlNet obj's underlying member method code with example usage: obj.build_train_valid_test_datasets() and returns: self,  self,  self