code: def tensor_to_numpy(value: Any):
      if hasattr(value, "numpy"):
          return value.numpy()  # tf.Tensor (TF2).
      if hasattr(value, "device_buffer"):
          return np.asarray(value)  # jnp.DeviceArray.
      return value
  
file_path: acme/acme/utils/loggers/base.py
imports: import abc
  from typing import Any, Mapping, Optional
  import numpy
  import tree
  from typing_extensions import Protocol
label_desc: Use image node_id 1 for calling a global function with example usage: tensor_to_numpy(value) and returns: value, value, np