code: def _assert_dtype_support(
      metric_module: Optional[Metric],
      metric_functional: Optional[Callable],
      preds: Tensor,
      target: Union[Tensor, List[Dict[str, Tensor]]],
      device: str = "cpu",
      dtype: torch.dtype = torch.half,
      **kwargs_update: Any,
  ):
      """Test if a metric can be used with half precision tensors.
  
      Args:
          metric_module: the metric module to test
          metric_functional: the metric functional to test
          preds: torch tensor with predictions
          target: torch tensor with targets
          device: determine device, either "cpu" or "cuda"
          dtype: dtype to run test with
          kwargs_update: Additional keyword arguments that will be passed with preds and
              target when running update on the metric.
  
      """
      y_hat = (
          preds[0].to(dtype=dtype, device=device)
          if preds[0].is_floating_point()
          else preds[0].to(device)
      )
      y = (
          target[0].to(dtype=dtype, device=device)
          if isinstance(target[0], Tensor)
          and target[0].is_floating_point()
          else {
              k: target[0][k].to(dtype=dtype, device=device)
              if target[0][k].is_floating_point()
              else target[0][k].to(device)
              for k in target[0]
          }
          if isinstance(target[0], dict)
          else target[0].to(device)
      )
      kwargs_update = {
          k: (
              v[0].to(dtype=dtype) if v.is_floating_point() else v[0]
          ).to(device)
          if isinstance(v, Tensor)
          else v
          for k, v in kwargs_update.items()
      }
      if metric_module is not None:
          metric_module = metric_module.to(device)
          _assert_tensor(metric_module(y_hat, y, **kwargs_update))
      if metric_functional is not None:
          _assert_tensor(metric_functional(y_hat, y, **kwargs_update))
  
imports: import pickle
  import sys
  from copy import deepcopy
  from functools import partial
  from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
  import numpy
  import pytest
  import torch
  from lightning_utilities import apply_to_collection
  from torch import Tensor, tensor
  from torchmetrics import Metric
  from torchmetrics.utilities.data import _flatten
  from unittests import NUM_PROCESSES
label_desc: Use image node_id 6 for calling a global function with example usage: _assert_dtype_support(metric_module, metric_functional, preds, target, device, dtype) without return types