//  [python]
def get_input(self, batch, k, return_first_stage_outputs=False, force_c_encode=False,
                  cond_key=None, return_original_cond=False, bs=None):
        x = super().get_input(batch, k)
        if bs is not None:
            x = x[:bs]
        x = x.to(self.device)
        encoder_posterior = self.encode_first_stage(x)
        z = self.get_first_stage_encoding(encoder_posterior).detach()

        if self.model.conditioning_key is not None:# 'crossattn' for txt2image, 'hybird' for txt_inpaint
            if cond_key is None:
                cond_key = self.cond_stage_key # 'caption' for txt_inpaint
            if self.model.conditioning_key == 'hybrid':
                xc = {}
                assert cond_key == 'caption' # only txt_inpaint is implemented now
                assert 'masked_image' in batch.keys() 
                assert 'mask' in batch.keys()
                masked_image = super().get_input(batch,'masked_image')
                mask = super().get_input(batch,'mask')
                if bs is not None:
                    masked_image,mask = masked_image[:bs],mask[:bs]
                masked_image,mask = masked_image.to(self.device),mask.to(self.device)
                masked_image = self.get_first_stage_encoding(self.encode_first_stage(masked_image)).detach()
                resized_mask = torch.nn.functional.interpolate(mask,size=masked_image.shape[-2:])
                xc['c_concat'] = torch.cat((masked_image,resized_mask),dim = 1)
                xc[cond_key] = batch[cond_key]
            else:
                if cond_key != self.first_stage_key:
                    if cond_key in ['caption', 'coordinates_bbox']:
                        xc = batch[cond_key]
                    elif cond_key == 'class_label':
                        xc = batch
                    else:
                        xc = super().get_input(batch, cond_key).to(self.device)
                else:# cond_key == 'image'
                    xc = x
            if not self.cond_stage_trainable or force_c_encode:# cond_stage_trainable is true for txt2img，force_c_encoder = True，when called in log_images
                if isinstance(xc, list):
                    # import pudb; pudb.set_trace()
                    c = self.get_learned_conditioning(xc)# 因为log_images内接下来要调用sample_log,所以需要预先得到处理好的c
                if isinstance(xc, dict):
                    c = {}
                    c['c_concat'] = xc['c_concat']
                    c['c_crossattn'] = self.get_learned_conditioning(xc[cond_key])
                else:
                    c = self.get_learned_conditioning(xc.to(self.device))
            else:
                c = xc
            if bs is not None:
                if isinstance(c,dict):
                    for k in c.keys():
                        c[k] = c[k][:bs]
                else:
                    c = c[:bs]

            if self.use_positional_encodings:
                pos_x, pos_y = self.compute_latent_shifts(batch)
                ckey = __conditioning_keys__[self.model.conditioning_key]
                c = {ckey: c, 'pos_x': pos_x, 'pos_y': pos_y}

        else:
            c = None
            xc = None
            if self.use_positional_encodings:
                pos_x, pos_y = self.compute_latent_shifts(batch)
                c = {'pos_x': pos_x, 'pos_y': pos_y}
        out = [z, c]
        if return_first_stage_outputs:
            xrec = self.decode_first_stage(z)
            out.extend([x, xrec])
        if return_original_cond:
            out.append(xc)
        return out