Under investigation in this paper is a (3 + 1)-dimensional generalized nonlinear Schrodinger equation with the distributed coefficients for the spatiotemporal optical soli tons or light bullets. Through the symbolic computation and Hirota method, one- and two-soliton solutions are derived. We also present the Backlund transformation, through which we derive the soliton solutions. When the gain/loss coefficient is the monotonically decreasing function for the propagation coordinate z, amplitude for the spatiotemporal optical soliton or light bullet decreases along z, while when the gain/loss coefficient is the monotonically increasing function for z, amplitude for the spatiotemporal optical soliton or light bullet increases along z. Directions of the solitons are different because the signs of imaginary parts of the frequencies are adverse. Based on the two-soliton solutions, elastic and inelastic collisions between the two spatiotemporal optical solitons or light bullets are derived under different conditions presented in the paper.