
    Ph
              	       d    d dl mZ d dlmZmZ dgZ	 d	dej                  dee   deee      fdZy)
    )nn)ListOptionalpartition_modelNmodulebalancedevicesc                    d}d}g }|D ]k  }g }t        |      D ]  }|j                  | |          |dz  } ||n||   }	|j                  t        j                  | j	                  |	             |dz  }m t        j                  | S )ab  
    Partions the model accross multiple GPU devices.

    Given an :class:`nn.Sequential <torch.nn.Sequential>` module, partitions
    the model across multiple GPU devices according the provided ``balance``
    and ``devices``.

    Args:
        module (:class:`nn.Sequential <torch.nn.Sequential>`):
            Sequential model representing the pipe.
        balance (List[int]):
            List indicating the number of layers in each partition.
        devices (List[int], optional):
            List indicating the device to use for each partition. Defaults to
            ``range(len(balance))``
    r      )rangeappendr   
Sequentialto)
r   r   r	   
device_idxpipe_idxbalanced_pipe
num_layerslayersidevices
             pC:\Users\daisl\Desktop\realtime-object-detection\venv\Lib\site-packages\torch/distributed/pipeline/sync/utils.pyr   r      s    ( JHM
z"AMM&*+MH #  'GJ4GR]]F366v>?a
  ==-((    )N)	torchr   typingr   r   __all__r   intr    r   r   <module>r      sH     !

 (, ) )c ) $s)$ )r   