code: def any_np_pt(
      x: NdarrayOrTensor, axis: int | Sequence[int]
  ) -> NdarrayOrTensor:
      """`np.any` with equivalent implementation for torch.
  
      For pytorch, convert to boolean for compatibility with older versions.
  
      Args:
          x: input array/tensor.
          axis: axis to perform `any` over.
  
      Returns:
          Return a contiguous flattened array/tensor.
      """
      if isinstance(x, np.ndarray):
          return np.any(x, axis)  # type: ignore
  
      # pytorch can't handle multiple dimensions to `any` so loop across them
      axis = [axis] if not isinstance(axis, Sequence) else axis
      for ax in axis:
          try:
              x = torch.any(x, ax)
          except RuntimeError:
              # older versions of pytorch require the input to be cast to boolean
              x = torch.any(x.bool(), ax)
      return x
  
imports: from __future__ import annotations
  from collections.abc import Sequence
  from typing import TypeVar
  import numpy
  import torch
  from monai.config.type_definitions import NdarrayOrTensor, NdarrayTensor
  from monai.utils.misc import is_module_ver_at_least
  from monai.utils.type_conversion import convert_data_type, convert_to_dst_type
label_desc: Use image node_id 14 for calling a global function with example usage: any_np_pt(x, axis) and returns: x, np