class_docstr: A tensor with mutable shape information.
  Inspired by `Ideal FLOPS counter <https://dev-discuss.pytorch.org/t/the-ideal-pytorch-flop-counter-with-torch-dispatch/505>`__.
class_docstr_tok: ["A","tensor","with","mutable","shape","information",".","Inspired","by","`","Ideal","FLOPS","counter","<","https",":","\/\/dev-discuss.pytorch.org\/t\/the-ideal-pytorch-flop-counter-with-torch-dispatch\/505",">","`","__","."]
code: def _view_impl(
      self, tensor: torch.Tensor, *shape: IntProxy | int
  ) -> ShapeTensor:
      if any(s == -1 for s in shape):
          # the size -1 is inferred from other dimensions
          assert self.real_shape is not None
          all_size = self.real_shape.numel()
          shape_lst = list(shape)
          infer_index = shape_lst.index(-1)  # type: ignore
          assert infer_index != -1
          # Filter out -1, unwrap to get expression and multiply them together.
          shape_lst[infer_index] = all_size // functools.reduce(  # type: ignore
              lambda x, y: x * y,
              map(IntProxy.unwrap, filter(lambda x: x != -1, shape)),
              1,
          )
          shape = tuple(shape_lst)
  
      # Put in after "if" because `== -1` check doesn't work for mutables.
      return ShapeTensor(
          tensor, tuple(IntProxy.unwrap(s) for s in shape)
      )
  
imports: from __future__ import annotations
  import functools
  import logging
  import traceback
  from typing import Union, Tuple, Callable, Iterable, Any, NamedTuple, Dict, cast, overload
  import torch
  from torch import nn
  from torch.utils.hooks import RemovableHandle
  from nni.mutable import MutableExpression, Mutable, LabeledMutable, Sample, SampleValidationError
  from nni.mutable.mutable import _mutable_equal
  from .misc import is_leaf_module, argument_in_spec
label_desc: Use image node_id 8 for calling the ShapeTensor obj's underlying member method code with example usage: obj._view_impl(tensor) and returns: ShapeTensor