code: def infer_size(total_size: int, sizes: Shape) -> Shape:
      """
      One dimension input to view may be "-1".
  
      Infer the size of this dimension given the total_size.
      """
      infers = [i for i, s in enumerate(sizes) if s == -1]
      size = prod(sizes)
      assert len(infers) <= 1, "can only infer one size"
      if infers:
          size = -size
          missing_size = total_size // size
          assert (
              total_size % size == 0
          ), f"size inferred for -1 is not integral {sizes} should have {total_size} elements."
          return tuple(s if s != -1 else missing_size for s in sizes)
      assert (
          size == total_size
      ), f"sizes do not match {total_size} vs {size}"
      return sizes
  
imports: from dataclasses import dataclass
  from typing import Callable, cast, Dict, Iterable, Optional, Sequence, Set, Tuple, Union
  import torch
  from torch import Tensor
  from torch._subclasses.fake_tensor import unset_fake_temporarily
  from torch.distributed._tensor._utils import compute_local_shape
  from torch.distributed._tensor.api import Shard
  from torch.distributed._tensor.op_schema import OpSchema, OutputSharding, RuntimeSchemaInfo
  from torch.distributed._tensor.ops.utils import normalize_dim, normalize_dims, prod, register_prop_rule
  from torch.distributed._tensor.placement_types import DTensorSpec, Placement, Replicate
  from torch.fx.experimental.proxy_tensor import disable_proxy_modes_tracing
label_desc: Use image node_id 8 for calling a global function with example usage: infer_size(total_size, sizes) and returns: sizes, tuple