code: def calc_shape(size, newshape):
      if isinstance(newshape, int):
          newshape = (newshape,)
      else:
          newshape = tuple(int(s) for s in newshape)
  
      known_shape = [s for s in newshape if s >= 0]
      missing_dim = len(newshape) - len(known_shape)
      if missing_dim > 1:
          raise ValueError("can only specify one unknown dimension")
      if missing_dim == 1:
          known_size = np.prod(known_shape)
          newshape = tuple(
              int(size / known_size) if s < 0 and known_size > 0 else s
              for s in newshape
          )
  
      return newshape
  
imports: import itertools
  import logging
  import numpy
  from ...None import opcodes
  from ...core import recursive_tile
  from ...core.operand import OperandStage
  from ...serialization.serializables import FieldTypes, KeyField, TupleField, StringField
  from ...utils import has_unknown_shape
  from ..array_utils import as_same_device, device
  from ..datasource import tensor
  from ..operands import TensorOperandMixin, TensorMapReduceOperand, TensorShuffleProxy
  from ..utils import get_order, decide_chunk_sizes
label_desc: Use image node_id 1 for calling a global function with example usage: calc_shape(size, newshape) and returns: newshape