code: def _flatten_tensor_size(size) -> torch.Size:
      """
      Checks if tensor size is valid, then flatten/return a torch.Size object.
      """
      if len(size) == 1 and isinstance(
          size[0], collections.abc.Sequence
      ):
          dims = list(*size)
      else:
          dims = list(size)
  
      for dim in dims:
          if not isinstance(dim, int):
              raise TypeError(
                  f"size has to be a sequence of ints, found: {dims}"
              )
  
      return torch.Size(dims)
  
file_path: pytorch/torch/distributed/_shard/sharded_tensor/utils.py
imports: import collections.abc
  import copy
  from typing import Optional, List, Sequence
  import torch
  from torch.distributed import distributed_c10d
  from torch.distributed import rpc
  from torch.distributed._shard.sharding_spec._internals import check_tensor, validate_non_overlapping_shards_metadata
  from torch.distributed._shard.metadata import ShardMetadata
  from .metadata import TensorProperties, ShardedTensorMetadata
  from .shard import Shard
label_desc: Use image node_id 3 for calling a global function with example usage: _flatten_tensor_size(size) and returns: torch