code: def flatten_check(out:Tensor, targ:Tensor) -> Tensor:
      "Check that `out` and `targ` have the same number of elements and flatten them."
      out,targ = out.contiguous().view(-1),targ.contiguous().view(-1)
      assert len(out) == len(targ), f"Expected output and target to have the same number of elements but got {len(out)} and {len(targ)}."
      return out,tarf flatten_check(out:Tensor, targ:Tensor) -> Tensor:
      "Check that `out` and `targ` have the same number of elements and flatten them."
      out,targ = out.contiguous().view(-1),targ.contiguous().view(-1)
      assert len(out) == len(targ), f"Expected output and target to have the same number of elements but got {len(out)} and {len(targ)}."
      return out,targ
docs: Check that `out` and `targ` have the same number of elements and flatten them.