code: def _iterate_over_multidim_slice(ms: multidim_slice):
      """Get :class:`MaybeWeighted` instances in ``ms``."""
      for s in ms:
          if s is not None and s is not Ellipsis:
              yield from _iterate_over_slice_type(s)
  
imports: from __future__ import annotations
  import operator
  from typing import Callable, Iterator, TypeVar, Any, Optional, Tuple, Union, List, Dict, Generic, cast
  import numpy
  import torch
label_desc: Use image node_id 5 for calling a global function with example usage: _iterate_over_multidim_slice(ms) without return types