class_docstr: An error for a mismatch in shapes.
class_docstr_tok: ["An","error","for","a","mismatch","in","shapes","."]
docstr: Raise an exception if the shape does not match the reference.
  
  This method normalizes the shapes first.
  
  :param shape:
      the shape to check
  :param reference:
      the reference shape. If None, the shape always matches.
  
  :raises ShapeError:
      if the two shapes do not match.
  
  :return:
      the normalized shape
docstr_tok: ["Raise","an","exception","if","the","shape","does","not","match","the","reference",".","This","method","normalizes","the","shapes","first",".",":","param","shape",":","the","shape","to","check",":","param","reference",":","the","reference","shape",".","If","None",",","the","shape","always","matches",".",":","raises","ShapeError",":","if","the","two","shapes","do","not","match",".",":","return",":","the","normalized","shape"]
code: def verify(
      cls,
      shape: OneOrSequence[int],
      reference: Optional[OneOrSequence[int]],
  ) -> Sequence[int]:
      """
      Raise an exception if the shape does not match the reference.
  
      This method normalizes the shapes first.
  
      :param shape:
          the shape to check
      :param reference:
          the reference shape. If None, the shape always matches.
  
      :raises ShapeError:
          if the two shapes do not match.
  
      :return:
          the normalized shape
      """
      shape = upgrade_to_sequence(shape)
      if reference is None:
          return shape
      reference = upgrade_to_sequence(reference)
      if reference != shape:
          # darglint does not like
          # raise cls(shape=shape, reference=reference)
          raise ShapeError(shape=shape, reference=reference)
      return shape
  
imports: from __future__ import annotations
  import functools
  import logging
  import pathlib
  import re
  import subprocess
  from abc import ABC, abstractmethod
  from itertools import chain
  from textwrap import dedent
  from typing import Any, Callable, Collection, Dict, Iterable, List, Literal, Mapping, Optional, Sequence, Union, cast
  import more_itertools
  import requests
  import torch
  from tqdm.auto import tqdm
  from ..constants import PYKEEN_MODULE
  from ..typing import OneOrSequence
  from ..utils import nested_get, rate_limited, upgrade_to_sequence
  from ..version import get_version
label_desc: Use image node_id 2 for calling the ShapeError obj's underlying member method code with example usage: obj.verify(cls, shape, reference) and returns: shape, shape