---
title: "encodeBatch(commandBuffer:sourceGradients:sourceImages:labels:weights:sourceStates:)"
framework: metalperformanceshaders
role: symbol
role_heading: Instance Method
path: "metalperformanceshaders/mpsnnlossgradient/encodebatch(commandbuffer:sourcegradients:sourceimages:labels:weights:sourcestates:)"
---

# encodeBatch(commandBuffer:sourceGradients:sourceImages:labels:weights:sourceStates:)

## Declaration

```swift
func encodeBatch(commandBuffer: any MTLCommandBuffer, sourceGradients: [MPSImage], sourceImages: [MPSImage], labels: [MPSImage], weights: [MPSImage]?, sourceStates: [MPSState]?) -> [MPSImage]
```
