{"record":{"id":"3333ee6c963682de","repo":"Stability-AI/generative-models","slug":"notimplementederror","errorCode":null,"errorMessage":"NotImplementedError","messagePattern":"NotImplementedError","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"sgm/modules/diffusionmodules/util.py","lineNumber":46,"sourceCode":"        alpha = mix_factor\n    elif merge_strategy == \"learned_with_images\":\n        alpha = torch.where(\n            image_only_indicator.bool(),\n            torch.ones(1, 1, device=image_only_indicator.device),\n            rearrange(mix_factor, \"... -> ... 1\"),\n        )\n        if is_attn:\n            alpha = rearrange(alpha, \"b t -> (b t) 1 1\")\n        else:\n            alpha = rearrange(alpha, \"b t -> b 1 t 1 1\")\n    elif merge_strategy == \"fixed_with_images\":\n        alpha = image_only_indicator\n        if is_attn:\n            alpha = rearrange(alpha, \"b t -> (b t) 1 1\")\n        else:\n            alpha = rearrange(alpha, \"b t -> b 1 t 1 1\")\n    else:\n        raise NotImplementedError\n    return torch.sigmoid(alpha) if apply_sigmoid else alpha\n\n    \ndef make_beta_schedule(\n    schedule,\n    n_timestep,\n    linear_start=1e-4,\n    linear_end=2e-2,\n):\n    if schedule == \"linear\":\n        betas = (\n            torch.linspace(\n                linear_start**0.5, linear_end**0.5, n_timestep, dtype=torch.float64\n            )\n            ** 2\n        )\n    return betas.numpy()\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/Stability-AI/generative-models/blob/e8cd657656fa5d61688191730d0e03242bf4ed44/sgm/modules/diffusionmodules/util.py#L28-L64","documentation":"The video-block attention-mask helper (get_alpha-like function in util.py) supports only specific image_only_indicator layouts: 'b t' when is_attn, else 'b t' rearranged for 5D spatial. Reaching the final else raises a bare NotImplementedError — the input shape does not match either expected layout.","triggerScenarios":"Calling the function with image_only_indicator whose shape is not (b,) or (b,t) — e.g. passing a per-pixel mask (b,1,h,w) or None — while apply_sigmoid handling expects the two supported cases.","commonSituations":"Wiring a spatial segmentation mask where a per-frame indicator is expected; passing wrong-shape conditioning tensors in video diffusion training.","solutions":["Pass image_only_indicator with shape (batch, num_frames) ('b t')","Squeeze/reshape the mask to (b,t) before calling","Add an explicit branch for your input layout if a spatial mask is genuinely needed"],"exampleFix":"// before\nalpha = get_alpha(mask_4d, is_attn=True)  # mask_4d: (b,1,h,w)\n// after\nframe_flags = mask_4d.mean(dim=(1,2,3))  # (b,) -> then expand per frame as (b,t)\nalpha = get_alpha(frame_flags.unsqueeze(-1).expand(-1, t), is_attn=True)","handlingStrategy":"validation","validationCode":"def validate_frame_indicator(img_ind, is_attn):\n    if img_ind.dim() != 2 or img_ind.shape[0] == 0:\n        raise ValueError(f\"image_only_indicator must be (b,t), got shape {tuple(img_ind.shape)}\")\nvalidate_frame_indicator(image_only_indicator, is_attn=True)","typeGuard":"def is_frame_indicator(t, num_frames=None) -> bool:\n    return t.dim() == 2 and (num_frames is None or t.shape[1] == num_frames)","tryCatchPattern":"try:\n    alpha = get_alpha(image_only_indicator, is_attn=is_attn)\nexcept NotImplementedError as e:\n    raise RuntimeError(\"image_only_indicator must be a (b,t) per-frame tensor, not a spatial mask\") from e","preventionTips":["Always pass per-frame binary indicators of shape (b, num_frames)","Do not substitute spatial masks for frame indicators","Read the function source to confirm expected layouts before new integrations"],"tags":["python","not-implemented","shape-mismatch","video"],"backgroundTag":"unsupported-tensor-rank","analyzedSha":"e8cd657656fa5d61688191730d0e03242bf4ed44","analyzedAt":"2026-08-29T11:23:43.234Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}