class_docstr: Glue together encoder transform, entropy model and decoder transform
code: def encode_Pscene(
      self,
      scene: Tensor,  # [B, C, H, W]
      scene_index: int,
      state: State,  # \hat y_t-1
      cache: memoize.Cache,
  ) -> Tuple[State, Bottleneck]:
      if not self.training and self._code_to_strings:
          # `compress` runs encoding and decoding
          output = self.entropy_model.compress(
              latent_unquantized=scene,
              previous_latents=state,
              # Since compression is lossless, decode only the first couple of latents
              # to check for errors, and skip decoding afterwards
              run_decode=scene_index < 3,
              validate_causal=False,
          )
      else:
          # forward pass through the entropy model, returns TemporalEntropyModelOut
          output = self.entropy_model(
              latent_unquantized=scene, previous_latents=state
          )  # [B, C, H, W], bits [b', seq_len^2, C], features [B, d_model, H, W]
  
      assert output.features is not None
      bottleneck = Bottleneck(
          latent_q=output.perturbed_latent,
          likelihood=output.bits,
          entropy_model_features=output.features,
      )
  
      # Run pscene decoder -- returns (reconstruction, new state)
      decode_Pscene = memoize.bind(self.decode_Pscene, cache)
      _, new_state = decode_Pscene(
          bottleneck=bottleneck, state=state, cache=cache
      )
  
      return new_state, bottleneck
  
imports: import itertools
  import math
  from typing import Generator, List, NamedTuple, Optional, Sequence, Tuple, Union
  import torch
  import torch.nn
  import utils.memoize
  from datamodules.video_data_api import Scenes, VideoData
  from neural.entropy_model import PreviousLatent, VCTEntropyModel
  from torch import Tensor
label_desc: Use image node_id 3 for calling the VCTPipeline obj's underlying member method code with example usage: obj.encode_Pscene(scene, scene_index, state, cache) and returns: new_state,  bottleneck