code: def from_tensor(
      self, *, tensor, batched, name="TensorSpec.from_tensor"
  ):
      if not isinstance(tensor, TensorDict):
          raise TensorforceError.type(
              name=name, argument="tensor", dtype=type(tensor)
          )
  
      # TODO: improve exception message to include invalid keys
      if set(tensor) != set(self):
          raise TensorforceError.value(
              name=name, argument="tensor", value=tensor
          )
  
      value = ArrayDict()
      for name, spec in super(NestedDict, self).items():
          value[name] = spec.from_tensor(
              tensor=tensor[name], batched=batched, name=name
          )
      return value
  
file_path: tensorforce/tensorforce/core/utils/tensors_spec.py
imports: from tensorforce import TensorforceError
  from tensorforce.core.utils import ArrayDict, NestedDict, SignatureDict, TensorDict, TensorSpec
label_desc: Use image node_id 4 for calling the TensorsSpec obj's underlying member method code with example usage: obj.from_tensor() and returns: value