code: def openpnm_to_im(network, pore_shape="sphere", throat_shape="cylinder",
                    max_dim=None, verbose=1, rtol=0.1):
      r
      return generate_voxel_image(network, pore_shape=pore_shape,
                                  throat_shape=throat_shape, max_dim=max_dim,
                                  verbose=verbose, rtol=rtol)
docs: r"""
      Generates voxel image from an OpenPNM network object.
  
      Parameters
      ----------
      network : OpenPNM GenericNetwork
          Network from which voxel image is to be generated
  
      pore_shape : str
          Shape of pores in the network, valid choices are "sphere", "cube"
  
      throat_shape : str
          Shape of throats in the network, valid choices are "cylinder", "cuboid"
  
      max_dim : int
          Number of voxels in the largest dimension of the network
  
      rtol : float
          Stopping criteria for finding the smallest voxel image such that
          further increasing the number of voxels in each dimension by 25% would
          improve the predicted porosity of the image by less that ``rtol``
  
      Returns
      -------
      im : ND-array
          Voxelated image corresponding to the given pore network model
  
      Notes
      -----
      (1) The generated voxelated image is labeled with 0s, 1s and 2s signifying
      solid phase, pores, and throats respectively.
  
      (2) If max_dim is not provided, the method calculates it such that the
      further increasing it doesn't change porosity by much.