code: def where(
      condition: NdarrayOrTensor, x=None, y=None
  ) -> NdarrayOrTensor:
      """
      Note that `torch.where` may convert y.dtype to x.dtype.
      """
      result: NdarrayOrTensor
      if isinstance(condition, np.ndarray):
          if x is not None:
              result = np.where(condition, x, y)
          else:
              result = np.where(condition)  # type: ignore
      else:
          if x is not None:
              x = torch.as_tensor(x, device=condition.device)
              y = torch.as_tensor(
                  y, device=condition.device, dtype=x.dtype
              )
              result = torch.where(condition, x, y)
          else:
              result = torch.where(condition)  # type: ignore
      return result
  
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 6 for calling a global function with example usage: where(condition, x, y) and returns: result