code: def get_encoder_hidden_states(self, prompt=None, cfg=True):
      if prompt is None:
          prompt = [""]
      text_inputs = self.tokenizer(
          prompt,
          padding="max_length",
          max_length=self.tokenizer.model_max_length,
          truncation=True,
          return_tensors="pt",
      )
      text_input_ids = text_inputs.input_ids
      untruncated_ids = self.tokenizer(
          prompt, padding="max_length", return_tensors="pt"
      ).input_ids
  
      text_embeddings = self.text_encoder(
          text_input_ids.to(self.device),
          attention_mask=None,
      )
      text_embeddings = text_embeddings[0]
  
      # get unconditional embeddings for classifier free guidance
      if cfg:
          uncond_tokens = [""]
  
          max_length = text_input_ids.shape[-1]
          uncond_input = self.tokenizer(
              uncond_tokens,
              padding="max_length",
              max_length=max_length,
              truncation=True,
              return_tensors="pt",
          )
  
          uncond_embeddings = self.text_encoder(
              uncond_input.input_ids.to(self.device),
              attention_mask=None,
          )
          uncond_embeddings = uncond_embeddings[0]
  
          # For classifier free guidance, we need to do two forward passes.
          # Here we concatenate the unconditional and text embeddings into a single batch
          # to avoid doing two forward passes
          text_embeddings = torch.cat(
              [uncond_embeddings, text_embeddings]
          )
  
      return text_embeddings
  
imports: import os
  import torch
  import inspect
  import numpy
  from tqdm.auto import tqdm
  import multiprocessing
  from bigdl.nano.pytorch import InferenceOptimizer
  from typing import Callable, List, Optional, Union
  from diffusers import AutoencoderKL
  from transformers import CLIPTokenizer, CLIPTextModel
  from diffusers.schedulers import *
  from diffusers.utils import logging
  from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
  from diffusers.pipeline_utils import DiffusionPipeline
  from diffusers.models import UNet2DConditionModel
label_desc: Use image node_id 9 for calling the NanoStableDiffusionPipeline obj's underlying member method code with example usage: obj.get_encoder_hidden_states(prompt, cfg) and returns: text_embeddings