class_docstr: A helper class to be used with the __getitem__ method. This can be used for
  getting/setting the values for an attribute of a class at one particular
  index.  This is useful when the attributes of a class are batched tensors
  and one element in the batch needs to be modified.
docstr: Update the attribute given by `name` to the value given by `value`
  at the index specified by `self.index`.
  
  Args:
      name: str, name of the attribute.
      value: value to set the attribute to.
docstr_tok: ["Update","the","attribute","given","by","`","name","`","to","the","value","given","by","`","value","`","at","the","index","specified","by","`","self.index","`",".","Args",":","name",":","str",",","name","of","the","attribute",".","value",":","value","to","set","the","attribute","to","."]
code: def __setattr__(self, name: str, value: Any):
      """
      Update the attribute given by `name` to the value given by `value`
      at the index specified by `self.index`.
  
      Args:
          name: str, name of the attribute.
          value: value to set the attribute to.
      """
      v = getattr(self.class_object, name)
      if not torch.is_tensor(v):
          msg = "Can only set values on attributes which are tensors; got %r"
          raise AttributeError(msg % type(v))
  
      # Convert the attribute to a tensor if it is not a tensor.
      if not torch.is_tensor(value):
          value = torch.tensor(
              value,
              device=v.device,
              dtype=v.dtype,
              requires_grad=v.requires_grad,
          )
  
      # Check the shapes match the existing shape and the shape of the index.
      if (
          v.dim() > 1
          and value.dim() > 1
          and value.shape[1:] != v.shape[1:]
      ):
          msg = "Expected value to have shape %r; got %r"
          raise ValueError(msg % (v.shape, value.shape))
      if (
          v.dim() == 0
          and isinstance(self.index, slice)
          and len(value) != len(self.index)
      ):
          msg = "Expected value to have len %r; got %r"
          raise ValueError(msg % (len(self.index), len(value)))
      self.class_object.__dict__[name][self.index] = value
  
imports: import copy
  import inspect
  import warnings
  from typing import Any, List, Optional, Tuple, TypeVar, Union
  import numpy
  import torch
  import torch.nn
  from ..common.datatypes import Device, make_device
label_desc: Use image node_id 2 for calling the TensorAccessor obj's underlying member method code with example usage: obj.__setattr__(name, value) without return types