class_docstr: PipelineStageManager is a helper class to manage pipeline stages.
  
  Args:
      pg_mesh (ProcessGroupMesh): Process group mesh.
      pipeline_axis (int): The axis along which the pipeline is constructed.
      is_virtual (bool): Whether to use circle p2p communication, it will make the first and last stage communicate with each other.
  
  Attributes:
      num_stages (int): Number of stages in the pipeline.
      stage (int): The current stage.
class_docstr_tok: ["PipelineStageManager","is","a","helper","class","to","manage","pipeline","stages",".","Args",":","pg_mesh","(","ProcessGroupMesh",")",":","Process","group","mesh",".","pipeline_axis","(","int",")",":","The","axis","along","which","the","pipeline","is","constructed",".","is_virtual","(","bool",")",":","Whether","to","use","circle","p2p","communication",",","it","will","make","the","first","and","last","stage","communicate","with","each","other",".","Attributes",":","num_stages","(","int",")",":","Number","of","stages","in","the","pipeline",".","stage","(","int",")",":","The","current","stage","."]
docstr: Is the current stage the first stage.
  
  NOTE:
      1. if using interleaved pipeline parallel, the first stage is the first chunk of the first device.
      2. invoke is_first_stage() with ignore_chunk=True is equivalent to invoke is_first_device()
  
  Returns:
      bool: Whether the current stage is the first stage.
docstr_tok: ["Is","the","current","stage","the","first","stage",".","NOTE",":","1.","if","using","interleaved","pipeline","parallel",",","the","first","stage","is","the","first","chunk","of","the","first","device",".","2.","invoke","is_first_stage","(",")","with","ignore_chunk=True","is","equivalent","to","invoke","is_first_device","(",")","Returns",":","bool",":","Whether","the","current","stage","is","the","first","stage","."]
code: def is_first_stage(self, ignore_chunk: bool = False) -> bool:
      """Is the current stage the first stage.
  
      NOTE:
          1. if using interleaved pipeline parallel, the first stage is the first chunk of the first device.
          2. invoke is_first_stage() with ignore_chunk=True is equivalent to invoke is_first_device()
  
      Returns:
          bool: Whether the current stage is the first stage.
      """
      assert isinstance(ignore_chunk, bool)
      assert not self.is_interleave or (
          ignore_chunk or self.model_chunk_id is not None
      )
      if not self.is_interleave or ignore_chunk:
          return self.stage == 0
      else:
          return self.stage == 0 and self.model_chunk_id == 0
  
file_path: colossalai/colossalai/pipeline/stage_manager.py
imports: import contextlib
  from typing import Dict, List, Optional, Tuple
  import torch.distributed
  from torch.distributed import ProcessGroup
  from colossalai.cluster import ProcessGroupMesh
label_desc: Use image node_id 2 for calling the PipelineStageManager obj's underlying member method code with example usage: obj.is_first_stage(ignore_chunk) and returns: unknown, unknown