code: def normalize_transform(
      shape,
      device: torch.device | str | None = None,
      dtype: torch.dtype | None = None,
      align_corners: bool = False,
      zero_centered: bool = False,
  ) -> torch.Tensor:
      """
      Compute an affine matrix according to the input shape.
      The transform normalizes the homogeneous image coordinates to the
      range of `[-1, 1]`.  Currently the following source coordinates are supported:
  
          - `align_corners=False`, `zero_centered=False`, normalizing from ``[-0.5, d-0.5]``.
          - `align_corners=True`, `zero_centered=False`, normalizing from ``[0, d-1]``.
          - `align_corners=False`, `zero_centered=True`, normalizing from ``[-(d-1)/2, (d-1)/2]``.
          - `align_corners=True`, `zero_centered=True`, normalizing from ``[-d/2, d/2]``.
  
      Args:
          shape: input spatial shape, a sequence of integers.
          device: device on which the returned affine will be allocated.
          dtype: data type of the returned affine
          align_corners: if True, consider -1 and 1 to refer to the centers of the
              corner pixels rather than the image corners.
              See also: https://pytorch.org/docs/stable/nn.functional.html#torch.nn.functional.grid_sample
          zero_centered: whether the coordinates are normalized from a zero-centered range, default to `False`.
              Setting this flag and `align_corners` will jointly specify the normalization source range.
      """
      shape = convert_to_tensor(
          shape,
          torch.float64,
          device=device,
          wrap_sequence=True,
          track_meta=False,
      )
      norm = (
          shape.clone().detach().to(dtype=torch.float64, device=device)
      )  # no in-place change
      if align_corners:
          norm[norm <= 1.0] = 2.0
          norm = 2.0 / (norm if zero_centered else norm - 1.0)
          norm = torch.diag(
              torch.cat(
                  (
                      norm,
                      torch.ones(
                          (1,), dtype=torch.float64, device=device
                      ),
                  )
              )
          )
          if not zero_centered:  # else shift is 0
              norm[:-1, -1] = -1.0
      else:
          norm[norm <= 0.0] = 2.0
          norm = 2.0 / (norm - 1.0 if zero_centered else norm)
          norm = torch.diag(
              torch.cat(
                  (
                      norm,
                      torch.ones(
                          (1,), dtype=torch.float64, device=device
                      ),
                  )
              )
          )
          if not zero_centered:
              norm[:-1, -1] = 1.0 / shape - 1.0
      norm = norm.unsqueeze(0).to(dtype=dtype)
      norm.requires_grad = False
      return norm
  
imports: from __future__ import annotations
  import io
  import re
  import warnings
  from collections import OrderedDict
  from collections.abc import Callable, Mapping, Sequence
  from contextlib import contextmanager
  from copy import deepcopy
  from typing import Any
  import numpy
  import torch
  import torch.nn
  from monai.apps.utils import get_logger
  from monai.config import PathLike
  from monai.utils.misc import ensure_tuple, save_obj, set_determinism
  from monai.utils.module import look_up_option, optional_import, pytorch_after
  from monai.utils.type_conversion import convert_to_dst_type, convert_to_tensor
label_desc: Use image node_id 6 for calling a global function with example usage: normalize_transform(shape, device, dtype, align_corners, zero_centered) and returns: norm