code: def __init__(self, values, offsets, *, lengths=None, **kwargs):
      super().__init__()
      # Only support jagged for now.
      assert offsets is not None
      assert offsets.ndim == 1
      assert not isinstance(values, NestedTensor)
  
      # Query cache for the symint associated with offsets or lengths
      # (create a new one if needed).
      ragged_source = offsets if lengths is None else lengths
      ragged_size = get_tensor_symint(ragged_source, coeff=1)
      self._ragged_idx = kwargs.get("_ragged_idx", 1)
      B = offsets.shape[0] - 1
      Ds = (
          values.shape[: self._ragged_idx - 1]
          + values.shape[self._ragged_idx :]
      )
  
      nested_size = [B]
      nested_size.extend(Ds[: self._ragged_idx - 1])
      nested_size.append(ragged_size)
      nested_size.extend(Ds[self._ragged_idx - 1 :])
      self._size = tuple(nested_size)
  
      stride = values.stride()
      self._strides = (
          ragged_size * stride[self._ragged_idx - 1],
          *stride,
      )
  
      if values.requires_grad:
          raise ValueError(
              "NestedTensor values cannot require grad, please "
              "detach before passing to NestedTensor constructor"
          )
      self._values = values
      self._offsets = offsets
      self._lengths = lengths
  
      # holds properties that are computed lazily
      self._metadata_cache = kwargs.get("_metadata_cache", {})
  
      # collapsed ragged dim must always be dynamic
      torch._dynamo.mark_dynamic(self, self._ragged_idx)
      torch._dynamo.mark_dynamic(self._values, self._ragged_idx - 1)
  
imports: from typing import Tuple
  import torch
  from torch._C import DispatchKey, DispatchKeySet
  from torch._prims_common import is_expandable_to
  from torch.fx.experimental.symbolic_shapes import has_free_symbols
  from torch.utils.weak import WeakTensorKeyDictionary
  from typing import *
label_desc: Use image node_id 2 to create a new NestedTensor object from inherited base classes: torch with example: obj = NestedTensor(values, offsets)