docstr: Defines heuristics to log different conditionings.
  These can be lists of strings (text-to-image), tensors, ints, ...
docstr_tok: ["Defines","heuristics","to","log","different","conditionings",".","These","can","be","lists","of","strings","(","text-to-image",")",",","tensors",",","ints",",","..."]
code: def log_conditionings(self, batch: Dict, n: int) -> Dict:
      """
      Defines heuristics to log different conditionings.
      These can be lists of strings (text-to-image), tensors, ints, ...
      """
      image_h, image_w = batch[self.input_key].shape[2:]
      log = dict()
  
      for embedder in self.conditioner.embedders:
          if (
              (self.log_keys is None)
              or (embedder.input_key in self.log_keys)
          ) and not self.no_cond_log:
              x = batch[embedder.input_key][:n]
              if isinstance(x, torch.Tensor):
                  if x.dim() == 1:
                      # class-conditional, convert integer to string
                      x = [str(x[i].item()) for i in range(x.shape[0])]
                      xc = log_txt_as_img(
                          (image_h, image_w), x, size=image_h // 4
                      )
                  elif x.dim() == 2:
                      # size and crop cond and the like
                      x = [
                          "x".join([str(xx) for xx in x[i].tolist()])
                          for i in range(x.shape[0])
                      ]
                      xc = log_txt_as_img(
                          (image_h, image_w), x, size=image_h // 20
                      )
                  else:
                      raise NotImplementedError()
              elif isinstance(x, (List, ListConfig)):
                  if isinstance(x[0], str):
                      # strings
                      xc = log_txt_as_img(
                          (image_h, image_w), x, size=image_h // 20
                      )
                  else:
                      raise NotImplementedError()
              else:
                  raise NotImplementedError()
              log[embedder.input_key] = xc
      return log
  
imports: import math
  from contextlib import contextmanager
  from typing import Any, Dict, List, Optional, Tuple, Union
  import pytorch_lightning
  import torch
  from omegaconf import ListConfig, OmegaConf
  from safetensors.torch import load_file
  from torch.optim.lr_scheduler import LambdaLR
  from ..modules import UNCONDITIONAL_CONFIG
  from ..modules.autoencoding.temporal_ae import VideoDecoder
  from ..modules.diffusionmodules.wrappers import OPENAIUNETWRAPPER
  from ..modules.ema import LitEma
  from ..util import default, disabled_train, get_obj_from_str, instantiate_from_config, log_txt_as_img
label_desc: Use image node_id 16 for calling the DiffusionEngine obj's underlying member method code with example usage: obj.log_conditionings(batch, n) and returns: log