code: def _str_to_torch_type(name: str, torch_type: type):
      try:
          value = getattr(torch, name.split(".")[-1])
      except AttributeError:
          raise ValueError(
              f"Invalid dtype: torch has no attribute {name}"
          )
      if not isinstance(value, torch_type):
          raise ValueError(
              f"Invalid dtype: expected {torch_type}, got: {type(value)}"
          )
  
      return value
  
imports: from __future__ import annotations
  import warnings
  from dataclasses import asdict, dataclass
  from typing import Tuple
  import numpy
  import torch
  from hivemind.proto.runtime_pb2 import CompressionType
  from hivemind.utils.serializer import MSGPackSerializer
label_desc: Use image node_id 1 for calling a global function with example usage: _str_to_torch_type(name, torch_type) and returns: value