code: def get_memory_info(device):
      """Get memory info for the chosen device, as a dict.
  
      This function returns a dict containing information about the device's memory
      usage. For example:
  
      >>> if tf.config.list_physical_devices('GPU'):
      ...   # Returns a dict in the form {'current': <current mem usage>,
      ...   #                             'peak': <peak mem usage>}
      ...   tf.config.experimental.get_memory_info('GPU:0')
  
      Currently returns the following keys:
        - `'current'`: The current memory used by the device, in bytes.
        - `'peak'`: The peak memory used by the device across the run of the
            program, in bytes. Can be reset with
            `tf.config.experimental.reset_memory_stats`.
  
      More keys may be added in the future, including device-specific keys.
  
      Currently only supports GPU and TPU. If called on a CPU device, an exception
      will be raised.
  
      For GPUs, TensorFlow will allocate all the memory by default, unless changed
      with `tf.config.experimental.set_memory_growth`. The dict specifies only the
      current and peak memory that TensorFlow is actually using, not the memory that
      TensorFlow has allocated on the GPU.
  
      Args:
        device: Device string to get the memory information for, e.g. `"GPU:0"`,
        `"TPU:0"`. See https://www.tensorflow.org/api_docs/python/tf/device for
          specifying device strings.
  
      Returns:
        A dict with keys `'current'` and `'peak'`, specifying the current and peak
        memory usage respectively.
  
      Raises:
        ValueError: No device found with the device name, like '"nonexistent"'.
        ValueError: Invalid device name, like '"GPU"', '"CPU:GPU"', '"CPU:"'.
        ValueError: Multiple devices matched with the device name.
        ValueError: Memory statistics not tracked, like '"CPU:0"'.
      """
      return context.context().get_memory_info(device)
  
imports: from typing import Union
  from tensorflow.python.eager import context
  from tensorflow.python.framework import errors
  from tensorflow.python.util import _pywrap_determinism
  from tensorflow.python.util import _pywrap_tensor_float_32_execution
  from tensorflow.python.util import deprecation
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 21 for calling a global function with example usage: get_memory_info(device) and returns: context