class_docstr: Temporal Entropy Model
class_docstr_tok: ["Temporal","Entropy","Model"]
docstr: Validate that the masking is causal
docstr_tok: ["Validate","that","the","masking","is","causal"]
code: def validate_causal(
      self, latent_q_patched: Tensor, encoded: Tensor
  ) -> None:
      """
      Validate that the masking is causal
      """
      # run model
      masked_means, masked_scales, _ = self._get_transformer_output(
          encoded_patched=encoded, latent_q_patched=latent_q_patched
      )
      # run model iteratively
      current_inp = torch.full_like(latent_q_patched, fill_value=10.0)
      autoreg_means = torch.full_like(latent_q_patched, fill_value=10.0)
      autoreg_scales = torch.full_like(
          latent_q_patched, fill_value=10.0
      )
  
      for i in range(self.seq_len_dec):
          if i > 0:  # first token is the learnt StartSym
              current_inp[:, i - 1, :] = latent_q_patched[:, i - 1, :]
          mean_i, scale_i, _ = self._get_transformer_output(
              encoded_patched=encoded, latent_q_patched=current_inp
          )
          autoreg_means[:, i, :] = mean_i[:, i, :]
          autoreg_scales[:, i, :] = scale_i[:, i, :]
  
      isclose_means = autoreg_means.isclose(masked_means).all()
      isclose_scales = autoreg_scales.isclose(masked_scales).all()
      causal = isclose_means and isclose_scales
      if not causal:
          msg_mean = "" if isclose_means else "means"
          msg_scales = "" if isclose_scales else "scales"
          raise ValueError(
              f"Larger than expected discrepancy: {msg_mean} {msg_scales}"
          )
  
imports: import itertools
  import sys
  from typing import Dict, List, NamedTuple, Optional, Sequence, Tuple
  import torch
  import torch.nn
  from torch import Tensor
  from .bottlenecks import GsnConditionalLocScaleShift
  from .entropy_model_layers import EncoderSection, LearnedPosition, StartSym, Transformer
  from .layers_utils import make_embedding
  from .patcher import Patcher
label_desc: Use image node_id 9 for calling the VCTEntropyModel obj's underlying member method code with example usage: obj.validate_causal(latent_q_patched, encoded) without return types