code: def _get_size_from_shape(shape, dtype):
      """
      Calculates size based on shape and dtype, returns (None, None) if either
      shape or dtype are None
      """
  
      if shape is None or dtype is None:
          return (None, None)
  
      itemsize = GlobalSettings().xpy.dtype(dtype).itemsize
      if isinstance(shape, int):
          size = itemsize * shape
          shape = (shape,)
      elif isinstance(shape, tuple):
          size = functools.reduce(operator.mul, shape)
          size = size * itemsize
      else:
          raise ValueError("Shape must be int or tuple of ints.")
      return (size, shape)
  
imports: import functools
  import operator
  import re
  from functools import wraps
  from cuml.internals.global_settings import GlobalSettings
  from cuml.internals.device_support import GPU_ENABLED
  from cuml.internals.mem_type import MemoryType
  from cuml.internals.output_type import INTERNAL_VALID_OUTPUT_TYPES, VALID_OUTPUT_TYPES
  from cuml.internals.safe_imports import cpu_only_import_from, gpu_only_import_from, UnavailableNullContext
label_desc: Use image node_id 5 for calling a global function with example usage: _get_size_from_shape(shape, dtype) and returns: size,  shape, None,  None