parameters: (torch_dtype)
docstring: Converts PyTorch types to Numpy types
  
      Also must map to types accepted by:
          MLDataType NumpyTypeToOnnxRuntimeType(int numpy_type)
  
      References:
          https://docs.scipy.org/doc/numpy-1.13.0/user/basics.types.html
          https://pytorch.org/docs/stable/tensors.html
docstring_summary: Converts PyTorch types to Numpy types
docstring_tokens: Converts PyTorch types to Numpy types
function: def dtype_torch_to_numpy(torch_dtype):
      '''Converts PyTorch types to Numpy types
  
      Also must map to types accepted by:
          MLDataType NumpyTypeToOnnxRuntimeType(int numpy_type)
  
      References:
          https://docs.scipy.org/doc/numpy-1.13.0/user/basics.types.html
          https://pytorch.org/docs/stable/tensors.html
      '''
      if torch_dtype == torch.float64 or torch_dtype == torch.double:
          return np.float64
      elif torch_dtype == torch.float32 or torch_dtype == torch.float:
          return np.float32
      elif torch_dtype == torch.float16 or torch_dtype == torch.half or torch_dtype == torch.bfloat16:
          # NOTE: numpy doesn't support bfloat16
          return np.float16
      elif torch_dtype == torch.int64 or torch_dtype == torch.long:
          return np.longlong  # np.int64 doesn't work!?
      elif torch_dtype == torch.int32 or torch_dtype == torch.int:
          return np.int32
      elif torch_dtype == torch.int16 or torch_dtype == torch.short:
          return np.int16
      elif torch_dtype == torch.int8:
          return np.int8
      elif torch_dtype == torch.uint8:
          return np.uint8
      elif torch_dtype == torch.complex32 or torch_dtype == torch.complex64:
          # NOTE: numpy doesn't support complex32
          return np.complex64
      elif torch_dtype == torch.complex128 or torch_dtype == torch.cdouble:
          return np.complex128
      elif torch_dtype == torch.bool:
          return np.bool_
      else:
          raise ValueError(
              f'torch_dtype ({str(torch_dtype)}) type is not supported by Numpy')
function_tokens: def dtype_torch_to_numpy ( torch_dtype ) : if torch_dtype == torch . float64 or torch_dtype == torch . double : return np . float64 elif torch_dtype == torch . float32 or torch_dtype == torch . float : return np . float32 elif torch_dtype == torch . float16 or torch_dtype == torch . half or torch_dtype == torch . bfloat16 : # NOTE: numpy doesn't support bfloat16 return np . float16 elif torch_dtype == torch . int64 or torch_dtype == torch . long : return np . longlong # np.int64 doesn't work!? elif torch_dtype == torch . int32 or torch_dtype == torch . int : return np . int32 elif torch_dtype == torch . int16 or torch_dtype == torch . short : return np . int16 elif torch_dtype == torch . int8 : return np . int8 elif torch_dtype == torch . uint8 : return np . uint8 elif torch_dtype == torch . complex32 or torch_dtype == torch . complex64 : # NOTE: numpy doesn't support complex32 return np . complex64 elif torch_dtype == torch . complex128 or torch_dtype == torch . cdouble : return np . complex128 elif torch_dtype == torch . bool : return np . bool_ else : raise ValueError ( f'torch_dtype ({str(torch_dtype)}) type is not supported by Numpy' )