Hello Miglena,
You cannot copy-paste multi-line code to a simple console, if you want to input multi-line Python script to the Console pane you need to enable Rich Console option via Advanced Preferences tab of Metashape window.
Also you need to make an assignment for the chunk variable before using those lines, so if you want to have a complete code that works for the active chunk of the currently opened document, use the following:
import Metashape
chunk = Metashape.app.document.chunk
chunk.buildUV()
chunk.buildTexture(blending_mode = Metashape.BlendingMode.MosaicBlending, texture_size = 4096, texture_type = Metashape.Model.TextureType.DiffuseMap, source_model = chunk.model.key, transfer_texture = False)
It can be also executed via Run Script dialog, if saved in .py file.