def METHOD_NAME(self, inputs: Dict[str, Any]):
    samples = inputs['samples']
    targets = inputs['targets']
    text_queries = inputs['text_queries']
    valid_indices = torch.tensor(
        [i for i, t in enumerate(targets) if None not in t])
    targets = [targets[i] for i in valid_indices.tolist()]
    if self._device_name == 'gpu':
        samples = samples.to(self.device)
        valid_indices = valid_indices.to(self.device)
    if isinstance(text_queries, tuple):
        text_queries = list(text_queries)
    outputs = self.model(samples, valid_indices, text_queries)
    losses = -1
    if self.training:
        loss_dict = self.criterion(outputs, targets)
        weight_dict = self.criterion.weight_dict
        losses = sum(loss_dict[k] * weight_dict[k]
                     for k in loss_dict.keys() if k in weight_dict)
    predictions = []
    if not self.training:
        outputs.pop('aux_outputs', None)
        outputs, targets = flatten_temporal_batch_dims(outputs, targets)
        processed_outputs = self.postprocessor(
            outputs,
            resized_padded_sample_size=samples.tensors.shape[-2:],
            resized_sample_sizes=[t['size'] for t in targets],
            orig_sample_sizes=[t['orig_size'] for t in targets])
        image_ids = [t['image_id'] for t in targets]
        predictions = []
        for p, image_id in zip(processed_outputs, image_ids):
            for s, m in zip(p['scores'], p['rle_masks']):
                predictions.append({
                    'image_id': image_id,
                    'category_id':
                    1,  # dummy label, as categories are not predicted in ref-vos
                    'segmentation': m,
                    'score': s.item()
                })
    re = dict(pred=predictions, loss=losses)
    return re